PluginProbe
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin / 6.5.1.7
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin v6.5.1.7
6.5.1.7 6.5.1.6 6.5.1.5 6.5.1.4 6.5.1.3 6.5.1.2 6.5.1.1 6.5.0.9 6.5.0.8 6.5.0.7 6.5.0.6 trunk 3.4.2.40 3.4.2.41 3.4.2.42 3.4.2.43 3.4.2.44 3.4.2.45 3.4.2.46 3.4.2.47 3.4.2.48 3.4.2.49 3.4.2.50 6.3.2 6.3.3.1 All 47 releases
wpdatatables / lib / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Style / Supervisor.php

Supervisor.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php

176 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Style;
4
5 use PhpOffice\PhpSpreadsheet\IComparable;
6 use PhpOffice\PhpSpreadsheet\Spreadsheet;
7 use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
8
9 abstract class Supervisor implements IComparable
10 {
11 /**
12 * Supervisor?
13 *
14 * @var bool
15 */
16 protected $isSupervisor;
17
18 /**
19 * Parent. Only used for supervisor.
20 *
21 * @var Spreadsheet|Supervisor
22 */
23 protected $parent;
24
25 /**
26 * Parent property name.
27 *
28 * @var null|string
29 */
30 protected $parentPropertyName;
31
32 /**
33 * Create a new Supervisor.
34 *
35 * @param bool $isSupervisor Flag indicating if this is a supervisor or not
36 * Leave this value at default unless you understand exactly what
37 * its ramifications are
38 */
39 public function __construct($isSupervisor = false)
40 {
41 // Supervisor?
42 $this->isSupervisor = $isSupervisor;
43 }
44
45 /**
46 * Bind parent. Only used for supervisor.
47 *
48 * @param Spreadsheet|Supervisor $parent
49 * @param null|string $parentPropertyName
50 *
51 * @return $this
52 */
53 public function bindParent($parent, $parentPropertyName = null)
54 {
55 $this->parent = $parent;
56 $this->parentPropertyName = $parentPropertyName;
57
58 return $this;
59 }
60
61 /**
62 * Is this a supervisor or a cell style component?
63 *
64 * @return bool
65 */
66 public function getIsSupervisor()
67 {
68 return $this->isSupervisor;
69 }
70
71 /**
72 * Get the currently active sheet. Only used for supervisor.
73 *
74 * @return Worksheet
75 */
76 public function getActiveSheet()
77 {
78 return $this->parent->getActiveSheet();
79 }
80
81 /**
82 * Get the currently active cell coordinate in currently active sheet.
83 * Only used for supervisor.
84 *
85 * @return string E.g. 'A1'
86 */
87 public function getSelectedCells()
88 {
89 return $this->getActiveSheet()->getSelectedCells();
90 }
91
92 /**
93 * Get the currently active cell coordinate in currently active sheet.
94 * Only used for supervisor.
95 *
96 * @return string E.g. 'A1'
97 */
98 public function getActiveCell()
99 {
100 return $this->getActiveSheet()->getActiveCell();
101 }
102
103 /**
104 * Implement PHP __clone to create a deep clone, not just a shallow copy.
105 */
106 public function __clone()
107 {
108 $vars = get_object_vars($this);
109 foreach ($vars as $key => $value) {
110 if ((is_object($value)) && ($key != 'parent')) {
111 $this->$key = clone $value;
112 } else {
113 $this->$key = $value;
114 }
115 }
116 }
117
118 /**
119 * Export style as array.
120 *
121 * Available to anything which extends this class:
122 * Alignment, Border, Borders, Color, Fill, Font,
123 * NumberFormat, Protection, and Style.
124 */
125 final public function exportArray(): array
126 {
127 return $this->exportArray1();
128 }
129
130 /**
131 * Abstract method to be implemented in anything which
132 * extends this class.
133 *
134 * This method invokes exportArray2 with the names and values
135 * of all properties to be included in output array,
136 * returning that array to exportArray, then to caller.
137 */
138 abstract protected function exportArray1(): array;
139
140 /**
141 * Populate array from exportArray1.
142 * This method is available to anything which extends this class.
143 * The parameter index is the key to be added to the array.
144 * The parameter objOrValue is either a primitive type,
145 * which is the value added to the array,
146 * or a Style object to be recursively added via exportArray.
147 *
148 * @param mixed $objOrValue
149 */
150 final protected function exportArray2(array &$exportedArray, string $index, $objOrValue): void
151 {
152 if ($objOrValue instanceof self) {
153 $exportedArray[$index] = $objOrValue->exportArray();
154 } else {
155 $exportedArray[$index] = $objOrValue;
156 }
157 }
158
159 /**
160 * Get the shared style component for the currently active cell in currently active sheet.
161 * Only used for style supervisor.
162 *
163 * @return mixed
164 */
165 abstract public function getSharedComponent();
166
167 /**
168 * Build style array from subcomponents.
169 *
170 * @param array $array
171 *
172 * @return array
173 */
174 abstract public function getStyleArray($array);
175 }
176