4
* PHPExcel_CachedObjectStorage_Memory
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_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
31
* Dummy method callable from CacheBase, but unused by Memory cache
35
protected function storeData()
40
* Add or Update a cell in cache identified by coordinate address
42
* @param string $pCoord Coordinate address of the cell to update
43
* @param PHPExcel_Cell $cell Cell to update
44
* @return PHPExcel_Cell
45
* @throws PHPExcel_Exception
47
public function addCacheData($pCoord, PHPExcel_Cell $cell)
49
$this->cellCache[$pCoord] = $cell;
51
// Set current entry to the new/updated entry
52
$this->currentObjectID = $pCoord;
59
* Get cell at a specific coordinate
61
* @param string $pCoord Coordinate of the cell
62
* @throws PHPExcel_Exception
63
* @return PHPExcel_Cell Cell that was found, or null if not found
65
public function getCacheData($pCoord)
67
// Check if the entry that has been requested actually exists
68
if (!isset($this->cellCache[$pCoord])) {
69
$this->currentObjectID = null;
70
// Return null if requested entry doesn't exist in cache
74
// Set current entry to the requested entry
75
$this->currentObjectID = $pCoord;
77
// Return requested entry
78
return $this->cellCache[$pCoord];
83
* Clone the cell collection
85
* @param PHPExcel_Worksheet $parent The new worksheet
87
public function copyCellCollection(PHPExcel_Worksheet $parent)
89
parent::copyCellCollection($parent);
91
$newCollection = array();
92
foreach ($this->cellCache as $k => &$cell) {
93
$newCollection[$k] = clone $cell;
94
$newCollection[$k]->attach($this);
97
$this->cellCache = $newCollection;
101
* Clear the cell collection and disconnect from our parent
104
public function unsetWorksheetCells()
106
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
107
foreach ($this->cellCache as $k => &$cell) {
109
$this->cellCache[$k] = null;
113
$this->cellCache = array();
115
// detach ourself from the worksheet, so that it can then delete this object successfully
116
$this->parent = null;