PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.10
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/phpoffice/phpexcel/Classes/PHPExcel/Style.php +97 -73 3.1.13.0.10 View file →
@@ -1,10 +1,9 @@
1 1 <?php
2 -
3 2 /**
4 - * PHPExcel_Style
3 + * PHPExcel
5 4 *
6 - * Copyright (c) 2006 - 2015 PHPExcel
5 + * Copyright (c) 2006 - 2014 PHPExcel
7 6 *
8 7 * This library is free software; you can redistribute it and/or
9 8 * modify it under the terms of the GNU Lesser General Public
10 9 * License as published by the Free Software Foundation; either
@@ -20,12 +19,21 @@
20 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 20 *
22 21 * @category PHPExcel
23 22 * @package PHPExcel_Style
24 - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
23 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
25 24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
26 25 * @version ##VERSION##, ##DATE##
27 26 */
27 +
28 +
29 +/**
30 + * PHPExcel_Style
31 + *
32 + * @category PHPExcel
33 + * @package PHPExcel_Style
34 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35 + */
28 36 class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
29 37 {
30 38 /**
31 39 * Font
@@ -31,9 +39,9 @@
31 39 * Font
32 40 *
33 41 * @var PHPExcel_Style_Font
34 42 */
35 - protected $font;
43 + protected $_font;
36 44
37 45 /**
38 46 * Fill
39 47 *
@@ -38,9 +46,9 @@
38 46 * Fill
39 47 *
40 48 * @var PHPExcel_Style_Fill
41 49 */
42 - protected $fill;
50 + protected $_fill;
43 51
44 52 /**
45 53 * Borders
46 54 *
@@ -45,9 +53,9 @@
45 53 * Borders
46 54 *
47 55 * @var PHPExcel_Style_Borders
48 56 */
49 - protected $borders;
57 + protected $_borders;
50 58
51 59 /**
52 60 * Alignment
53 61 *
@@ -52,9 +60,9 @@
52 60 * Alignment
53 61 *
54 62 * @var PHPExcel_Style_Alignment
55 63 */
56 - protected $alignment;
64 + protected $_alignment;
57 65
58 66 /**
59 67 * Number Format
60 68 *
@@ -59,9 +67,9 @@
59 67 * Number Format
60 68 *
61 69 * @var PHPExcel_Style_NumberFormat
62 70 */
63 - protected $numberFormat;
71 + protected $_numberFormat;
64 72
65 73 /**
66 74 * Conditional styles
67 75 *
@@ -66,9 +74,9 @@
66 74 * Conditional styles
67 75 *
68 76 * @var PHPExcel_Style_Conditional[]
69 77 */
70 - protected $conditionalStyles;
78 + protected $_conditionalStyles;
71 79
72 80 /**
73 81 * Protection
74 82 *
@@ -73,9 +81,9 @@
73 81 * Protection
74 82 *
75 83 * @var PHPExcel_Style_Protection
76 84 */
77 - protected $protection;
85 + protected $_protection;
78 86
79 87 /**
80 88 * Index of style in collection. Only used for real style.
81 89 *
@@ -80,9 +88,9 @@
80 88 * Index of style in collection. Only used for real style.
81 89 *
82 90 * @var int
83 91 */
84 - protected $index;
92 + protected $_index;
85 93
86 94 /**
87 95 * Use Quote Prefix when displaying in cell editor. Only used for real style.
88 96 *
@@ -87,42 +95,42 @@
87 95 * Use Quote Prefix when displaying in cell editor. Only used for real style.
88 96 *
89 97 * @var boolean
90 98 */
91 - protected $quotePrefix = false;
99 + protected $_quotePrefix = false;
92 100
93 101 /**
94 102 * Create a new PHPExcel_Style
95 103 *
96 104 * @param boolean $isSupervisor Flag indicating if this is a supervisor or not
97 - * Leave this value at default unless you understand exactly what
105 + * Leave this value at default unless you understand exactly what
98 106 * its ramifications are
99 107 * @param boolean $isConditional Flag indicating if this is a conditional style or not
100 - * Leave this value at default unless you understand exactly what
108 + * Leave this value at default unless you understand exactly what
101 109 * its ramifications are
102 110 */
103 111 public function __construct($isSupervisor = false, $isConditional = false)
104 112 {
105 113 // Supervisor?
106 - $this->isSupervisor = $isSupervisor;
114 + $this->_isSupervisor = $isSupervisor;
107 115
108 116 // Initialise values
109 - $this->conditionalStyles = array();
110 - $this->font = new PHPExcel_Style_Font($isSupervisor, $isConditional);
111 - $this->fill = new PHPExcel_Style_Fill($isSupervisor, $isConditional);
112 - $this->borders = new PHPExcel_Style_Borders($isSupervisor, $isConditional);
113 - $this->alignment = new PHPExcel_Style_Alignment($isSupervisor, $isConditional);
114 - $this->numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor, $isConditional);
115 - $this->protection = new PHPExcel_Style_Protection($isSupervisor, $isConditional);
117 + $this->_conditionalStyles = array();
118 + $this->_font = new PHPExcel_Style_Font($isSupervisor, $isConditional);
119 + $this->_fill = new PHPExcel_Style_Fill($isSupervisor, $isConditional);
120 + $this->_borders = new PHPExcel_Style_Borders($isSupervisor, $isConditional);
121 + $this->_alignment = new PHPExcel_Style_Alignment($isSupervisor, $isConditional);
122 + $this->_numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor, $isConditional);
123 + $this->_protection = new PHPExcel_Style_Protection($isSupervisor, $isConditional);
116 124
117 125 // bind parent if we are a supervisor
118 126 if ($isSupervisor) {
119 - $this->font->bindParent($this);
120 - $this->fill->bindParent($this);
121 - $this->borders->bindParent($this);
122 - $this->alignment->bindParent($this);
123 - $this->numberFormat->bindParent($this);
124 - $this->protection->bindParent($this);
127 + $this->_font->bindParent($this);
128 + $this->_fill->bindParent($this);
129 + $this->_borders->bindParent($this);
130 + $this->_alignment->bindParent($this);
131 + $this->_numberFormat->bindParent($this);
132 + $this->_protection->bindParent($this);
125 133 }
126 134 }
127 135
128 136 /**
@@ -141,9 +149,9 @@
141 149 } else {
142 150 $xfIndex = 0;
143 151 }
144 152
145 - return $this->parent->getCellXfByIndex($xfIndex);
153 + return $this->_parent->getCellXfByIndex($xfIndex);
146 154 }
147 155
148 156 /**
149 157 * Get parent. Only used for style supervisor
@@ -151,21 +159,21 @@
151 159 * @return PHPExcel
152 160 */
153 161 public function getParent()
154 162 {
155 - return $this->parent;
163 + return $this->_parent;
156 164 }
157 165
158 - /**
159 - * Build style array from subcomponents
160 - *
161 - * @param array $array
162 - * @return array
163 - */
164 - public function getStyleArray($array)
165 - {
166 - return array('quotePrefix' => $array);
167 - }
166 + /**
167 + * Build style array from subcomponents
168 + *
169 + * @param array $array
170 + * @return array
171 + */
172 + public function getStyleArray($array)
173 + {
174 + return array('quotePrefix' => $array);
175 + }
168 176
169 177 /**
170 178 * Apply styles from array
171 179 *
@@ -208,9 +216,10 @@
208 216 */
209 217 public function applyFromArray($pStyles = null, $pAdvanced = true)
210 218 {
211 219 if (is_array($pStyles)) {
212 - if ($this->isSupervisor) {
220 + if ($this->_isSupervisor) {
221 +
213 222 $pRange = $this->getSelectedCells();
214 223
215 224 // Uppercase coordinate
216 225 $pRange = strtoupper($pRange);
@@ -224,9 +233,9 @@
224 233 }
225 234
226 235 // Calculate range outer borders
227 236 $rangeStart = PHPExcel_Cell::coordinateFromString($rangeA);
228 - $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB);
237 + $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB);
229 238
230 239 // Translate column into index
231 240 $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1;
232 241 $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1;
@@ -238,9 +247,11 @@
238 247 $rangeEnd = $tmp;
239 248 }
240 249
241 250 // ADVANCED MODE:
251 +
242 252 if ($pAdvanced && isset($pStyles['borders'])) {
253 +
243 254 // 'allborders' is a shorthand property for 'outline' and 'inside' and
244 255 // it applies to components that have not been set explicitly
245 256 if (isset($pStyles['borders']['allborders'])) {
246 257 foreach (array('outline', 'inside') as $component) {
@@ -249,8 +260,9 @@
249 260 }
250 261 }
251 262 unset($pStyles['borders']['allborders']); // not needed any more
252 263 }
264 +
253 265 // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left'
254 266 // it applies to components that have not been set explicitly
255 267 if (isset($pStyles['borders']['outline'])) {
256 268 foreach (array('top', 'right', 'bottom', 'left') as $component) {
@@ -259,8 +271,9 @@
259 271 }
260 272 }
261 273 unset($pStyles['borders']['outline']); // not needed any more
262 274 }
275 +
263 276 // 'inside' is a shorthand property for 'vertical' and 'horizontal'
264 277 // it applies to components that have not been set explicitly
265 278 if (isset($pStyles['borders']['inside'])) {
266 279 foreach (array('vertical', 'horizontal') as $component) {
@@ -269,8 +282,9 @@
269 282 }
270 283 }
271 284 unset($pStyles['borders']['inside']); // not needed any more
272 285 }
286 +
273 287 // width and height characteristics of selection, 1, 2, or 3 (for 3 or more)
274 288 $xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3);
275 289 $yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3);
276 290
@@ -279,8 +293,9 @@
279 293 // start column index for region
280 294 $colStart = ($x == 3) ?
281 295 PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0])
282 296 : PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1);
297 +
283 298 // end column index for region
284 299 $colEnd = ($x == 1) ?
285 300 PHPExcel_Cell::stringFromColumnIndex($rangeStart[0])
286 301 : PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x);
@@ -285,24 +300,29 @@
285 300 PHPExcel_Cell::stringFromColumnIndex($rangeStart[0])
286 301 : PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x);
287 302
288 303 for ($y = 1; $y <= $yMax; ++$y) {
304 +
289 305 // which edges are touching the region
290 306 $edges = array();
307 +
308 + // are we at left edge
291 309 if ($x == 1) {
292 - // are we at left edge
293 310 $edges[] = 'left';
294 311 }
312 +
313 + // are we at right edge
295 314 if ($x == $xMax) {
296 - // are we at right edge
297 315 $edges[] = 'right';
298 316 }
317 +
318 + // are we at top edge?
299 319 if ($y == 1) {
300 - // are we at top edge?
301 320 $edges[] = 'top';
302 321 }
322 +
323 + // are we at bottom edge?
303 324 if ($y == $yMax) {
304 - // are we at bottom edge?
305 325 $edges[] = 'bottom';
306 326 }
307 327
308 328 // start row index for region
@@ -320,9 +340,9 @@
320 340 $regionStyles = $pStyles;
321 341 unset($regionStyles['borders']['inside']);
322 342
323 343 // what are the inner edges of the region when looking at the selection
324 - $innerEdges = array_diff(array('top', 'right', 'bottom', 'left'), $edges);
344 + $innerEdges = array_diff( array('top', 'right', 'bottom', 'left'), $edges );
325 345
326 346 // inner edges that are not touching the region should take the 'inside' border properties if they have been set
327 347 foreach ($innerEdges as $innerEdge) {
328 348 switch ($innerEdge) {
@@ -354,12 +374,13 @@
354 374 return $this;
355 375 }
356 376
357 377 // SIMPLE MODE:
378 +
358 379 // Selection type, inspect
359 380 if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) {
360 381 $selectionType = 'COLUMN';
361 - } elseif (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) {
382 + } else if (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) {
362 383 $selectionType = 'ROW';
363 384 } else {
364 385 $selectionType = 'CELL';
365 386 }
@@ -371,8 +392,9 @@
371 392 for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
372 393 $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true;
373 394 }
374 395 break;
396 +
375 397 case 'ROW':
376 398 $oldXfIndexes = array();
377 399 for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
378 400 if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() == null) {
@@ -381,8 +403,9 @@
381 403 $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true;
382 404 }
383 405 }
384 406 break;
407 +
385 408 case 'CELL':
386 409 $oldXfIndexes = array();
387 410 for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
388 411 for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
@@ -459,9 +482,9 @@
459 482 if (array_key_exists('protection', $pStyles)) {
460 483 $this->getProtection()->applyFromArray($pStyles['protection']);
461 484 }
462 485 if (array_key_exists('quotePrefix', $pStyles)) {
463 - $this->quotePrefix = $pStyles['quotePrefix'];
486 + $this->_quotePrefix = $pStyles['quotePrefix'];
464 487 }
465 488 }
466 489 } else {
467 490 throw new PHPExcel_Exception("Invalid style array passed.");
@@ -475,9 +498,9 @@
475 498 * @return PHPExcel_Style_Fill
476 499 */
477 500 public function getFill()
478 501 {
479 - return $this->fill;
502 + return $this->_fill;
480 503 }
481 504
482 505 /**
483 506 * Get Font
@@ -485,9 +508,9 @@
485 508 * @return PHPExcel_Style_Font
486 509 */
487 510 public function getFont()
488 511 {
489 - return $this->font;
512 + return $this->_font;
490 513 }
491 514
492 515 /**
493 516 * Set font
@@ -496,9 +519,9 @@
496 519 * @return PHPExcel_Style
497 520 */
498 521 public function setFont(PHPExcel_Style_Font $font)
499 522 {
500 - $this->font = $font;
523 + $this->_font = $font;
501 524 return $this;
502 525 }
503 526
504 527 /**
@@ -507,9 +530,9 @@
507 530 * @return PHPExcel_Style_Borders
508 531 */
509 532 public function getBorders()
510 533 {
511 - return $this->borders;
534 + return $this->_borders;
512 535 }
513 536
514 537 /**
515 538 * Get Alignment
@@ -517,9 +540,9 @@
517 540 * @return PHPExcel_Style_Alignment
518 541 */
519 542 public function getAlignment()
520 543 {
521 - return $this->alignment;
544 + return $this->_alignment;
522 545 }
523 546
524 547 /**
525 548 * Get Number Format
@@ -527,9 +550,9 @@
527 550 * @return PHPExcel_Style_NumberFormat
528 551 */
529 552 public function getNumberFormat()
530 553 {
531 - return $this->numberFormat;
554 + return $this->_numberFormat;
532 555 }
533 556
534 557 /**
535 558 * Get Conditional Styles. Only used on supervisor.
@@ -561,9 +584,9 @@
561 584 * @return PHPExcel_Style_Protection
562 585 */
563 586 public function getProtection()
564 587 {
565 - return $this->protection;
588 + return $this->_protection;
566 589 }
567 590
568 591 /**
569 592 * Get quote prefix
@@ -571,12 +594,12 @@
571 594 * @return boolean
572 595 */
573 596 public function getQuotePrefix()
574 597 {
575 - if ($this->isSupervisor) {
598 + if ($this->_isSupervisor) {
576 599 return $this->getSharedComponent()->getQuotePrefix();
577 600 }
578 - return $this->quotePrefix;
601 + return $this->_quotePrefix;
579 602 }
580 603
581 604 /**
582 605 * Set quote prefix
@@ -587,13 +610,13 @@
587 610 {
588 611 if ($pValue == '') {
589 612 $pValue = false;
590 613 }
591 - if ($this->isSupervisor) {
614 + if ($this->_isSupervisor) {
592 615 $styleArray = array('quotePrefix' => $pValue);
593 616 $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
594 617 } else {
595 - $this->quotePrefix = (boolean) $pValue;
618 + $this->_quotePrefix = (boolean) $pValue;
596 619 }
597 620 return $this;
598 621 }
599 622
@@ -604,22 +627,22 @@
604 627 */
605 628 public function getHashCode()
606 629 {
607 630 $hashConditionals = '';
608 - foreach ($this->conditionalStyles as $conditional) {
631 + foreach ($this->_conditionalStyles as $conditional) {
609 632 $hashConditionals .= $conditional->getHashCode();
610 633 }
611 634
612 635 return md5(
613 - $this->fill->getHashCode() .
614 - $this->font->getHashCode() .
615 - $this->borders->getHashCode() .
616 - $this->alignment->getHashCode() .
617 - $this->numberFormat->getHashCode() .
618 - $hashConditionals .
619 - $this->protection->getHashCode() .
620 - ($this->quotePrefix ? 't' : 'f') .
621 - __CLASS__
636 + $this->_fill->getHashCode()
637 + . $this->_font->getHashCode()
638 + . $this->_borders->getHashCode()
639 + . $this->_alignment->getHashCode()
640 + . $this->_numberFormat->getHashCode()
641 + . $hashConditionals
642 + . $this->_protection->getHashCode()
643 + . ($this->_quotePrefix ? 't' : 'f')
644 + . __CLASS__
622 645 );
623 646 }
624 647
625 648 /**
@@ -628,9 +651,9 @@
628 651 * @return int
629 652 */
630 653 public function getIndex()
631 654 {
632 - return $this->index;
655 + return $this->_index;
633 656 }
634 657
635 658 /**
636 659 * Set own index in style collection
@@ -638,7 +661,8 @@
638 661 * @param int $pValue
639 662 */
640 663 public function setIndex($pValue)
641 664 {
642 - $this->index = $pValue;
665 + $this->_index = $pValue;
643 666 }
667 +
644 668 }