Code Duplication    Length = 13-19 lines in 8 locations

src/PhpSpreadsheet/Reader/Excel5.php 8 locations

@@ 1865-1877 (lines=13) @@
1862
     * --    "OpenOffice.org's Documentation of the Microsoft
1863
     *         Excel File Format"
1864
     */
1865
    private function readCodepage()
1866
    {
1867
        $length = self::getInt2d($this->data, $this->pos + 2);
1868
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
1869
1870
        // move stream pointer to next record
1871
        $this->pos += 4 + $length;
1872
1873
        // offset: 0; size: 2; code page identifier
1874
        $codepage = self::getInt2d($recordData, 0);
1875
1876
        $this->codepage = \PhpSpreadsheet\Shared\CodePage::numberToName($codepage);
1877
    }
1878
1879
    /**
1880
     * DATEMODE
@@ 3021-3033 (lines=13) @@
3018
    /**
3019
     * Read DEFAULTROWHEIGHT record
3020
     */
3021
    private function readDefaultRowHeight()
3022
    {
3023
        $length = self::getInt2d($this->data, $this->pos + 2);
3024
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3025
3026
        // move stream pointer to next record
3027
        $this->pos += 4 + $length;
3028
3029
        // offset: 0; size: 2; option flags
3030
        // offset: 2; size: 2; default height for unused rows, (twips 1/20 point)
3031
        $height = self::getInt2d($recordData, 2);
3032
        $this->phpSheet->getDefaultRowDimension()->setRowHeight($height / 20);
3033
    }
3034
3035
    /**
3036
     * Read SHEETPR record
@@ 3171-3185 (lines=15) @@
3168
    /**
3169
     * Read HCENTER record
3170
     */
3171
    private function readHcenter()
3172
    {
3173
        $length = self::getInt2d($this->data, $this->pos + 2);
3174
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3175
3176
        // move stream pointer to next record
3177
        $this->pos += 4 + $length;
3178
3179
        if (!$this->readDataOnly) {
3180
            // offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally
3181
            $isHorizontalCentered = (bool) self::getInt2d($recordData, 0);
3182
3183
            $this->phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered);
3184
        }
3185
    }
3186
3187
    /**
3188
     * Read VCENTER record
@@ 3190-3204 (lines=15) @@
3187
    /**
3188
     * Read VCENTER record
3189
     */
3190
    private function readVcenter()
3191
    {
3192
        $length = self::getInt2d($this->data, $this->pos + 2);
3193
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3194
3195
        // move stream pointer to next record
3196
        $this->pos += 4 + $length;
3197
3198
        if (!$this->readDataOnly) {
3199
            // offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered
3200
            $isVerticalCentered = (bool) self::getInt2d($recordData, 0);
3201
3202
            $this->phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered);
3203
        }
3204
    }
3205
3206
    /**
3207
     * Read LEFTMARGIN record
@@ 3338-3355 (lines=18) @@
3335
     * PROTECT - Sheet protection (BIFF2 through BIFF8)
3336
     *   if this record is omitted, then it also means no sheet protection
3337
     */
3338
    private function readProtect()
3339
    {
3340
        $length = self::getInt2d($this->data, $this->pos + 2);
3341
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3342
3343
        // move stream pointer to next record
3344
        $this->pos += 4 + $length;
3345
3346
        if ($this->readDataOnly) {
3347
            return;
3348
        }
3349
3350
        // offset: 0; size: 2;
3351
3352
        // bit 0, mask 0x01; 1 = sheet is protected
3353
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3354
        $this->phpSheet->getProtection()->setSheet((bool) $bool);
3355
    }
3356
3357
    /**
3358
     * SCENPROTECT
@@ 3360-3378 (lines=19) @@
3357
    /**
3358
     * SCENPROTECT
3359
     */
3360
    private function readScenProtect()
3361
    {
3362
        $length = self::getInt2d($this->data, $this->pos + 2);
3363
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3364
3365
        // move stream pointer to next record
3366
        $this->pos += 4 + $length;
3367
3368
        if ($this->readDataOnly) {
3369
            return;
3370
        }
3371
3372
        // offset: 0; size: 2;
3373
3374
        // bit: 0, mask 0x01; 1 = scenarios are protected
3375
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3376
3377
        $this->phpSheet->getProtection()->setScenarios((bool) $bool);
3378
    }
3379
3380
    /**
3381
     * OBJECTPROTECT
@@ 3383-3401 (lines=19) @@
3380
    /**
3381
     * OBJECTPROTECT
3382
     */
3383
    private function readObjectProtect()
3384
    {
3385
        $length = self::getInt2d($this->data, $this->pos + 2);
3386
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3387
3388
        // move stream pointer to next record
3389
        $this->pos += 4 + $length;
3390
3391
        if ($this->readDataOnly) {
3392
            return;
3393
        }
3394
3395
        // offset: 0; size: 2;
3396
3397
        // bit: 0, mask 0x01; 1 = objects are protected
3398
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3399
3400
        $this->phpSheet->getProtection()->setObjects((bool) $bool);
3401
    }
3402
3403
    /**
3404
     * PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8)
@@ 3424-3437 (lines=14) @@
3421
    /**
3422
     * Read DEFCOLWIDTH record
3423
     */
3424
    private function readDefColWidth()
3425
    {
3426
        $length = self::getInt2d($this->data, $this->pos + 2);
3427
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3428
3429
        // move stream pointer to next record
3430
        $this->pos += 4 + $length;
3431
3432
        // offset: 0; size: 2; default column width
3433
        $width = self::getInt2d($recordData, 0);
3434
        if ($width != 8) {
3435
            $this->phpSheet->getDefaultColumnDimension()->setWidth($width);
3436
        }
3437
    }
3438
3439
    /**
3440
     * Read COLINFO record