Code Duplication    Length = 13-19 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

@@ 1841-1853 (lines=13) @@
1838
     * --    "OpenOffice.org's Documentation of the Microsoft
1839
     *         Excel File Format"
1840
     */
1841
    private function readCodepage()
1842
    {
1843
        $length = self::getInt2d($this->data, $this->pos + 2);
1844
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
1845
1846
        // move stream pointer to next record
1847
        $this->pos += 4 + $length;
1848
1849
        // offset: 0; size: 2; code page identifier
1850
        $codepage = self::getInt2d($recordData, 0);
1851
1852
        $this->codepage = \PhpOffice\PhpSpreadsheet\Shared\CodePage::numberToName($codepage);
1853
    }
1854
1855
    /**
1856
     * DATEMODE
@@ 2997-3009 (lines=13) @@
2994
    /**
2995
     * Read DEFAULTROWHEIGHT record
2996
     */
2997
    private function readDefaultRowHeight()
2998
    {
2999
        $length = self::getInt2d($this->data, $this->pos + 2);
3000
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3001
3002
        // move stream pointer to next record
3003
        $this->pos += 4 + $length;
3004
3005
        // offset: 0; size: 2; option flags
3006
        // offset: 2; size: 2; default height for unused rows, (twips 1/20 point)
3007
        $height = self::getInt2d($recordData, 2);
3008
        $this->phpSheet->getDefaultRowDimension()->setRowHeight($height / 20);
3009
    }
3010
3011
    /**
3012
     * Read SHEETPR record
@@ 3147-3161 (lines=15) @@
3144
    /**
3145
     * Read HCENTER record
3146
     */
3147
    private function readHcenter()
3148
    {
3149
        $length = self::getInt2d($this->data, $this->pos + 2);
3150
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3151
3152
        // move stream pointer to next record
3153
        $this->pos += 4 + $length;
3154
3155
        if (!$this->readDataOnly) {
3156
            // offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally
3157
            $isHorizontalCentered = (bool) self::getInt2d($recordData, 0);
3158
3159
            $this->phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered);
3160
        }
3161
    }
3162
3163
    /**
3164
     * Read VCENTER record
@@ 3166-3180 (lines=15) @@
3163
    /**
3164
     * Read VCENTER record
3165
     */
3166
    private function readVcenter()
3167
    {
3168
        $length = self::getInt2d($this->data, $this->pos + 2);
3169
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3170
3171
        // move stream pointer to next record
3172
        $this->pos += 4 + $length;
3173
3174
        if (!$this->readDataOnly) {
3175
            // offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered
3176
            $isVerticalCentered = (bool) self::getInt2d($recordData, 0);
3177
3178
            $this->phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered);
3179
        }
3180
    }
3181
3182
    /**
3183
     * Read LEFTMARGIN record
@@ 3314-3331 (lines=18) @@
3311
     * PROTECT - Sheet protection (BIFF2 through BIFF8)
3312
     *   if this record is omitted, then it also means no sheet protection
3313
     */
3314
    private function readProtect()
3315
    {
3316
        $length = self::getInt2d($this->data, $this->pos + 2);
3317
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3318
3319
        // move stream pointer to next record
3320
        $this->pos += 4 + $length;
3321
3322
        if ($this->readDataOnly) {
3323
            return;
3324
        }
3325
3326
        // offset: 0; size: 2;
3327
3328
        // bit 0, mask 0x01; 1 = sheet is protected
3329
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3330
        $this->phpSheet->getProtection()->setSheet((bool) $bool);
3331
    }
3332
3333
    /**
3334
     * SCENPROTECT
@@ 3336-3354 (lines=19) @@
3333
    /**
3334
     * SCENPROTECT
3335
     */
3336
    private function readScenProtect()
3337
    {
3338
        $length = self::getInt2d($this->data, $this->pos + 2);
3339
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3340
3341
        // move stream pointer to next record
3342
        $this->pos += 4 + $length;
3343
3344
        if ($this->readDataOnly) {
3345
            return;
3346
        }
3347
3348
        // offset: 0; size: 2;
3349
3350
        // bit: 0, mask 0x01; 1 = scenarios are protected
3351
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3352
3353
        $this->phpSheet->getProtection()->setScenarios((bool) $bool);
3354
    }
3355
3356
    /**
3357
     * OBJECTPROTECT
@@ 3359-3377 (lines=19) @@
3356
    /**
3357
     * OBJECTPROTECT
3358
     */
3359
    private function readObjectProtect()
3360
    {
3361
        $length = self::getInt2d($this->data, $this->pos + 2);
3362
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3363
3364
        // move stream pointer to next record
3365
        $this->pos += 4 + $length;
3366
3367
        if ($this->readDataOnly) {
3368
            return;
3369
        }
3370
3371
        // offset: 0; size: 2;
3372
3373
        // bit: 0, mask 0x01; 1 = objects are protected
3374
        $bool = (0x01 & self::getInt2d($recordData, 0)) >> 0;
3375
3376
        $this->phpSheet->getProtection()->setObjects((bool) $bool);
3377
    }
3378
3379
    /**
3380
     * PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8)
@@ 3400-3413 (lines=14) @@
3397
    /**
3398
     * Read DEFCOLWIDTH record
3399
     */
3400
    private function readDefColWidth()
3401
    {
3402
        $length = self::getInt2d($this->data, $this->pos + 2);
3403
        $recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
3404
3405
        // move stream pointer to next record
3406
        $this->pos += 4 + $length;
3407
3408
        // offset: 0; size: 2; default column width
3409
        $width = self::getInt2d($recordData, 0);
3410
        if ($width != 8) {
3411
            $this->phpSheet->getDefaultColumnDimension()->setWidth($width);
3412
        }
3413
    }
3414
3415
    /**
3416
     * Read COLINFO record