Code Duplication    Length = 13-19 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

@@ 1877-1889 (lines=13) @@
1874
     * --    "OpenOffice.org's Documentation of the Microsoft
1875
     *         Excel File Format"
1876
     */
1877
    private function readCodepage()
1878
    {
1879
        $length = self::getInt2d($this->data, $this->pos + 2);
1880
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
1881
1882
        // move stream pointer to next record
1883
        $this->pos += 4 + $length;
1884
1885
        // offset: 0; size: 2; code page identifier
1886
        $codepage = self::getInt2d($recordData, 0);
1887
1888
        $this->codepage = CodePage::numberToName($codepage);
1889
    }
1890
1891
    /**
1892
     * DATEMODE.
@@ 3029-3041 (lines=13) @@
3026
    /**
3027
     * Read DEFAULTROWHEIGHT record.
3028
     */
3029
    private function readDefaultRowHeight()
3030
    {
3031
        $length = self::getInt2d($this->data, $this->pos + 2);
3032
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3033
3034
        // move stream pointer to next record
3035
        $this->pos += 4 + $length;
3036
3037
        // offset: 0; size: 2; option flags
3038
        // offset: 2; size: 2; default height for unused rows, (twips 1/20 point)
3039
        $height = self::getInt2d($recordData, 2);
3040
        $this->phpSheet->getDefaultRowDimension()->setRowHeight($height / 20);
3041
    }
3042
3043
    /**
3044
     * Read SHEETPR record.
@@ 3179-3193 (lines=15) @@
3176
    /**
3177
     * Read HCENTER record.
3178
     */
3179
    private function readHcenter()
3180
    {
3181
        $length = self::getInt2d($this->data, $this->pos + 2);
3182
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3183
3184
        // move stream pointer to next record
3185
        $this->pos += 4 + $length;
3186
3187
        if (!$this->readDataOnly) {
3188
            // offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally
3189
            $isHorizontalCentered = (bool) self::getInt2d($recordData, 0);
3190
3191
            $this->phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered);
3192
        }
3193
    }
3194
3195
    /**
3196
     * Read VCENTER record.
@@ 3198-3212 (lines=15) @@
3195
    /**
3196
     * Read VCENTER record.
3197
     */
3198
    private function readVcenter()
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 aligned at top page border, 1 = print sheet vertically centered
3208
            $isVerticalCentered = (bool) self::getInt2d($recordData, 0);
3209
3210
            $this->phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered);
3211
        }
3212
    }
3213
3214
    /**
3215
     * Read LEFTMARGIN record.
@@ 3346-3363 (lines=18) @@
3343
     * PROTECT - Sheet protection (BIFF2 through BIFF8)
3344
     *   if this record is omitted, then it also means no sheet protection.
3345
     */
3346
    private function readProtect()
3347
    {
3348
        $length = self::getInt2d($this->data, $this->pos + 2);
3349
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3350
3351
        // move stream pointer to next record
3352
        $this->pos += 4 + $length;
3353
3354
        if ($this->readDataOnly) {
3355
            return;
3356
        }
3357
3358
        // offset: 0; size: 2;
3359
3360
        // bit 0, mask 0x01; 1 = sheet is protected
3361
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3362
        $this->phpSheet->getProtection()->setSheet((bool) $bool);
3363
    }
3364
3365
    /**
3366
     * SCENPROTECT.
@@ 3368-3386 (lines=19) @@
3365
    /**
3366
     * SCENPROTECT.
3367
     */
3368
    private function readScenProtect()
3369
    {
3370
        $length = self::getInt2d($this->data, $this->pos + 2);
3371
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3372
3373
        // move stream pointer to next record
3374
        $this->pos += 4 + $length;
3375
3376
        if ($this->readDataOnly) {
3377
            return;
3378
        }
3379
3380
        // offset: 0; size: 2;
3381
3382
        // bit: 0, mask 0x01; 1 = scenarios are protected
3383
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3384
3385
        $this->phpSheet->getProtection()->setScenarios((bool) $bool);
3386
    }
3387
3388
    /**
3389
     * OBJECTPROTECT.
@@ 3391-3409 (lines=19) @@
3388
    /**
3389
     * OBJECTPROTECT.
3390
     */
3391
    private function readObjectProtect()
3392
    {
3393
        $length = self::getInt2d($this->data, $this->pos + 2);
3394
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3395
3396
        // move stream pointer to next record
3397
        $this->pos += 4 + $length;
3398
3399
        if ($this->readDataOnly) {
3400
            return;
3401
        }
3402
3403
        // offset: 0; size: 2;
3404
3405
        // bit: 0, mask 0x01; 1 = objects are protected
3406
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3407
3408
        $this->phpSheet->getProtection()->setObjects((bool) $bool);
3409
    }
3410
3411
    /**
3412
     * PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8).
@@ 3432-3445 (lines=14) @@
3429
    /**
3430
     * Read DEFCOLWIDTH record.
3431
     */
3432
    private function readDefColWidth()
3433
    {
3434
        $length = self::getInt2d($this->data, $this->pos + 2);
3435
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3436
3437
        // move stream pointer to next record
3438
        $this->pos += 4 + $length;
3439
3440
        // offset: 0; size: 2; default column width
3441
        $width = self::getInt2d($recordData, 0);
3442
        if ($width != 8) {
3443
            $this->phpSheet->getDefaultColumnDimension()->setWidth($width);
3444
        }
3445
    }
3446
3447
    /**
3448
     * Read COLINFO record.