123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace Util\PHPExcel\CachedObjectStorage;
- use Util\PHPExcel\Cell;
- use Util\PHPExcel\CachedObjectStorage\CacheBase;
- use Util\PHPExcel\CachedObjectStorage\ICache;
- class MemorySerialized extends CacheBase implements ICache
- {
-
- public function addCacheData($pCoord, Cell $cell)
- {
- if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
- $this->storeData();
- }
- $this->currentObjectID = $pCoord;
- $this->currentObject = $cell;
- $this->currentCellIsDirty = true;
- return $cell;
- }
-
- protected function storeData()
- {
- if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
- $this->currentObject->detach();
- $this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
- $this->currentCellIsDirty = false;
- }
- $this->currentObjectID = $this->currentObject = null;
- }
-
- public function getCacheData($pCoord)
- {
- if ($pCoord === $this->currentObjectID) {
- return $this->currentObject;
- }
- $this->storeData();
-
- if (!isset($this->cellCache[$pCoord])) {
-
- return null;
- }
-
- $this->currentObjectID = $pCoord;
- $this->currentObject = unserialize($this->cellCache[$pCoord]);
-
- $this->currentObject->attach($this);
-
- return $this->currentObject;
- }
-
- public function getCellList()
- {
- if ($this->currentObjectID !== null) {
- $this->storeData();
- }
- return parent::getCellList();
- }
-
- public function unsetWorksheetCells()
- {
- if (!is_null($this->currentObject)) {
- $this->currentObject->detach();
- $this->currentObject = $this->currentObjectID = null;
- }
- $this->cellCache = array();
-
- $this->parent = null;
- }
- }
|