PHPExcel_CachedObjectStorage
[ class tree: PHPExcel_CachedObjectStorage ] [ index: PHPExcel_CachedObjectStorage ] [ all elements ]

Source for file CacheBase.php

Documentation is available at CacheBase.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2010 PHPExcel
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPExcel
  22.  * @package    PHPExcel_CachedObjectStorage
  23.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.3c, 2010-06-01
  26.  */
  27.  
  28.  
  29. /**
  30.  * PHPExcel_CachedObjectStorage_CacheBase
  31.  *
  32.  * @category   PHPExcel
  33.  * @package    PHPExcel_CachedObjectStorage
  34.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  35.  */
  36.  
  37.     /**
  38.      *    Parent worksheet
  39.      *
  40.      *    @var PHPExcel_Worksheet 
  41.      */
  42.     protected $_parent;
  43.  
  44.     /**
  45.      *    The currently active Cell
  46.      *
  47.      *    @var PHPExcel_Cell 
  48.      */
  49.     protected $_currentObject = null;
  50.  
  51.     /**
  52.      *    Coordinate address of the currently active Cell
  53.      *
  54.      *    @var string 
  55.      */
  56.     protected $_currentObjectID = null;
  57.  
  58.  
  59.     /**
  60.      *    An array of cells or cell pointers for the worksheet cells held in this cache,
  61.      *        and indexed by their coordinate address within the worksheet
  62.      *
  63.      *    @var array of mixed
  64.      */
  65.     protected $_cellCache = array();
  66.  
  67.  
  68.     public function __construct(PHPExcel_Worksheet $parent{
  69.         //    Set our parent worksheet.
  70.         //    This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
  71.         //        they are woken from a serialized state
  72.         $this->_parent = $parent;
  73.     }    //    function __construct()
  74.  
  75.  
  76.     /**
  77.      *    Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
  78.      *
  79.      *    @param    string        $pCoord        Coordinate address of the cell to check
  80.      *    @return    void 
  81.      *    @return    boolean 
  82.      */
  83.     public function isDataSet($pCoord{
  84.         if ($pCoord === $this->_currentObjectID{
  85.             return true;
  86.         }
  87.         //    Check if the requested entry exists in the cache
  88.         return isset($this->_cellCache[$pCoord]);
  89.     }    //    function isDataSet()
  90.  
  91.  
  92.     /**
  93.      *    Add or Update a cell in cache
  94.      *
  95.      *    @param    PHPExcel_Cell    $cell        Cell to update
  96.      *    @return    void 
  97.      *    @throws    Exception
  98.      */
  99.     public function updateCacheData(PHPExcel_Cell $cell{
  100.         $pCoord $cell->getCoordinate();
  101.  
  102.         return $this->addCacheData($pCoord,$cell);
  103.     }    //    function updateCacheData()
  104.  
  105.  
  106.     /**
  107.      *    Delete a cell in cache identified by coordinate address
  108.      *
  109.      *    @param    string            $pCoord        Coordinate address of the cell to delete
  110.      *    @throws    Exception
  111.      */
  112.     public function deleteCacheData($pCoord{
  113.         if ($pCoord === $this->_currentObjectID{
  114.             $this->_currentObject->detach();
  115.             $this->_currentObjectID = $this->_currentObject = null;
  116.         }
  117.  
  118.         if (isset($this->_cellCache[$pCoord])) {
  119.             $this->_cellCache[$pCoord]->detach();
  120.             unset($this->_cellCache[$pCoord]);
  121.         }
  122.     }    //    function deleteCacheData()
  123.  
  124.  
  125.     /**
  126.      *    Get a list of all cell addresses currently held in cache
  127.      *
  128.      *    @return    array of string
  129.      */
  130.     public function getCellList({
  131.         return array_keys($this->_cellCache);
  132.     }    //    function getCellList()
  133.  
  134.  
  135.     /**
  136.      *    Sort the list of all cell addresses currently held in cache by row and column
  137.      *
  138.      *    @return    void 
  139.      */
  140.     public function getSortedCellList({
  141.         $sortKeys array();
  142.         foreach ($this->_cellCache as $coord => $value{
  143.             preg_match('/^(\w+)(\d+)$/U',$coord,$matches);
  144.             list(,$colNum,$rowNum$matches;
  145.             $sortKeys[$coord=  str_pad($rowNum str_pad($colNum,3,'@',STR_PAD_LEFT),12,'0',STR_PAD_LEFT);
  146.         }
  147.         asort($sortKeys);
  148.  
  149.         return array_keys($sortKeys);
  150.     }    //    function sortCellList()
  151.  
  152. }

Documentation generated on Tue, 01 Jun 2010 17:02:15 +0200 by phpDocumentor 1.4.3