123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <?php
- namespace Util\PHPExcel\CachedObjectStorage;
- use Util\PHPExcel\Worksheet;
- use Util\PHPExcel\Cell;
- abstract class CacheBase
- {
-
- protected $currentObjectID = null;
-
- protected $currentObject = null;
-
- protected $currentCellIsDirty = true;
-
- protected $cellCache = array();
-
- protected $parent;
-
- public function __construct(Worksheet $parent)
- {
-
-
-
- $this->parent = $parent;
- }
-
- public function getParent()
- {
- return $this->parent;
- }
-
- public static function cacheMethodIsAvailable()
- {
- return true;
- }
-
- public function updateCacheData(Cell $cell)
- {
- return $this->addCacheData($cell->getCoordinate(), $cell);
- }
-
- public function deleteCacheData($pCoord)
- {
- if ($pCoord === $this->currentObjectID && !is_null($this->currentObject)) {
- $this->currentObject->detach();
- $this->currentObjectID = $this->currentObject = null;
- }
- if (is_object($this->cellCache[$pCoord])) {
- $this->cellCache[$pCoord]->detach();
- unset($this->cellCache[$pCoord]);
- }
- $this->currentCellIsDirty = false;
- }
-
- public function isDataSet($pCoord)
- {
- if ($pCoord === $this->currentObjectID) {
- return true;
- }
-
- return isset($this->cellCache[$pCoord]);
- }
-
- public function copyCellCollection(Worksheet $parent)
- {
- $this->currentCellIsDirty;
- $this->storeData();
- $this->parent = $parent;
- if (($this->currentObject !== null) && (is_object($this->currentObject))) {
- $this->currentObject->attach($this);
- }
- }
-
- public function getSortedCellList()
- {
- $sortKeys = array();
- foreach ($this->getCellList() as $coord) {
- sscanf($coord, '%[A-Z]%d', $column, $row);
- $sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
- }
- ksort($sortKeys);
- return array_values($sortKeys);
- }
-
- public function getCellList()
- {
- return array_keys($this->cellCache);
- }
-
- public function getCurrentAddress()
- {
- return $this->currentObjectID;
- }
- }
|