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

Source for file MemorySerialized.php

Documentation is available at MemorySerialized.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2011 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 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.6, 2011-02-27
  26.  */
  27.  
  28.  
  29. /**
  30.  * PHPExcel_CachedObjectStorage_MemorySerialized
  31.  *
  32.  * @category   PHPExcel
  33.  * @package    PHPExcel_CachedObjectStorage
  34.  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
  35.  */
  36.  
  37.     private function _storeData({
  38.         $this->_currentObject->detach();
  39.  
  40.         $this->_cellCache[$this->_currentObjectIDserialize($this->_currentObject);
  41.         $this->_currentObjectID = $this->_currentObject = null;
  42.     }    //    function _storeData()
  43.  
  44.  
  45.     /**
  46.      *    Add or Update a cell in cache identified by coordinate address
  47.      *
  48.      *    @param    string            $pCoord        Coordinate address of the cell to update
  49.      *    @param    PHPExcel_Cell    $cell        Cell to update
  50.      *    @return    void 
  51.      *    @throws    Exception
  52.      */
  53.     public function addCacheData($pCoordPHPExcel_Cell $cell{
  54.         if (($pCoord !== $this->_currentObjectID&& ($this->_currentObjectID !== null)) {
  55.             $this->_storeData();
  56.         }
  57.  
  58.         $this->_currentObjectID = $pCoord;
  59.         $this->_currentObject = $cell;
  60.  
  61.         return $cell;
  62.     }    //    function addCacheData()
  63.  
  64.  
  65.     /**
  66.      * Get cell at a specific coordinate
  67.      *
  68.      * @param     string             $pCoord        Coordinate of the cell
  69.      * @throws     Exception
  70.      * @return     PHPExcel_Cell     Cell that was found, or null if not found
  71.      */
  72.     public function getCacheData($pCoord{
  73.         if ($pCoord === $this->_currentObjectID{
  74.             return $this->_currentObject;
  75.         }
  76.         $this->_storeData();
  77.  
  78.         //    Check if the entry that has been requested actually exists
  79.         if (!isset($this->_cellCache[$pCoord])) {
  80.             //    Return null if requested entry doesn't exist in cache
  81.             return null;
  82.         }
  83.  
  84.         //    Set current entry to the requested entry
  85.         $this->_currentObjectID = $pCoord;
  86.         $this->_currentObject = unserialize($this->_cellCache[$pCoord]);
  87.         //    Re-attach the parent worksheet
  88.         $this->_currentObject->attach($this->_parent);
  89.  
  90.         //    Return requested entry
  91.         return $this->_currentObject;
  92.     }    //    function getCacheData()
  93.  
  94.  
  95.     public function unsetWorksheetCells({
  96.         if(!is_null($this->_currentObject)) {
  97.             $this->_currentObject->detach();
  98.             $this->_currentObject = $this->_currentObjectID = null;
  99.         }
  100.         $this->_cellCache = array();
  101.  
  102.         //    detach ourself from the worksheet, so that it can then delete this object successfully
  103.         $this->_parent = null;
  104.     }    //    function unsetWorksheetCells()
  105.  
  106. }

Documentation generated on Sun, 27 Feb 2011 16:32:48 -0800 by phpDocumentor 1.4.3