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
|
|
|
* Conditional styles. |
47
|
|
|
* |
48
|
|
|
* @var Conditional[] |
49
|
|
|
*/ |
50
|
|
|
protected $conditionalStyles; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Protection. |
54
|
|
|
* |
55
|
|
|
* @var Protection |
56
|
|
|
*/ |
57
|
|
|
protected $protection; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Index of style in collection. Only used for real style. |
61
|
|
|
* |
62
|
|
|
* @var int |
63
|
|
|
*/ |
64
|
|
|
protected $index; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Use Quote Prefix when displaying in cell editor. Only used for real style. |
68
|
|
|
* |
69
|
|
|
* @var bool |
70
|
|
|
*/ |
71
|
|
|
protected $quotePrefix = false; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Create a new Style. |
75
|
|
|
* |
76
|
|
|
* @param bool $isSupervisor Flag indicating if this is a supervisor or not |
77
|
|
|
* Leave this value at default unless you understand exactly what |
78
|
|
|
* its ramifications are |
79
|
|
|
* @param bool $isConditional Flag indicating if this is a conditional style or not |
80
|
|
|
* Leave this value at default unless you understand exactly what |
81
|
|
|
* its ramifications are |
82
|
|
|
*/ |
83
|
185 |
|
public function __construct($isSupervisor = false, $isConditional = false) |
84
|
|
|
{ |
85
|
185 |
|
parent::__construct($isSupervisor); |
86
|
|
|
|
87
|
|
|
// Initialise values |
88
|
185 |
|
$this->conditionalStyles = []; |
89
|
185 |
|
$this->font = new Font($isSupervisor, $isConditional); |
90
|
185 |
|
$this->fill = new Fill($isSupervisor, $isConditional); |
91
|
185 |
|
$this->borders = new Borders($isSupervisor, $isConditional); |
92
|
185 |
|
$this->alignment = new Alignment($isSupervisor, $isConditional); |
93
|
185 |
|
$this->numberFormat = new NumberFormat($isSupervisor, $isConditional); |
94
|
185 |
|
$this->protection = new Protection($isSupervisor, $isConditional); |
95
|
|
|
|
96
|
|
|
// bind parent if we are a supervisor |
97
|
185 |
|
if ($isSupervisor) { |
98
|
185 |
|
$this->font->bindParent($this); |
99
|
185 |
|
$this->fill->bindParent($this); |
100
|
185 |
|
$this->borders->bindParent($this); |
101
|
185 |
|
$this->alignment->bindParent($this); |
102
|
185 |
|
$this->numberFormat->bindParent($this); |
103
|
185 |
|
$this->protection->bindParent($this); |
104
|
|
|
} |
105
|
185 |
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Get the shared style component for the currently active cell in currently active sheet. |
109
|
|
|
* Only used for style supervisor. |
110
|
|
|
* |
111
|
|
|
* @return Style |
112
|
|
|
*/ |
113
|
8 |
|
public function getSharedComponent() |
114
|
|
|
{ |
115
|
8 |
|
$activeSheet = $this->getActiveSheet(); |
116
|
8 |
|
$selectedCell = $this->getActiveCell(); // e.g. 'A1' |
117
|
|
|
|
118
|
8 |
|
if ($activeSheet->cellExists($selectedCell)) { |
119
|
8 |
|
$xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex(); |
120
|
|
|
} else { |
121
|
2 |
|
$xfIndex = 0; |
122
|
|
|
} |
123
|
|
|
|
124
|
8 |
|
return $this->parent->getCellXfByIndex($xfIndex); |
|
|
|
|
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Get parent. Only used for style supervisor. |
129
|
|
|
* |
130
|
|
|
* @return Spreadsheet |
131
|
|
|
*/ |
132
|
|
|
public function getParent() |
133
|
|
|
{ |
134
|
|
|
return $this->parent; |
|
|
|
|
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Build style array from subcomponents. |
139
|
|
|
* |
140
|
|
|
* @param array $array |
141
|
|
|
* |
142
|
|
|
* @return array |
143
|
|
|
*/ |
144
|
|
|
public function getStyleArray($array) |
145
|
|
|
{ |
146
|
|
|
return ['quotePrefix' => $array]; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Apply styles from array. |
151
|
|
|
* |
152
|
|
|
* <code> |
153
|
|
|
* $spreadsheet->getActiveSheet()->getStyle('B2')->applyFromArray( |
154
|
|
|
* [ |
155
|
|
|
* 'font' => [ |
156
|
|
|
* 'name' => 'Arial', |
157
|
|
|
* 'bold' => true, |
158
|
|
|
* 'italic' => false, |
159
|
|
|
* 'underline' => Font::UNDERLINE_DOUBLE, |
160
|
|
|
* 'strikethrough' => false, |
161
|
|
|
* 'color' => [ |
162
|
|
|
* 'rgb' => '808080' |
163
|
|
|
* ] |
164
|
|
|
* ], |
165
|
|
|
* 'borders' => [ |
166
|
|
|
* 'bottom' => [ |
167
|
|
|
* 'borderStyle' => Border::BORDER_DASHDOT, |
168
|
|
|
* 'color' => [ |
169
|
|
|
* 'rgb' => '808080' |
170
|
|
|
* ] |
171
|
|
|
* ], |
172
|
|
|
* 'top' => [ |
173
|
|
|
* 'borderStyle' => Border::BORDER_DASHDOT, |
174
|
|
|
* 'color' => [ |
175
|
|
|
* 'rgb' => '808080' |
176
|
|
|
* ] |
177
|
|
|
* ] |
178
|
|
|
* ], |
179
|
|
|
* 'quotePrefix' => true |
180
|
|
|
* ] |
181
|
|
|
* ); |
182
|
|
|
* </code> |
183
|
|
|
* |
184
|
|
|
* @param array $pStyles Array containing style information |
185
|
|
|
* @param bool $pAdvanced advanced mode for setting borders |
186
|
|
|
* |
187
|
|
|
* @return Style |
188
|
|
|
*/ |
189
|
54 |
|
public function applyFromArray(array $pStyles, $pAdvanced = true) |
190
|
|
|
{ |
191
|
54 |
|
if ($this->isSupervisor) { |
192
|
53 |
|
$pRange = $this->getSelectedCells(); |
193
|
|
|
|
194
|
|
|
// Uppercase coordinate |
195
|
53 |
|
$pRange = strtoupper($pRange); |
196
|
|
|
|
197
|
|
|
// Is it a cell range or a single cell? |
198
|
53 |
|
if (strpos($pRange, ':') === false) { |
199
|
37 |
|
$rangeA = $pRange; |
200
|
37 |
|
$rangeB = $pRange; |
201
|
|
|
} else { |
202
|
33 |
|
list($rangeA, $rangeB) = explode(':', $pRange); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
// Calculate range outer borders |
206
|
53 |
|
$rangeStart = Coordinate::coordinateFromString($rangeA); |
207
|
53 |
|
$rangeEnd = Coordinate::coordinateFromString($rangeB); |
208
|
|
|
|
209
|
|
|
// Translate column into index |
210
|
53 |
|
$rangeStart[0] = Coordinate::columnIndexFromString($rangeStart[0]); |
211
|
53 |
|
$rangeEnd[0] = Coordinate::columnIndexFromString($rangeEnd[0]); |
212
|
|
|
|
213
|
|
|
// Make sure we can loop upwards on rows and columns |
214
|
53 |
|
if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { |
215
|
|
|
$tmp = $rangeStart; |
216
|
|
|
$rangeStart = $rangeEnd; |
217
|
|
|
$rangeEnd = $tmp; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
// ADVANCED MODE: |
221
|
53 |
|
if ($pAdvanced && isset($pStyles['borders'])) { |
222
|
|
|
// 'allBorders' is a shorthand property for 'outline' and 'inside' and |
223
|
|
|
// it applies to components that have not been set explicitly |
224
|
20 |
|
if (isset($pStyles['borders']['allBorders'])) { |
225
|
1 |
|
foreach (['outline', 'inside'] as $component) { |
226
|
1 |
|
if (!isset($pStyles['borders'][$component])) { |
227
|
1 |
|
$pStyles['borders'][$component] = $pStyles['borders']['allBorders']; |
228
|
|
|
} |
229
|
|
|
} |
230
|
1 |
|
unset($pStyles['borders']['allBorders']); // not needed any more |
231
|
|
|
} |
232
|
|
|
// 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left' |
|
|
|
|
233
|
|
|
// it applies to components that have not been set explicitly |
234
|
20 |
|
if (isset($pStyles['borders']['outline'])) { |
235
|
13 |
|
foreach (['top', 'right', 'bottom', 'left'] as $component) { |
236
|
13 |
|
if (!isset($pStyles['borders'][$component])) { |
237
|
13 |
|
$pStyles['borders'][$component] = $pStyles['borders']['outline']; |
238
|
|
|
} |
239
|
|
|
} |
240
|
13 |
|
unset($pStyles['borders']['outline']); // not needed any more |
241
|
|
|
} |
242
|
|
|
// 'inside' is a shorthand property for 'vertical' and 'horizontal' |
243
|
|
|
// it applies to components that have not been set explicitly |
244
|
20 |
|
if (isset($pStyles['borders']['inside'])) { |
245
|
1 |
|
foreach (['vertical', 'horizontal'] as $component) { |
246
|
1 |
|
if (!isset($pStyles['borders'][$component])) { |
247
|
1 |
|
$pStyles['borders'][$component] = $pStyles['borders']['inside']; |
248
|
|
|
} |
249
|
|
|
} |
250
|
1 |
|
unset($pStyles['borders']['inside']); // not needed any more |
251
|
|
|
} |
252
|
|
|
// width and height characteristics of selection, 1, 2, or 3 (for 3 or more) |
|
|
|
|
253
|
20 |
|
$xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3); |
254
|
20 |
|
$yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3); |
255
|
|
|
|
256
|
|
|
// loop through up to 3 x 3 = 9 regions |
257
|
20 |
|
for ($x = 1; $x <= $xMax; ++$x) { |
258
|
|
|
// start column index for region |
259
|
20 |
|
$colStart = ($x == 3) ? |
260
|
15 |
|
Coordinate::stringFromColumnIndex($rangeEnd[0]) |
261
|
20 |
|
: Coordinate::stringFromColumnIndex($rangeStart[0] + $x - 1); |
262
|
|
|
// end column index for region |
263
|
20 |
|
$colEnd = ($x == 1) ? |
264
|
20 |
|
Coordinate::stringFromColumnIndex($rangeStart[0]) |
265
|
20 |
|
: Coordinate::stringFromColumnIndex($rangeEnd[0] - $xMax + $x); |
266
|
|
|
|
267
|
20 |
|
for ($y = 1; $y <= $yMax; ++$y) { |
268
|
|
|
// which edges are touching the region |
269
|
20 |
|
$edges = []; |
270
|
20 |
|
if ($x == 1) { |
271
|
|
|
// are we at left edge |
272
|
20 |
|
$edges[] = 'left'; |
273
|
|
|
} |
274
|
20 |
|
if ($x == $xMax) { |
275
|
|
|
// are we at right edge |
276
|
20 |
|
$edges[] = 'right'; |
277
|
|
|
} |
278
|
20 |
|
if ($y == 1) { |
279
|
|
|
// are we at top edge? |
280
|
20 |
|
$edges[] = 'top'; |
281
|
|
|
} |
282
|
20 |
|
if ($y == $yMax) { |
283
|
|
|
// are we at bottom edge? |
284
|
20 |
|
$edges[] = 'bottom'; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
// start row index for region |
288
|
20 |
|
$rowStart = ($y == 3) ? |
289
|
20 |
|
$rangeEnd[1] : $rangeStart[1] + $y - 1; |
290
|
|
|
|
291
|
|
|
// end row index for region |
292
|
20 |
|
$rowEnd = ($y == 1) ? |
293
|
20 |
|
$rangeStart[1] : $rangeEnd[1] - $yMax + $y; |
294
|
|
|
|
295
|
|
|
// build range for region |
296
|
20 |
|
$range = $colStart . $rowStart . ':' . $colEnd . $rowEnd; |
297
|
|
|
|
298
|
|
|
// retrieve relevant style array for region |
299
|
20 |
|
$regionStyles = $pStyles; |
300
|
20 |
|
unset($regionStyles['borders']['inside']); |
301
|
|
|
|
302
|
|
|
// what are the inner edges of the region when looking at the selection |
303
|
20 |
|
$innerEdges = array_diff(['top', 'right', 'bottom', 'left'], $edges); |
304
|
|
|
|
305
|
|
|
// inner edges that are not touching the region should take the 'inside' border properties if they have been set |
306
|
20 |
|
foreach ($innerEdges as $innerEdge) { |
307
|
|
|
switch ($innerEdge) { |
308
|
18 |
|
case 'top': |
309
|
18 |
|
case 'bottom': |
310
|
|
|
// should pick up 'horizontal' border property if set |
311
|
17 |
|
if (isset($pStyles['borders']['horizontal'])) { |
312
|
|
|
$regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal']; |
313
|
|
|
} else { |
314
|
17 |
|
unset($regionStyles['borders'][$innerEdge]); |
315
|
|
|
} |
316
|
|
|
|
317
|
17 |
|
break; |
318
|
18 |
|
case 'left': |
319
|
18 |
|
case 'right': |
320
|
|
|
// should pick up 'vertical' border property if set |
321
|
18 |
|
if (isset($pStyles['borders']['vertical'])) { |
322
|
|
|
$regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical']; |
323
|
|
|
} else { |
324
|
18 |
|
unset($regionStyles['borders'][$innerEdge]); |
325
|
|
|
} |
326
|
|
|
|
327
|
18 |
|
break; |
328
|
|
|
} |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
// apply region style to region by calling applyFromArray() in simple mode |
332
|
20 |
|
$this->getActiveSheet()->getStyle($range)->applyFromArray($regionStyles, false); |
333
|
|
|
} |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
// restore initial cell selection range |
337
|
20 |
|
$this->getActiveSheet()->getStyle($pRange); |
338
|
|
|
|
339
|
20 |
|
return $this; |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
// SIMPLE MODE: |
343
|
|
|
// Selection type, inspect |
344
|
53 |
|
if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) { |
345
|
|
|
$selectionType = 'COLUMN'; |
346
|
53 |
|
} elseif (preg_match('/^A\d+:XFD\d+$/', $pRange)) { |
347
|
|
|
$selectionType = 'ROW'; |
348
|
|
|
} else { |
349
|
53 |
|
$selectionType = 'CELL'; |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
// First loop through columns, rows, or cells to find out which styles are affected by this operation |
353
|
|
|
switch ($selectionType) { |
354
|
53 |
|
case 'COLUMN': |
355
|
|
|
$oldXfIndexes = []; |
356
|
|
|
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { |
357
|
|
|
$oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
break; |
361
|
53 |
|
case 'ROW': |
362
|
|
|
$oldXfIndexes = []; |
363
|
|
|
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { |
364
|
|
|
if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() == null) { |
|
|
|
|
365
|
|
|
$oldXfIndexes[0] = true; // row without explicit style should be formatted based on default style |
366
|
|
|
} else { |
367
|
|
|
$oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true; |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
break; |
372
|
53 |
|
case 'CELL': |
373
|
53 |
|
$oldXfIndexes = []; |
374
|
53 |
|
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { |
375
|
53 |
|
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { |
376
|
53 |
|
$oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true; |
|
|
|
|
377
|
|
|
} |
378
|
|
|
} |
379
|
|
|
|
380
|
53 |
|
break; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
// clone each of the affected styles, apply the style array, and add the new styles to the workbook |
384
|
53 |
|
$workbook = $this->getActiveSheet()->getParent(); |
385
|
53 |
|
foreach ($oldXfIndexes as $oldXfIndex => $dummy) { |
|
|
|
|
386
|
53 |
|
$style = $workbook->getCellXfByIndex($oldXfIndex); |
387
|
53 |
|
$newStyle = clone $style; |
388
|
53 |
|
$newStyle->applyFromArray($pStyles); |
389
|
|
|
|
390
|
53 |
|
if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) { |
391
|
|
|
// there is already such cell Xf in our collection |
392
|
39 |
|
$newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); |
393
|
|
|
} else { |
394
|
|
|
// we don't have such a cell Xf, need to add |
395
|
48 |
|
$workbook->addCellXf($newStyle); |
396
|
53 |
|
$newXfIndexes[$oldXfIndex] = $newStyle->getIndex(); |
397
|
|
|
} |
398
|
|
|
} |
399
|
|
|
|
400
|
|
|
// Loop through columns, rows, or cells again and update the XF index |
401
|
|
|
switch ($selectionType) { |
402
|
53 |
|
case 'COLUMN': |
403
|
|
|
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { |
404
|
|
|
$columnDimension = $this->getActiveSheet()->getColumnDimensionByColumn($col); |
405
|
|
|
$oldXfIndex = $columnDimension->getXfIndex(); |
406
|
|
|
$columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]); |
|
|
|
|
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
break; |
410
|
53 |
|
case 'ROW': |
411
|
|
|
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { |
412
|
|
|
$rowDimension = $this->getActiveSheet()->getRowDimension($row); |
413
|
|
|
$oldXfIndex = $rowDimension->getXfIndex() === null ? |
414
|
|
|
0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style |
415
|
|
|
$rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
break; |
419
|
53 |
|
case 'CELL': |
420
|
53 |
|
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { |
421
|
53 |
|
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { |
422
|
53 |
|
$cell = $this->getActiveSheet()->getCellByColumnAndRow($col, $row); |
423
|
53 |
|
$oldXfIndex = $cell->getXfIndex(); |
424
|
53 |
|
$cell->setXfIndex($newXfIndexes[$oldXfIndex]); |
425
|
|
|
} |
426
|
|
|
} |
427
|
|
|
|
428
|
53 |
|
break; |
429
|
|
|
} |
430
|
|
|
} else { |
431
|
|
|
// not a supervisor, just apply the style array directly on style object |
432
|
54 |
|
if (isset($pStyles['fill'])) { |
433
|
19 |
|
$this->getFill()->applyFromArray($pStyles['fill']); |
434
|
|
|
} |
435
|
54 |
|
if (isset($pStyles['font'])) { |
436
|
24 |
|
$this->getFont()->applyFromArray($pStyles['font']); |
437
|
|
|
} |
438
|
54 |
|
if (isset($pStyles['borders'])) { |
439
|
21 |
|
$this->getBorders()->applyFromArray($pStyles['borders']); |
440
|
|
|
} |
441
|
54 |
|
if (isset($pStyles['alignment'])) { |
442
|
22 |
|
$this->getAlignment()->applyFromArray($pStyles['alignment']); |
443
|
|
|
} |
444
|
54 |
|
if (isset($pStyles['numberFormat'])) { |
445
|
41 |
|
$this->getNumberFormat()->applyFromArray($pStyles['numberFormat']); |
446
|
|
|
} |
447
|
54 |
|
if (isset($pStyles['protection'])) { |
448
|
13 |
|
$this->getProtection()->applyFromArray($pStyles['protection']); |
449
|
|
|
} |
450
|
54 |
|
if (isset($pStyles['quotePrefix'])) { |
451
|
1 |
|
$this->quotePrefix = $pStyles['quotePrefix']; |
452
|
|
|
} |
453
|
|
|
} |
454
|
|
|
|
455
|
54 |
|
return $this; |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
/** |
459
|
|
|
* Get Fill. |
460
|
|
|
* |
461
|
|
|
* @return Fill |
462
|
|
|
*/ |
463
|
123 |
|
public function getFill() |
464
|
|
|
{ |
465
|
123 |
|
return $this->fill; |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
/** |
469
|
|
|
* Get Font. |
470
|
|
|
* |
471
|
|
|
* @return Font |
472
|
|
|
*/ |
473
|
115 |
|
public function getFont() |
474
|
|
|
{ |
475
|
115 |
|
return $this->font; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* Set font. |
480
|
|
|
* |
481
|
|
|
* @param Font $font |
482
|
|
|
* |
483
|
|
|
* @return Style |
484
|
|
|
*/ |
485
|
21 |
|
public function setFont(Font $font) |
486
|
|
|
{ |
487
|
21 |
|
$this->font = $font; |
488
|
|
|
|
489
|
21 |
|
return $this; |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
/** |
493
|
|
|
* Get Borders. |
494
|
|
|
* |
495
|
|
|
* @return Borders |
496
|
|
|
*/ |
497
|
118 |
|
public function getBorders() |
498
|
|
|
{ |
499
|
118 |
|
return $this->borders; |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
/** |
503
|
|
|
* Get Alignment. |
504
|
|
|
* |
505
|
|
|
* @return Alignment |
506
|
|
|
*/ |
507
|
116 |
|
public function getAlignment() |
508
|
|
|
{ |
509
|
116 |
|
return $this->alignment; |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* Get Number Format. |
514
|
|
|
* |
515
|
|
|
* @return NumberFormat |
516
|
|
|
*/ |
517
|
147 |
|
public function getNumberFormat() |
518
|
|
|
{ |
519
|
147 |
|
return $this->numberFormat; |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* Get Conditional Styles. Only used on supervisor. |
524
|
|
|
* |
525
|
|
|
* @return Conditional[] |
526
|
|
|
*/ |
527
|
2 |
|
public function getConditionalStyles() |
528
|
|
|
{ |
529
|
2 |
|
return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell()); |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
/** |
533
|
|
|
* Set Conditional Styles. Only used on supervisor. |
534
|
|
|
* |
535
|
|
|
* @param Conditional[] $pValue Array of conditional styles |
536
|
|
|
* |
537
|
|
|
* @return Style |
538
|
|
|
*/ |
539
|
3 |
|
public function setConditionalStyles(array $pValue) |
540
|
|
|
{ |
541
|
3 |
|
$this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue); |
542
|
|
|
|
543
|
3 |
|
return $this; |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
/** |
547
|
|
|
* Get Protection. |
548
|
|
|
* |
549
|
|
|
* @return Protection |
550
|
|
|
*/ |
551
|
102 |
|
public function getProtection() |
552
|
|
|
{ |
553
|
102 |
|
return $this->protection; |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
/** |
557
|
|
|
* Get quote prefix. |
558
|
|
|
* |
559
|
|
|
* @return bool |
560
|
|
|
*/ |
561
|
79 |
|
public function getQuotePrefix() |
562
|
|
|
{ |
563
|
79 |
|
if ($this->isSupervisor) { |
564
|
|
|
return $this->getSharedComponent()->getQuotePrefix(); |
565
|
|
|
} |
566
|
|
|
|
567
|
79 |
|
return $this->quotePrefix; |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* Set quote prefix. |
572
|
|
|
* |
573
|
|
|
* @param bool $pValue |
574
|
|
|
* |
575
|
|
|
* @return Style |
576
|
|
|
*/ |
577
|
36 |
|
public function setQuotePrefix($pValue) |
578
|
|
|
{ |
579
|
36 |
|
if ($pValue == '') { |
580
|
35 |
|
$pValue = false; |
581
|
|
|
} |
582
|
36 |
|
if ($this->isSupervisor) { |
583
|
1 |
|
$styleArray = ['quotePrefix' => $pValue]; |
584
|
1 |
|
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); |
585
|
|
|
} else { |
586
|
35 |
|
$this->quotePrefix = (bool) $pValue; |
587
|
|
|
} |
588
|
|
|
|
589
|
36 |
|
return $this; |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
/** |
593
|
|
|
* Get hash code. |
594
|
|
|
* |
595
|
|
|
* @return string Hash code |
596
|
|
|
*/ |
597
|
106 |
|
public function getHashCode() |
598
|
|
|
{ |
599
|
106 |
|
$hashConditionals = ''; |
600
|
106 |
|
foreach ($this->conditionalStyles as $conditional) { |
601
|
|
|
$hashConditionals .= $conditional->getHashCode(); |
602
|
|
|
} |
603
|
|
|
|
604
|
106 |
|
return md5( |
605
|
106 |
|
$this->fill->getHashCode() . |
606
|
106 |
|
$this->font->getHashCode() . |
607
|
106 |
|
$this->borders->getHashCode() . |
608
|
106 |
|
$this->alignment->getHashCode() . |
609
|
106 |
|
$this->numberFormat->getHashCode() . |
610
|
106 |
|
$hashConditionals . |
611
|
106 |
|
$this->protection->getHashCode() . |
612
|
106 |
|
($this->quotePrefix ? 't' : 'f') . |
613
|
106 |
|
__CLASS__ |
614
|
|
|
); |
615
|
|
|
} |
616
|
|
|
|
617
|
|
|
/** |
618
|
|
|
* Get own index in style collection. |
619
|
|
|
* |
620
|
|
|
* @return int |
621
|
|
|
*/ |
622
|
56 |
|
public function getIndex() |
623
|
|
|
{ |
624
|
56 |
|
return $this->index; |
625
|
|
|
} |
626
|
|
|
|
627
|
|
|
/** |
628
|
|
|
* Set own index in style collection. |
629
|
|
|
* |
630
|
|
|
* @param int $pValue |
631
|
|
|
*/ |
632
|
185 |
|
public function setIndex($pValue) |
633
|
|
|
{ |
634
|
185 |
|
$this->index = $pValue; |
635
|
185 |
|
} |
636
|
|
|
} |
637
|
|
|
|
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.