Completed
Push — develop ( 2922a1...cfa1fe )
by Adrien
24:40
created

Xf::mapTextRotation()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 4
nop 1
dl 0
loc 10
rs 9.2
c 0
b 0
f 0
ccs 0
cts 10
cp 0
crap 20
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Writer\Excel5;
4
5
/**
6
 * Copyright (c) 2006 - 2015 PhpSpreadsheet
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
 *
22
 * @category   PhpSpreadsheet
23
 * @copyright  Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
24
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
25
 * @version    ##VERSION##, ##DATE##
26
 */
27
28
// Original file header of PEAR::Spreadsheet_Excel_Writer_Format (used as the base for this class):
29
// -----------------------------------------------------------------------------------------
30
// /*
31
// *  Module written/ported by Xavier Noguer <[email protected]>
32
// *
33
// *  The majority of this is _NOT_ my code.  I simply ported it from the
34
// *  PERL Spreadsheet::WriteExcel module.
35
// *
36
// *  The author of the Spreadsheet::WriteExcel module is John McNamara
37
// *  <[email protected]>
38
// *
39
// *  I _DO_ maintain this code, and John McNamara has nothing to do with the
40
// *  porting of this code to PHP.  Any questions directly related to this
41
// *  class library should be directed to me.
42
// *
43
// *  License Information:
44
// *
45
// *    Spreadsheet_Excel_Writer:  A library for generating Excel Spreadsheets
46
// *    Copyright (c) 2002-2003 Xavier Noguer [email protected]
47
// *
48
// *    This library is free software; you can redistribute it and/or
49
// *    modify it under the terms of the GNU Lesser General Public
50
// *    License as published by the Free Software Foundation; either
51
// *    version 2.1 of the License, or (at your option) any later version.
52
// *
53
// *    This library is distributed in the hope that it will be useful,
54
// *    but WITHOUT ANY WARRANTY; without even the implied warranty of
55
// *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
56
// *    Lesser General Public License for more details.
57
// *
58
// *    You should have received a copy of the GNU Lesser General Public
59
// *    License along with this library; if not, write to the Free Software
60
// *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
61
// */
62
class Xf
63
{
64
    /**
65
     * Style XF or a cell XF ?
66
     *
67
     * @var bool
68
     */
69
    private $isStyleXf;
70
71
    /**
72
     * Index to the FONT record. Index 4 does not exist
73
     * @var int
74
     */
75
    private $fontIndex;
76
77
    /**
78
     * An index (2 bytes) to a FORMAT record (number format).
79
     * @var int
80
     */
81
    private $numberFormatIndex;
82
83
    /**
84
     * 1 bit, apparently not used.
85
     * @var int
86
     */
87
    private $textJustLast;
88
89
    /**
90
     * The cell's foreground color.
91
     * @var int
92
     */
93
    private $foregroundColor;
94
95
    /**
96
     * The cell's background color.
97
     * @var int
98
     */
99
    private $backgroundColor;
100
101
    /**
102
     * Color of the bottom border of the cell.
103
     * @var int
104
     */
105
    private $bottomBorderColor;
106
107
    /**
108
     * Color of the top border of the cell.
109
     * @var int
110
     */
111
    private $topBorderColor;
112
113
    /**
114
     * Color of the left border of the cell.
115
     * @var int
116
     */
117
    private $leftBorderColor;
118
119
    /**
120
     * Color of the right border of the cell.
121
     * @var int
122
     */
123
    private $rightBorderColor;
124
125
    /**
126
     * Constructor
127
     *
128
     * @param \PhpOffice\PhpSpreadsheet\Style    The XF format
129
     */
130
    public function __construct(\PhpOffice\PhpSpreadsheet\Style $style = null)
131
    {
132
        $this->isStyleXf = false;
133
        $this->fontIndex = 0;
134
135
        $this->numberFormatIndex = 0;
136
137
        $this->textJustLast = 0;
138
139
        $this->foregroundColor = 0x40;
140
        $this->backgroundColor = 0x41;
141
142
        $this->_diag = 0;
0 ignored issues
show
Bug introduced by
The property _diag does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
143
144
        $this->bottomBorderColor = 0x40;
145
        $this->topBorderColor = 0x40;
146
        $this->leftBorderColor = 0x40;
147
        $this->rightBorderColor = 0x40;
148
        $this->_diag_color = 0x40;
0 ignored issues
show
Bug introduced by
The property _diag_color does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
149
        $this->_style = $style;
0 ignored issues
show
Bug introduced by
The property _style does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
150
    }
151
152
    /**
153
     * Generate an Excel BIFF XF record (style or cell).
154
     *
155
     * @return string The XF record
156
     */
157
    public function writeXf()
158
    {
159
        // Set the type of the XF record and some of the attributes.
160
        if ($this->isStyleXf) {
161
            $style = 0xFFF5;
162
        } else {
163
            $style = self::mapLocked($this->_style->getProtection()->getLocked());
164
            $style |= self::mapHidden($this->_style->getProtection()->getHidden()) << 1;
165
        }
166
167
        // Flags to indicate if attributes have been set.
168
        $atr_num = ($this->numberFormatIndex != 0) ? 1 : 0;
169
        $atr_fnt = ($this->fontIndex != 0) ? 1 : 0;
170
        $atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0;
171
        $atr_bdr = (self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
172
                        self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
173
                        self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
174
                        self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle())) ? 1 : 0;
175
        $atr_pat = (($this->foregroundColor != 0x40) ||
176
                        ($this->backgroundColor != 0x41) ||
177
                        self::mapFillType($this->_style->getFill()->getFillType())) ? 1 : 0;
178
        $atr_prot = self::mapLocked($this->_style->getProtection()->getLocked())
179
                        | self::mapHidden($this->_style->getProtection()->getHidden());
180
181
        // Zero the default border colour if the border has not been set.
182
        if (self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
183
            $this->bottomBorderColor = 0;
184
        }
185
        if (self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
186
            $this->topBorderColor = 0;
187
        }
188
        if (self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
189
            $this->rightBorderColor = 0;
190
        }
191
        if (self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
192
            $this->leftBorderColor = 0;
193
        }
194
        if (self::mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
195
            $this->_diag_color = 0;
196
        }
197
198
        $record = 0x00E0; // Record identifier
199
        $length = 0x0014; // Number of bytes to follow
200
201
        $ifnt = $this->fontIndex; // Index to FONT record
202
        $ifmt = $this->numberFormatIndex; // Index to FORMAT record
203
204
        $align = $this->mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
205
        $align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
206
        $align |= self::mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
207
        $align |= $this->textJustLast << 7;
208
209
        $used_attrib = $atr_num << 2;
210
        $used_attrib |= $atr_fnt << 3;
211
        $used_attrib |= $atr_alc << 4;
212
        $used_attrib |= $atr_bdr << 5;
213
        $used_attrib |= $atr_pat << 6;
214
        $used_attrib |= $atr_prot << 7;
215
216
        $icv = $this->foregroundColor; // fg and bg pattern colors
217
        $icv |= $this->backgroundColor << 7;
218
219
        $border1 = self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color
220
        $border1 |= self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
221
        $border1 |= self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
222
        $border1 |= self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
223
        $border1 |= $this->leftBorderColor << 16;
224
        $border1 |= $this->rightBorderColor << 23;
225
226
        $diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
227
        $diag_tl_to_rb = $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH
228
                            || $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_DOWN;
229
        $diag_tr_to_lb = $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH
230
                            || $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_UP;
231
        $border1 |= $diag_tl_to_rb << 30;
232
        $border1 |= $diag_tr_to_lb << 31;
233
234
        $border2 = $this->topBorderColor; // Border color
235
        $border2 |= $this->bottomBorderColor << 7;
236
        $border2 |= $this->_diag_color << 14;
237
        $border2 |= self::mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
238
        $border2 |= self::mapFillType($this->_style->getFill()->getFillType()) << 26;
239
240
        $header = pack('vv', $record, $length);
241
242
        //BIFF8 options: identation, shrinkToFit and  text direction
243
        $biff8_options = $this->_style->getAlignment()->getIndent();
244
        $biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
245
246
        $data = pack('vvvC', $ifnt, $ifmt, $style, $align);
247
        $data .= pack('CCC', self::mapTextRotation($this->_style->getAlignment()->getTextRotation()), $biff8_options, $used_attrib);
248
        $data .= pack('VVv', $border1, $border2, $icv);
249
250
        return $header . $data;
251
    }
252
253
    /**
254
     * Is this a style XF ?
255
     *
256
     * @param bool $value
257
     */
258
    public function setIsStyleXf($value)
259
    {
260
        $this->isStyleXf = $value;
261
    }
262
263
    /**
264
     * Sets the cell's bottom border color
265
     *
266
     * @param int $colorIndex Color index
267
     */
268
    public function setBottomColor($colorIndex)
269
    {
270
        $this->bottomBorderColor = $colorIndex;
271
    }
272
273
    /**
274
     * Sets the cell's top border color
275
     *
276
     * @param int $colorIndex Color index
277
     */
278
    public function setTopColor($colorIndex)
279
    {
280
        $this->topBorderColor = $colorIndex;
281
    }
282
283
    /**
284
     * Sets the cell's left border color
285
     *
286
     * @param int $colorIndex Color index
287
     */
288
    public function setLeftColor($colorIndex)
289
    {
290
        $this->leftBorderColor = $colorIndex;
291
    }
292
293
    /**
294
     * Sets the cell's right border color
295
     *
296
     * @param int $colorIndex Color index
297
     */
298
    public function setRightColor($colorIndex)
299
    {
300
        $this->rightBorderColor = $colorIndex;
301
    }
302
303
    /**
304
     * Sets the cell's diagonal border color
305
     *
306
     * @param int $colorIndex Color index
307
     */
308
    public function setDiagColor($colorIndex)
309
    {
310
        $this->_diag_color = $colorIndex;
311
    }
312
313
    /**
314
     * Sets the cell's foreground color
315
     *
316
     * @param int $colorIndex Color index
317
     */
318
    public function setFgColor($colorIndex)
319
    {
320
        $this->foregroundColor = $colorIndex;
321
    }
322
323
    /**
324
     * Sets the cell's background color
325
     *
326
     * @param int $colorIndex Color index
327
     */
328
    public function setBgColor($colorIndex)
329
    {
330
        $this->backgroundColor = $colorIndex;
331
    }
332
333
    /**
334
     * Sets the index to the number format record
335
     * It can be date, time, currency, etc...
336
     *
337
     * @param int $numberFormatIndex Index to format record
338
     */
339
    public function setNumberFormatIndex($numberFormatIndex)
340
    {
341
        $this->numberFormatIndex = $numberFormatIndex;
342
    }
343
344
    /**
345
     * Set the font index.
346
     *
347
     * @param int $value Font index, note that value 4 does not exist
348
     */
349
    public function setFontIndex($value)
350
    {
351
        $this->fontIndex = $value;
352
    }
353
354
    /**
355
     * Map of BIFF2-BIFF8 codes for border styles
356
     * @static    array of int
357
     */
358
    private static $mapBorderStyles = [
359
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE => 0x00,
360
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN => 0x01,
361
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUM => 0x02,
362
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHED => 0x03,
363
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOTTED => 0x04,
364
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK => 0x05,
365
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DOUBLE => 0x06,
366
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_HAIR => 0x07,
367
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHED => 0x08,
368
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOT => 0x09,
369
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOT => 0x0A,
370
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_DASHDOTDOT => 0x0B,
371
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_MEDIUMDASHDOTDOT => 0x0C,
372
        \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_SLANTDASHDOT => 0x0D,
373
    ];
374
375
    /**
376
     * Map border style
377
     *
378
     * @param string $borderStyle
379
     * @return int
380
     */
381
    private static function mapBorderStyle($borderStyle)
382
    {
383
        if (isset(self::$mapBorderStyles[$borderStyle])) {
384
            return self::$mapBorderStyles[$borderStyle];
385
        }
386
387
        return 0x00;
388
    }
389
390
    /**
391
     * Map of BIFF2-BIFF8 codes for fill types
392
     * @static    array of int
393
     */
394
    private static $mapFillTypes = [
395
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_NONE => 0x00,
396
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID => 0x01,
397
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_MEDIUMGRAY => 0x02,
398
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRAY => 0x03,
399
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRAY => 0x04,
400
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05,
401
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKVERTICAL => 0x06,
402
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKDOWN => 0x07,
403
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKUP => 0x08,
404
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRID => 0x09,
405
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKTRELLIS => 0x0A,
406
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B,
407
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C,
408
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTDOWN => 0x0D,
409
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTUP => 0x0E,
410
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRID => 0x0F,
411
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10,
412
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125 => 0x11,
413
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY0625 => 0x12,
414
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8
415
        \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8
416
    ];
417
418
    /**
419
     * Map fill type
420
     *
421
     * @param string $fillType
422
     * @return int
423
     */
424
    private static function mapFillType($fillType)
425
    {
426
        if (isset(self::$mapFillTypes[$fillType])) {
427
            return self::$mapFillTypes[$fillType];
428
        }
429
430
        return 0x00;
431
    }
432
433
    /**
434
     * Map of BIFF2-BIFF8 codes for horizontal alignment
435
     * @static    array of int
436
     */
437
    private static $mapHAlignments = [
438
        \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_GENERAL => 0,
439
        \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT => 1,
440
        \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER => 2,
441
        \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT => 3,
442
        \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_FILL => 4,
443
        \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY => 5,
444
        \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6,
445
    ];
446
447
    /**
448
     * Map to BIFF2-BIFF8 codes for horizontal alignment
449
     *
450
     * @param string $hAlign
451
     * @return int
452
     */
453
    private function mapHAlign($hAlign)
454
    {
455
        if (isset(self::$mapHAlignments[$hAlign])) {
456
            return self::$mapHAlignments[$hAlign];
457
        }
458
459
        return 0;
460
    }
461
462
    /**
463
     * Map of BIFF2-BIFF8 codes for vertical alignment
464
     * @static    array of int
465
     */
466
    private static $mapVAlignments = [
467
        \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP => 0,
468
        \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER => 1,
469
        \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM => 2,
470
        \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_JUSTIFY => 3,
471
    ];
472
473
    /**
474
     * Map to BIFF2-BIFF8 codes for vertical alignment
475
     *
476
     * @param string $vAlign
477
     * @return int
478
     */
479
    private static function mapVAlign($vAlign)
480
    {
481
        if (isset(self::$mapVAlignments[$vAlign])) {
482
            return self::$mapVAlignments[$vAlign];
483
        }
484
485
        return 2;
486
    }
487
488
    /**
489
     * Map to BIFF8 codes for text rotation angle
490
     *
491
     * @param int $textRotation
492
     * @return int
493
     */
494
    private static function mapTextRotation($textRotation)
495
    {
496
        if ($textRotation >= 0) {
497
            return $textRotation;
498
        } elseif ($textRotation == -165) {
499
            return 255;
500
        } elseif ($textRotation < 0) {
501
            return 90 - $textRotation;
502
        }
503
    }
504
505
    /**
506
     * Map locked
507
     *
508
     * @param string
509
     * @return int
510
     */
511
    private static function mapLocked($locked)
512
    {
513
        switch ($locked) {
514
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT:
515
                return 1;
516
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED:
517
                return 1;
518
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED:
519
                return 0;
520
            default:
521
                return 1;
522
        }
523
    }
524
525
    /**
526
     * Map hidden
527
     *
528
     * @param string
529
     * @return int
530
     */
531
    private static function mapHidden($hidden)
532
    {
533
        switch ($hidden) {
534
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT:
535
                return 0;
536
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED:
537
                return 1;
538
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED:
539
                return 0;
540
            default:
541
                return 0;
542
        }
543
    }
544
}
545