Move toward PSR-2 coding standards
This commit is contained in:
		
							parent
							
								
									fca778225c
								
							
						
					
					
						commit
						e83c359c7c
					
				
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -1,4 +1,15 @@ | ||||
| <?php | ||||
| 
 | ||||
| PHPExcel_Autoloader::Register(); | ||||
| //    As we always try to run the autoloader before anything else, we can use it to do a few
 | ||||
| //        simple checks and initialisations
 | ||||
| //PHPExcel_Shared_ZipStreamWrapper::register();
 | ||||
| // check mbstring.func_overload
 | ||||
| if (ini_get('mbstring.func_overload') & 2) { | ||||
|     throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).'); | ||||
| } | ||||
| PHPExcel_Shared_String::buildCharacterSets(); | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
| @ -24,66 +35,47 @@ | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| PHPExcel_Autoloader::Register(); | ||||
| //    As we always try to run the autoloader before anything else, we can use it to do a few
 | ||||
| //        simple checks and initialisations
 | ||||
| //PHPExcel_Shared_ZipStreamWrapper::register();
 | ||||
| // check mbstring.func_overload
 | ||||
| if (ini_get('mbstring.func_overload') & 2) { | ||||
|     throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).'); | ||||
| } | ||||
| PHPExcel_Shared_String::buildCharacterSets(); | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_Autoloader | ||||
|  * | ||||
|  * @category    PHPExcel | ||||
|  * @package     PHPExcel | ||||
|  * @copyright   Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Autoloader | ||||
| { | ||||
|     /** | ||||
|      * Register the Autoloader with SPL | ||||
|      * | ||||
|      */ | ||||
|     public static function Register() { | ||||
|     public static function Register() | ||||
|     { | ||||
|         if (function_exists('__autoload')) { | ||||
|             //    Register any existing autoloader function with SPL, so we don't get any clashes
 | ||||
|             // Register any existing autoloader function with SPL, so we don't get any clashes
 | ||||
|             spl_autoload_register('__autoload'); | ||||
|         } | ||||
|         //    Register ourselves with SPL
 | ||||
|         // Register ourselves with SPL
 | ||||
|         if (version_compare(PHP_VERSION, '5.3.0') >= 0) { | ||||
|             return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'), true, true); | ||||
|         } else { | ||||
|             return spl_autoload_register(array('PHPExcel_Autoloader', 'Load')); | ||||
|         } | ||||
|     }   //    function Register()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Autoload a class identified by name | ||||
|      * | ||||
|      * @param    string    $pClassName        Name of the object to load | ||||
|      */ | ||||
|     public static function Load($pClassName){ | ||||
|         if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) { | ||||
|             //    Either already loaded, or not a PHPExcel class request
 | ||||
|             return FALSE; | ||||
|     public static function Load($pClassName) | ||||
|     { | ||||
|         if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) { | ||||
|             // Either already loaded, or not a PHPExcel class request
 | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         $pClassFilePath = PHPEXCEL_ROOT . | ||||
|                           str_replace('_',DIRECTORY_SEPARATOR,$pClassName) . | ||||
|                           '.php'; | ||||
|             str_replace('_', DIRECTORY_SEPARATOR, $pClassName) . | ||||
|             '.php'; | ||||
| 
 | ||||
|         if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) { | ||||
|             //    Can't load
 | ||||
|             return FALSE; | ||||
|         if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) { | ||||
|             // Can't load
 | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         require($pClassFilePath); | ||||
|     }   //    function Load()
 | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * PHPExcel_CachedObjectStorage_APC | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
| @ -24,17 +25,8 @@ | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_APC | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
| class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Prefix used to uniquely identify cache data for this worksheet | ||||
|      * | ||||
| @ -51,7 +43,6 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|      */ | ||||
|     private $_cacheTime = 600; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
| @ -60,19 +51,23 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|      * @return  void | ||||
|      * @throws  PHPExcel_Exception | ||||
|      */ | ||||
|     protected function _storeData() { | ||||
|     protected function _storeData() | ||||
|     { | ||||
|         if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
|             $this->_currentObject->detach(); | ||||
| 
 | ||||
|             if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) { | ||||
|             if (!apc_store( | ||||
|                 $this->_cachePrefix . $this->_currentObjectID . '.cache', | ||||
|                 serialize($this->_currentObject), | ||||
|                 $this->_cacheTime | ||||
|             )) { | ||||
|                 $this->__destruct(); | ||||
|                 throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC'); | ||||
|                 throw new PHPExcel_Exception('Failed to store cell ' . $this->_currentObjectID . ' in APC'); | ||||
|             } | ||||
|             $this->_currentCellIsDirty = false; | ||||
|         } | ||||
|         $this->_currentObjectID = $this->_currentObject = null; | ||||
|     }    //    function _storeData()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
| @ -83,7 +78,8 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|      * @return  PHPExcel_Cell | ||||
|      * @throws  PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| @ -94,8 +90,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     }    //    function addCacheData()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | ||||
| @ -105,7 +100,8 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|      * @throws  PHPExcel_Exception | ||||
|      * @return  boolean | ||||
|      */ | ||||
|     public function isDataSet($pCoord) { | ||||
|     public function isDataSet($pCoord) | ||||
|     { | ||||
|         //    Check if the requested entry is the current object, or exists in the cache
 | ||||
|         if (parent::isDataSet($pCoord)) { | ||||
|             if ($this->_currentObjectID == $pCoord) { | ||||
| @ -113,7 +109,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|             } | ||||
|             //    Check if the requested entry still exists in apc
 | ||||
|             $success = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); | ||||
|             if ($success === FALSE) { | ||||
|             if ($success === false) { | ||||
|                 //    Entry no longer exists in APC, so clear it from the cache array
 | ||||
|                 parent::deleteCacheData($pCoord); | ||||
|                 throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); | ||||
| @ -121,8 +117,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|             return true; | ||||
|         } | ||||
|         return false; | ||||
|     }    //    function isDataSet()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
| @ -132,7 +127,8 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|      * @throws  PHPExcel_Exception | ||||
|      * @return  PHPExcel_Cell  Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) { | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
| @ -140,8 +136,8 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
| 
 | ||||
|         //    Check if the entry that has been requested actually exists
 | ||||
|         if (parent::isDataSet($pCoord)) { | ||||
|             $obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); | ||||
|             if ($obj === FALSE) { | ||||
|             $obj = apc_fetch($this->_cachePrefix . $pCoord . '.cache'); | ||||
|             if ($obj === false) { | ||||
|                 //    Entry no longer exists in APC, so clear it from the cache array
 | ||||
|                 parent::deleteCacheData($pCoord); | ||||
|                 throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache'); | ||||
| @ -159,22 +155,21 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     }    //    function getCacheData()
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return  string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return  string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		return parent::getCellList(); | ||||
| 	} | ||||
| 
 | ||||
|         return parent::getCellList(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Delete a cell in cache identified by coordinate address | ||||
| @ -183,14 +178,14 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|      * @param   string  $pCoord  Coordinate address of the cell to delete | ||||
|      * @throws  PHPExcel_Exception | ||||
|      */ | ||||
|     public function deleteCacheData($pCoord) { | ||||
|     public function deleteCacheData($pCoord) | ||||
|     { | ||||
|         //    Delete the entry from APC
 | ||||
|         apc_delete($this->_cachePrefix.$pCoord.'.cache'); | ||||
| 
 | ||||
|         //    Delete the entry from our cell address array
 | ||||
|         parent::deleteCacheData($pCoord); | ||||
|     }    //    function deleteCacheData()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
| @ -200,37 +195,38 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|      * @throws  PHPExcel_Exception | ||||
|      * @return  void | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) { | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         parent::copyCellCollection($parent); | ||||
|         //    Get a new id for the new file name
 | ||||
|         $baseUnique = $this->_getUniqueID(); | ||||
|         $newCachePrefix = substr(md5($baseUnique),0,8).'.'; | ||||
|         $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.'; | ||||
|         $cacheList = $this->getCellList(); | ||||
|         foreach($cacheList as $cellID) { | ||||
|         foreach ($cacheList as $cellID) { | ||||
|             if ($cellID != $this->_currentObjectID) { | ||||
|                 $obj = apc_fetch($this->_cachePrefix.$cellID.'.cache'); | ||||
|                 if ($obj === FALSE) { | ||||
|                 $obj = apc_fetch($this->_cachePrefix . $cellID . '.cache'); | ||||
|                 if ($obj === false) { | ||||
|                     //    Entry no longer exists in APC, so clear it from the cache array
 | ||||
|                     parent::deleteCacheData($cellID); | ||||
|                     throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC'); | ||||
|                     throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in APC'); | ||||
|                 } | ||||
|                 if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) { | ||||
|                 if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->_cacheTime)) { | ||||
|                     $this->__destruct(); | ||||
|                     throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC'); | ||||
|                     throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in APC'); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         $this->_cachePrefix = $newCachePrefix; | ||||
|     }    //    function copyCellCollection()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      * @return  void | ||||
|      */ | ||||
|     public function unsetWorksheetCells() { | ||||
|         if ($this->_currentObject !== NULL) { | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if ($this->_currentObject !== null) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
| @ -242,8 +238,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
| 
 | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
|     }    //    function unsetWorksheetCells()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise this new cell collection | ||||
| @ -251,29 +246,29 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|      * @param  PHPExcel_Worksheet  $parent     The worksheet for this cell collection | ||||
|      * @param  array of mixed      $arguments  Additional initialisation arguments | ||||
|      */ | ||||
|     public function __construct(PHPExcel_Worksheet $parent, $arguments) { | ||||
|     public function __construct(PHPExcel_Worksheet $parent, $arguments) | ||||
|     { | ||||
|         $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; | ||||
| 
 | ||||
|         if ($this->_cachePrefix === NULL) { | ||||
|         if ($this->_cachePrefix === null) { | ||||
|             $baseUnique = $this->_getUniqueID(); | ||||
|             $this->_cachePrefix = substr(md5($baseUnique),0,8).'.'; | ||||
|             $this->_cachePrefix = substr(md5($baseUnique), 0, 8) . '.'; | ||||
|             $this->_cacheTime = $cacheTime; | ||||
| 
 | ||||
|             parent::__construct($parent); | ||||
|         } | ||||
|     }    //    function __construct()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Destroy this cell collection | ||||
|      */ | ||||
|     public function __destruct() { | ||||
|     public function __destruct() | ||||
|     { | ||||
|         $cacheList = $this->getCellList(); | ||||
|         foreach($cacheList as $cellID) { | ||||
|             apc_delete($this->_cachePrefix.$cellID.'.cache'); | ||||
|         foreach ($cacheList as $cellID) { | ||||
|             apc_delete($this->_cachePrefix . $cellID . '.cache'); | ||||
|         } | ||||
|     }    //    function __destruct()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Identify whether the caching method is currently available | ||||
| @ -281,15 +276,15 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach | ||||
|      * | ||||
|      * @return  boolean | ||||
|      */ | ||||
|     public static function cacheMethodIsAvailable() { | ||||
|     public static function cacheMethodIsAvailable() | ||||
|     { | ||||
|         if (!function_exists('apc_store')) { | ||||
|             return FALSE; | ||||
|             return false; | ||||
|         } | ||||
|         if (apc_sma_info() === FALSE) { | ||||
|             return FALSE; | ||||
|         if (apc_sma_info() === false) { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         return TRUE; | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -1,376 +1,368 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_CacheBase | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| abstract class PHPExcel_CachedObjectStorage_CacheBase { | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Parent worksheet | ||||
| 	 * | ||||
| 	 * @var PHPExcel_Worksheet | ||||
| 	 */ | ||||
| 	protected $_parent; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * The currently active Cell | ||||
| 	 * | ||||
| 	 * @var PHPExcel_Cell | ||||
| 	 */ | ||||
| 	protected $_currentObject = null; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Coordinate address of the currently active Cell | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	protected $_currentObjectID = null; | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Flag indicating whether the currently active Cell requires saving | ||||
| 	 * | ||||
| 	 * @var boolean | ||||
| 	 */ | ||||
| 	protected $_currentCellIsDirty = true; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * An array of cells or cell pointers for the worksheet cells held in this cache, | ||||
| 	 *		and indexed by their coordinate address within the worksheet | ||||
| 	 * | ||||
| 	 * @var array of mixed | ||||
| 	 */ | ||||
| 	protected $_cellCache = array(); | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Initialise this new cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The worksheet for this cell collection | ||||
| 	 */ | ||||
| 	public function __construct(PHPExcel_Worksheet $parent) { | ||||
| 		//	Set our parent worksheet.
 | ||||
| 		//	This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
 | ||||
| 		//		they are woken from a serialized state
 | ||||
| 		$this->_parent = $parent; | ||||
| 	}	//	function __construct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return the parent worksheet for this cell collection | ||||
| 	 * | ||||
| 	 * @return	PHPExcel_Worksheet | ||||
| 	 */ | ||||
| 	public function getParent() | ||||
| 	{ | ||||
| 		return $this->_parent; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | ||||
| 	 * | ||||
| 	 * @param	string		$pCoord		Coordinate address of the cell to check | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public function isDataSet($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		//	Check if the requested entry exists in the cache
 | ||||
| 		return isset($this->_cellCache[$pCoord]); | ||||
| 	}	//	function isDataSet()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Move a cell object from one address to another | ||||
| 	 * | ||||
| 	 * @param	string		$fromAddress	Current address of the cell to move | ||||
| 	 * @param	string		$toAddress		Destination address of the cell to move | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public function moveCell($fromAddress, $toAddress) { | ||||
| 		if ($fromAddress === $this->_currentObjectID) { | ||||
| 			$this->_currentObjectID = $toAddress; | ||||
| 		} | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 		if (isset($this->_cellCache[$fromAddress])) { | ||||
| 			$this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress]; | ||||
| 			unset($this->_cellCache[$fromAddress]); | ||||
| 		} | ||||
| 
 | ||||
| 		return TRUE; | ||||
| 	}	//	function moveCell()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache | ||||
|      * | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function updateCacheData(PHPExcel_Cell $cell) { | ||||
| 		return $this->addCacheData($cell->getCoordinate(),$cell); | ||||
| 	}	//	function updateCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to delete | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	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; | ||||
| 	}	//	function deleteCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return	string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		return array_keys($this->_cellCache); | ||||
| 	}	//	function getCellList()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Sort the list of all cell addresses currently held in cache by row and column | ||||
| 	 * | ||||
| 	 * @return	string[] | ||||
| 	 */ | ||||
| 	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); | ||||
| 	}	//	function sortCellList()
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get highest worksheet column and highest row that have cell records | ||||
| 	 * | ||||
| 	 * @return array Highest column name and highest row number | ||||
| 	 */ | ||||
| 	public function getHighestRowAndColumn() | ||||
| 	{ | ||||
| 		// Lookup highest column and highest row
 | ||||
| 		$col = array('A' => '1A'); | ||||
| 		$row = array(1); | ||||
| 		foreach ($this->getCellList() as $coord) { | ||||
| 			sscanf($coord,'%[A-Z]%d', $c, $r); | ||||
| 			$row[$r] = $r; | ||||
| 			$col[$c] = strlen($c).$c; | ||||
|  		} | ||||
| 		if (!empty($row)) { | ||||
| 			// Determine highest column and row
 | ||||
| 			$highestRow = max($row); | ||||
| 			$highestColumn = substr(max($col),1); | ||||
| 		} | ||||
| 
 | ||||
| 		return array( 'row'	   => $highestRow, | ||||
| 					  'column' => $highestColumn | ||||
| 					); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return the cell address of the currently active cell object | ||||
| 	 * | ||||
| 	 * @return	string | ||||
| 	 */ | ||||
| 	public function getCurrentAddress() | ||||
| 	{ | ||||
| 		return $this->_currentObjectID; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return the column address of the currently active cell object | ||||
| 	 * | ||||
| 	 * @return	string | ||||
| 	 */ | ||||
| 	public function getCurrentColumn() | ||||
| 	{ | ||||
| 		sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); | ||||
| 		return $column; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return the row address of the currently active cell object | ||||
| 	 * | ||||
| 	 * @return	integer | ||||
| 	 */ | ||||
| 	public function getCurrentRow() | ||||
| 	{ | ||||
| 		sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); | ||||
| 		return (integer) $row; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get highest worksheet column | ||||
| 	 * | ||||
|      * @param   string     $row        Return the highest column for the specified row, | ||||
|      *                                     or the highest column of any row if no row number is passed | ||||
| 	 * @return  string     Highest column name | ||||
| 	 */ | ||||
| 	public function getHighestColumn($row = null) | ||||
| 	{ | ||||
|         if ($row == null) { | ||||
|     		$colRow = $this->getHighestRowAndColumn(); | ||||
| 	    	return $colRow['column']; | ||||
|         } | ||||
| 
 | ||||
|         $columnList = array(1); | ||||
|         foreach ($this->getCellList() as $coord) { | ||||
|             sscanf($coord,'%[A-Z]%d', $c, $r); | ||||
|             if ($r != $row) { | ||||
|                 continue; | ||||
|             } | ||||
|             $columnList[] = PHPExcel_Cell::columnIndexFromString($c); | ||||
|         } | ||||
|         return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1); | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get highest worksheet row | ||||
| 	 * | ||||
|      * @param   string     $column     Return the highest row for the specified column, | ||||
|      *                                     or the highest row of any column if no column letter is passed | ||||
| 	 * @return  int        Highest row number | ||||
| 	 */ | ||||
| 	public function getHighestRow($column = null) | ||||
| 	{ | ||||
|         if ($column == null) { | ||||
| 	    	$colRow = $this->getHighestRowAndColumn(); | ||||
|     		return $colRow['row']; | ||||
|         } | ||||
| 
 | ||||
|         $rowList = array(0); | ||||
|         foreach ($this->getCellList() as $coord) { | ||||
|             sscanf($coord,'%[A-Z]%d', $c, $r); | ||||
|             if ($c != $column) { | ||||
|                 continue; | ||||
|             } | ||||
|             $rowList[] = $r; | ||||
|         } | ||||
| 
 | ||||
|         return max($rowList); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Generate a unique ID for cache referencing | ||||
| 	 * | ||||
| 	 * @return string Unique Reference | ||||
| 	 */ | ||||
| 	protected function _getUniqueID() { | ||||
| 		if (function_exists('posix_getpid')) { | ||||
| 			$baseUnique = posix_getpid(); | ||||
| 		} else { | ||||
| 			$baseUnique = mt_rand(); | ||||
| 		} | ||||
| 		return uniqid($baseUnique,true); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clone the cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The new worksheet | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function copyCellCollection(PHPExcel_Worksheet $parent) { | ||||
| 		$this->_currentCellIsDirty; | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
| 		$this->_parent = $parent; | ||||
| 		if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) { | ||||
| 			$this->_currentObject->attach($this); | ||||
| 		} | ||||
| 	}	//	function copyCellCollection()
 | ||||
| 
 | ||||
|     /** | ||||
|      * Remove a row, deleting all cells in that row | ||||
|      * | ||||
|      * @param string    $row    Row number to remove | ||||
|      * @return void | ||||
|      */ | ||||
|     public function removeRow($row) { | ||||
|         foreach ($this->getCellList() as $coord) { | ||||
|             sscanf($coord,'%[A-Z]%d', $c, $r); | ||||
|             if ($r == $row) { | ||||
|                 $this->deleteCacheData($coord); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Remove a column, deleting all cells in that column | ||||
|      * | ||||
|      * @param string    $column    Column ID to remove | ||||
|      * @return void | ||||
|      */ | ||||
|     public function removeColumn($column) { | ||||
|         foreach ($this->getCellList() as $coord) { | ||||
|             sscanf($coord,'%[A-Z]%d', $c, $r); | ||||
|             if ($c == $column) { | ||||
|                 $this->deleteCacheData($coord); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Identify whether the caching method is currently available | ||||
| 	 * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
| 	 * | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public static function cacheMethodIsAvailable() { | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_CacheBase | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| abstract class PHPExcel_CachedObjectStorage_CacheBase | ||||
| { | ||||
|     /** | ||||
|      * Parent worksheet | ||||
|      * | ||||
|      * @var PHPExcel_Worksheet | ||||
|      */ | ||||
|     protected $_parent; | ||||
| 
 | ||||
|     /** | ||||
|      * The currently active Cell | ||||
|      * | ||||
|      * @var PHPExcel_Cell | ||||
|      */ | ||||
|     protected $_currentObject = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Coordinate address of the currently active Cell | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $_currentObjectID = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Flag indicating whether the currently active Cell requires saving | ||||
|      * | ||||
|      * @var boolean | ||||
|      */ | ||||
|     protected $_currentCellIsDirty = true; | ||||
| 
 | ||||
|     /** | ||||
|      * An array of cells or cell pointers for the worksheet cells held in this cache, | ||||
|      *        and indexed by their coordinate address within the worksheet | ||||
|      * | ||||
|      * @var array of mixed | ||||
|      */ | ||||
|     protected $_cellCache = array(); | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise this new cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The worksheet for this cell collection | ||||
|      */ | ||||
|     public function __construct(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         //    Set our parent worksheet.
 | ||||
|         //    This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
 | ||||
|         //        they are woken from a serialized state
 | ||||
|         $this->_parent = $parent; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return the parent worksheet for this cell collection | ||||
|      * | ||||
|      * @return    PHPExcel_Worksheet | ||||
|      */ | ||||
|     public function getParent() | ||||
|     { | ||||
|         return $this->_parent; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | ||||
|      * | ||||
|      * @param    string        $pCoord        Coordinate address of the cell to check | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public function isDataSet($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return true; | ||||
|         } | ||||
|         //    Check if the requested entry exists in the cache
 | ||||
|         return isset($this->_cellCache[$pCoord]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Move a cell object from one address to another | ||||
|      * | ||||
|      * @param    string        $fromAddress    Current address of the cell to move | ||||
|      * @param    string        $toAddress        Destination address of the cell to move | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public function moveCell($fromAddress, $toAddress) | ||||
|     { | ||||
|         if ($fromAddress === $this->_currentObjectID) { | ||||
|             $this->_currentObjectID = $toAddress; | ||||
|         } | ||||
|         $this->_currentCellIsDirty = true; | ||||
|         if (isset($this->_cellCache[$fromAddress])) { | ||||
|             $this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress]; | ||||
|             unset($this->_cellCache[$fromAddress]); | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache | ||||
|      * | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function updateCacheData(PHPExcel_Cell $cell) | ||||
|     { | ||||
|         return $this->addCacheData($cell->getCoordinate(), $cell); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to delete | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     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; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return    string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         return array_keys($this->_cellCache); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Sort the list of all cell addresses currently held in cache by row and column | ||||
|      * | ||||
|      * @return    string[] | ||||
|      */ | ||||
|     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); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get highest worksheet column and highest row that have cell records | ||||
|      * | ||||
|      * @return array Highest column name and highest row number | ||||
|      */ | ||||
|     public function getHighestRowAndColumn() | ||||
|     { | ||||
|         // Lookup highest column and highest row
 | ||||
|         $col = array('A' => '1A'); | ||||
|         $row = array(1); | ||||
|         foreach ($this->getCellList() as $coord) { | ||||
|             sscanf($coord, '%[A-Z]%d', $c, $r); | ||||
|             $row[$r] = $r; | ||||
|             $col[$c] = strlen($c).$c; | ||||
|         } | ||||
|         if (!empty($row)) { | ||||
|             // Determine highest column and row
 | ||||
|             $highestRow = max($row); | ||||
|             $highestColumn = substr(max($col), 1); | ||||
|         } | ||||
| 
 | ||||
|         return array( | ||||
|             'row'    => $highestRow, | ||||
|             'column' => $highestColumn | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return the cell address of the currently active cell object | ||||
|      * | ||||
|      * @return    string | ||||
|      */ | ||||
|     public function getCurrentAddress() | ||||
|     { | ||||
|         return $this->_currentObjectID; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return the column address of the currently active cell object | ||||
|      * | ||||
|      * @return    string | ||||
|      */ | ||||
|     public function getCurrentColumn() | ||||
|     { | ||||
|         sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); | ||||
|         return $column; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return the row address of the currently active cell object | ||||
|      * | ||||
|      * @return    integer | ||||
|      */ | ||||
|     public function getCurrentRow() | ||||
|     { | ||||
|         sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row); | ||||
|         return (integer) $row; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get highest worksheet column | ||||
|      * | ||||
|      * @param   string     $row        Return the highest column for the specified row, | ||||
|      *                                     or the highest column of any row if no row number is passed | ||||
|      * @return  string     Highest column name | ||||
|      */ | ||||
|     public function getHighestColumn($row = null) | ||||
|     { | ||||
|         if ($row == null) { | ||||
|             $colRow = $this->getHighestRowAndColumn(); | ||||
|             return $colRow['column']; | ||||
|         } | ||||
| 
 | ||||
|         $columnList = array(1); | ||||
|         foreach ($this->getCellList() as $coord) { | ||||
|             sscanf($coord, '%[A-Z]%d', $c, $r); | ||||
|             if ($r != $row) { | ||||
|                 continue; | ||||
|             } | ||||
|             $columnList[] = PHPExcel_Cell::columnIndexFromString($c); | ||||
|         } | ||||
|         return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get highest worksheet row | ||||
|      * | ||||
|      * @param   string     $column     Return the highest row for the specified column, | ||||
|      *                                     or the highest row of any column if no column letter is passed | ||||
|      * @return  int        Highest row number | ||||
|      */ | ||||
|     public function getHighestRow($column = null) | ||||
|     { | ||||
|         if ($column == null) { | ||||
|             $colRow = $this->getHighestRowAndColumn(); | ||||
|             return $colRow['row']; | ||||
|         } | ||||
| 
 | ||||
|         $rowList = array(0); | ||||
|         foreach ($this->getCellList() as $coord) { | ||||
|             sscanf($coord, '%[A-Z]%d', $c, $r); | ||||
|             if ($c != $column) { | ||||
|                 continue; | ||||
|             } | ||||
|             $rowList[] = $r; | ||||
|         } | ||||
| 
 | ||||
|         return max($rowList); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Generate a unique ID for cache referencing | ||||
|      * | ||||
|      * @return string Unique Reference | ||||
|      */ | ||||
|     protected function _getUniqueID() | ||||
|     { | ||||
|         if (function_exists('posix_getpid')) { | ||||
|             $baseUnique = posix_getpid(); | ||||
|         } else { | ||||
|             $baseUnique = mt_rand(); | ||||
|         } | ||||
|         return uniqid($baseUnique, true); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The new worksheet | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         $this->_currentCellIsDirty; | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         $this->_parent = $parent; | ||||
|         if (($this->_currentObject !== null) && (is_object($this->_currentObject))) { | ||||
|             $this->_currentObject->attach($this); | ||||
|         } | ||||
|     }    //    function copyCellCollection()
 | ||||
| 
 | ||||
|     /** | ||||
|      * Remove a row, deleting all cells in that row | ||||
|      * | ||||
|      * @param string    $row    Row number to remove | ||||
|      * @return void | ||||
|      */ | ||||
|     public function removeRow($row) | ||||
|     { | ||||
|         foreach ($this->getCellList() as $coord) { | ||||
|             sscanf($coord, '%[A-Z]%d', $c, $r); | ||||
|             if ($r == $row) { | ||||
|                 $this->deleteCacheData($coord); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Remove a column, deleting all cells in that column | ||||
|      * | ||||
|      * @param string    $column    Column ID to remove | ||||
|      * @return void | ||||
|      */ | ||||
|     public function removeColumn($column) | ||||
|     { | ||||
|         foreach ($this->getCellList() as $coord) { | ||||
|             sscanf($coord, '%[A-Z]%d', $c, $r); | ||||
|             if ($c == $column) { | ||||
|                 $this->deleteCacheData($coord); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Identify whether the caching method is currently available | ||||
|      * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
|      * | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public static function cacheMethodIsAvailable() | ||||
|     { | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,219 +1,208 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_DiscISAM | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Name of the file for this cache | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	private $_fileName = NULL; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * File handle for this cache file | ||||
| 	 * | ||||
| 	 * @var resource | ||||
| 	 */ | ||||
| 	private $_fileHandle = NULL; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Directory/Folder where the cache file is located | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	private $_cacheDirectory = NULL; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
| 	 * @return	void | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	protected function _storeData() { | ||||
| 		if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 
 | ||||
| 			fseek($this->_fileHandle,0,SEEK_END); | ||||
| 
 | ||||
| 			$this->_cellCache[$this->_currentObjectID] = array( | ||||
|                 'ptr' => ftell($this->_fileHandle), | ||||
| 				'sz'  => fwrite($this->_fileHandle, serialize($this->_currentObject)) | ||||
| 			); | ||||
| 			$this->_currentCellIsDirty = false; | ||||
| 		} | ||||
| 		$this->_currentObjectID = $this->_currentObject = null; | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = $cell; | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param 	string 			$pCoord		Coordinate of the cell | ||||
|      * @throws 	PHPExcel_Exception | ||||
|      * @return 	PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return $this->_currentObject; | ||||
| 		} | ||||
| 		$this->_storeData(); | ||||
| 
 | ||||
| 		//	Check if the entry that has been requested actually exists
 | ||||
| 		if (!isset($this->_cellCache[$pCoord])) { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		fseek($this->_fileHandle, $this->_cellCache[$pCoord]['ptr']); | ||||
| 		$this->_currentObject = unserialize(fread($this->_fileHandle, $this->_cellCache[$pCoord]['sz'])); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_currentObject; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return  string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		return parent::getCellList(); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clone the cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The new worksheet | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function copyCellCollection(PHPExcel_Worksheet $parent) { | ||||
| 		parent::copyCellCollection($parent); | ||||
| 		//	Get a new id for the new file name
 | ||||
| 		$baseUnique = $this->_getUniqueID(); | ||||
| 		$newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; | ||||
| 		//	Copy the existing cell cache file
 | ||||
| 		copy ($this->_fileName,$newFileName); | ||||
| 		$this->_fileName = $newFileName; | ||||
| 		//	Open the copied cell cache file
 | ||||
| 		$this->_fileHandle = fopen($this->_fileName,'a+'); | ||||
| 	}	//	function copyCellCollection()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		if(!is_null($this->_currentObject)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObject = $this->_currentObjectID = null; | ||||
| 		} | ||||
| 		$this->_cellCache = array(); | ||||
| 
 | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 
 | ||||
| 		//	Close down the temporary cache file
 | ||||
| 		$this->__destruct(); | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Initialise this new cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The worksheet for this cell collection | ||||
| 	 * @param	array of mixed		$arguments	Additional initialisation arguments | ||||
| 	 */ | ||||
| 	public function __construct(PHPExcel_Worksheet $parent, $arguments) { | ||||
| 		$this->_cacheDirectory	= ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL)) | ||||
| 									? $arguments['dir'] | ||||
| 									: PHPExcel_Shared_File::sys_get_temp_dir(); | ||||
| 
 | ||||
| 		parent::__construct($parent); | ||||
| 		if (is_null($this->_fileHandle)) { | ||||
| 			$baseUnique = $this->_getUniqueID(); | ||||
| 			$this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; | ||||
| 			$this->_fileHandle = fopen($this->_fileName,'a+'); | ||||
| 		} | ||||
| 	}	//	function __construct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Destroy this cell collection | ||||
| 	 */ | ||||
| 	public function __destruct() { | ||||
| 		if (!is_null($this->_fileHandle)) { | ||||
| 			fclose($this->_fileHandle); | ||||
| 			unlink($this->_fileName); | ||||
| 		} | ||||
| 		$this->_fileHandle = null; | ||||
| 	}	//	function __destruct()
 | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_DiscISAM | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Name of the file for this cache | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private $_fileName = null; | ||||
| 
 | ||||
|     /** | ||||
|      * File handle for this cache file | ||||
|      * | ||||
|      * @var resource | ||||
|      */ | ||||
|     private $_fileHandle = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Directory/Folder where the cache file is located | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private $_cacheDirectory = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
|      * @return    void | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     protected function _storeData() | ||||
|     { | ||||
|         if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
|             $this->_currentObject->detach(); | ||||
| 
 | ||||
|             fseek($this->_fileHandle, 0, SEEK_END); | ||||
| 
 | ||||
|             $this->_cellCache[$this->_currentObjectID] = array( | ||||
|                 'ptr' => ftell($this->_fileHandle), | ||||
|                 'sz'  => fwrite($this->_fileHandle, serialize($this->_currentObject)) | ||||
|             ); | ||||
|             $this->_currentCellIsDirty = false; | ||||
|         } | ||||
|         $this->_currentObjectID = $this->_currentObject = null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = $cell; | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param     string             $pCoord        Coordinate of the cell | ||||
|      * @throws     PHPExcel_Exception | ||||
|      * @return     PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         //    Check if the entry that has been requested actually exists
 | ||||
|         if (!isset($this->_cellCache[$pCoord])) { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         fseek($this->_fileHandle, $this->_cellCache[$pCoord]['ptr']); | ||||
|         $this->_currentObject = unserialize(fread($this->_fileHandle, $this->_cellCache[$pCoord]['sz'])); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return  string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         return parent::getCellList(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The new worksheet | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         parent::copyCellCollection($parent); | ||||
|         //    Get a new id for the new file name
 | ||||
|         $baseUnique = $this->_getUniqueID(); | ||||
|         $newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; | ||||
|         //    Copy the existing cell cache file
 | ||||
|         copy($this->_fileName, $newFileName); | ||||
|         $this->_fileName = $newFileName; | ||||
|         //    Open the copied cell cache file
 | ||||
|         $this->_fileHandle = fopen($this->_fileName, 'a+'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if (!is_null($this->_currentObject)) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
|         $this->_cellCache = array(); | ||||
| 
 | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
| 
 | ||||
|         //    Close down the temporary cache file
 | ||||
|         $this->__destruct(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise this new cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The worksheet for this cell collection | ||||
|      * @param    array of mixed        $arguments    Additional initialisation arguments | ||||
|      */ | ||||
|     public function __construct(PHPExcel_Worksheet $parent, $arguments) | ||||
|     { | ||||
|         $this->_cacheDirectory    = ((isset($arguments['dir'])) && ($arguments['dir'] !== null)) | ||||
|                                     ? $arguments['dir'] | ||||
|                                     : PHPExcel_Shared_File::sys_get_temp_dir(); | ||||
| 
 | ||||
|         parent::__construct($parent); | ||||
|         if (is_null($this->_fileHandle)) { | ||||
|             $baseUnique = $this->_getUniqueID(); | ||||
|             $this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache'; | ||||
|             $this->_fileHandle = fopen($this->_fileName, 'a+'); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Destroy this cell collection | ||||
|      */ | ||||
|     public function __destruct() | ||||
|     { | ||||
|         if (!is_null($this->_fileHandle)) { | ||||
|             fclose($this->_fileHandle); | ||||
|             unlink($this->_fileName); | ||||
|         } | ||||
|         $this->_fileHandle = null; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * PHPExcel_CachedObjectStorage_ICache | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
| @ -21,92 +22,82 @@ | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_ICache | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| interface PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell); | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell); | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache | ||||
|      * | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
| 	public function updateCacheData(PHPExcel_Cell $cell); | ||||
|     public function updateCacheData(PHPExcel_Cell $cell); | ||||
| 
 | ||||
|     /** | ||||
|      * Fetch a cell from cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to retrieve | ||||
|      * @return PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      * @throws	PHPExcel_Exception | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to retrieve | ||||
|      * @return PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
| 	public function getCacheData($pCoord); | ||||
|     public function getCacheData($pCoord); | ||||
| 
 | ||||
|     /** | ||||
|      * Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to delete | ||||
|      * @throws	PHPExcel_Exception | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to delete | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
| 	public function deleteCacheData($pCoord); | ||||
|     public function deleteCacheData($pCoord); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | ||||
| 	 * | ||||
| 	 * @param	string		$pCoord		Coordinate address of the cell to check | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public function isDataSet($pCoord); | ||||
|     /** | ||||
|      * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | ||||
|      * | ||||
|      * @param    string        $pCoord        Coordinate address of the cell to check | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public function isDataSet($pCoord); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return	string[] | ||||
| 	 */ | ||||
| 	public function getCellList(); | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return    string[] | ||||
|      */ | ||||
|     public function getCellList(); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get the list of all cell addresses currently held in cache sorted by column and row | ||||
| 	 * | ||||
| 	 * @return	string[] | ||||
| 	 */ | ||||
| 	public function getSortedCellList(); | ||||
|     /** | ||||
|      * Get the list of all cell addresses currently held in cache sorted by column and row | ||||
|      * | ||||
|      * @return    string[] | ||||
|      */ | ||||
|     public function getSortedCellList(); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clone the cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The new worksheet | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function copyCellCollection(PHPExcel_Worksheet $parent); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Identify whether the caching method is currently available | ||||
| 	 * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
| 	 * | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public static function cacheMethodIsAvailable(); | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The new worksheet | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent); | ||||
| 
 | ||||
|     /** | ||||
|      * Identify whether the caching method is currently available | ||||
|      * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
|      * | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public static function cacheMethodIsAvailable(); | ||||
| } | ||||
|  | ||||
| @ -1,152 +1,149 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_Igbinary | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
| 	 * @return	void | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	protected function _storeData() { | ||||
| 		if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 
 | ||||
| 			$this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject); | ||||
| 			$this->_currentCellIsDirty = false; | ||||
| 		} | ||||
| 		$this->_currentObjectID = $this->_currentObject = null; | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = $cell; | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param 	string 			$pCoord		Coordinate of the cell | ||||
|      * @throws 	PHPExcel_Exception | ||||
|      * @return 	PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return $this->_currentObject; | ||||
| 		} | ||||
| 		$this->_storeData(); | ||||
| 
 | ||||
| 		//	Check if the entry that has been requested actually exists
 | ||||
| 		if (!isset($this->_cellCache[$pCoord])) { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_currentObject; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return  string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		return parent::getCellList(); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		if(!is_null($this->_currentObject)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObject = $this->_currentObjectID = null; | ||||
| 		} | ||||
| 		$this->_cellCache = array(); | ||||
| 
 | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Identify whether the caching method is currently available | ||||
| 	 * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
| 	 * | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public static function cacheMethodIsAvailable() { | ||||
| 		if (!function_exists('igbinary_serialize')) { | ||||
| 			return false; | ||||
| 		} | ||||
| 
 | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_Igbinary | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
|      * @return    void | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     protected function _storeData() | ||||
|     { | ||||
|         if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
|             $this->_currentObject->detach(); | ||||
| 
 | ||||
|             $this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject); | ||||
|             $this->_currentCellIsDirty = false; | ||||
|         } | ||||
|         $this->_currentObjectID = $this->_currentObject = null; | ||||
|     }    //    function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = $cell; | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     }    //    function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param     string             $pCoord        Coordinate of the cell | ||||
|      * @throws     PHPExcel_Exception | ||||
|      * @return     PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         //    Check if the entry that has been requested actually exists
 | ||||
|         if (!isset($this->_cellCache[$pCoord])) { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     }    //    function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return  string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         return parent::getCellList(); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if (!is_null($this->_currentObject)) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
|         $this->_cellCache = array(); | ||||
| 
 | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
|     }    //    function unsetWorksheetCells()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Identify whether the caching method is currently available | ||||
|      * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
|      * | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public static function cacheMethodIsAvailable() | ||||
|     { | ||||
|         if (!function_exists('igbinary_serialize')) { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,312 +1,308 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_Memcache | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Prefix used to uniquely identify cache data for this worksheet | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	private $_cachePrefix = null; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Cache timeout | ||||
| 	 * | ||||
| 	 * @var integer | ||||
| 	 */ | ||||
| 	private $_cacheTime = 600; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Memcache interface | ||||
| 	 * | ||||
| 	 * @var resource | ||||
| 	 */ | ||||
| 	private $_memcache = null; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
| 	 * @return	void | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	protected function _storeData() { | ||||
| 		if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 
 | ||||
| 			$obj = serialize($this->_currentObject); | ||||
| 			if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) { | ||||
| 				if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) { | ||||
| 					$this->__destruct(); | ||||
| 					throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache'); | ||||
| 				} | ||||
| 			} | ||||
| 			$this->_currentCellIsDirty = false; | ||||
| 		} | ||||
| 		$this->_currentObjectID = $this->_currentObject = null; | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 		$this->_cellCache[$pCoord] = true; | ||||
| 
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = $cell; | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | ||||
| 	 * | ||||
| 	 * @param	string		$pCoord		Coordinate address of the cell to check | ||||
| 	 * @return	boolean | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public function isDataSet($pCoord) { | ||||
| 		//	Check if the requested entry is the current object, or exists in the cache
 | ||||
| 		if (parent::isDataSet($pCoord)) { | ||||
| 			if ($this->_currentObjectID == $pCoord) { | ||||
| 				return true; | ||||
| 			} | ||||
| 			//	Check if the requested entry still exists in Memcache
 | ||||
| 			$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache'); | ||||
| 			if ($success === false) { | ||||
| 				//	Entry no longer exists in Memcache, so clear it from the cache array
 | ||||
| 				parent::deleteCacheData($pCoord); | ||||
| 				throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); | ||||
| 			} | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	}	//	function isDataSet()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param 	string 			$pCoord		Coordinate of the cell | ||||
|      * @throws 	PHPExcel_Exception | ||||
|      * @return 	PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return $this->_currentObject; | ||||
| 		} | ||||
| 		$this->_storeData(); | ||||
| 
 | ||||
| 		//	Check if the entry that has been requested actually exists
 | ||||
| 		if (parent::isDataSet($pCoord)) { | ||||
| 			$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache'); | ||||
| 			if ($obj === false) { | ||||
| 				//	Entry no longer exists in Memcache, so clear it from the cache array
 | ||||
| 				parent::deleteCacheData($pCoord); | ||||
| 				throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); | ||||
| 			} | ||||
| 		} else { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = unserialize($obj); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_currentObject; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return  string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		return parent::getCellList(); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to delete | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function deleteCacheData($pCoord) { | ||||
| 		//	Delete the entry from Memcache
 | ||||
| 		$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache'); | ||||
| 
 | ||||
| 		//	Delete the entry from our cell address array
 | ||||
| 		parent::deleteCacheData($pCoord); | ||||
| 	}	//	function deleteCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clone the cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The new worksheet | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function copyCellCollection(PHPExcel_Worksheet $parent) { | ||||
| 		parent::copyCellCollection($parent); | ||||
| 		//	Get a new id for the new file name
 | ||||
| 		$baseUnique = $this->_getUniqueID(); | ||||
| 		$newCachePrefix = substr(md5($baseUnique),0,8).'.'; | ||||
| 		$cacheList = $this->getCellList(); | ||||
| 		foreach($cacheList as $cellID) { | ||||
| 			if ($cellID != $this->_currentObjectID) { | ||||
| 				$obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache'); | ||||
| 				if ($obj === false) { | ||||
| 					//	Entry no longer exists in Memcache, so clear it from the cache array
 | ||||
| 					parent::deleteCacheData($cellID); | ||||
| 					throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in MemCache'); | ||||
| 				} | ||||
| 				if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) { | ||||
| 					$this->__destruct(); | ||||
| 					throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in MemCache'); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		$this->_cachePrefix = $newCachePrefix; | ||||
| 	}	//	function copyCellCollection()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		if(!is_null($this->_currentObject)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObject = $this->_currentObjectID = null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Flush the Memcache cache
 | ||||
| 		$this->__destruct(); | ||||
| 
 | ||||
| 		$this->_cellCache = array(); | ||||
| 
 | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Initialise this new cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The worksheet for this cell collection | ||||
| 	 * @param	array of mixed		$arguments	Additional initialisation arguments | ||||
| 	 */ | ||||
| 	public function __construct(PHPExcel_Worksheet $parent, $arguments) { | ||||
| 		$memcacheServer	= (isset($arguments['memcacheServer']))	? $arguments['memcacheServer']	: 'localhost'; | ||||
| 		$memcachePort	= (isset($arguments['memcachePort']))	? $arguments['memcachePort']	: 11211; | ||||
| 		$cacheTime		= (isset($arguments['cacheTime']))		? $arguments['cacheTime']		: 600; | ||||
| 
 | ||||
| 		if (is_null($this->_cachePrefix)) { | ||||
| 			$baseUnique = $this->_getUniqueID(); | ||||
| 			$this->_cachePrefix = substr(md5($baseUnique),0,8).'.'; | ||||
| 
 | ||||
| 			//	Set a new Memcache object and connect to the Memcache server
 | ||||
| 			$this->_memcache = new Memcache(); | ||||
| 			if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) { | ||||
| 				throw new PHPExcel_Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort); | ||||
| 			} | ||||
| 			$this->_cacheTime = $cacheTime; | ||||
| 
 | ||||
| 			parent::__construct($parent); | ||||
| 		} | ||||
| 	}	//	function __construct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Memcache error handler | ||||
| 	 * | ||||
| 	 * @param	string	$host		Memcache server | ||||
| 	 * @param	integer	$port		Memcache port | ||||
|      * @throws	PHPExcel_Exception | ||||
| 	 */ | ||||
| 	public function failureCallback($host, $port) { | ||||
| 		throw new PHPExcel_Exception('memcache '.$host.':'.$port.' failed'); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Destroy this cell collection | ||||
| 	 */ | ||||
| 	public function __destruct() { | ||||
| 		$cacheList = $this->getCellList(); | ||||
| 		foreach($cacheList as $cellID) { | ||||
| 			$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache'); | ||||
| 		} | ||||
| 	}	//	function __destruct()
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Identify whether the caching method is currently available | ||||
| 	 * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
| 	 * | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public static function cacheMethodIsAvailable() { | ||||
| 		if (!function_exists('memcache_add')) { | ||||
| 			return false; | ||||
| 		} | ||||
| 
 | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_Memcache | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Prefix used to uniquely identify cache data for this worksheet | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private $_cachePrefix = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Cache timeout | ||||
|      * | ||||
|      * @var integer | ||||
|      */ | ||||
|     private $_cacheTime = 600; | ||||
| 
 | ||||
|     /** | ||||
|      * Memcache interface | ||||
|      * | ||||
|      * @var resource | ||||
|      */ | ||||
|     private $_memcache = null; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
|      * @return    void | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     protected function _storeData() | ||||
|     { | ||||
|         if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
|             $this->_currentObject->detach(); | ||||
| 
 | ||||
|             $obj = serialize($this->_currentObject); | ||||
|             if (!$this->_memcache->replace($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, null, $this->_cacheTime)) { | ||||
|                 if (!$this->_memcache->add($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, null, $this->_cacheTime)) { | ||||
|                     $this->__destruct(); | ||||
|                     throw new PHPExcel_Exception("Failed to store cell {$this->_currentObjectID} in MemCache"); | ||||
|                 } | ||||
|             } | ||||
|             $this->_currentCellIsDirty = false; | ||||
|         } | ||||
|         $this->_currentObjectID = $this->_currentObject = null; | ||||
|     }    //    function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
|         $this->_cellCache[$pCoord] = true; | ||||
| 
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = $cell; | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     }    //    function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | ||||
|      * | ||||
|      * @param    string        $pCoord        Coordinate address of the cell to check | ||||
|      * @return    boolean | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public function isDataSet($pCoord) | ||||
|     { | ||||
|         //    Check if the requested entry is the current object, or exists in the cache
 | ||||
|         if (parent::isDataSet($pCoord)) { | ||||
|             if ($this->_currentObjectID == $pCoord) { | ||||
|                 return true; | ||||
|             } | ||||
|             //    Check if the requested entry still exists in Memcache
 | ||||
|             $success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache'); | ||||
|             if ($success === false) { | ||||
|                 //    Entry no longer exists in Memcache, so clear it from the cache array
 | ||||
|                 parent::deleteCacheData($pCoord); | ||||
|                 throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache'); | ||||
|             } | ||||
|             return true; | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param     string             $pCoord        Coordinate of the cell | ||||
|      * @throws     PHPExcel_Exception | ||||
|      * @return     PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         //    Check if the entry that has been requested actually exists
 | ||||
|         if (parent::isDataSet($pCoord)) { | ||||
|             $obj = $this->_memcache->get($this->_cachePrefix . $pCoord . '.cache'); | ||||
|             if ($obj === false) { | ||||
|                 //    Entry no longer exists in Memcache, so clear it from the cache array
 | ||||
|                 parent::deleteCacheData($pCoord); | ||||
|                 throw new PHPExcel_Exception("Cell entry {$pCoord} no longer exists in MemCache"); | ||||
|             } | ||||
|         } else { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = unserialize($obj); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return  string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         return parent::getCellList(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to delete | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function deleteCacheData($pCoord) | ||||
|     { | ||||
|         //    Delete the entry from Memcache
 | ||||
|         $this->_memcache->delete($this->_cachePrefix . $pCoord . '.cache'); | ||||
| 
 | ||||
|         //    Delete the entry from our cell address array
 | ||||
|         parent::deleteCacheData($pCoord); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The new worksheet | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         parent::copyCellCollection($parent); | ||||
|         //    Get a new id for the new file name
 | ||||
|         $baseUnique = $this->_getUniqueID(); | ||||
|         $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.'; | ||||
|         $cacheList = $this->getCellList(); | ||||
|         foreach ($cacheList as $cellID) { | ||||
|             if ($cellID != $this->_currentObjectID) { | ||||
|                 $obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache'); | ||||
|                 if ($obj === false) { | ||||
|                     //    Entry no longer exists in Memcache, so clear it from the cache array
 | ||||
|                     parent::deleteCacheData($cellID); | ||||
|                     throw new PHPExcel_Exception("Cell entry {$cellID} no longer exists in MemCache"); | ||||
|                 } | ||||
|                 if (!$this->_memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->_cacheTime)) { | ||||
|                     $this->__destruct(); | ||||
|                     throw new PHPExcel_Exception("Failed to store cell {$cellID} in MemCache"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         $this->_cachePrefix = $newCachePrefix; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if (!is_null($this->_currentObject)) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
| 
 | ||||
|         //    Flush the Memcache cache
 | ||||
|         $this->__destruct(); | ||||
| 
 | ||||
|         $this->_cellCache = array(); | ||||
| 
 | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise this new cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The worksheet for this cell collection | ||||
|      * @param    array of mixed        $arguments    Additional initialisation arguments | ||||
|      */ | ||||
|     public function __construct(PHPExcel_Worksheet $parent, $arguments) | ||||
|     { | ||||
|         $memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost'; | ||||
|         $memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211; | ||||
|         $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; | ||||
| 
 | ||||
|         if (is_null($this->_cachePrefix)) { | ||||
|             $baseUnique = $this->_getUniqueID(); | ||||
|             $this->_cachePrefix = substr(md5($baseUnique), 0, 8) . '.'; | ||||
| 
 | ||||
|             //    Set a new Memcache object and connect to the Memcache server
 | ||||
|             $this->_memcache = new Memcache(); | ||||
|             if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) { | ||||
|                 throw new PHPExcel_Exception("Could not connect to MemCache server at {$memcacheServer}:{$memcachePort}"; | ||||
|             } | ||||
|             $this->_cacheTime = $cacheTime; | ||||
| 
 | ||||
|             parent::__construct($parent); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Memcache error handler | ||||
|      * | ||||
|      * @param    string    $host        Memcache server | ||||
|      * @param    integer    $port        Memcache port | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function failureCallback($host, $port) | ||||
|     { | ||||
|         throw new PHPExcel_Exception("memcache {$host}:{$port} failed"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Destroy this cell collection | ||||
|      */ | ||||
|     public function __destruct() | ||||
|     { | ||||
|         $cacheList = $this->getCellList(); | ||||
|         foreach ($cacheList as $cellID) { | ||||
|             $this->_memcache->delete($this->_cachePrefix.$cellID . '.cache'); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Identify whether the caching method is currently available | ||||
|      * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
|      * | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public static function cacheMethodIsAvailable() | ||||
|     { | ||||
|         if (!function_exists('memcache_add')) { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,125 +1,118 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_Memory | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
|     /** | ||||
|      * Dummy method callable from CacheBase, but unused by Memory cache | ||||
|      * | ||||
| 	 * @return	void | ||||
|      */ | ||||
| 	protected function _storeData() { | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		$this->_cellCache[$pCoord] = $cell; | ||||
| 
 | ||||
| 		//	Set current entry to the new/updated entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param 	string 			$pCoord		Coordinate of the cell | ||||
|      * @throws 	PHPExcel_Exception | ||||
|      * @return 	PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		//	Check if the entry that has been requested actually exists
 | ||||
| 		if (!isset($this->_cellCache[$pCoord])) { | ||||
| 			$this->_currentObjectID = NULL; | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_cellCache[$pCoord]; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clone the cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The new worksheet | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function copyCellCollection(PHPExcel_Worksheet $parent) { | ||||
| 		parent::copyCellCollection($parent); | ||||
| 
 | ||||
| 		$newCollection = array(); | ||||
| 		foreach($this->_cellCache as $k => &$cell) { | ||||
| 			$newCollection[$k] = clone $cell; | ||||
| 			$newCollection[$k]->attach($this); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_cellCache = $newCollection; | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		//	Because cells are all stored as intact objects in memory, we need to detach each one from the parent
 | ||||
| 		foreach($this->_cellCache as $k => &$cell) { | ||||
| 			$cell->detach(); | ||||
| 			$this->_cellCache[$k] = null; | ||||
| 		} | ||||
| 		unset($cell); | ||||
| 
 | ||||
| 		$this->_cellCache = array(); | ||||
| 
 | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_Memory | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Dummy method callable from CacheBase, but unused by Memory cache | ||||
|      * | ||||
|      * @return    void | ||||
|      */ | ||||
|     protected function _storeData() | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         $this->_cellCache[$pCoord] = $cell; | ||||
| 
 | ||||
|         //    Set current entry to the new/updated entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
| 
 | ||||
|         return $cell; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param     string             $pCoord        Coordinate of the cell | ||||
|      * @throws     PHPExcel_Exception | ||||
|      * @return     PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         //    Check if the entry that has been requested actually exists
 | ||||
|         if (!isset($this->_cellCache[$pCoord])) { | ||||
|             $this->_currentObjectID = null; | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_cellCache[$pCoord]; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The new worksheet | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         parent::copyCellCollection($parent); | ||||
| 
 | ||||
|         $newCollection = array(); | ||||
|         foreach ($this->_cellCache as $k => &$cell) { | ||||
|             $newCollection[$k] = clone $cell; | ||||
|             $newCollection[$k]->attach($this); | ||||
|         } | ||||
| 
 | ||||
|         $this->_cellCache = $newCollection; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         // Because cells are all stored as intact objects in memory, we need to detach each one from the parent
 | ||||
|         foreach ($this->_cellCache as $k => &$cell) { | ||||
|             $cell->detach(); | ||||
|             $this->_cellCache[$k] = null; | ||||
|         } | ||||
|         unset($cell); | ||||
| 
 | ||||
|         $this->_cellCache = array(); | ||||
| 
 | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,137 +1,133 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_MemoryGZip | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
| 	 * @return	void | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	protected function _storeData() { | ||||
| 		if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 
 | ||||
| 			$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject)); | ||||
| 			$this->_currentCellIsDirty = false; | ||||
| 		} | ||||
| 		$this->_currentObjectID = $this->_currentObject = null; | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = $cell; | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param 	string 			$pCoord		Coordinate of the cell | ||||
|      * @throws 	PHPExcel_Exception | ||||
|      * @return 	PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return $this->_currentObject; | ||||
| 		} | ||||
| 		$this->_storeData(); | ||||
| 
 | ||||
| 		//	Check if the entry that has been requested actually exists
 | ||||
| 		if (!isset($this->_cellCache[$pCoord])) { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord])); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_currentObject; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return  string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		return parent::getCellList(); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		if(!is_null($this->_currentObject)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObject = $this->_currentObjectID = null; | ||||
| 		} | ||||
| 		$this->_cellCache = array(); | ||||
| 
 | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_MemoryGZip | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
|      * @return    void | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     protected function _storeData() | ||||
|     { | ||||
|         if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
|             $this->_currentObject->detach(); | ||||
| 
 | ||||
|             $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject)); | ||||
|             $this->_currentCellIsDirty = false; | ||||
|         } | ||||
|         $this->_currentObjectID = $this->_currentObject = null; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = $cell; | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param     string             $pCoord        Coordinate of the cell | ||||
|      * @throws     PHPExcel_Exception | ||||
|      * @return     PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         //    Check if the entry that has been requested actually exists
 | ||||
|         if (!isset($this->_cellCache[$pCoord])) { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord])); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return  string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         return parent::getCellList(); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if (!is_null($this->_currentObject)) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
|         $this->_cellCache = array(); | ||||
| 
 | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,137 +1,129 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_MemorySerialized | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
| 	 * @return	void | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	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; | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = $cell; | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param 	string 			$pCoord		Coordinate of the cell | ||||
|      * @throws 	PHPExcel_Exception | ||||
|      * @return 	PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return $this->_currentObject; | ||||
| 		} | ||||
| 		$this->_storeData(); | ||||
| 
 | ||||
| 		//	Check if the entry that has been requested actually exists
 | ||||
| 		if (!isset($this->_cellCache[$pCoord])) { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = unserialize($this->_cellCache[$pCoord]); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_currentObject; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return  string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		return parent::getCellList(); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		if(!is_null($this->_currentObject)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObject = $this->_currentObjectID = null; | ||||
| 		} | ||||
| 		$this->_cellCache = array(); | ||||
| 
 | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_MemorySerialized | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
|      * @return    void | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     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; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = $cell; | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param     string             $pCoord        Coordinate of the cell | ||||
|      * @throws     PHPExcel_Exception | ||||
|      * @return     PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         //    Check if the entry that has been requested actually exists
 | ||||
|         if (!isset($this->_cellCache[$pCoord])) { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = unserialize($this->_cellCache[$pCoord]); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return  string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         return parent::getCellList(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if (!is_null($this->_currentObject)) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
|         $this->_cellCache = array(); | ||||
| 
 | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,206 +1,200 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_PHPTemp | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Name of the file for this cache | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	private $_fileHandle = null; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Memory limit to use before reverting to file cache | ||||
| 	 * | ||||
| 	 * @var integer | ||||
| 	 */ | ||||
| 	private $_memoryCacheSize = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
| 	 * @return	void | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	protected function _storeData() { | ||||
| 		if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 
 | ||||
| 			fseek($this->_fileHandle,0,SEEK_END); | ||||
| 
 | ||||
| 			$this->_cellCache[$this->_currentObjectID] = array( | ||||
|                 'ptr' => ftell($this->_fileHandle), | ||||
| 				'sz'  => fwrite($this->_fileHandle, serialize($this->_currentObject)) | ||||
| 			); | ||||
| 			$this->_currentCellIsDirty = false; | ||||
| 		} | ||||
| 		$this->_currentObjectID = $this->_currentObject = null; | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = $cell; | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param 	string 			$pCoord		Coordinate of the cell | ||||
|      * @throws 	PHPExcel_Exception | ||||
|      * @return 	PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return $this->_currentObject; | ||||
| 		} | ||||
| 		$this->_storeData(); | ||||
| 
 | ||||
| 		//	Check if the entry that has been requested actually exists
 | ||||
| 		if (!isset($this->_cellCache[$pCoord])) { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']); | ||||
| 		$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz'])); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_currentObject; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return  string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		return parent::getCellList(); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clone the cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The new worksheet | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function copyCellCollection(PHPExcel_Worksheet $parent) { | ||||
| 		parent::copyCellCollection($parent); | ||||
| 		//	Open a new stream for the cell cache data
 | ||||
| 		$newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+'); | ||||
| 		//	Copy the existing cell cache data to the new stream
 | ||||
| 		fseek($this->_fileHandle,0); | ||||
| 		while (!feof($this->_fileHandle)) { | ||||
| 			fwrite($newFileHandle,fread($this->_fileHandle, 1024)); | ||||
| 		} | ||||
| 		$this->_fileHandle = $newFileHandle; | ||||
| 	}	//	function copyCellCollection()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		if(!is_null($this->_currentObject)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObject = $this->_currentObjectID = null; | ||||
| 		} | ||||
| 		$this->_cellCache = array(); | ||||
| 
 | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 
 | ||||
| 		//	Close down the php://temp file
 | ||||
| 		$this->__destruct(); | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Initialise this new cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The worksheet for this cell collection | ||||
| 	 * @param	array of mixed		$arguments	Additional initialisation arguments | ||||
| 	 */ | ||||
| 	public function __construct(PHPExcel_Worksheet $parent, $arguments) { | ||||
| 		$this->_memoryCacheSize	= (isset($arguments['memoryCacheSize']))	? $arguments['memoryCacheSize']	: '1MB'; | ||||
| 
 | ||||
| 		parent::__construct($parent); | ||||
| 		if (is_null($this->_fileHandle)) { | ||||
| 			$this->_fileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+'); | ||||
| 		} | ||||
| 	}	//	function __construct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Destroy this cell collection | ||||
| 	 */ | ||||
| 	public function __destruct() { | ||||
| 		if (!is_null($this->_fileHandle)) { | ||||
| 			fclose($this->_fileHandle); | ||||
| 		} | ||||
| 		$this->_fileHandle = null; | ||||
| 	}	//	function __destruct()
 | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_PHPTemp | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Name of the file for this cache | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private $_fileHandle = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Memory limit to use before reverting to file cache | ||||
|      * | ||||
|      * @var integer | ||||
|      */ | ||||
|     private $_memoryCacheSize = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
|      * @return    void | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     protected function _storeData() | ||||
|     { | ||||
|         if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
|             $this->_currentObject->detach(); | ||||
| 
 | ||||
|             fseek($this->_fileHandle, 0, SEEK_END); | ||||
| 
 | ||||
|             $this->_cellCache[$this->_currentObjectID] = array( | ||||
|                 'ptr' => ftell($this->_fileHandle), | ||||
|                 'sz'  => fwrite($this->_fileHandle, serialize($this->_currentObject)) | ||||
|             ); | ||||
|             $this->_currentCellIsDirty = false; | ||||
|         } | ||||
|         $this->_currentObjectID = $this->_currentObject = null; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = $cell; | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param     string             $pCoord        Coordinate of the cell | ||||
|      * @throws     PHPExcel_Exception | ||||
|      * @return     PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         //    Check if the entry that has been requested actually exists
 | ||||
|         if (!isset($this->_cellCache[$pCoord])) { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         fseek($this->_fileHandle, $this->_cellCache[$pCoord]['ptr']); | ||||
|         $this->_currentObject = unserialize(fread($this->_fileHandle, $this->_cellCache[$pCoord]['sz'])); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return  string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         return parent::getCellList(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The new worksheet | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         parent::copyCellCollection($parent); | ||||
|         //    Open a new stream for the cell cache data
 | ||||
|         $newFileHandle = fopen('php://temp/maxmemory:' . $this->_memoryCacheSize, 'a+'); | ||||
|         //    Copy the existing cell cache data to the new stream
 | ||||
|         fseek($this->_fileHandle, 0); | ||||
|         while (!feof($this->_fileHandle)) { | ||||
|             fwrite($newFileHandle, fread($this->_fileHandle, 1024)); | ||||
|         } | ||||
|         $this->_fileHandle = $newFileHandle; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if (!is_null($this->_currentObject)) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
|         $this->_cellCache = array(); | ||||
| 
 | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
| 
 | ||||
|         //    Close down the php://temp file
 | ||||
|         $this->__destruct(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise this new cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The worksheet for this cell collection | ||||
|      * @param    array of mixed        $arguments    Additional initialisation arguments | ||||
|      */ | ||||
|     public function __construct(PHPExcel_Worksheet $parent, $arguments) | ||||
|     { | ||||
|         $this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB'; | ||||
| 
 | ||||
|         parent::__construct($parent); | ||||
|         if (is_null($this->_fileHandle)) { | ||||
|             $this->_fileHandle = fopen('php://temp/maxmemory:' . $this->_memoryCacheSize, 'a+'); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Destroy this cell collection | ||||
|      */ | ||||
|     public function __destruct() | ||||
|     { | ||||
|         if (!is_null($this->_fileHandle)) { | ||||
|             fclose($this->_fileHandle); | ||||
|         } | ||||
|         $this->_fileHandle = null; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,306 +1,307 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_SQLite | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Database table name | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	private $_TableName = null; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Database handle | ||||
| 	 * | ||||
| 	 * @var resource | ||||
| 	 */ | ||||
| 	private $_DBHandle = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
| 	 * @return	void | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	protected function _storeData() { | ||||
| 		if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 
 | ||||
| 			if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) | ||||
| 				throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
| 			$this->_currentCellIsDirty = false; | ||||
| 		} | ||||
| 		$this->_currentObjectID = $this->_currentObject = null; | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = $cell; | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param 	string 			$pCoord		Coordinate of the cell | ||||
|      * @throws 	PHPExcel_Exception | ||||
|      * @return 	PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return $this->_currentObject; | ||||
| 		} | ||||
| 		$this->_storeData(); | ||||
| 
 | ||||
| 		$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; | ||||
| 		$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC); | ||||
| 		if ($cellResultSet === false) { | ||||
| 			throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
| 		} elseif ($cellResultSet->numRows() == 0) { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 
 | ||||
| 		$cellResult = $cellResultSet->fetchSingle(); | ||||
| 		$this->_currentObject = unserialize($cellResult); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_currentObject; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Is a value set for an indexed cell? | ||||
| 	 * | ||||
| 	 * @param	string		$pCoord		Coordinate address of the cell to check | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public function isDataSet($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return true; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Check if the requested entry exists in the cache
 | ||||
| 		$query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; | ||||
| 		$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC); | ||||
| 		if ($cellResultSet === false) { | ||||
| 			throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
| 		} elseif ($cellResultSet->numRows() == 0) { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return false; | ||||
| 		} | ||||
| 		return true; | ||||
| 	}	//	function isDataSet()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to delete | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function deleteCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObjectID = $this->_currentObject = null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Check if the requested entry exists in the cache
 | ||||
| 		$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; | ||||
| 		if (!$this->_DBHandle->queryExec($query)) | ||||
| 			throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
| 
 | ||||
| 		$this->_currentCellIsDirty = false; | ||||
| 	}	//	function deleteCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Move a cell object from one address to another | ||||
| 	 * | ||||
| 	 * @param	string		$fromAddress	Current address of the cell to move | ||||
| 	 * @param	string		$toAddress		Destination address of the cell to move | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public function moveCell($fromAddress, $toAddress) { | ||||
| 		if ($fromAddress === $this->_currentObjectID) { | ||||
| 			$this->_currentObjectID = $toAddress; | ||||
| 		} | ||||
| 
 | ||||
| 		$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'"; | ||||
| 		$result = $this->_DBHandle->exec($query); | ||||
| 		if ($result === false) | ||||
| 			throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 
 | ||||
| 		$query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'"; | ||||
| 		$result = $this->_DBHandle->exec($query); | ||||
| 		if ($result === false) | ||||
| 			throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 
 | ||||
| 		return TRUE; | ||||
| 	}	//	function moveCell()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return	string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		$query = "SELECT id FROM kvp_".$this->_TableName; | ||||
| 		$cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC); | ||||
| 		if ($cellIdsResult === false) | ||||
| 			throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
| 
 | ||||
| 		$cellKeys = array(); | ||||
| 		foreach($cellIdsResult as $row) { | ||||
| 			$cellKeys[] = $row['id']; | ||||
| 		} | ||||
| 
 | ||||
| 		return $cellKeys; | ||||
| 	}	//	function getCellList()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clone the cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The new worksheet | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function copyCellCollection(PHPExcel_Worksheet $parent) { | ||||
| 		$this->_currentCellIsDirty; | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
| 		//	Get a new id for the new table name
 | ||||
| 		$tableName = str_replace('.','_',$this->_getUniqueID()); | ||||
| 		if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) | ||||
| 													AS SELECT * FROM kvp_'.$this->_TableName)) | ||||
| 			throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
| 
 | ||||
| 		//	Copy the existing cell cache file
 | ||||
| 		$this->_TableName = $tableName; | ||||
| 	}	//	function copyCellCollection()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		if(!is_null($this->_currentObject)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObject = $this->_currentObjectID = null; | ||||
| 		} | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 
 | ||||
| 		//	Close down the temporary cache file
 | ||||
| 		$this->__destruct(); | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Initialise this new cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The worksheet for this cell collection | ||||
| 	 */ | ||||
| 	public function __construct(PHPExcel_Worksheet $parent) { | ||||
| 		parent::__construct($parent); | ||||
| 		if (is_null($this->_DBHandle)) { | ||||
| 			$this->_TableName = str_replace('.','_',$this->_getUniqueID()); | ||||
| 			$_DBName = ':memory:'; | ||||
| 
 | ||||
| 			$this->_DBHandle = new SQLiteDatabase($_DBName); | ||||
| 			if ($this->_DBHandle === false) | ||||
| 				throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
| 			if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) | ||||
| 				throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
| 		} | ||||
| 	}	//	function __construct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Destroy this cell collection | ||||
| 	 */ | ||||
| 	public function __destruct() { | ||||
| 		if (!is_null($this->_DBHandle)) { | ||||
| 			$this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName); | ||||
| 		} | ||||
| 		$this->_DBHandle = null; | ||||
| 	}	//	function __destruct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Identify whether the caching method is currently available | ||||
| 	 * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
| 	 * | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public static function cacheMethodIsAvailable() { | ||||
| 		if (!function_exists('sqlite_open')) { | ||||
| 			return false; | ||||
| 		} | ||||
| 
 | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_SQLite | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Database table name | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private $_TableName = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Database handle | ||||
|      * | ||||
|      * @var resource | ||||
|      */ | ||||
|     private $_DBHandle = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
|      * @return    void | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     protected function _storeData() | ||||
|     { | ||||
|         if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
|             $this->_currentObject->detach(); | ||||
| 
 | ||||
|             if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) { | ||||
|                 throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
|             } | ||||
|             $this->_currentCellIsDirty = false; | ||||
|         } | ||||
|         $this->_currentObjectID = $this->_currentObject = null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = $cell; | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param     string             $pCoord        Coordinate of the cell | ||||
|      * @throws     PHPExcel_Exception | ||||
|      * @return     PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; | ||||
|         $cellResultSet = $this->_DBHandle->query($query, SQLITE_ASSOC); | ||||
|         if ($cellResultSet === false) { | ||||
|             throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
|         } elseif ($cellResultSet->numRows() == 0) { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
| 
 | ||||
|         $cellResult = $cellResultSet->fetchSingle(); | ||||
|         $this->_currentObject = unserialize($cellResult); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Is a value set for an indexed cell? | ||||
|      * | ||||
|      * @param    string        $pCoord        Coordinate address of the cell to check | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public function isDataSet($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return true; | ||||
|         } | ||||
| 
 | ||||
|         //    Check if the requested entry exists in the cache
 | ||||
|         $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; | ||||
|         $cellResultSet = $this->_DBHandle->query($query, SQLITE_ASSOC); | ||||
|         if ($cellResultSet === false) { | ||||
|             throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
|         } elseif ($cellResultSet->numRows() == 0) { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return false; | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to delete | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function deleteCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObjectID = $this->_currentObject = null; | ||||
|         } | ||||
| 
 | ||||
|         //    Check if the requested entry exists in the cache
 | ||||
|         $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'"; | ||||
|         if (!$this->_DBHandle->queryExec($query)) { | ||||
|             throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentCellIsDirty = false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Move a cell object from one address to another | ||||
|      * | ||||
|      * @param    string        $fromAddress    Current address of the cell to move | ||||
|      * @param    string        $toAddress        Destination address of the cell to move | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public function moveCell($fromAddress, $toAddress) | ||||
|     { | ||||
|         if ($fromAddress === $this->_currentObjectID) { | ||||
|             $this->_currentObjectID = $toAddress; | ||||
|         } | ||||
| 
 | ||||
|         $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'"; | ||||
|         $result = $this->_DBHandle->exec($query); | ||||
|         if ($result === false) { | ||||
|             throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|         } | ||||
| 
 | ||||
|         $query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'"; | ||||
|         $result = $this->_DBHandle->exec($query); | ||||
|         if ($result === false) { | ||||
|             throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return    string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         $query = "SELECT id FROM kvp_".$this->_TableName; | ||||
|         $cellIdsResult = $this->_DBHandle->unbufferedQuery($query, SQLITE_ASSOC); | ||||
|         if ($cellIdsResult === false) { | ||||
|             throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
|         } | ||||
| 
 | ||||
|         $cellKeys = array(); | ||||
|         foreach ($cellIdsResult as $row) { | ||||
|             $cellKeys[] = $row['id']; | ||||
|         } | ||||
| 
 | ||||
|         return $cellKeys; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The new worksheet | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         $this->_currentCellIsDirty; | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         //    Get a new id for the new table name
 | ||||
|         $tableName = str_replace('.', '_', $this->_getUniqueID()); | ||||
|         if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) | ||||
|             AS SELECT * FROM kvp_'.$this->_TableName) | ||||
|         ) { | ||||
|             throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
|         } | ||||
| 
 | ||||
|         //    Copy the existing cell cache file
 | ||||
|         $this->_TableName = $tableName; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if (!is_null($this->_currentObject)) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
| 
 | ||||
|         //    Close down the temporary cache file
 | ||||
|         $this->__destruct(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise this new cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The worksheet for this cell collection | ||||
|      */ | ||||
|     public function __construct(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         parent::__construct($parent); | ||||
|         if (is_null($this->_DBHandle)) { | ||||
|             $this->_TableName = str_replace('.', '_', $this->_getUniqueID()); | ||||
|             $_DBName = ':memory:'; | ||||
| 
 | ||||
|             $this->_DBHandle = new SQLiteDatabase($_DBName); | ||||
|             if ($this->_DBHandle === false) { | ||||
|                 throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
|             } | ||||
|             if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) { | ||||
|                 throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError())); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Destroy this cell collection | ||||
|      */ | ||||
|     public function __destruct() | ||||
|     { | ||||
|         if (!is_null($this->_DBHandle)) { | ||||
|             $this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName); | ||||
|         } | ||||
|         $this->_DBHandle = null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Identify whether the caching method is currently available | ||||
|      * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
|      * | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public static function cacheMethodIsAvailable() | ||||
|     { | ||||
|         if (!function_exists('sqlite_open')) { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,345 +1,346 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_SQLite3 | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Database table name | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	private $_TableName = null; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Database handle | ||||
| 	 * | ||||
| 	 * @var resource | ||||
| 	 */ | ||||
| 	private $_DBHandle = null; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Prepared statement for a SQLite3 select query | ||||
| 	 * | ||||
| 	 * @var SQLite3Stmt | ||||
| 	 */ | ||||
| 	private $_selectQuery; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Prepared statement for a SQLite3 insert query | ||||
| 	 * | ||||
| 	 * @var SQLite3Stmt | ||||
| 	 */ | ||||
| 	private $_insertQuery; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Prepared statement for a SQLite3 update query | ||||
| 	 * | ||||
| 	 * @var SQLite3Stmt | ||||
| 	 */ | ||||
| 	private $_updateQuery; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Prepared statement for a SQLite3 delete query | ||||
| 	 * | ||||
| 	 * @var SQLite3Stmt | ||||
| 	 */ | ||||
| 	private $_deleteQuery; | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
| 	 * @return	void | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	protected function _storeData() { | ||||
| 		if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 
 | ||||
| 			$this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT); | ||||
| 			$this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB); | ||||
| 			$result = $this->_insertQuery->execute(); | ||||
| 			if ($result === false) | ||||
| 				throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 			$this->_currentCellIsDirty = false; | ||||
| 		} | ||||
| 		$this->_currentObjectID = $this->_currentObject = null; | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to update | ||||
|      * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = $cell; | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param 	string 			$pCoord		Coordinate of the cell | ||||
|      * @throws 	PHPExcel_Exception | ||||
|      * @return 	PHPExcel_Cell 	Cell that was found, or null if not found | ||||
|      */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return $this->_currentObject; | ||||
| 		} | ||||
| 		$this->_storeData(); | ||||
| 
 | ||||
| 		$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT); | ||||
| 		$cellResult = $this->_selectQuery->execute(); | ||||
| 		if ($cellResult === FALSE) { | ||||
| 			throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 		} | ||||
| 		$cellData = $cellResult->fetchArray(SQLITE3_ASSOC); | ||||
| 		if ($cellData === FALSE) { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return NULL; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 
 | ||||
| 		$this->_currentObject = unserialize($cellData['value']); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_currentObject; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 *	Is a value set for an indexed cell? | ||||
| 	 * | ||||
| 	 * @param	string		$pCoord		Coordinate address of the cell to check | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public function isDataSet($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return TRUE; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Check if the requested entry exists in the cache
 | ||||
| 		$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT); | ||||
| 		$cellResult = $this->_selectQuery->execute(); | ||||
| 		if ($cellResult === FALSE) { | ||||
| 			throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 		} | ||||
| 		$cellData = $cellResult->fetchArray(SQLITE3_ASSOC); | ||||
| 
 | ||||
| 		return ($cellData === FALSE) ? FALSE : TRUE; | ||||
| 	}	//	function isDataSet()
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      *	Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param	string			$pCoord		Coordinate address of the cell to delete | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	public function deleteCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObjectID = $this->_currentObject = NULL; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Check if the requested entry exists in the cache
 | ||||
| 		$this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT); | ||||
| 		$result = $this->_deleteQuery->execute(); | ||||
| 		if ($result === FALSE) | ||||
| 			throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 
 | ||||
| 		$this->_currentCellIsDirty = FALSE; | ||||
| 	}	//	function deleteCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Move a cell object from one address to another | ||||
| 	 * | ||||
| 	 * @param	string		$fromAddress	Current address of the cell to move | ||||
| 	 * @param	string		$toAddress		Destination address of the cell to move | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public function moveCell($fromAddress, $toAddress) { | ||||
| 		if ($fromAddress === $this->_currentObjectID) { | ||||
| 			$this->_currentObjectID = $toAddress; | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT); | ||||
| 		$result = $this->_deleteQuery->execute(); | ||||
| 		if ($result === false) | ||||
| 			throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 
 | ||||
| 		$this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT); | ||||
| 		$this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT); | ||||
| 		$result = $this->_updateQuery->execute(); | ||||
| 		if ($result === false) | ||||
| 			throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 
 | ||||
| 		return TRUE; | ||||
| 	}	//	function moveCell()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return	string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		$query = "SELECT id FROM kvp_".$this->_TableName; | ||||
| 		$cellIdsResult = $this->_DBHandle->query($query); | ||||
| 		if ($cellIdsResult === false) | ||||
| 			throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 
 | ||||
| 		$cellKeys = array(); | ||||
| 		while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) { | ||||
| 			$cellKeys[] = $row['id']; | ||||
| 		} | ||||
| 
 | ||||
| 		return $cellKeys; | ||||
| 	}	//	function getCellList()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clone the cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The new worksheet | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function copyCellCollection(PHPExcel_Worksheet $parent) { | ||||
| 		$this->_currentCellIsDirty; | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
| 		//	Get a new id for the new table name
 | ||||
| 		$tableName = str_replace('.','_',$this->_getUniqueID()); | ||||
| 		if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) | ||||
| 		                                       AS SELECT * FROM kvp_'.$this->_TableName)) | ||||
| 			throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 
 | ||||
| 		//	Copy the existing cell cache file
 | ||||
| 		$this->_TableName = $tableName; | ||||
| 	}	//	function copyCellCollection()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		if(!is_null($this->_currentObject)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObject = $this->_currentObjectID = null; | ||||
| 		} | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 
 | ||||
| 		//	Close down the temporary cache file
 | ||||
| 		$this->__destruct(); | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Initialise this new cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The worksheet for this cell collection | ||||
| 	 */ | ||||
| 	public function __construct(PHPExcel_Worksheet $parent) { | ||||
| 		parent::__construct($parent); | ||||
| 		if (is_null($this->_DBHandle)) { | ||||
| 			$this->_TableName = str_replace('.','_',$this->_getUniqueID()); | ||||
| 			$_DBName = ':memory:'; | ||||
| 
 | ||||
| 			$this->_DBHandle = new SQLite3($_DBName); | ||||
| 			if ($this->_DBHandle === false) | ||||
| 				throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 			if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) | ||||
| 				throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id"); | ||||
| 		$this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)"); | ||||
| 		$this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId"); | ||||
| 		$this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id"); | ||||
| 	}	//	function __construct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Destroy this cell collection | ||||
| 	 */ | ||||
| 	public function __destruct() { | ||||
| 		if (!is_null($this->_DBHandle)) { | ||||
| 			$this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName); | ||||
| 			$this->_DBHandle->close(); | ||||
| 		} | ||||
| 		$this->_DBHandle = null; | ||||
| 	}	//	function __destruct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Identify whether the caching method is currently available | ||||
| 	 * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
| 	 * | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public static function cacheMethodIsAvailable() { | ||||
| 		if (!class_exists('SQLite3',FALSE)) { | ||||
| 			return false; | ||||
| 		} | ||||
| 
 | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_SQLite3 | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Database table name | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private $_TableName = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Database handle | ||||
|      * | ||||
|      * @var resource | ||||
|      */ | ||||
|     private $_DBHandle = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Prepared statement for a SQLite3 select query | ||||
|      * | ||||
|      * @var SQLite3Stmt | ||||
|      */ | ||||
|     private $_selectQuery; | ||||
| 
 | ||||
|     /** | ||||
|      * Prepared statement for a SQLite3 insert query | ||||
|      * | ||||
|      * @var SQLite3Stmt | ||||
|      */ | ||||
|     private $_insertQuery; | ||||
| 
 | ||||
|     /** | ||||
|      * Prepared statement for a SQLite3 update query | ||||
|      * | ||||
|      * @var SQLite3Stmt | ||||
|      */ | ||||
|     private $_updateQuery; | ||||
| 
 | ||||
|     /** | ||||
|      * Prepared statement for a SQLite3 delete query | ||||
|      * | ||||
|      * @var SQLite3Stmt | ||||
|      */ | ||||
|     private $_deleteQuery; | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
|      * @return    void | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     protected function _storeData() | ||||
|     { | ||||
|         if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
|             $this->_currentObject->detach(); | ||||
| 
 | ||||
|             $this->_insertQuery->bindValue('id', $this->_currentObjectID, SQLITE3_TEXT); | ||||
|             $this->_insertQuery->bindValue('data', serialize($this->_currentObject), SQLITE3_BLOB); | ||||
|             $result = $this->_insertQuery->execute(); | ||||
|             if ($result === false) { | ||||
|                 throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|             } | ||||
|             $this->_currentCellIsDirty = false; | ||||
|         } | ||||
|         $this->_currentObjectID = $this->_currentObject = null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = $cell; | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param     string             $pCoord        Coordinate of the cell | ||||
|      * @throws     PHPExcel_Exception | ||||
|      * @return     PHPExcel_Cell     Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         $this->_selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT); | ||||
|         $cellResult = $this->_selectQuery->execute(); | ||||
|         if ($cellResult === false) { | ||||
|             throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|         } | ||||
|         $cellData = $cellResult->fetchArray(SQLITE3_ASSOC); | ||||
|         if ($cellData === false) { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
| 
 | ||||
|         $this->_currentObject = unserialize($cellData['value']); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      *    Is a value set for an indexed cell? | ||||
|      * | ||||
|      * @param    string        $pCoord        Coordinate address of the cell to check | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public function isDataSet($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return true; | ||||
|         } | ||||
| 
 | ||||
|         //    Check if the requested entry exists in the cache
 | ||||
|         $this->_selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT); | ||||
|         $cellResult = $this->_selectQuery->execute(); | ||||
|         if ($cellResult === false) { | ||||
|             throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|         } | ||||
|         $cellData = $cellResult->fetchArray(SQLITE3_ASSOC); | ||||
| 
 | ||||
|         return ($cellData === false) ? false : true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      *    Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to delete | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function deleteCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObjectID = $this->_currentObject = null; | ||||
|         } | ||||
| 
 | ||||
|         //    Check if the requested entry exists in the cache
 | ||||
|         $this->_deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT); | ||||
|         $result = $this->_deleteQuery->execute(); | ||||
|         if ($result === false) { | ||||
|             throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentCellIsDirty = false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Move a cell object from one address to another | ||||
|      * | ||||
|      * @param    string        $fromAddress    Current address of the cell to move | ||||
|      * @param    string        $toAddress        Destination address of the cell to move | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public function moveCell($fromAddress, $toAddress) | ||||
|     { | ||||
|         if ($fromAddress === $this->_currentObjectID) { | ||||
|             $this->_currentObjectID = $toAddress; | ||||
|         } | ||||
| 
 | ||||
|         $this->_deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT); | ||||
|         $result = $this->_deleteQuery->execute(); | ||||
|         if ($result === false) { | ||||
|             throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|         } | ||||
| 
 | ||||
|         $this->_updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT); | ||||
|         $this->_updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT); | ||||
|         $result = $this->_updateQuery->execute(); | ||||
|         if ($result === false) { | ||||
|             throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return    string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         $query = "SELECT id FROM kvp_".$this->_TableName; | ||||
|         $cellIdsResult = $this->_DBHandle->query($query); | ||||
|         if ($cellIdsResult === false) { | ||||
|             throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|         } | ||||
| 
 | ||||
|         $cellKeys = array(); | ||||
|         while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) { | ||||
|             $cellKeys[] = $row['id']; | ||||
|         } | ||||
| 
 | ||||
|         return $cellKeys; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The new worksheet | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         $this->_currentCellIsDirty; | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         //    Get a new id for the new table name
 | ||||
|         $tableName = str_replace('.', '_', $this->_getUniqueID()); | ||||
|         if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB) | ||||
|             AS SELECT * FROM kvp_'.$this->_TableName) | ||||
|         ) { | ||||
|             throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|         } | ||||
| 
 | ||||
|         //    Copy the existing cell cache file
 | ||||
|         $this->_TableName = $tableName; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if (!is_null($this->_currentObject)) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
| 
 | ||||
|         //    Close down the temporary cache file
 | ||||
|         $this->__destruct(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise this new cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The worksheet for this cell collection | ||||
|      */ | ||||
|     public function __construct(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         parent::__construct($parent); | ||||
|         if (is_null($this->_DBHandle)) { | ||||
|             $this->_TableName = str_replace('.', '_', $this->_getUniqueID()); | ||||
|             $_DBName = ':memory:'; | ||||
| 
 | ||||
|             $this->_DBHandle = new SQLite3($_DBName); | ||||
|             if ($this->_DBHandle === false) { | ||||
|                 throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|             } | ||||
|             if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) { | ||||
|                 throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg()); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         $this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id"); | ||||
|         $this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)"); | ||||
|         $this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId"); | ||||
|         $this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Destroy this cell collection | ||||
|      */ | ||||
|     public function __destruct() | ||||
|     { | ||||
|         if (!is_null($this->_DBHandle)) { | ||||
|             $this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName); | ||||
|             $this->_DBHandle->close(); | ||||
|         } | ||||
|         $this->_DBHandle = null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Identify whether the caching method is currently available | ||||
|      * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
|      * | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public static function cacheMethodIsAvailable() | ||||
|     { | ||||
|         if (!class_exists('SQLite3', false)) { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,294 +1,289 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package	PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license	http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version	##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_Wincache | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package	PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Prefix used to uniquely identify cache data for this worksheet | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	private $_cachePrefix = null; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Cache timeout | ||||
| 	 * | ||||
| 	 * @var integer | ||||
| 	 */ | ||||
| 	private $_cacheTime = 600; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
| 	 * @return	void | ||||
|      * @throws	PHPExcel_Exception | ||||
|      */ | ||||
| 	protected function _storeData() { | ||||
| 		if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 
 | ||||
| 			$obj = serialize($this->_currentObject); | ||||
| 			if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) { | ||||
| 				if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { | ||||
| 					$this->__destruct(); | ||||
| 					throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); | ||||
| 				} | ||||
| 			} else { | ||||
| 				if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { | ||||
| 					$this->__destruct(); | ||||
| 					throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); | ||||
| 				} | ||||
| 			} | ||||
| 			$this->_currentCellIsDirty = false; | ||||
| 		} | ||||
| 
 | ||||
| 		$this->_currentObjectID = $this->_currentObject = null; | ||||
| 	}	//	function _storeData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Add or Update a cell in cache identified by coordinate address | ||||
| 	 * | ||||
| 	 * @param	string			$pCoord		Coordinate address of the cell to update | ||||
| 	 * @param	PHPExcel_Cell	$cell		Cell to update | ||||
| 	 * @return	PHPExcel_Cell | ||||
| 	 * @throws	PHPExcel_Exception | ||||
| 	 */ | ||||
| 	public function addCacheData($pCoord, PHPExcel_Cell $cell) { | ||||
| 		if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 		$this->_cellCache[$pCoord] = true; | ||||
| 
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = $cell; | ||||
| 		$this->_currentCellIsDirty = true; | ||||
| 
 | ||||
| 		return $cell; | ||||
| 	}	//	function addCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | ||||
| 	 * | ||||
| 	 * @param	string		$pCoord		Coordinate address of the cell to check | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public function isDataSet($pCoord) { | ||||
| 		//	Check if the requested entry is the current object, or exists in the cache
 | ||||
| 		if (parent::isDataSet($pCoord)) { | ||||
| 			if ($this->_currentObjectID == $pCoord) { | ||||
| 				return true; | ||||
| 			} | ||||
| 			//	Check if the requested entry still exists in cache
 | ||||
| 			$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache'); | ||||
| 			if ($success === false) { | ||||
| 				//	Entry no longer exists in Wincache, so clear it from the cache array
 | ||||
| 				parent::deleteCacheData($pCoord); | ||||
| 				throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); | ||||
| 			} | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	}	//	function isDataSet()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get cell at a specific coordinate | ||||
| 	 * | ||||
| 	 * @param	string			$pCoord		Coordinate of the cell | ||||
| 	 * @throws	PHPExcel_Exception | ||||
| 	 * @return	PHPExcel_Cell	Cell that was found, or null if not found | ||||
| 	 */ | ||||
| 	public function getCacheData($pCoord) { | ||||
| 		if ($pCoord === $this->_currentObjectID) { | ||||
| 			return $this->_currentObject; | ||||
| 		} | ||||
| 		$this->_storeData(); | ||||
| 
 | ||||
| 		//	Check if the entry that has been requested actually exists
 | ||||
| 		$obj = null; | ||||
| 		if (parent::isDataSet($pCoord)) { | ||||
| 			$success = false; | ||||
| 			$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success); | ||||
| 			if ($success === false) { | ||||
| 				//	Entry no longer exists in WinCache, so clear it from the cache array
 | ||||
| 				parent::deleteCacheData($pCoord); | ||||
| 				throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); | ||||
| 			} | ||||
| 		} else { | ||||
| 			//	Return null if requested entry doesn't exist in cache
 | ||||
| 			return null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Set current entry to the requested entry
 | ||||
| 		$this->_currentObjectID = $pCoord; | ||||
| 		$this->_currentObject = unserialize($obj); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
| 		//	Return requested entry
 | ||||
| 		return $this->_currentObject; | ||||
| 	}	//	function getCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Get a list of all cell addresses currently held in cache | ||||
| 	 * | ||||
| 	 * @return  string[] | ||||
| 	 */ | ||||
| 	public function getCellList() { | ||||
| 		if ($this->_currentObjectID !== null) { | ||||
| 			$this->_storeData(); | ||||
| 		} | ||||
| 
 | ||||
| 		return parent::getCellList(); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Delete a cell in cache identified by coordinate address | ||||
| 	 * | ||||
| 	 * @param	string			$pCoord		Coordinate address of the cell to delete | ||||
| 	 * @throws	PHPExcel_Exception | ||||
| 	 */ | ||||
| 	public function deleteCacheData($pCoord) { | ||||
| 		//	Delete the entry from Wincache
 | ||||
| 		wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache'); | ||||
| 
 | ||||
| 		//	Delete the entry from our cell address array
 | ||||
| 		parent::deleteCacheData($pCoord); | ||||
| 	}	//	function deleteCacheData()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clone the cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The new worksheet | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function copyCellCollection(PHPExcel_Worksheet $parent) { | ||||
| 		parent::copyCellCollection($parent); | ||||
| 		//	Get a new id for the new file name
 | ||||
| 		$baseUnique = $this->_getUniqueID(); | ||||
| 		$newCachePrefix = substr(md5($baseUnique),0,8).'.'; | ||||
| 		$cacheList = $this->getCellList(); | ||||
| 		foreach($cacheList as $cellID) { | ||||
| 			if ($cellID != $this->_currentObjectID) { | ||||
| 				$success = false; | ||||
| 				$obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success); | ||||
| 				if ($success === false) { | ||||
| 					//	Entry no longer exists in WinCache, so clear it from the cache array
 | ||||
| 					parent::deleteCacheData($cellID); | ||||
| 					throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache'); | ||||
| 				} | ||||
| 				if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) { | ||||
| 					$this->__destruct(); | ||||
| 					throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache'); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		$this->_cachePrefix = $newCachePrefix; | ||||
| 	}	//	function copyCellCollection()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the cell collection and disconnect from our parent | ||||
| 	 * | ||||
| 	 * @return	void | ||||
| 	 */ | ||||
| 	public function unsetWorksheetCells() { | ||||
| 		if(!is_null($this->_currentObject)) { | ||||
| 			$this->_currentObject->detach(); | ||||
| 			$this->_currentObject = $this->_currentObjectID = null; | ||||
| 		} | ||||
| 
 | ||||
| 		//	Flush the WinCache cache
 | ||||
| 		$this->__destruct(); | ||||
| 
 | ||||
| 		$this->_cellCache = array(); | ||||
| 
 | ||||
| 		//	detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
| 		$this->_parent = null; | ||||
| 	}	//	function unsetWorksheetCells()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Initialise this new cell collection | ||||
| 	 * | ||||
| 	 * @param	PHPExcel_Worksheet	$parent		The worksheet for this cell collection | ||||
| 	 * @param	array of mixed		$arguments	Additional initialisation arguments | ||||
| 	 */ | ||||
| 	public function __construct(PHPExcel_Worksheet $parent, $arguments) { | ||||
| 		$cacheTime	= (isset($arguments['cacheTime']))	? $arguments['cacheTime']	: 600; | ||||
| 
 | ||||
| 		if (is_null($this->_cachePrefix)) { | ||||
| 			$baseUnique = $this->_getUniqueID(); | ||||
| 			$this->_cachePrefix = substr(md5($baseUnique),0,8).'.'; | ||||
| 			$this->_cacheTime = $cacheTime; | ||||
| 
 | ||||
| 			parent::__construct($parent); | ||||
| 		} | ||||
| 	}	//	function __construct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Destroy this cell collection | ||||
| 	 */ | ||||
| 	public function __destruct() { | ||||
| 		$cacheList = $this->getCellList(); | ||||
| 		foreach($cacheList as $cellID) { | ||||
| 			wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache'); | ||||
| 		} | ||||
| 	}	//	function __destruct()
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Identify whether the caching method is currently available | ||||
| 	 * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
| 	 * | ||||
| 	 * @return	boolean | ||||
| 	 */ | ||||
| 	public static function cacheMethodIsAvailable() { | ||||
| 		if (!function_exists('wincache_ucache_add')) { | ||||
| 			return false; | ||||
| 		} | ||||
| 
 | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorage_Wincache | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_CachedObjectStorage | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache | ||||
| { | ||||
|     /** | ||||
|      * Prefix used to uniquely identify cache data for this worksheet | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private $_cachePrefix = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Cache timeout | ||||
|      * | ||||
|      * @var integer | ||||
|      */ | ||||
|     private $_cacheTime = 600; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Store cell data in cache for the current cell object if it's "dirty", | ||||
|      *     and the 'nullify' the current cell object | ||||
|      * | ||||
|      * @return    void | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     protected function _storeData() | ||||
|     { | ||||
|         if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { | ||||
|             $this->_currentObject->detach(); | ||||
| 
 | ||||
|             $obj = serialize($this->_currentObject); | ||||
|             if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) { | ||||
|                 if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { | ||||
|                     $this->__destruct(); | ||||
|                     throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); | ||||
|                 } | ||||
|             } else { | ||||
|                 if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) { | ||||
|                     $this->__destruct(); | ||||
|                     throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache'); | ||||
|                 } | ||||
|             } | ||||
|             $this->_currentCellIsDirty = false; | ||||
|         } | ||||
| 
 | ||||
|         $this->_currentObjectID = $this->_currentObject = null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Add or Update a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to update | ||||
|      * @param    PHPExcel_Cell    $cell        Cell to update | ||||
|      * @return    PHPExcel_Cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function addCacheData($pCoord, PHPExcel_Cell $cell) | ||||
|     { | ||||
|         if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
|         $this->_cellCache[$pCoord] = true; | ||||
| 
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = $cell; | ||||
|         $this->_currentCellIsDirty = true; | ||||
| 
 | ||||
|         return $cell; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? | ||||
|      * | ||||
|      * @param    string        $pCoord        Coordinate address of the cell to check | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public function isDataSet($pCoord) | ||||
|     { | ||||
|         //    Check if the requested entry is the current object, or exists in the cache
 | ||||
|         if (parent::isDataSet($pCoord)) { | ||||
|             if ($this->_currentObjectID == $pCoord) { | ||||
|                 return true; | ||||
|             } | ||||
|             //    Check if the requested entry still exists in cache
 | ||||
|             $success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache'); | ||||
|             if ($success === false) { | ||||
|                 //    Entry no longer exists in Wincache, so clear it from the cache array
 | ||||
|                 parent::deleteCacheData($pCoord); | ||||
|                 throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); | ||||
|             } | ||||
|             return true; | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get cell at a specific coordinate | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate of the cell | ||||
|      * @throws    PHPExcel_Exception | ||||
|      * @return    PHPExcel_Cell    Cell that was found, or null if not found | ||||
|      */ | ||||
|     public function getCacheData($pCoord) | ||||
|     { | ||||
|         if ($pCoord === $this->_currentObjectID) { | ||||
|             return $this->_currentObject; | ||||
|         } | ||||
|         $this->_storeData(); | ||||
| 
 | ||||
|         //    Check if the entry that has been requested actually exists
 | ||||
|         $obj = null; | ||||
|         if (parent::isDataSet($pCoord)) { | ||||
|             $success = false; | ||||
|             $obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success); | ||||
|             if ($success === false) { | ||||
|                 //    Entry no longer exists in WinCache, so clear it from the cache array
 | ||||
|                 parent::deleteCacheData($pCoord); | ||||
|                 throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache'); | ||||
|             } | ||||
|         } else { | ||||
|             //    Return null if requested entry doesn't exist in cache
 | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         //    Set current entry to the requested entry
 | ||||
|         $this->_currentObjectID = $pCoord; | ||||
|         $this->_currentObject = unserialize($obj); | ||||
|         //    Re-attach this as the cell's parent
 | ||||
|         $this->_currentObject->attach($this); | ||||
| 
 | ||||
|         //    Return requested entry
 | ||||
|         return $this->_currentObject; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Get a list of all cell addresses currently held in cache | ||||
|      * | ||||
|      * @return  string[] | ||||
|      */ | ||||
|     public function getCellList() | ||||
|     { | ||||
|         if ($this->_currentObjectID !== null) { | ||||
|             $this->_storeData(); | ||||
|         } | ||||
| 
 | ||||
|         return parent::getCellList(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Delete a cell in cache identified by coordinate address | ||||
|      * | ||||
|      * @param    string            $pCoord        Coordinate address of the cell to delete | ||||
|      * @throws    PHPExcel_Exception | ||||
|      */ | ||||
|     public function deleteCacheData($pCoord) | ||||
|     { | ||||
|         //    Delete the entry from Wincache
 | ||||
|         wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache'); | ||||
| 
 | ||||
|         //    Delete the entry from our cell address array
 | ||||
|         parent::deleteCacheData($pCoord); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clone the cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The new worksheet | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function copyCellCollection(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         parent::copyCellCollection($parent); | ||||
|         //    Get a new id for the new file name
 | ||||
|         $baseUnique = $this->_getUniqueID(); | ||||
|         $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.'; | ||||
|         $cacheList = $this->getCellList(); | ||||
|         foreach ($cacheList as $cellID) { | ||||
|             if ($cellID != $this->_currentObjectID) { | ||||
|                 $success = false; | ||||
|                 $obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success); | ||||
|                 if ($success === false) { | ||||
|                     //    Entry no longer exists in WinCache, so clear it from the cache array
 | ||||
|                     parent::deleteCacheData($cellID); | ||||
|                     throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache'); | ||||
|                 } | ||||
|                 if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) { | ||||
|                     $this->__destruct(); | ||||
|                     throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache'); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         $this->_cachePrefix = $newCachePrefix; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cell collection and disconnect from our parent | ||||
|      * | ||||
|      * @return    void | ||||
|      */ | ||||
|     public function unsetWorksheetCells() | ||||
|     { | ||||
|         if (!is_null($this->_currentObject)) { | ||||
|             $this->_currentObject->detach(); | ||||
|             $this->_currentObject = $this->_currentObjectID = null; | ||||
|         } | ||||
| 
 | ||||
|         //    Flush the WinCache cache
 | ||||
|         $this->__destruct(); | ||||
| 
 | ||||
|         $this->_cellCache = array(); | ||||
| 
 | ||||
|         //    detach ourself from the worksheet, so that it can then delete this object successfully
 | ||||
|         $this->_parent = null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise this new cell collection | ||||
|      * | ||||
|      * @param    PHPExcel_Worksheet    $parent        The worksheet for this cell collection | ||||
|      * @param    array of mixed        $arguments    Additional initialisation arguments | ||||
|      */ | ||||
|     public function __construct(PHPExcel_Worksheet $parent, $arguments) | ||||
|     { | ||||
|         $cacheTime    = (isset($arguments['cacheTime']))    ? $arguments['cacheTime']    : 600; | ||||
| 
 | ||||
|         if (is_null($this->_cachePrefix)) { | ||||
|             $baseUnique = $this->_getUniqueID(); | ||||
|             $this->_cachePrefix = substr(md5($baseUnique), 0, 8).'.'; | ||||
|             $this->_cacheTime = $cacheTime; | ||||
| 
 | ||||
|             parent::__construct($parent); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Destroy this cell collection | ||||
|      */ | ||||
|     public function __destruct() | ||||
|     { | ||||
|         $cacheList = $this->getCellList(); | ||||
|         foreach ($cacheList as $cellID) { | ||||
|             wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache'); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Identify whether the caching method is currently available | ||||
|      * Some methods are dependent on the availability of certain extensions being enabled in the PHP build | ||||
|      * | ||||
|      * @return    boolean | ||||
|      */ | ||||
|     public static function cacheMethodIsAvailable() | ||||
|     { | ||||
|         if (!function_exists('wincache_ucache_add')) { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * PHPExcel_CachedObjectStorageFactory | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
| @ -25,15 +25,6 @@ | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CachedObjectStorageFactory | ||||
|  * | ||||
|  * @category    PHPExcel | ||||
|  * @package        PHPExcel_CachedObjectStorage | ||||
|  * @copyright    Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CachedObjectStorageFactory | ||||
| { | ||||
|     const cache_in_memory               = 'Memory'; | ||||
| @ -48,21 +39,19 @@ class PHPExcel_CachedObjectStorageFactory | ||||
|     const cache_to_sqlite               = 'SQLite'; | ||||
|     const cache_to_sqlite3              = 'SQLite3'; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Name of the method used for cell cacheing | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private static $_cacheStorageMethod = NULL; | ||||
|     private static $_cacheStorageMethod = null; | ||||
| 
 | ||||
|     /** | ||||
|      * Name of the class used for cell cacheing | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private static $_cacheStorageClass = NULL; | ||||
| 
 | ||||
|     private static $_cacheStorageClass = null; | ||||
| 
 | ||||
|     /** | ||||
|      * List of all possible cache storage methods | ||||
| @ -83,7 +72,6 @@ class PHPExcel_CachedObjectStorageFactory | ||||
|         self::cache_to_sqlite3, | ||||
|     ); | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Default arguments for each cache storage method | ||||
|      * | ||||
| @ -100,7 +88,7 @@ class PHPExcel_CachedObjectStorageFactory | ||||
|                                                     ), | ||||
|         self::cache_to_phpTemp              => array( 'memoryCacheSize' => '1MB' | ||||
|                                                     ), | ||||
|         self::cache_to_discISAM             => array( 'dir'             => NULL | ||||
|         self::cache_to_discISAM             => array( 'dir'             => null | ||||
|                                                     ), | ||||
|         self::cache_to_apc                  => array( 'cacheTime'       => 600 | ||||
|                                                     ), | ||||
| @ -116,7 +104,6 @@ class PHPExcel_CachedObjectStorageFactory | ||||
|                                                     ), | ||||
|     ); | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Arguments for the active cache storage method | ||||
|      * | ||||
| @ -124,28 +111,25 @@ class PHPExcel_CachedObjectStorageFactory | ||||
|      */ | ||||
|     private static $_storageMethodParameters = array(); | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Return the current cache storage method | ||||
|      * | ||||
|      * @return string|NULL | ||||
|      * @return string|null | ||||
|      **/ | ||||
|     public static function getCacheStorageMethod() | ||||
|     { | ||||
|         return self::$_cacheStorageMethod; | ||||
|     }   //    function getCacheStorageMethod()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return the current cache storage class | ||||
|      * | ||||
|      * @return PHPExcel_CachedObjectStorage_ICache|NULL | ||||
|      * @return PHPExcel_CachedObjectStorage_ICache|null | ||||
|      **/ | ||||
|     public static function getCacheStorageClass() | ||||
|     { | ||||
|         return self::$_cacheStorageClass; | ||||
|     }   //    function getCacheStorageClass()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return the list of all possible cache storage methods | ||||
| @ -155,8 +139,7 @@ class PHPExcel_CachedObjectStorageFactory | ||||
|     public static function getAllCacheStorageMethods() | ||||
|     { | ||||
|         return self::$_storageMethods; | ||||
|     }   //    function getCacheStorageMethods()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return the list of all available cache storage methods | ||||
| @ -166,15 +149,14 @@ class PHPExcel_CachedObjectStorageFactory | ||||
|     public static function getCacheStorageMethods() | ||||
|     { | ||||
|         $activeMethods = array(); | ||||
|         foreach(self::$_storageMethods as $storageMethod) { | ||||
|         foreach (self::$_storageMethods as $storageMethod) { | ||||
|             $cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod; | ||||
|             if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) { | ||||
|                 $activeMethods[] = $storageMethod; | ||||
|             } | ||||
|         } | ||||
|         return $activeMethods; | ||||
|     }   //    function getCacheStorageMethods()
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Identify the cache storage method to use | ||||
| @ -186,30 +168,29 @@ class PHPExcel_CachedObjectStorageFactory | ||||
|      **/ | ||||
|     public static function initialize($method = self::cache_in_memory, $arguments = array()) | ||||
|     { | ||||
|         if (!in_array($method,self::$_storageMethods)) { | ||||
|             return FALSE; | ||||
|         if (!in_array($method, self::$_storageMethods)) { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         $cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method; | ||||
|         if (!call_user_func(array( $cacheStorageClass, | ||||
|                                    'cacheMethodIsAvailable'))) { | ||||
|             return FALSE; | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method]; | ||||
|         foreach($arguments as $k => $v) { | ||||
|         foreach ($arguments as $k => $v) { | ||||
|             if (array_key_exists($k, self::$_storageMethodParameters[$method])) { | ||||
|                 self::$_storageMethodParameters[$method][$k] = $v; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (self::$_cacheStorageMethod === NULL) { | ||||
|         if (self::$_cacheStorageMethod === null) { | ||||
|             self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method; | ||||
|             self::$_cacheStorageMethod = $method; | ||||
|         } | ||||
|         return TRUE; | ||||
|     }   //    function initialize()
 | ||||
| 
 | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Initialise the cache storage | ||||
| @ -219,33 +200,32 @@ class PHPExcel_CachedObjectStorageFactory | ||||
|      **/ | ||||
|     public static function getInstance(PHPExcel_Worksheet $parent) | ||||
|     { | ||||
|         $cacheMethodIsAvailable = TRUE; | ||||
|         if (self::$_cacheStorageMethod === NULL) { | ||||
|         $cacheMethodIsAvailable = true; | ||||
|         if (self::$_cacheStorageMethod === null) { | ||||
|             $cacheMethodIsAvailable = self::initialize(); | ||||
|         } | ||||
| 
 | ||||
|         if ($cacheMethodIsAvailable) { | ||||
|             $instance = new self::$_cacheStorageClass( $parent, | ||||
|                                                        self::$_storageMethodParameters[self::$_cacheStorageMethod] | ||||
|                                                      ); | ||||
|             if ($instance !== NULL) { | ||||
|             $instance = new self::$_cacheStorageClass( | ||||
|                 $parent, | ||||
|                 self::$_storageMethodParameters[self::$_cacheStorageMethod] | ||||
|             ); | ||||
|             if ($instance !== null) { | ||||
|                 return $instance; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return FALSE; | ||||
|     }   //    function getInstance()
 | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clear the cache storage | ||||
|      * | ||||
|      **/ | ||||
| 	public static function finalize() | ||||
| 	{ | ||||
| 		self::$_cacheStorageMethod = NULL; | ||||
| 		self::$_cacheStorageClass = NULL; | ||||
| 		self::$_storageMethodParameters = array(); | ||||
| 	} | ||||
| 
 | ||||
|     public static function finalize() | ||||
|     { | ||||
|         self::$_cacheStorageMethod = null; | ||||
|         self::$_cacheStorageClass = null; | ||||
|         self::$_storageMethodParameters = array(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * PHPExcel_CalcEngine_CyclicReferenceStack | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
| @ -21,78 +22,73 @@ | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Calculation | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license	http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version	##VERSION##, ##DATE##
 | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CalcEngine_CyclicReferenceStack | ||||
| { | ||||
|     /** | ||||
|      *  The call stack for calculated cells | ||||
|      * | ||||
|      *  @var mixed[] | ||||
|      */ | ||||
|     private $_stack = array(); | ||||
| 
 | ||||
|     /** | ||||
|      * Return the number of entries on the stack | ||||
|      * | ||||
|      * @return  integer | ||||
|      */ | ||||
|     public function count() | ||||
|     { | ||||
|         return count($this->_stack); | ||||
|     } | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CalcEngine_CyclicReferenceStack | ||||
|  * | ||||
|  * @category	PHPExcel_CalcEngine_CyclicReferenceStack | ||||
|  * @package		PHPExcel_Calculation | ||||
|  * @copyright	Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CalcEngine_CyclicReferenceStack { | ||||
|     /** | ||||
|      * Push a new entry onto the stack | ||||
|      * | ||||
|      * @param  mixed  $value | ||||
|      */ | ||||
|     public function push($value) | ||||
|     { | ||||
|         $this->_stack[$value] = $value; | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 *  The call stack for calculated cells | ||||
| 	 * | ||||
| 	 *  @var mixed[] | ||||
| 	 */ | ||||
| 	private $_stack = array(); | ||||
|     /** | ||||
|      * Pop the last entry from the stack | ||||
|      * | ||||
|      * @return  mixed | ||||
|      */ | ||||
|     public function pop() | ||||
|     { | ||||
|         return array_pop($this->_stack); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Test to see if a specified entry exists on the stack | ||||
|      * | ||||
|      * @param  mixed  $value  The value to test | ||||
|      */ | ||||
|     public function onStack($value) | ||||
|     { | ||||
|         return isset($this->_stack[$value]); | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return the number of entries on the stack | ||||
| 	 * | ||||
| 	 * @return  integer | ||||
| 	 */ | ||||
| 	public function count() { | ||||
| 		return count($this->_stack); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Push a new entry onto the stack | ||||
| 	 * | ||||
| 	 * @param  mixed  $value | ||||
| 	 */ | ||||
| 	public function push($value) { | ||||
| 		$this->_stack[$value] = $value; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Pop the last entry from the stack | ||||
| 	 * | ||||
| 	 * @return  mixed | ||||
| 	 */ | ||||
| 	public function pop() { | ||||
| 		return array_pop($this->_stack); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Test to see if a specified entry exists on the stack | ||||
| 	 * | ||||
| 	 * @param  mixed  $value  The value to test | ||||
| 	 */ | ||||
| 	public function onStack($value) { | ||||
| 		return isset($this->_stack[$value]); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the stack | ||||
| 	 */ | ||||
| 	public function clear() { | ||||
| 		$this->_stack = array(); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return an array of all entries on the stack | ||||
| 	 * | ||||
| 	 * @return  mixed[] | ||||
| 	 */ | ||||
| 	public function showStack() { | ||||
| 		return $this->_stack; | ||||
| 	} | ||||
|     /** | ||||
|      * Clear the stack | ||||
|      */ | ||||
|     public function clear() | ||||
|     { | ||||
|         $this->_stack = array(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return an array of all entries on the stack | ||||
|      * | ||||
|      * @return  mixed[] | ||||
|      */ | ||||
|     public function showStack() | ||||
|     { | ||||
|         return $this->_stack; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * PHPExcel_CalcEngine_Logger | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
| @ -21,133 +22,130 @@ | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Calculation | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license	http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version	##VERSION##, ##DATE##
 | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_CalcEngine_Logger | ||||
| { | ||||
|     /** | ||||
|      * Flag to determine whether a debug log should be generated by the calculation engine | ||||
|      *        If true, then a debug log will be generated | ||||
|      *        If false, then a debug log will not be generated | ||||
|      * | ||||
|      * @var boolean | ||||
|      */ | ||||
|     private $_writeDebugLog = false; | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_CalcEngine_Logger | ||||
|  * | ||||
|  * @category	PHPExcel | ||||
|  * @package		PHPExcel_Calculation | ||||
|  * @copyright	Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_CalcEngine_Logger { | ||||
|     /** | ||||
|      * Flag to determine whether a debug log should be echoed by the calculation engine | ||||
|      *        If true, then a debug log will be echoed | ||||
|      *        If false, then a debug log will not be echoed | ||||
|      * A debug log can only be echoed if it is generated | ||||
|      * | ||||
|      * @var boolean | ||||
|      */ | ||||
|     private $_echoDebugLog = false; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Flag to determine whether a debug log should be generated by the calculation engine | ||||
| 	 *		If true, then a debug log will be generated | ||||
| 	 *		If false, then a debug log will not be generated | ||||
| 	 * | ||||
| 	 * @var boolean | ||||
| 	 */ | ||||
| 	private $_writeDebugLog = FALSE; | ||||
|     /** | ||||
|      * The debug log generated by the calculation engine | ||||
|      * | ||||
|      * @var string[] | ||||
|      */ | ||||
|     private $_debugLog = array(); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Flag to determine whether a debug log should be echoed by the calculation engine | ||||
| 	 *		If true, then a debug log will be echoed | ||||
| 	 *		If false, then a debug log will not be echoed | ||||
| 	 * A debug log can only be echoed if it is generated | ||||
| 	 * | ||||
| 	 * @var boolean | ||||
| 	 */ | ||||
| 	private $_echoDebugLog = FALSE; | ||||
|     /** | ||||
|      * The calculation engine cell reference stack | ||||
|      * | ||||
|      * @var PHPExcel_CalcEngine_CyclicReferenceStack | ||||
|      */ | ||||
|     private $_cellStack; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * The debug log generated by the calculation engine | ||||
| 	 * | ||||
| 	 * @var string[] | ||||
| 	 */ | ||||
| 	private $_debugLog = array(); | ||||
|     /** | ||||
|      * Instantiate a Calculation engine logger | ||||
|      * | ||||
|      * @param  PHPExcel_CalcEngine_CyclicReferenceStack $stack | ||||
|      */ | ||||
|     public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack) | ||||
|     { | ||||
|         $this->_cellStack = $stack; | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * The calculation engine cell reference stack | ||||
| 	 * | ||||
| 	 * @var PHPExcel_CalcEngine_CyclicReferenceStack | ||||
| 	 */ | ||||
| 	private $_cellStack; | ||||
|     /** | ||||
|      * Enable/Disable Calculation engine logging | ||||
|      * | ||||
|      * @param  boolean $pValue | ||||
|      */ | ||||
|     public function setWriteDebugLog($pValue = false) | ||||
|     { | ||||
|         $this->_writeDebugLog = $pValue; | ||||
|     } | ||||
| 
 | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Instantiate a Calculation engine logger | ||||
| 	 * | ||||
| 	 * @param  PHPExcel_CalcEngine_CyclicReferenceStack $stack | ||||
| 	 */ | ||||
| 	public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack) { | ||||
| 		$this->_cellStack = $stack; | ||||
| 	} | ||||
|     /** | ||||
|      * Return whether calculation engine logging is enabled or disabled | ||||
|      * | ||||
|      * @return  boolean | ||||
|      */ | ||||
|     public function getWriteDebugLog() | ||||
|     { | ||||
|         return $this->_writeDebugLog; | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Enable/Disable Calculation engine logging | ||||
| 	 * | ||||
| 	 * @param  boolean $pValue | ||||
| 	 */ | ||||
| 	public function setWriteDebugLog($pValue = FALSE) { | ||||
| 		$this->_writeDebugLog = $pValue; | ||||
| 	} | ||||
|     /** | ||||
|      * Enable/Disable echoing of debug log information | ||||
|      * | ||||
|      * @param  boolean $pValue | ||||
|      */ | ||||
|     public function setEchoDebugLog($pValue = false) | ||||
|     { | ||||
|         $this->_echoDebugLog = $pValue; | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return whether calculation engine logging is enabled or disabled | ||||
| 	 * | ||||
| 	 * @return  boolean | ||||
| 	 */ | ||||
| 	public function getWriteDebugLog() { | ||||
| 		return $this->_writeDebugLog; | ||||
| 	} | ||||
|     /** | ||||
|      * Return whether echoing of debug log information is enabled or disabled | ||||
|      * | ||||
|      * @return  boolean | ||||
|      */ | ||||
|     public function getEchoDebugLog() | ||||
|     { | ||||
|         return $this->_echoDebugLog; | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Enable/Disable echoing of debug log information | ||||
| 	 * | ||||
| 	 * @param  boolean $pValue | ||||
| 	 */ | ||||
| 	public function setEchoDebugLog($pValue = FALSE) { | ||||
| 		$this->_echoDebugLog = $pValue; | ||||
| 	} | ||||
|     /** | ||||
|      * Write an entry to the calculation engine debug log | ||||
|      */ | ||||
|     public function writeDebugLog() | ||||
|     { | ||||
|         //    Only write the debug log if logging is enabled
 | ||||
|         if ($this->_writeDebugLog) { | ||||
|             $message = implode(func_get_args()); | ||||
|             $cellReference = implode(' -> ', $this->_cellStack->showStack()); | ||||
|             if ($this->_echoDebugLog) { | ||||
|                 echo $cellReference, | ||||
|                     ($this->_cellStack->count() > 0 ? ' => ' : ''), | ||||
|                     $message, | ||||
|                     PHP_EOL; | ||||
|             } | ||||
|             $this->_debugLog[] = $cellReference . | ||||
|                 ($this->_cellStack->count() > 0 ? ' => ' : '') . | ||||
|                 $message; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return whether echoing of debug log information is enabled or disabled | ||||
| 	 * | ||||
| 	 * @return  boolean | ||||
| 	 */ | ||||
| 	public function getEchoDebugLog() { | ||||
| 		return $this->_echoDebugLog; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Write an entry to the calculation engine debug log | ||||
| 	 */ | ||||
| 	public function writeDebugLog() { | ||||
| 		//	Only write the debug log if logging is enabled
 | ||||
| 		if ($this->_writeDebugLog) { | ||||
| 			$message = implode(func_get_args()); | ||||
| 			$cellReference = implode(' -> ', $this->_cellStack->showStack()); | ||||
| 			if ($this->_echoDebugLog) { | ||||
| 				echo $cellReference,  | ||||
| 					($this->_cellStack->count() > 0 ? ' => ' : ''),  | ||||
| 					$message,  | ||||
| 					PHP_EOL; | ||||
| 			} | ||||
| 			$this->_debugLog[] = $cellReference .  | ||||
| 				($this->_cellStack->count() > 0 ? ' => ' : '') .  | ||||
| 				$message; | ||||
| 		} | ||||
| 	}	//	function _writeDebug()
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the calculation engine debug log | ||||
| 	 */ | ||||
| 	public function clearLog() { | ||||
| 		$this->_debugLog = array(); | ||||
| 	}	//	function flushLogger()
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return the calculation engine debug log | ||||
| 	 * | ||||
| 	 * @return  string[] | ||||
| 	 */ | ||||
| 	public function getLog() { | ||||
| 		return $this->_debugLog; | ||||
| 	}	//	function flushLogger()
 | ||||
| 
 | ||||
| }	//	class PHPExcel_CalcEngine_Logger
 | ||||
|     /** | ||||
|      * Clear the calculation engine debug log | ||||
|      */ | ||||
|     public function clearLog() | ||||
|     { | ||||
|         $this->_debugLog = array(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return the calculation engine debug log | ||||
|      * | ||||
|      * @return  string[] | ||||
|      */ | ||||
|     public function getLog() | ||||
|     { | ||||
|         return $this->_debugLog; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * PHPExcel_Calculation_Token_Stack | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2015 PHPExcel | ||||
|  * | ||||
| @ -21,95 +21,90 @@ | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Calculation | ||||
|  * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license	http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version	##VERSION##, ##DATE##
 | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL | ||||
|  * @version    ##VERSION##, ##DATE##
 | ||||
|  */ | ||||
| class PHPExcel_Calculation_Token_Stack | ||||
| { | ||||
|     /** | ||||
|      *  The parser stack for formulae | ||||
|      * | ||||
|      *  @var mixed[] | ||||
|      */ | ||||
|     private $_stack = array(); | ||||
| 
 | ||||
|     /** | ||||
|      *  Count of entries in the parser stack | ||||
|      * | ||||
|      *  @var integer | ||||
|      */ | ||||
|     private $_count = 0; | ||||
| 
 | ||||
| /** | ||||
|  * PHPExcel_Calculation_Token_Stack | ||||
|  * | ||||
|  * @category	PHPExcel_Calculation_Token_Stack | ||||
|  * @package		PHPExcel_Calculation | ||||
|  * @copyright	Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Calculation_Token_Stack { | ||||
|     /** | ||||
|      * Return the number of entries on the stack | ||||
|      * | ||||
|      * @return  integer | ||||
|      */ | ||||
|     public function count() | ||||
|     { | ||||
|         return $this->_count; | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 *  The parser stack for formulae | ||||
| 	 * | ||||
| 	 *  @var mixed[] | ||||
| 	 */ | ||||
| 	private $_stack = array(); | ||||
|     /** | ||||
|      * Push a new entry onto the stack | ||||
|      * | ||||
|      * @param  mixed  $type | ||||
|      * @param  mixed  $value | ||||
|      * @param  mixed  $reference | ||||
|      */ | ||||
|     public function push($type, $value, $reference = null) | ||||
|     { | ||||
|         $this->_stack[$this->_count++] = array( | ||||
|             'type'        => $type, | ||||
|             'value'        => $value, | ||||
|             'reference'    => $reference | ||||
|         ); | ||||
|         if ($type == 'Function') { | ||||
|             $localeFunction = PHPExcel_Calculation::_localeFunc($value); | ||||
|             if ($localeFunction != $value) { | ||||
|                 $this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 *  Count of entries in the parser stack | ||||
| 	 * | ||||
| 	 *  @var integer | ||||
| 	 */ | ||||
| 	private $_count = 0; | ||||
|     /** | ||||
|      * Pop the last entry from the stack | ||||
|      * | ||||
|      * @return  mixed | ||||
|      */ | ||||
|     public function pop() | ||||
|     { | ||||
|         if ($this->_count > 0) { | ||||
|             return $this->_stack[--$this->_count]; | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Return an entry from the stack without removing it | ||||
|      * | ||||
|      * @param   integer  $n  number indicating how far back in the stack we want to look | ||||
|      * @return  mixed | ||||
|      */ | ||||
|     public function last($n = 1) | ||||
|     { | ||||
|         if ($this->_count - $n < 0) { | ||||
|             return null; | ||||
|         } | ||||
|         return $this->_stack[$this->_count - $n]; | ||||
|     } | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return the number of entries on the stack | ||||
| 	 * | ||||
| 	 * @return  integer | ||||
| 	 */ | ||||
| 	public function count() { | ||||
| 		return $this->_count; | ||||
| 	}	//	function count()
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Push a new entry onto the stack | ||||
| 	 * | ||||
| 	 * @param  mixed  $type | ||||
| 	 * @param  mixed  $value | ||||
| 	 * @param  mixed  $reference | ||||
| 	 */ | ||||
| 	public function push($type, $value, $reference = NULL) { | ||||
| 		$this->_stack[$this->_count++] = array('type'		=> $type, | ||||
| 											   'value'		=> $value, | ||||
| 											   'reference'	=> $reference | ||||
| 											  ); | ||||
| 		if ($type == 'Function') { | ||||
| 			$localeFunction = PHPExcel_Calculation::_localeFunc($value); | ||||
| 			if ($localeFunction != $value) { | ||||
| 				$this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction; | ||||
| 			} | ||||
| 		} | ||||
| 	}	//	function push()
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Pop the last entry from the stack | ||||
| 	 * | ||||
| 	 * @return  mixed | ||||
| 	 */ | ||||
| 	public function pop() { | ||||
| 		if ($this->_count > 0) { | ||||
| 			return $this->_stack[--$this->_count]; | ||||
| 		} | ||||
| 		return NULL; | ||||
| 	}	//	function pop()
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Return an entry from the stack without removing it | ||||
| 	 * | ||||
| 	 * @param   integer  $n  number indicating how far back in the stack we want to look | ||||
| 	 * @return  mixed | ||||
| 	 */ | ||||
| 	public function last($n = 1) { | ||||
| 		if ($this->_count - $n < 0) { | ||||
| 			return NULL; | ||||
| 		} | ||||
| 		return $this->_stack[$this->_count - $n]; | ||||
| 	}	//	function last()
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Clear the stack | ||||
| 	 */ | ||||
| 	function clear() { | ||||
| 		$this->_stack = array(); | ||||
| 		$this->_count = 0; | ||||
| 	} | ||||
| 
 | ||||
| }	//	class PHPExcel_Calculation_Token_Stack
 | ||||
|     /** | ||||
|      * Clear the stack | ||||
|      */ | ||||
|     function clear() | ||||
|     { | ||||
|         $this->_stack = array(); | ||||
|         $this->_count = 0; | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 MarkBaker
						MarkBaker