Code Duplication    Length = 13-19 lines in 8 locations

src/PhpSpreadsheet/Reader/Excel5.php 8 locations

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