PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.1.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.1.2
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
visualizer / vendor / phpoffice / phpexcel / Classes / PHPExcel / CachedObjectStorage / MemorySerialized.php

MemorySerialized.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.1.2, at vendor/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php

130 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * PHPExcel_CachedObjectStorage_MemorySerialized
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 class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
29 {
30 /**
31 * Store cell data in cache for the current cell object if it's "dirty",
32 * and the 'nullify' the current cell object
33 *
34 * @return void
35 * @throws PHPExcel_Exception
36 */
37 protected function storeData()
38 {
39 if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
40 $this->currentObject->detach();
41
42 $this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
43 $this->currentCellIsDirty = false;
44 }
45 $this->currentObjectID = $this->currentObject = null;
46 }
47
48 /**
49 * Add or Update a cell in cache identified by coordinate address
50 *
51 * @param string $pCoord Coordinate address of the cell to update
52 * @param PHPExcel_Cell $cell Cell to update
53 * @return PHPExcel_Cell
54 * @throws PHPExcel_Exception
55 */
56 public function addCacheData($pCoord, PHPExcel_Cell $cell)
57 {
58 if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
59 $this->storeData();
60 }
61
62 $this->currentObjectID = $pCoord;
63 $this->currentObject = $cell;
64 $this->currentCellIsDirty = true;
65
66 return $cell;
67 }
68
69 /**
70 * Get cell at a specific coordinate
71 *
72 * @param string $pCoord Coordinate of the cell
73 * @throws PHPExcel_Exception
74 * @return PHPExcel_Cell Cell that was found, or null if not found
75 */
76 public function getCacheData($pCoord)
77 {
78 if ($pCoord === $this->currentObjectID) {
79 return $this->currentObject;
80 }
81 $this->storeData();
82
83 // Check if the entry that has been requested actually exists
84 if (!isset($this->cellCache[$pCoord])) {
85 // Return null if requested entry doesn't exist in cache
86 return null;
87 }
88
89 // Set current entry to the requested entry
90 $this->currentObjectID = $pCoord;
91 $this->currentObject = unserialize($this->cellCache[$pCoord]);
92 // Re-attach this as the cell's parent
93 $this->currentObject->attach($this);
94
95 // Return requested entry
96 return $this->currentObject;
97 }
98
99 /**
100 * Get a list of all cell addresses currently held in cache
101 *
102 * @return string[]
103 */
104 public function getCellList()
105 {
106 if ($this->currentObjectID !== null) {
107 $this->storeData();
108 }
109
110 return parent::getCellList();
111 }
112
113 /**
114 * Clear the cell collection and disconnect from our parent
115 *
116 * @return void
117 */
118 public function unsetWorksheetCells()
119 {
120 if (!is_null($this->currentObject)) {
121 $this->currentObject->detach();
122 $this->currentObject = $this->currentObjectID = null;
123 }
124 $this->cellCache = array();
125
126 // detach ourself from the worksheet, so that it can then delete this object successfully
127 $this->parent = null;
128 }
129 }
130