Completed
Push — develop ( 39b55d...e2e982 )
by Adrien
19:14
created

Xf::setFgColor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Writer\Xls;
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 38
    public function __construct(\PhpOffice\PhpSpreadsheet\Style $style = null)
131
    {
132 38
        $this->isStyleXf = false;
133 38
        $this->fontIndex = 0;
134
135 38
        $this->numberFormatIndex = 0;
136
137 38
        $this->textJustLast = 0;
138
139 38
        $this->foregroundColor = 0x40;
140 38
        $this->backgroundColor = 0x41;
141
142 38
        $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 38
        $this->bottomBorderColor = 0x40;
145 38
        $this->topBorderColor = 0x40;
146 38
        $this->leftBorderColor = 0x40;
147 38
        $this->rightBorderColor = 0x40;
148 38
        $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 38
        $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 38
    }
151
152
    /**
153
     * Generate an Excel BIFF XF record (style or cell).
154
     *
155
     * @return string The XF record
156
     */
157 38
    public function writeXf()
158
    {
159
        // Set the type of the XF record and some of the attributes.
160 38
        if ($this->isStyleXf) {
161 38
            $style = 0xFFF5;
162
        } else {
163 38
            $style = self::mapLocked($this->_style->getProtection()->getLocked());
164 38
            $style |= self::mapHidden($this->_style->getProtection()->getHidden()) << 1;
165
        }
166
167
        // Flags to indicate if attributes have been set.
168 38
        $atr_num = ($this->numberFormatIndex != 0) ? 1 : 0;
169 38
        $atr_fnt = ($this->fontIndex != 0) ? 1 : 0;
170 38
        $atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0;
171 38
        $atr_bdr = (self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
172 38
                        self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
173 38
                        self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
174 38
                        self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle())) ? 1 : 0;
175 38
        $atr_pat = (($this->foregroundColor != 0x40) ||
176
                        ($this->backgroundColor != 0x41) ||
177 38
                        self::mapFillType($this->_style->getFill()->getFillType())) ? 1 : 0;
178 38
        $atr_prot = self::mapLocked($this->_style->getProtection()->getLocked())
179 38
                        | self::mapHidden($this->_style->getProtection()->getHidden());
180
181
        // Zero the default border colour if the border has not been set.
182 38
        if (self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
183 38
            $this->bottomBorderColor = 0;
184
        }
185 38
        if (self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
186 38
            $this->topBorderColor = 0;
187
        }
188 38
        if (self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
189 38
            $this->rightBorderColor = 0;
190
        }
191 38
        if (self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
192 38
            $this->leftBorderColor = 0;
193
        }
194 38
        if (self::mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
195 38
            $this->_diag_color = 0;
196
        }
197
198 38
        $record = 0x00E0; // Record identifier
199 38
        $length = 0x0014; // Number of bytes to follow
200
201 38
        $ifnt = $this->fontIndex; // Index to FONT record
202 38
        $ifmt = $this->numberFormatIndex; // Index to FORMAT record
203
204 38
        $align = $this->mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
205 38
        $align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
206 38
        $align |= self::mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
207 38
        $align |= $this->textJustLast << 7;
208
209 38
        $used_attrib = $atr_num << 2;
210 38
        $used_attrib |= $atr_fnt << 3;
211 38
        $used_attrib |= $atr_alc << 4;
212 38
        $used_attrib |= $atr_bdr << 5;
213 38
        $used_attrib |= $atr_pat << 6;
214 38
        $used_attrib |= $atr_prot << 7;
215
216 38
        $icv = $this->foregroundColor; // fg and bg pattern colors
217 38
        $icv |= $this->backgroundColor << 7;
218
219 38
        $border1 = self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color
220 38
        $border1 |= self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
221 38
        $border1 |= self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
222 38
        $border1 |= self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
223 38
        $border1 |= $this->leftBorderColor << 16;
224 38
        $border1 |= $this->rightBorderColor << 23;
225
226 38
        $diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
227 38
        $diag_tl_to_rb = $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH
228 38
                            || $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_DOWN;
229 38
        $diag_tr_to_lb = $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_BOTH
230 38
                            || $diagonalDirection == \PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_UP;
231 38
        $border1 |= $diag_tl_to_rb << 30;
232 38
        $border1 |= $diag_tr_to_lb << 31;
233
234 38
        $border2 = $this->topBorderColor; // Border color
235 38
        $border2 |= $this->bottomBorderColor << 7;
236 38
        $border2 |= $this->_diag_color << 14;
237 38
        $border2 |= self::mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
238 38
        $border2 |= self::mapFillType($this->_style->getFill()->getFillType()) << 26;
239
240 38
        $header = pack('vv', $record, $length);
241
242
        //BIFF8 options: identation, shrinkToFit and  text direction
243 38
        $biff8_options = $this->_style->getAlignment()->getIndent();
244 38
        $biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
245
246 38
        $data = pack('vvvC', $ifnt, $ifmt, $style, $align);
247 38
        $data .= pack('CCC', self::mapTextRotation($this->_style->getAlignment()->getTextRotation()), $biff8_options, $used_attrib);
248 38
        $data .= pack('VVv', $border1, $border2, $icv);
249
250 38
        return $header . $data;
251
    }
252
253
    /**
254
     * Is this a style XF ?
255
     *
256
     * @param bool $value
257
     */
258 38
    public function setIsStyleXf($value)
259
    {
260 38
        $this->isStyleXf = $value;
261 38
    }
262
263
    /**
264
     * Sets the cell's bottom border color
265
     *
266
     * @param int $colorIndex Color index
267
     */
268 38
    public function setBottomColor($colorIndex)
269
    {
270 38
        $this->bottomBorderColor = $colorIndex;
271 38
    }
272
273
    /**
274
     * Sets the cell's top border color
275
     *
276
     * @param int $colorIndex Color index
277
     */
278 38
    public function setTopColor($colorIndex)
279
    {
280 38
        $this->topBorderColor = $colorIndex;
281 38
    }
282
283
    /**
284
     * Sets the cell's left border color
285
     *
286
     * @param int $colorIndex Color index
287
     */
288 38
    public function setLeftColor($colorIndex)
289
    {
290 38
        $this->leftBorderColor = $colorIndex;
291 38
    }
292
293
    /**
294
     * Sets the cell's right border color
295
     *
296
     * @param int $colorIndex Color index
297
     */
298 38
    public function setRightColor($colorIndex)
299
    {
300 38
        $this->rightBorderColor = $colorIndex;
301 38
    }
302
303
    /**
304
     * Sets the cell's diagonal border color
305
     *
306
     * @param int $colorIndex Color index
307
     */
308 38
    public function setDiagColor($colorIndex)
309
    {
310 38
        $this->_diag_color = $colorIndex;
311 38
    }
312
313
    /**
314
     * Sets the cell's foreground color
315
     *
316
     * @param int $colorIndex Color index
317
     */
318 38
    public function setFgColor($colorIndex)
319
    {
320 38
        $this->foregroundColor = $colorIndex;
321 38
    }
322
323
    /**
324
     * Sets the cell's background color
325
     *
326
     * @param int $colorIndex Color index
327
     */
328 38
    public function setBgColor($colorIndex)
329
    {
330 38
        $this->backgroundColor = $colorIndex;
331 38
    }
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 38
    public function setNumberFormatIndex($numberFormatIndex)
340
    {
341 38
        $this->numberFormatIndex = $numberFormatIndex;
342 38
    }
343
344
    /**
345
     * Set the font index.
346
     *
347
     * @param int $value Font index, note that value 4 does not exist
348
     */
349 38
    public function setFontIndex($value)
350
    {
351 38
        $this->fontIndex = $value;
352 38
    }
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 38
    private static function mapBorderStyle($borderStyle)
382
    {
383 38
        if (isset(self::$mapBorderStyles[$borderStyle])) {
384 38
            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 38
    private static function mapFillType($fillType)
425
    {
426 38
        if (isset(self::$mapFillTypes[$fillType])) {
427 38
            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 38
    private function mapHAlign($hAlign)
454
    {
455 38
        if (isset(self::$mapHAlignments[$hAlign])) {
456 38
            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 38
    private static function mapVAlign($vAlign)
480
    {
481 38
        if (isset(self::$mapVAlignments[$vAlign])) {
482 38
            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 38
    private static function mapTextRotation($textRotation)
495
    {
496 38
        if ($textRotation >= 0) {
497 38
            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 38
    private static function mapLocked($locked)
512
    {
513
        switch ($locked) {
514 38
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT:
515 38
                return 1;
516 7
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED:
517
                return 1;
518 7
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED:
519 7
                return 0;
520
            default:
521
                return 1;
522
        }
523
    }
524
525
    /**
526
     * Map hidden
527
     *
528
     * @param string
529
     * @return int
530
     */
531 38
    private static function mapHidden($hidden)
532
    {
533
        switch ($hidden) {
534 38
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT:
535 35
                return 0;
536 4
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED:
537
                return 1;
538 4
            case \PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED:
539 4
                return 0;
540
            default:
541
                return 0;
542
        }
543
    }
544
}
545