Code Duplication    Length = 13-19 lines in 8 locations

src/PhpSpreadsheet/Reader/Excel5.php 8 locations

@@ 1871-1883 (lines=13) @@
1868
     * --    "OpenOffice.org's Documentation of the Microsoft
1869
     *         Excel File Format"
1870
     */
1871
    private function readCodepage()
1872
    {
1873
        $length = self::getInt2d($this->data, $this->pos + 2);
1874
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
1875
1876
        // move stream pointer to next record
1877
        $this->pos += 4 + $length;
1878
1879
        // offset: 0; size: 2; code page identifier
1880
        $codepage = self::getInt2d($recordData, 0);
1881
1882
        $this->codepage = \PhpSpreadsheet\Shared\CodePage::numberToName($codepage);
1883
    }
1884
1885
1886
    /**
@@ 3042-3054 (lines=13) @@
3039
    /**
3040
     * Read DEFAULTROWHEIGHT record
3041
     */
3042
    private function readDefaultRowHeight()
3043
    {
3044
        $length = self::getInt2d($this->data, $this->pos + 2);
3045
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3046
3047
        // move stream pointer to next record
3048
        $this->pos += 4 + $length;
3049
3050
        // offset: 0; size: 2; option flags
3051
        // offset: 2; size: 2; default height for unused rows, (twips 1/20 point)
3052
        $height = self::getInt2d($recordData, 2);
3053
        $this->phpSheet->getDefaultRowDimension()->setRowHeight($height / 20);
3054
    }
3055
3056
3057
    /**
@@ 3198-3212 (lines=15) @@
3195
    /**
3196
     * Read HCENTER record
3197
     */
3198
    private function readHcenter()
3199
    {
3200
        $length = self::getInt2d($this->data, $this->pos + 2);
3201
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3202
3203
        // move stream pointer to next record
3204
        $this->pos += 4 + $length;
3205
3206
        if (!$this->readDataOnly) {
3207
            // offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally
3208
            $isHorizontalCentered = (bool) self::getInt2d($recordData, 0);
3209
3210
            $this->phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered);
3211
        }
3212
    }
3213
3214
3215
    /**
@@ 3218-3232 (lines=15) @@
3215
    /**
3216
     * Read VCENTER record
3217
     */
3218
    private function readVcenter()
3219
    {
3220
        $length = self::getInt2d($this->data, $this->pos + 2);
3221
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3222
3223
        // move stream pointer to next record
3224
        $this->pos += 4 + $length;
3225
3226
        if (!$this->readDataOnly) {
3227
            // offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered
3228
            $isVerticalCentered = (bool) self::getInt2d($recordData, 0);
3229
3230
            $this->phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered);
3231
        }
3232
    }
3233
3234
3235
    /**
@@ 3372-3389 (lines=18) @@
3369
     * PROTECT - Sheet protection (BIFF2 through BIFF8)
3370
     *   if this record is omitted, then it also means no sheet protection
3371
     */
3372
    private function readProtect()
3373
    {
3374
        $length = self::getInt2d($this->data, $this->pos + 2);
3375
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3376
3377
        // move stream pointer to next record
3378
        $this->pos += 4 + $length;
3379
3380
        if ($this->readDataOnly) {
3381
            return;
3382
        }
3383
3384
        // offset: 0; size: 2;
3385
3386
        // bit 0, mask 0x01; 1 = sheet is protected
3387
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3388
        $this->phpSheet->getProtection()->setSheet((bool)$bool);
3389
    }
3390
3391
3392
    /**
@@ 3395-3413 (lines=19) @@
3392
    /**
3393
     * SCENPROTECT
3394
     */
3395
    private function readScenProtect()
3396
    {
3397
        $length = self::getInt2d($this->data, $this->pos + 2);
3398
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3399
3400
        // move stream pointer to next record
3401
        $this->pos += 4 + $length;
3402
3403
        if ($this->readDataOnly) {
3404
            return;
3405
        }
3406
3407
        // offset: 0; size: 2;
3408
3409
        // bit: 0, mask 0x01; 1 = scenarios are protected
3410
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3411
3412
        $this->phpSheet->getProtection()->setScenarios((bool)$bool);
3413
    }
3414
3415
3416
    /**
@@ 3419-3437 (lines=19) @@
3416
    /**
3417
     * OBJECTPROTECT
3418
     */
3419
    private function readObjectProtect()
3420
    {
3421
        $length = self::getInt2d($this->data, $this->pos + 2);
3422
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3423
3424
        // move stream pointer to next record
3425
        $this->pos += 4 + $length;
3426
3427
        if ($this->readDataOnly) {
3428
            return;
3429
        }
3430
3431
        // offset: 0; size: 2;
3432
3433
        // bit: 0, mask 0x01; 1 = objects are protected
3434
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3435
3436
        $this->phpSheet->getProtection()->setObjects((bool)$bool);
3437
    }
3438
3439
3440
    /**
@@ 3462-3475 (lines=14) @@
3459
    /**
3460
     * Read DEFCOLWIDTH record
3461
     */
3462
    private function readDefColWidth()
3463
    {
3464
        $length = self::getInt2d($this->data, $this->pos + 2);
3465
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3466
3467
        // move stream pointer to next record
3468
        $this->pos += 4 + $length;
3469
3470
        // offset: 0; size: 2; default column width
3471
        $width = self::getInt2d($recordData, 0);
3472
        if ($width != 8) {
3473
            $this->phpSheet->getDefaultColumnDimension()->setWidth($width);
3474
        }
3475
    }
3476
3477
3478
    /**