Code Duplication    Length = 13-19 lines in 8 locations

src/PhpSpreadsheet/Reader/Xls.php 8 locations

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