Failed Conditions
Push — master ( a2bb82...a189d9 )
by Adrien
10:27 queued 01:00
created

Style::getAlignment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Style;
4
5
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
6
use PhpOffice\PhpSpreadsheet\Spreadsheet;
7
8
class Style extends Supervisor
9
{
10
    /**
11
     * Font.
12
     *
13
     * @var Font
14
     */
15
    protected $font;
16
17
    /**
18
     * Fill.
19
     *
20
     * @var Fill
21
     */
22
    protected $fill;
23
24
    /**
25
     * Borders.
26
     *
27
     * @var Borders
28
     */
29
    protected $borders;
30
31
    /**
32
     * Alignment.
33
     *
34
     * @var Alignment
35
     */
36
    protected $alignment;
37
38
    /**
39
     * Number Format.
40
     *
41
     * @var NumberFormat
42
     */
43
    protected $numberFormat;
44
45
    /**
46
     * Protection.
47
     *
48
     * @var Protection
49
     */
50
    protected $protection;
51
52
    /**
53
     * Index of style in collection. Only used for real style.
54
     *
55
     * @var int
56
     */
57
    protected $index;
58
59
    /**
60
     * Use Quote Prefix when displaying in cell editor. Only used for real style.
61
     *
62
     * @var bool
63
     */
64
    protected $quotePrefix = false;
65
66
    /**
67
     * Create a new Style.
68
     *
69
     * @param bool $isSupervisor Flag indicating if this is a supervisor or not
70
     *         Leave this value at default unless you understand exactly what
71
     *    its ramifications are
72
     * @param bool $isConditional Flag indicating if this is a conditional style or not
73
     *       Leave this value at default unless you understand exactly what
74
     *    its ramifications are
75
     */
76 3867
    public function __construct($isSupervisor = false, $isConditional = false)
77
    {
78 3867
        parent::__construct($isSupervisor);
79
80
        // Initialise values
81 3867
        $this->font = new Font($isSupervisor, $isConditional);
82 3867
        $this->fill = new Fill($isSupervisor, $isConditional);
83 3867
        $this->borders = new Borders($isSupervisor);
84 3867
        $this->alignment = new Alignment($isSupervisor, $isConditional);
85 3867
        $this->numberFormat = new NumberFormat($isSupervisor, $isConditional);
86 3867
        $this->protection = new Protection($isSupervisor, $isConditional);
87
88
        // bind parent if we are a supervisor
89 3867
        if ($isSupervisor) {
90 3865
            $this->font->bindParent($this);
91 3865
            $this->fill->bindParent($this);
92 3865
            $this->borders->bindParent($this);
93 3865
            $this->alignment->bindParent($this);
94 3865
            $this->numberFormat->bindParent($this);
95 3865
            $this->protection->bindParent($this);
96
        }
97 3867
    }
98
99
    /**
100
     * Get the shared style component for the currently active cell in currently active sheet.
101
     * Only used for style supervisor.
102
     *
103
     * @return Style
104
     */
105 3321
    public function getSharedComponent()
106
    {
107 3321
        $activeSheet = $this->getActiveSheet();
108 3321
        $selectedCell = $this->getActiveCell(); // e.g. 'A1'
109
110 3321
        if ($activeSheet->cellExists($selectedCell)) {
111 3321
            $xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex();
112
        } else {
113 4
            $xfIndex = 0;
114
        }
115
116 3321
        return $this->parent->getCellXfByIndex($xfIndex);
0 ignored issues
show
Bug introduced by
The method getCellXfByIndex() does not exist on PhpOffice\PhpSpreadsheet\Style\Style. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

116
        return $this->parent->/** @scrutinizer ignore-call */ getCellXfByIndex($xfIndex);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
117
    }
118
119
    /**
120
     * Get parent. Only used for style supervisor.
121
     *
122
     * @return Spreadsheet
123
     */
124 1
    public function getParent()
125
    {
126 1
        return $this->parent;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->parent also could return the type PhpOffice\PhpSpreadsheet\Style\Style which is incompatible with the documented return type PhpOffice\PhpSpreadsheet\Spreadsheet.
Loading history...
127
    }
128
129
    /**
130
     * Build style array from subcomponents.
131
     *
132
     * @param array $array
133
     *
134
     * @return array
135
     */
136 1
    public function getStyleArray($array)
137
    {
138 1
        return ['quotePrefix' => $array];
139
    }
140
141
    /**
142
     * Apply styles from array.
143
     *
144
     * <code>
145
     * $spreadsheet->getActiveSheet()->getStyle('B2')->applyFromArray(
146
     *     [
147
     *         'font' => [
148
     *             'name' => 'Arial',
149
     *             'bold' => true,
150
     *             'italic' => false,
151
     *             'underline' => Font::UNDERLINE_DOUBLE,
152
     *             'strikethrough' => false,
153
     *             'color' => [
154
     *                 'rgb' => '808080'
155
     *             ]
156
     *         ],
157
     *         'borders' => [
158
     *             'bottom' => [
159
     *                 'borderStyle' => Border::BORDER_DASHDOT,
160
     *                 'color' => [
161
     *                     'rgb' => '808080'
162
     *                 ]
163
     *             ],
164
     *             'top' => [
165
     *                 'borderStyle' => Border::BORDER_DASHDOT,
166
     *                 'color' => [
167
     *                     'rgb' => '808080'
168
     *                 ]
169
     *             ]
170
     *         ],
171
     *         'alignment' => [
172
     *             'horizontal' => Alignment::HORIZONTAL_CENTER,
173
     *             'vertical' => Alignment::VERTICAL_CENTER,
174
     *             'wrapText' => true,
175
     *         ],
176
     *         'quotePrefix'    => true
177
     *     ]
178
     * );
179
     * </code>
180
     *
181
     * @param array $pStyles Array containing style information
182
     * @param bool $pAdvanced advanced mode for setting borders
183
     *
184
     * @return $this
185
     */
186 248
    public function applyFromArray(array $pStyles, $pAdvanced = true)
187
    {
188 248
        if ($this->isSupervisor) {
189 247
            $pRange = $this->getSelectedCells();
190
191
            // Uppercase coordinate
192 247
            $pRange = strtoupper($pRange);
193
194
            // Is it a cell range or a single cell?
195 247
            if (strpos($pRange, ':') === false) {
196 214
                $rangeA = $pRange;
197 214
                $rangeB = $pRange;
198
            } else {
199 81
                [$rangeA, $rangeB] = explode(':', $pRange);
200
            }
201
202
            // Calculate range outer borders
203 247
            $rangeStart = Coordinate::coordinateFromString($rangeA);
204 247
            $rangeEnd = Coordinate::coordinateFromString($rangeB);
205
206
            // Translate column into index
207 247
            $rangeStart0 = $rangeStart[0];
208 247
            $rangeEnd0 = $rangeEnd[0];
209 247
            $rangeStart[0] = Coordinate::columnIndexFromString($rangeStart[0]);
210 247
            $rangeEnd[0] = Coordinate::columnIndexFromString($rangeEnd[0]);
211
212
            // Make sure we can loop upwards on rows and columns
213 247
            if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
214 1
                $tmp = $rangeStart;
215 1
                $rangeStart = $rangeEnd;
216 1
                $rangeEnd = $tmp;
217
            }
218
219
            // ADVANCED MODE:
220 247
            if ($pAdvanced && isset($pStyles['borders'])) {
221
                // 'allBorders' is a shorthand property for 'outline' and 'inside' and
222
                //        it applies to components that have not been set explicitly
223 55
                if (isset($pStyles['borders']['allBorders'])) {
224 4
                    foreach (['outline', 'inside'] as $component) {
225 4
                        if (!isset($pStyles['borders'][$component])) {
226 4
                            $pStyles['borders'][$component] = $pStyles['borders']['allBorders'];
227
                        }
228
                    }
229 4
                    unset($pStyles['borders']['allBorders']); // not needed any more
230
                }
231
                // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left'
232
                //        it applies to components that have not been set explicitly
233 55
                if (isset($pStyles['borders']['outline'])) {
234 21
                    foreach (['top', 'right', 'bottom', 'left'] as $component) {
235 21
                        if (!isset($pStyles['borders'][$component])) {
236 21
                            $pStyles['borders'][$component] = $pStyles['borders']['outline'];
237
                        }
238
                    }
239 21
                    unset($pStyles['borders']['outline']); // not needed any more
240
                }
241
                // 'inside' is a shorthand property for 'vertical' and 'horizontal'
242
                //        it applies to components that have not been set explicitly
243 55
                if (isset($pStyles['borders']['inside'])) {
244 5
                    foreach (['vertical', 'horizontal'] as $component) {
245 5
                        if (!isset($pStyles['borders'][$component])) {
246 5
                            $pStyles['borders'][$component] = $pStyles['borders']['inside'];
247
                        }
248
                    }
249 5
                    unset($pStyles['borders']['inside']); // not needed any more
250
                }
251
                // width and height characteristics of selection, 1, 2, or 3 (for 3 or more)
252 55
                $xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3);
253 55
                $yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3);
254
255
                // loop through up to 3 x 3 = 9 regions
256 55
                for ($x = 1; $x <= $xMax; ++$x) {
257
                    // start column index for region
258 55
                    $colStart = ($x == 3) ?
259 19
                        Coordinate::stringFromColumnIndex($rangeEnd[0])
260 55
                        : Coordinate::stringFromColumnIndex($rangeStart[0] + $x - 1);
261
                    // end column index for region
262 55
                    $colEnd = ($x == 1) ?
263 55
                        Coordinate::stringFromColumnIndex($rangeStart[0])
264 55
                        : Coordinate::stringFromColumnIndex($rangeEnd[0] - $xMax + $x);
265
266 55
                    for ($y = 1; $y <= $yMax; ++$y) {
267
                        // which edges are touching the region
268 55
                        $edges = [];
269 55
                        if ($x == 1) {
270
                            // are we at left edge
271 55
                            $edges[] = 'left';
272
                        }
273 55
                        if ($x == $xMax) {
274
                            // are we at right edge
275 55
                            $edges[] = 'right';
276
                        }
277 55
                        if ($y == 1) {
278
                            // are we at top edge?
279 55
                            $edges[] = 'top';
280
                        }
281 55
                        if ($y == $yMax) {
282
                            // are we at bottom edge?
283 55
                            $edges[] = 'bottom';
284
                        }
285
286
                        // start row index for region
287 55
                        $rowStart = ($y == 3) ?
288 55
                            $rangeEnd[1] : $rangeStart[1] + $y - 1;
289
290
                        // end row index for region
291 55
                        $rowEnd = ($y == 1) ?
292 55
                            $rangeStart[1] : $rangeEnd[1] - $yMax + $y;
293
294
                        // build range for region
295 55
                        $range = $colStart . $rowStart . ':' . $colEnd . $rowEnd;
296
297
                        // retrieve relevant style array for region
298 55
                        $regionStyles = $pStyles;
299 55
                        unset($regionStyles['borders']['inside']);
300
301
                        // what are the inner edges of the region when looking at the selection
302 55
                        $innerEdges = array_diff(['top', 'right', 'bottom', 'left'], $edges);
303
304
                        // inner edges that are not touching the region should take the 'inside' border properties if they have been set
305 55
                        foreach ($innerEdges as $innerEdge) {
306
                            switch ($innerEdge) {
307 36
                                case 'top':
308 36
                                case 'bottom':
309
                                    // should pick up 'horizontal' border property if set
310 35
                                    if (isset($pStyles['borders']['horizontal'])) {
311 3
                                        $regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal'];
312
                                    } else {
313 32
                                        unset($regionStyles['borders'][$innerEdge]);
314
                                    }
315
316 35
                                    break;
317 36
                                case 'left':
318 36
                                case 'right':
319
                                    // should pick up 'vertical' border property if set
320 36
                                    if (isset($pStyles['borders']['vertical'])) {
321 3
                                        $regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical'];
322
                                    } else {
323 33
                                        unset($regionStyles['borders'][$innerEdge]);
324
                                    }
325
326 36
                                    break;
327
                            }
328
                        }
329
330
                        // apply region style to region by calling applyFromArray() in simple mode
331 55
                        $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStyles, false);
332
                    }
333
                }
334
335
                // restore initial cell selection range
336 55
                $this->getActiveSheet()->getStyle($pRange);
337
338 55
                return $this;
339
            }
340
341
            // SIMPLE MODE:
342
            // Selection type, inspect
343 247
            if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) {
344 3
                $selectionType = 'COLUMN';
345 247
            } elseif (preg_match('/^A\d+:XFD\d+$/', $pRange)) {
346 1
                $selectionType = 'ROW';
347
            } else {
348 247
                $selectionType = 'CELL';
349
            }
350
351
            // First loop through columns, rows, or cells to find out which styles are affected by this operation
352 247
            $oldXfIndexes = $this->getOldXfIndexes($selectionType, $rangeStart, $rangeEnd, $rangeStart0, $rangeEnd0, $pStyles);
353
354
            // clone each of the affected styles, apply the style array, and add the new styles to the workbook
355 247
            $workbook = $this->getActiveSheet()->getParent();
356 247
            $newXfIndexes = [];
357 247
            foreach ($oldXfIndexes as $oldXfIndex => $dummy) {
358 247
                $style = $workbook->getCellXfByIndex($oldXfIndex);
359 247
                $newStyle = clone $style;
360 247
                $newStyle->applyFromArray($pStyles);
361
362 247
                if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
363
                    // there is already such cell Xf in our collection
364 101
                    $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex();
365
                } else {
366
                    // we don't have such a cell Xf, need to add
367 232
                    $workbook->addCellXf($newStyle);
368 232
                    $newXfIndexes[$oldXfIndex] = $newStyle->getIndex();
369
                }
370
            }
371
372
            // Loop through columns, rows, or cells again and update the XF index
373
            switch ($selectionType) {
374 247
                case 'COLUMN':
375 3
                    for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
376 3
                        $columnDimension = $this->getActiveSheet()->getColumnDimensionByColumn($col);
377 3
                        $oldXfIndex = $columnDimension->getXfIndex();
378 3
                        $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
379
                    }
380
381 3
                    break;
382 247
                case 'ROW':
383 1
                    for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
384 1
                        $rowDimension = $this->getActiveSheet()->getRowDimension($row);
0 ignored issues
show
Bug introduced by
$row of type string is incompatible with the type integer expected by parameter $pRow of PhpOffice\PhpSpreadsheet...heet::getRowDimension(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

384
                        $rowDimension = $this->getActiveSheet()->getRowDimension(/** @scrutinizer ignore-type */ $row);
Loading history...
385
                        // row without explicit style should be formatted based on default style
386 1
                        $oldXfIndex = $rowDimension->getXfIndex() ?? 0;
387 1
                        $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
388
                    }
389
390 1
                    break;
391 247
                case 'CELL':
392 247
                    for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
393 247
                        for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
394 247
                            $cell = $this->getActiveSheet()->getCellByColumnAndRow($col, $row);
0 ignored issues
show
Bug introduced by
$row of type string is incompatible with the type integer expected by parameter $row of PhpOffice\PhpSpreadsheet...getCellByColumnAndRow(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

394
                            $cell = $this->getActiveSheet()->getCellByColumnAndRow($col, /** @scrutinizer ignore-type */ $row);
Loading history...
395 247
                            $oldXfIndex = $cell->getXfIndex();
396 247
                            $cell->setXfIndex($newXfIndexes[$oldXfIndex]);
397
                        }
398
                    }
399
400 247
                    break;
401
            }
402
        } else {
403
            // not a supervisor, just apply the style array directly on style object
404 248
            if (isset($pStyles['fill'])) {
405 52
                $this->getFill()->applyFromArray($pStyles['fill']);
406
            }
407 248
            if (isset($pStyles['font'])) {
408 69
                $this->getFont()->applyFromArray($pStyles['font']);
409
            }
410 248
            if (isset($pStyles['borders'])) {
411 56
                $this->getBorders()->applyFromArray($pStyles['borders']);
412
            }
413 248
            if (isset($pStyles['alignment'])) {
414 60
                $this->getAlignment()->applyFromArray($pStyles['alignment']);
415
            }
416 248
            if (isset($pStyles['numberFormat'])) {
417 194
                $this->getNumberFormat()->applyFromArray($pStyles['numberFormat']);
418
            }
419 248
            if (isset($pStyles['protection'])) {
420 23
                $this->getProtection()->applyFromArray($pStyles['protection']);
421
            }
422 248
            if (isset($pStyles['quotePrefix'])) {
423 2
                $this->quotePrefix = $pStyles['quotePrefix'];
424
            }
425
        }
426
427 248
        return $this;
428
    }
429
430 247
    private function getOldXfIndexes(string $selectionType, array $rangeStart, array $rangeEnd, string $rangeStart0, string $rangeEnd0, array $pStyles): array
431
    {
432 247
        $oldXfIndexes = [];
433
        switch ($selectionType) {
434 247
            case 'COLUMN':
435 3
                for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
436 3
                    $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true;
437
                }
438 3
                foreach ($this->getActiveSheet()->getColumnIterator($rangeStart0, $rangeEnd0) as $columnIterator) {
439 3
                    $cellIterator = $columnIterator->getCellIterator();
440 3
                    $cellIterator->setIterateOnlyExistingCells(true);
441 3
                    foreach ($cellIterator as $columnCell) {
442 2
                        if ($columnCell !== null) {
443 2
                            $columnCell->getStyle()->applyFromArray($pStyles);
444
                        }
445
                    }
446
                }
447
448 3
                break;
449 247
            case 'ROW':
450 1
                for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
451 1
                    if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() === null) {
452 1
                        $oldXfIndexes[0] = true; // row without explicit style should be formatted based on default style
453
                    } else {
454 1
                        $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true;
455
                    }
456
                }
457 1
                foreach ($this->getActiveSheet()->getRowIterator((int) $rangeStart[1], (int) $rangeEnd[1]) as $rowIterator) {
458 1
                    $cellIterator = $rowIterator->getCellIterator();
459 1
                    $cellIterator->setIterateOnlyExistingCells(true);
460 1
                    foreach ($cellIterator as $rowCell) {
461 1
                        if ($rowCell !== null) {
462 1
                            $rowCell->getStyle()->applyFromArray($pStyles);
463
                        }
464
                    }
465
                }
466
467 1
                break;
468 247
            case 'CELL':
469 247
                for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
470 247
                    for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
471 247
                        $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true;
472
                    }
473
                }
474
475 247
                break;
476
        }
477
478 247
        return $oldXfIndexes;
479
    }
480
481
    /**
482
     * Get Fill.
483
     *
484
     * @return Fill
485
     */
486 422
    public function getFill()
487
    {
488 422
        return $this->fill;
489
    }
490
491
    /**
492
     * Get Font.
493
     *
494
     * @return Font
495
     */
496 423
    public function getFont()
497
    {
498 423
        return $this->font;
499
    }
500
501
    /**
502
     * Set font.
503
     *
504
     * @return $this
505
     */
506 38
    public function setFont(Font $font)
507
    {
508 38
        $this->font = $font;
509
510 38
        return $this;
511
    }
512
513
    /**
514
     * Get Borders.
515
     *
516
     * @return Borders
517
     */
518 416
    public function getBorders()
519
    {
520 416
        return $this->borders;
521
    }
522
523
    /**
524
     * Get Alignment.
525
     *
526
     * @return Alignment
527
     */
528 425
    public function getAlignment()
529
    {
530 425
        return $this->alignment;
531
    }
532
533
    /**
534
     * Get Number Format.
535
     *
536
     * @return NumberFormat
537
     */
538 472
    public function getNumberFormat()
539
    {
540 472
        return $this->numberFormat;
541
    }
542
543
    /**
544
     * Get Conditional Styles. Only used on supervisor.
545
     *
546
     * @return Conditional[]
547
     */
548 3
    public function getConditionalStyles()
549
    {
550 3
        return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell());
551
    }
552
553
    /**
554
     * Set Conditional Styles. Only used on supervisor.
555
     *
556
     * @param Conditional[] $pValue Array of conditional styles
557
     *
558
     * @return $this
559
     */
560 13
    public function setConditionalStyles(array $pValue)
561
    {
562 13
        $this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue);
563
564 13
        return $this;
565
    }
566
567
    /**
568
     * Get Protection.
569
     *
570
     * @return Protection
571
     */
572 175
    public function getProtection()
573
    {
574 175
        return $this->protection;
575
    }
576
577
    /**
578
     * Get quote prefix.
579
     *
580
     * @return bool
581
     */
582 3349
    public function getQuotePrefix()
583
    {
584 3349
        if ($this->isSupervisor) {
585 3273
            return $this->getSharedComponent()->getQuotePrefix();
586
        }
587
588 3349
        return $this->quotePrefix;
589
    }
590
591
    /**
592
     * Set quote prefix.
593
     *
594
     * @param bool $pValue
595
     *
596
     * @return $this
597
     */
598 125
    public function setQuotePrefix($pValue)
599
    {
600 125
        if ($pValue == '') {
601 123
            $pValue = false;
602
        }
603 125
        if ($this->isSupervisor) {
604 2
            $styleArray = ['quotePrefix' => $pValue];
605 2
            $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
606
        } else {
607 123
            $this->quotePrefix = (bool) $pValue;
608
        }
609
610 125
        return $this;
611
    }
612
613
    /**
614
     * Get hash code.
615
     *
616
     * @return string Hash code
617
     */
618 347
    public function getHashCode()
619
    {
620 347
        return md5(
621 347
            $this->fill->getHashCode() .
622 347
            $this->font->getHashCode() .
623 347
            $this->borders->getHashCode() .
624 347
            $this->alignment->getHashCode() .
625 347
            $this->numberFormat->getHashCode() .
626 347
            $this->protection->getHashCode() .
627 347
            ($this->quotePrefix ? 't' : 'f') .
628 347
            __CLASS__
629
        );
630
    }
631
632
    /**
633
     * Get own index in style collection.
634
     *
635
     * @return int
636
     */
637 251
    public function getIndex()
638
    {
639 251
        return $this->index;
640
    }
641
642
    /**
643
     * Set own index in style collection.
644
     *
645
     * @param int $pValue
646
     */
647 3865
    public function setIndex($pValue): void
648
    {
649 3865
        $this->index = $pValue;
650 3865
    }
651
652 5
    protected function exportArray1(): array
653
    {
654 5
        $exportedArray = [];
655 5
        $this->exportArray2($exportedArray, 'alignment', $this->getAlignment());
656 5
        $this->exportArray2($exportedArray, 'borders', $this->getBorders());
657 5
        $this->exportArray2($exportedArray, 'fill', $this->getFill());
658 5
        $this->exportArray2($exportedArray, 'font', $this->getFont());
659 5
        $this->exportArray2($exportedArray, 'numberFormat', $this->getNumberFormat());
660 5
        $this->exportArray2($exportedArray, 'protection', $this->getProtection());
661 5
        $this->exportArray2($exportedArray, 'quotePrefx', $this->getQuotePrefix());
662
663 5
        return $exportedArray;
664
    }
665
}
666