Code Duplication    Length = 13-19 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

@@ 1853-1865 (lines=13) @@
1850
     * --    "OpenOffice.org's Documentation of the Microsoft
1851
     *         Excel File Format"
1852
     */
1853
    private function readCodepage()
1854
    {
1855
        $length = self::getInt2d($this->data, $this->pos + 2);
1856
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
1857
1858
        // move stream pointer to next record
1859
        $this->pos += 4 + $length;
1860
1861
        // offset: 0; size: 2; code page identifier
1862
        $codepage = self::getInt2d($recordData, 0);
1863
1864
        $this->codepage = \PhpOffice\PhpSpreadsheet\Shared\CodePage::numberToName($codepage);
1865
    }
1866
1867
    /**
1868
     * DATEMODE.
@@ 3005-3017 (lines=13) @@
3002
    /**
3003
     * Read DEFAULTROWHEIGHT record.
3004
     */
3005
    private function readDefaultRowHeight()
3006
    {
3007
        $length = self::getInt2d($this->data, $this->pos + 2);
3008
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3009
3010
        // move stream pointer to next record
3011
        $this->pos += 4 + $length;
3012
3013
        // offset: 0; size: 2; option flags
3014
        // offset: 2; size: 2; default height for unused rows, (twips 1/20 point)
3015
        $height = self::getInt2d($recordData, 2);
3016
        $this->phpSheet->getDefaultRowDimension()->setRowHeight($height / 20);
3017
    }
3018
3019
    /**
3020
     * Read SHEETPR record.
@@ 3155-3169 (lines=15) @@
3152
    /**
3153
     * Read HCENTER record.
3154
     */
3155
    private function readHcenter()
3156
    {
3157
        $length = self::getInt2d($this->data, $this->pos + 2);
3158
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3159
3160
        // move stream pointer to next record
3161
        $this->pos += 4 + $length;
3162
3163
        if (!$this->readDataOnly) {
3164
            // offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally
3165
            $isHorizontalCentered = (bool) self::getInt2d($recordData, 0);
3166
3167
            $this->phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered);
3168
        }
3169
    }
3170
3171
    /**
3172
     * Read VCENTER record.
@@ 3174-3188 (lines=15) @@
3171
    /**
3172
     * Read VCENTER record.
3173
     */
3174
    private function readVcenter()
3175
    {
3176
        $length = self::getInt2d($this->data, $this->pos + 2);
3177
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3178
3179
        // move stream pointer to next record
3180
        $this->pos += 4 + $length;
3181
3182
        if (!$this->readDataOnly) {
3183
            // offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered
3184
            $isVerticalCentered = (bool) self::getInt2d($recordData, 0);
3185
3186
            $this->phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered);
3187
        }
3188
    }
3189
3190
    /**
3191
     * Read LEFTMARGIN record.
@@ 3322-3339 (lines=18) @@
3319
     * PROTECT - Sheet protection (BIFF2 through BIFF8)
3320
     *   if this record is omitted, then it also means no sheet protection.
3321
     */
3322
    private function readProtect()
3323
    {
3324
        $length = self::getInt2d($this->data, $this->pos + 2);
3325
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3326
3327
        // move stream pointer to next record
3328
        $this->pos += 4 + $length;
3329
3330
        if ($this->readDataOnly) {
3331
            return;
3332
        }
3333
3334
        // offset: 0; size: 2;
3335
3336
        // bit 0, mask 0x01; 1 = sheet is protected
3337
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3338
        $this->phpSheet->getProtection()->setSheet((bool) $bool);
3339
    }
3340
3341
    /**
3342
     * SCENPROTECT.
@@ 3344-3362 (lines=19) @@
3341
    /**
3342
     * SCENPROTECT.
3343
     */
3344
    private function readScenProtect()
3345
    {
3346
        $length = self::getInt2d($this->data, $this->pos + 2);
3347
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3348
3349
        // move stream pointer to next record
3350
        $this->pos += 4 + $length;
3351
3352
        if ($this->readDataOnly) {
3353
            return;
3354
        }
3355
3356
        // offset: 0; size: 2;
3357
3358
        // bit: 0, mask 0x01; 1 = scenarios are protected
3359
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3360
3361
        $this->phpSheet->getProtection()->setScenarios((bool) $bool);
3362
    }
3363
3364
    /**
3365
     * OBJECTPROTECT.
@@ 3367-3385 (lines=19) @@
3364
    /**
3365
     * OBJECTPROTECT.
3366
     */
3367
    private function readObjectProtect()
3368
    {
3369
        $length = self::getInt2d($this->data, $this->pos + 2);
3370
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3371
3372
        // move stream pointer to next record
3373
        $this->pos += 4 + $length;
3374
3375
        if ($this->readDataOnly) {
3376
            return;
3377
        }
3378
3379
        // offset: 0; size: 2;
3380
3381
        // bit: 0, mask 0x01; 1 = objects are protected
3382
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3383
3384
        $this->phpSheet->getProtection()->setObjects((bool) $bool);
3385
    }
3386
3387
    /**
3388
     * PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8).
@@ 3408-3421 (lines=14) @@
3405
    /**
3406
     * Read DEFCOLWIDTH record.
3407
     */
3408
    private function readDefColWidth()
3409
    {
3410
        $length = self::getInt2d($this->data, $this->pos + 2);
3411
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3412
3413
        // move stream pointer to next record
3414
        $this->pos += 4 + $length;
3415
3416
        // offset: 0; size: 2; default column width
3417
        $width = self::getInt2d($recordData, 0);
3418
        if ($width != 8) {
3419
            $this->phpSheet->getDefaultColumnDimension()->setWidth($width);
3420
        }
3421
    }
3422
3423
    /**
3424
     * Read COLINFO record.