4
* PHPExcel_CachedObjectStorage_MemoryGZip
6
* Copyright (c) 2006 - 2015 PHPExcel
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.
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.
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
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##
28
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
31
* Store cell data in cache for the current cell object if it's "dirty",
32
* and the 'nullify' the current cell object
35
* @throws PHPExcel_Exception
37
protected function storeData()
39
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
40
$this->currentObject->detach();
42
$this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject));
43
$this->currentCellIsDirty = false;
45
$this->currentObjectID = $this->currentObject = null;
50
* Add or Update a cell in cache identified by coordinate address
52
* @param string $pCoord Coordinate address of the cell to update
53
* @param PHPExcel_Cell $cell Cell to update
54
* @return PHPExcel_Cell
55
* @throws PHPExcel_Exception
57
public function addCacheData($pCoord, PHPExcel_Cell $cell)
59
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
63
$this->currentObjectID = $pCoord;
64
$this->currentObject = $cell;
65
$this->currentCellIsDirty = true;
72
* Get cell at a specific coordinate
74
* @param string $pCoord Coordinate of the cell
75
* @throws PHPExcel_Exception
76
* @return PHPExcel_Cell Cell that was found, or null if not found
78
public function getCacheData($pCoord)
80
if ($pCoord === $this->currentObjectID) {
81
return $this->currentObject;
85
// Check if the entry that has been requested actually exists
86
if (!isset($this->cellCache[$pCoord])) {
87
// Return null if requested entry doesn't exist in cache
91
// Set current entry to the requested entry
92
$this->currentObjectID = $pCoord;
93
$this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
94
// Re-attach this as the cell's parent
95
$this->currentObject->attach($this);
97
// Return requested entry
98
return $this->currentObject;
103
* Get a list of all cell addresses currently held in cache
107
public function getCellList()
109
if ($this->currentObjectID !== null) {
113
return parent::getCellList();
118
* Clear the cell collection and disconnect from our parent
122
public function unsetWorksheetCells()
124
if (!is_null($this->currentObject)) {
125
$this->currentObject->detach();
126
$this->currentObject = $this->currentObjectID = null;
128
$this->cellCache = array();
130
// detach ourself from the worksheet, so that it can then delete this object successfully
131
$this->parent = null;