PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.3
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/CachedObjectStorage/CacheBase.php +376 -368 3.1.13.0.3 View file →
@@ -1,368 +1,376 @@
1 -<?php
2 -
3 -/**
4 - * PHPExcel_CachedObjectStorage_CacheBase
5 - *
6 - * Copyright (c) 2006 - 2015 PHPExcel
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 PHPExcel
23 - * @package PHPExcel_CachedObjectStorage
24 - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
25 - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
26 - * @version ##VERSION##, ##DATE##
27 - */
28 -abstract class PHPExcel_CachedObjectStorage_CacheBase
29 -{
30 - /**
31 - * Parent worksheet
32 - *
33 - * @var PHPExcel_Worksheet
34 - */
35 - protected $parent;
36 -
37 - /**
38 - * The currently active Cell
39 - *
40 - * @var PHPExcel_Cell
41 - */
42 - protected $currentObject = null;
43 -
44 - /**
45 - * Coordinate address of the currently active Cell
46 - *
47 - * @var string
48 - */
49 - protected $currentObjectID = null;
50 -
51 - /**
52 - * Flag indicating whether the currently active Cell requires saving
53 - *
54 - * @var boolean
55 - */
56 - protected $currentCellIsDirty = true;
57 -
58 - /**
59 - * An array of cells or cell pointers for the worksheet cells held in this cache,
60 - * and indexed by their coordinate address within the worksheet
61 - *
62 - * @var array of mixed
63 - */
64 - protected $cellCache = array();
65 -
66 - /**
67 - * Initialise this new cell collection
68 - *
69 - * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
70 - */
71 - public function __construct(PHPExcel_Worksheet $parent)
72 - {
73 - // Set our parent worksheet.
74 - // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
75 - // they are woken from a serialized state
76 - $this->parent = $parent;
77 - }
78 -
79 - /**
80 - * Return the parent worksheet for this cell collection
81 - *
82 - * @return PHPExcel_Worksheet
83 - */
84 - public function getParent()
85 - {
86 - return $this->parent;
87 - }
88 -
89 - /**
90 - * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
91 - *
92 - * @param string $pCoord Coordinate address of the cell to check
93 - * @return boolean
94 - */
95 - public function isDataSet($pCoord)
96 - {
97 - if ($pCoord === $this->currentObjectID) {
98 - return true;
99 - }
100 - // Check if the requested entry exists in the cache
101 - return isset($this->cellCache[$pCoord]);
102 - }
103 -
104 - /**
105 - * Move a cell object from one address to another
106 - *
107 - * @param string $fromAddress Current address of the cell to move
108 - * @param string $toAddress Destination address of the cell to move
109 - * @return boolean
110 - */
111 - public function moveCell($fromAddress, $toAddress)
112 - {
113 - if ($fromAddress === $this->currentObjectID) {
114 - $this->currentObjectID = $toAddress;
115 - }
116 - $this->currentCellIsDirty = true;
117 - if (isset($this->cellCache[$fromAddress])) {
118 - $this->cellCache[$toAddress] = &$this->cellCache[$fromAddress];
119 - unset($this->cellCache[$fromAddress]);
120 - }
121 -
122 - return true;
123 - }
124 -
125 - /**
126 - * Add or Update a cell in cache
127 - *
128 - * @param PHPExcel_Cell $cell Cell to update
129 - * @return PHPExcel_Cell
130 - * @throws PHPExcel_Exception
131 - */
132 - public function updateCacheData(PHPExcel_Cell $cell)
133 - {
134 - return $this->addCacheData($cell->getCoordinate(), $cell);
135 - }
136 -
137 - /**
138 - * Delete a cell in cache identified by coordinate address
139 - *
140 - * @param string $pCoord Coordinate address of the cell to delete
141 - * @throws PHPExcel_Exception
142 - */
143 - public function deleteCacheData($pCoord)
144 - {
145 - if ($pCoord === $this->currentObjectID && !is_null($this->currentObject)) {
146 - $this->currentObject->detach();
147 - $this->currentObjectID = $this->currentObject = null;
148 - }
149 -
150 - if (is_object($this->cellCache[$pCoord])) {
151 - $this->cellCache[$pCoord]->detach();
152 - unset($this->cellCache[$pCoord]);
153 - }
154 - $this->currentCellIsDirty = false;
155 - }
156 -
157 - /**
158 - * Get a list of all cell addresses currently held in cache
159 - *
160 - * @return string[]
161 - */
162 - public function getCellList()
163 - {
164 - return array_keys($this->cellCache);
165 - }
166 -
167 - /**
168 - * Sort the list of all cell addresses currently held in cache by row and column
169 - *
170 - * @return string[]
171 - */
172 - public function getSortedCellList()
173 - {
174 - $sortKeys = array();
175 - foreach ($this->getCellList() as $coord) {
176 - sscanf($coord, '%[A-Z]%d', $column, $row);
177 - $sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
178 - }
179 - ksort($sortKeys);
180 -
181 - return array_values($sortKeys);
182 - }
183 -
184 - /**
185 - * Get highest worksheet column and highest row that have cell records
186 - *
187 - * @return array Highest column name and highest row number
188 - */
189 - public function getHighestRowAndColumn()
190 - {
191 - // Lookup highest column and highest row
192 - $col = array('A' => '1A');
193 - $row = array(1);
194 - foreach ($this->getCellList() as $coord) {
195 - sscanf($coord, '%[A-Z]%d', $c, $r);
196 - $row[$r] = $r;
197 - $col[$c] = strlen($c).$c;
198 - }
199 - if (!empty($row)) {
200 - // Determine highest column and row
201 - $highestRow = max($row);
202 - $highestColumn = substr(max($col), 1);
203 - }
204 -
205 - return array(
206 - 'row' => $highestRow,
207 - 'column' => $highestColumn
208 - );
209 - }
210 -
211 - /**
212 - * Return the cell address of the currently active cell object
213 - *
214 - * @return string
215 - */
216 - public function getCurrentAddress()
217 - {
218 - return $this->currentObjectID;
219 - }
220 -
221 - /**
222 - * Return the column address of the currently active cell object
223 - *
224 - * @return string
225 - */
226 - public function getCurrentColumn()
227 - {
228 - sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
229 - return $column;
230 - }
231 -
232 - /**
233 - * Return the row address of the currently active cell object
234 - *
235 - * @return integer
236 - */
237 - public function getCurrentRow()
238 - {
239 - sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
240 - return (integer) $row;
241 - }
242 -
243 - /**
244 - * Get highest worksheet column
245 - *
246 - * @param string $row Return the highest column for the specified row,
247 - * or the highest column of any row if no row number is passed
248 - * @return string Highest column name
249 - */
250 - public function getHighestColumn($row = null)
251 - {
252 - if ($row == null) {
253 - $colRow = $this->getHighestRowAndColumn();
254 - return $colRow['column'];
255 - }
256 -
257 - $columnList = array(1);
258 - foreach ($this->getCellList() as $coord) {
259 - sscanf($coord, '%[A-Z]%d', $c, $r);
260 - if ($r != $row) {
261 - continue;
262 - }
263 - $columnList[] = PHPExcel_Cell::columnIndexFromString($c);
264 - }
265 - return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
266 - }
267 -
268 - /**
269 - * Get highest worksheet row
270 - *
271 - * @param string $column Return the highest row for the specified column,
272 - * or the highest row of any column if no column letter is passed
273 - * @return int Highest row number
274 - */
275 - public function getHighestRow($column = null)
276 - {
277 - if ($column == null) {
278 - $colRow = $this->getHighestRowAndColumn();
279 - return $colRow['row'];
280 - }
281 -
282 - $rowList = array(0);
283 - foreach ($this->getCellList() as $coord) {
284 - sscanf($coord, '%[A-Z]%d', $c, $r);
285 - if ($c != $column) {
286 - continue;
287 - }
288 - $rowList[] = $r;
289 - }
290 -
291 - return max($rowList);
292 - }
293 -
294 - /**
295 - * Generate a unique ID for cache referencing
296 - *
297 - * @return string Unique Reference
298 - */
299 - protected function getUniqueID()
300 - {
301 - if (function_exists('posix_getpid')) {
302 - $baseUnique = posix_getpid();
303 - } else {
304 - $baseUnique = mt_rand();
305 - }
306 - return uniqid($baseUnique, true);
307 - }
308 -
309 - /**
310 - * Clone the cell collection
311 - *
312 - * @param PHPExcel_Worksheet $parent The new worksheet
313 - * @return void
314 - */
315 - public function copyCellCollection(PHPExcel_Worksheet $parent)
316 - {
317 - $this->currentCellIsDirty;
318 - $this->storeData();
319 -
320 - $this->parent = $parent;
321 - if (($this->currentObject !== null) && (is_object($this->currentObject))) {
322 - $this->currentObject->attach($this);
323 - }
324 - } // function copyCellCollection()
325 -
326 - /**
327 - * Remove a row, deleting all cells in that row
328 - *
329 - * @param string $row Row number to remove
330 - * @return void
331 - */
332 - public function removeRow($row)
333 - {
334 - foreach ($this->getCellList() as $coord) {
335 - sscanf($coord, '%[A-Z]%d', $c, $r);
336 - if ($r == $row) {
337 - $this->deleteCacheData($coord);
338 - }
339 - }
340 - }
341 -
342 - /**
343 - * Remove a column, deleting all cells in that column
344 - *
345 - * @param string $column Column ID to remove
346 - * @return void
347 - */
348 - public function removeColumn($column)
349 - {
350 - foreach ($this->getCellList() as $coord) {
351 - sscanf($coord, '%[A-Z]%d', $c, $r);
352 - if ($c == $column) {
353 - $this->deleteCacheData($coord);
354 - }
355 - }
356 - }
357 -
358 - /**
359 - * Identify whether the caching method is currently available
360 - * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
361 - *
362 - * @return boolean
363 - */
364 - public static function cacheMethodIsAvailable()
365 - {
366 - return true;
367 - }
368 -}
1 +<?php
2 +/**
3 + * PHPExcel
4 + *
5 + * Copyright (c) 2006 - 2014 PHPExcel
6 + *
7 + * This library is free software; you can redistribute it and/or
8 + * modify it under the terms of the GNU Lesser General Public
9 + * License as published by the Free Software Foundation; either
10 + * version 2.1 of the License, or (at your option) any later version.
11 + *
12 + * This library is distributed in the hope that it will be useful,
13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 + * Lesser General Public License for more details.
16 + *
17 + * You should have received a copy of the GNU Lesser General Public
18 + * License along with this library; if not, write to the Free Software
19 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 + *
21 + * @category PHPExcel
22 + * @package PHPExcel_CachedObjectStorage
23 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 + * @version ##VERSION##, ##DATE##
26 + */
27 +
28 +
29 +/**
30 + * PHPExcel_CachedObjectStorage_CacheBase
31 + *
32 + * @category PHPExcel
33 + * @package PHPExcel_CachedObjectStorage
34 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35 + */
36 +abstract class PHPExcel_CachedObjectStorage_CacheBase {
37 +
38 + /**
39 + * Parent worksheet
40 + *
41 + * @var PHPExcel_Worksheet
42 + */
43 + protected $_parent;
44 +
45 + /**
46 + * The currently active Cell
47 + *
48 + * @var PHPExcel_Cell
49 + */
50 + protected $_currentObject = null;
51 +
52 + /**
53 + * Coordinate address of the currently active Cell
54 + *
55 + * @var string
56 + */
57 + protected $_currentObjectID = null;
58 +
59 +
60 + /**
61 + * Flag indicating whether the currently active Cell requires saving
62 + *
63 + * @var boolean
64 + */
65 + protected $_currentCellIsDirty = true;
66 +
67 + /**
68 + * An array of cells or cell pointers for the worksheet cells held in this cache,
69 + * and indexed by their coordinate address within the worksheet
70 + *
71 + * @var array of mixed
72 + */
73 + protected $_cellCache = array();
74 +
75 +
76 + /**
77 + * Initialise this new cell collection
78 + *
79 + * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
80 + */
81 + public function __construct(PHPExcel_Worksheet $parent) {
82 + // Set our parent worksheet.
83 + // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
84 + // they are woken from a serialized state
85 + $this->_parent = $parent;
86 + } // function __construct()
87 +
88 +
89 + /**
90 + * Return the parent worksheet for this cell collection
91 + *
92 + * @return PHPExcel_Worksheet
93 + */
94 + public function getParent()
95 + {
96 + return $this->_parent;
97 + }
98 +
99 + /**
100 + * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
101 + *
102 + * @param string $pCoord Coordinate address of the cell to check
103 + * @return boolean
104 + */
105 + public function isDataSet($pCoord) {
106 + if ($pCoord === $this->_currentObjectID) {
107 + return true;
108 + }
109 + // Check if the requested entry exists in the cache
110 + return isset($this->_cellCache[$pCoord]);
111 + } // function isDataSet()
112 +
113 +
114 + /**
115 + * Move a cell object from one address to another
116 + *
117 + * @param string $fromAddress Current address of the cell to move
118 + * @param string $toAddress Destination address of the cell to move
119 + * @return boolean
120 + */
121 + public function moveCell($fromAddress, $toAddress) {
122 + if ($fromAddress === $this->_currentObjectID) {
123 + $this->_currentObjectID = $toAddress;
124 + }
125 + $this->_currentCellIsDirty = true;
126 + if (isset($this->_cellCache[$fromAddress])) {
127 + $this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress];
128 + unset($this->_cellCache[$fromAddress]);
129 + }
130 +
131 + return TRUE;
132 + } // function moveCell()
133 +
134 +
135 + /**
136 + * Add or Update a cell in cache
137 + *
138 + * @param PHPExcel_Cell $cell Cell to update
139 + * @return PHPExcel_Cell
140 + * @throws PHPExcel_Exception
141 + */
142 + public function updateCacheData(PHPExcel_Cell $cell) {
143 + return $this->addCacheData($cell->getCoordinate(),$cell);
144 + } // function updateCacheData()
145 +
146 +
147 + /**
148 + * Delete a cell in cache identified by coordinate address
149 + *
150 + * @param string $pCoord Coordinate address of the cell to delete
151 + * @throws PHPExcel_Exception
152 + */
153 + public function deleteCacheData($pCoord) {
154 + if ($pCoord === $this->_currentObjectID && !is_null($this->_currentObject)) {
155 + $this->_currentObject->detach();
156 + $this->_currentObjectID = $this->_currentObject = null;
157 + }
158 +
159 + if (is_object($this->_cellCache[$pCoord])) {
160 + $this->_cellCache[$pCoord]->detach();
161 + unset($this->_cellCache[$pCoord]);
162 + }
163 + $this->_currentCellIsDirty = false;
164 + } // function deleteCacheData()
165 +
166 +
167 + /**
168 + * Get a list of all cell addresses currently held in cache
169 + *
170 + * @return string[]
171 + */
172 + public function getCellList() {
173 + return array_keys($this->_cellCache);
174 + } // function getCellList()
175 +
176 +
177 + /**
178 + * Sort the list of all cell addresses currently held in cache by row and column
179 + *
180 + * @return string[]
181 + */
182 + public function getSortedCellList() {
183 + $sortKeys = array();
184 + foreach ($this->getCellList() as $coord) {
185 + sscanf($coord,'%[A-Z]%d', $column, $row);
186 + $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
187 + }
188 + ksort($sortKeys);
189 +
190 + return array_values($sortKeys);
191 + } // function sortCellList()
192 +
193 +
194 +
195 + /**
196 + * Get highest worksheet column and highest row that have cell records
197 + *
198 + * @return array Highest column name and highest row number
199 + */
200 + public function getHighestRowAndColumn()
201 + {
202 + // Lookup highest column and highest row
203 + $col = array('A' => '1A');
204 + $row = array(1);
205 + foreach ($this->getCellList() as $coord) {
206 + sscanf($coord,'%[A-Z]%d', $c, $r);
207 + $row[$r] = $r;
208 + $col[$c] = strlen($c).$c;
209 + }
210 + if (!empty($row)) {
211 + // Determine highest column and row
212 + $highestRow = max($row);
213 + $highestColumn = substr(max($col),1);
214 + }
215 +
216 + return array( 'row' => $highestRow,
217 + 'column' => $highestColumn
218 + );
219 + }
220 +
221 +
222 + /**
223 + * Return the cell address of the currently active cell object
224 + *
225 + * @return string
226 + */
227 + public function getCurrentAddress()
228 + {
229 + return $this->_currentObjectID;
230 + }
231 +
232 + /**
233 + * Return the column address of the currently active cell object
234 + *
235 + * @return string
236 + */
237 + public function getCurrentColumn()
238 + {
239 + sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
240 + return $column;
241 + }
242 +
243 + /**
244 + * Return the row address of the currently active cell object
245 + *
246 + * @return integer
247 + */
248 + public function getCurrentRow()
249 + {
250 + sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
251 + return (integer) $row;
252 + }
253 +
254 + /**
255 + * Get highest worksheet column
256 + *
257 + * @param string $row Return the highest column for the specified row,
258 + * or the highest column of any row if no row number is passed
259 + * @return string Highest column name
260 + */
261 + public function getHighestColumn($row = null)
262 + {
263 + if ($row == null) {
264 + $colRow = $this->getHighestRowAndColumn();
265 + return $colRow['column'];
266 + }
267 +
268 + $columnList = array(1);
269 + foreach ($this->getCellList() as $coord) {
270 + sscanf($coord,'%[A-Z]%d', $c, $r);
271 + if ($r != $row) {
272 + continue;
273 + }
274 + $columnList[] = PHPExcel_Cell::columnIndexFromString($c);
275 + }
276 + return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
277 + }
278 +
279 + /**
280 + * Get highest worksheet row
281 + *
282 + * @param string $column Return the highest row for the specified column,
283 + * or the highest row of any column if no column letter is passed
284 + * @return int Highest row number
285 + */
286 + public function getHighestRow($column = null)
287 + {
288 + if ($column == null) {
289 + $colRow = $this->getHighestRowAndColumn();
290 + return $colRow['row'];
291 + }
292 +
293 + $rowList = array(0);
294 + foreach ($this->getCellList() as $coord) {
295 + sscanf($coord,'%[A-Z]%d', $c, $r);
296 + if ($c != $column) {
297 + continue;
298 + }
299 + $rowList[] = $r;
300 + }
301 +
302 + return max($rowList);
303 + }
304 +
305 +
306 + /**
307 + * Generate a unique ID for cache referencing
308 + *
309 + * @return string Unique Reference
310 + */
311 + protected function _getUniqueID() {
312 + if (function_exists('posix_getpid')) {
313 + $baseUnique = posix_getpid();
314 + } else {
315 + $baseUnique = mt_rand();
316 + }
317 + return uniqid($baseUnique,true);
318 + }
319 +
320 + /**
321 + * Clone the cell collection
322 + *
323 + * @param PHPExcel_Worksheet $parent The new worksheet
324 + * @return void
325 + */
326 + public function copyCellCollection(PHPExcel_Worksheet $parent) {
327 + $this->_currentCellIsDirty;
328 + $this->_storeData();
329 +
330 + $this->_parent = $parent;
331 + if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
332 + $this->_currentObject->attach($this);
333 + }
334 + } // function copyCellCollection()
335 +
336 + /**
337 + * Remove a row, deleting all cells in that row
338 + *
339 + * @param string $row Row number to remove
340 + * @return void
341 + */
342 + public function removeRow($row) {
343 + foreach ($this->getCellList() as $coord) {
344 + sscanf($coord,'%[A-Z]%d', $c, $r);
345 + if ($r == $row) {
346 + $this->deleteCacheData($coord);
347 + }
348 + }
349 + }
350 +
351 + /**
352 + * Remove a column, deleting all cells in that column
353 + *
354 + * @param string $column Column ID to remove
355 + * @return void
356 + */
357 + public function removeColumn($column) {
358 + foreach ($this->getCellList() as $coord) {
359 + sscanf($coord,'%[A-Z]%d', $c, $r);
360 + if ($c == $column) {
361 + $this->deleteCacheData($coord);
362 + }
363 + }
364 + }
365 +
366 + /**
367 + * Identify whether the caching method is currently available
368 + * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
369 + *
370 + * @return boolean
371 + */
372 + public static function cacheMethodIsAvailable() {
373 + return true;
374 + }
375 +
376 +}