Doc Block changes

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@88175 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2012-03-21 23:55:54 +00:00
parent ffdb1966b1
commit 3d7153c7f4
16 changed files with 418 additions and 41 deletions

View File

@ -34,8 +34,19 @@ if (ini_get('mbstring.func_overload') & 2) {
PHPExcel_Shared_String::buildCharacterSets(); PHPExcel_Shared_String::buildCharacterSets();
/**
* PHPExcel_Autoloader
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Autoloader class PHPExcel_Autoloader
{ {
/**
* Register the Autoloader with SPL
*
*/
public static function Register() { public static function Register() {
if (function_exists('__autoload')) { 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
@ -46,14 +57,19 @@ class PHPExcel_Autoloader
} // function Register() } // function Register()
public static function Load($pObjectName){ /**
if ((class_exists($pObjectName)) || (strpos($pObjectName, 'PHPExcel') !== 0)) { * Autoload a class identified by name
*
* @param string $pClassName Name of the object to load
*/
public static function Load($pClassName){
if ((class_exists($pClassName)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
// Either already loaded, or not a PHPExcel class request // Either already loaded, or not a PHPExcel class request
return FALSE; return FALSE;
} }
$pObjectFilePath = PHPEXCEL_ROOT . $pObjectFilePath = PHPEXCEL_ROOT .
str_replace('_',DIRECTORY_SEPARATOR,$pObjectName) . str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
'.php'; '.php';
if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) { if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) {

View File

@ -35,11 +35,28 @@
*/ */
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
*
* @var string
*/
private $_cachePrefix = null; private $_cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $_cacheTime = 600; 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -157,6 +174,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(PHPExcel_Worksheet $parent) {
@ -183,6 +201,11 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
} // function copyCellCollection() } // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if ($this->_currentObject !== NULL) { if ($this->_currentObject !== NULL) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -199,6 +222,12 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
} // function unsetWorksheetCells() } // 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) { public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
@ -212,6 +241,9 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
} // function __construct() } // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() { public function __destruct() {
$cacheList = $this->getCellList(); $cacheList = $this->getCellList();
foreach($cacheList as $cellID) { foreach($cacheList as $cellID) {

View File

@ -73,6 +73,11 @@ class PHPExcel_CachedObjectStorage_CacheBase {
protected $_cellCache = array(); protected $_cellCache = array();
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent) { public function __construct(PHPExcel_Worksheet $parent) {
// Set our parent worksheet. // Set our parent worksheet.
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
@ -205,6 +210,11 @@ class PHPExcel_CachedObjectStorage_CacheBase {
} }
/**
* Generate a unique ID for cache referencing
*
* @return string Unique Reference
*/
protected function _getUniqueID() { protected function _getUniqueID() {
if (function_exists('posix_getpid')) { if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid(); $baseUnique = posix_getpid();
@ -217,6 +227,7 @@ class PHPExcel_CachedObjectStorage_CacheBase {
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(PHPExcel_Worksheet $parent) {

View File

@ -35,12 +35,35 @@
*/ */
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Name of the file for this cache
*
* @var string
*/
private $_fileName = null; private $_fileName = null;
/**
* File handle for this cache file
*
* @var resource
*/
private $_fileHandle = null; private $_fileHandle = null;
/**
* Directory/Folder where the cache file is located
*
* @var string
*/
private $_cacheDirectory = NULL; 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -112,6 +135,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(PHPExcel_Worksheet $parent) {
@ -127,6 +151,11 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
} // function copyCellCollection() } // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) { if(!is_null($this->_currentObject)) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -142,6 +171,12 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
} // function unsetWorksheetCells() } // 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) { public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL)) $this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
? $arguments['dir'] ? $arguments['dir']
@ -156,6 +191,9 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
} // function __construct() } // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() { public function __destruct() {
if (!is_null($this->_fileHandle)) { if (!is_null($this->_fileHandle)) {
fclose($this->_fileHandle); fclose($this->_fileHandle);

View File

@ -75,7 +75,6 @@ interface PHPExcel_CachedObjectStorage_ICache
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed 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 * @param string $pCoord Coordinate address of the cell to check
* @return void
* @return boolean * @return boolean
*/ */
public function isDataSet($pCoord); public function isDataSet($pCoord);
@ -97,6 +96,7 @@ interface PHPExcel_CachedObjectStorage_ICache
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent); public function copyCellCollection(PHPExcel_Worksheet $parent);

View File

@ -35,6 +35,13 @@
*/ */
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -97,6 +104,11 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
} // function getCacheData() } // function getCacheData()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) { if(!is_null($this->_currentObject)) {
$this->_currentObject->detach(); $this->_currentObject->detach();

View File

@ -35,13 +35,35 @@
*/ */
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { 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; private $_cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $_cacheTime = 600; private $_cacheTime = 600;
/**
* Memcache interface
*
* @var resource
*/
private $_memcache = null; 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -162,6 +184,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(PHPExcel_Worksheet $parent) {
@ -188,6 +211,11 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
} // function copyCellCollection() } // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) { if(!is_null($this->_currentObject)) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -204,6 +232,12 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
} // function unsetWorksheetCells() } // 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) { public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost'; $memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211; $memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
@ -225,11 +259,21 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
} // function __construct() } // function __construct()
/**
* Memcache error handler
*
* @param string $host Memcache server
* @param integer $port Memcache port
* @throws Exception
*/
public function failureCallback($host, $port) { public function failureCallback($host, $port) {
throw new Exception('memcache '.$host.':'.$port.' failed'); throw new Exception('memcache '.$host.':'.$port.' failed');
} }
/**
* Destroy this cell collection
*/
public function __destruct() { public function __destruct() {
$cacheList = $this->getCellList(); $cacheList = $this->getCellList();
foreach($cacheList as $cellID) { foreach($cacheList as $cellID) {

View File

@ -68,6 +68,12 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
} // function getCacheData() } // function getCacheData()
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent); parent::copyCellCollection($parent);
@ -81,6 +87,11 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
} }
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent // 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) { foreach($this->_cellCache as $k => &$cell) {

View File

@ -35,6 +35,13 @@
*/ */
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -97,6 +104,11 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
} // function getCacheData() } // function getCacheData()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) { if(!is_null($this->_currentObject)) {
$this->_currentObject->detach(); $this->_currentObject->detach();

View File

@ -35,6 +35,13 @@
*/ */
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -97,6 +104,11 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
} // function getCacheData() } // function getCacheData()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) { if(!is_null($this->_currentObject)) {
$this->_currentObject->detach(); $this->_currentObject->detach();

View File

@ -35,11 +35,27 @@
*/ */
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Name of the file for this cache
*
* @var string
*/
private $_fileHandle = null; private $_fileHandle = null;
/**
* Memory limit to use before reverting to file cache
*
* @var integer
*/
private $_memoryCacheSize = null; 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -111,6 +127,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(PHPExcel_Worksheet $parent) {
@ -126,6 +143,11 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
} // function copyCellCollection() } // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) { if(!is_null($this->_currentObject)) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -141,6 +163,12 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
} // function unsetWorksheetCells() } // 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) { public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB'; $this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
@ -151,6 +179,9 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
} // function __construct() } // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() { public function __destruct() {
if (!is_null($this->_fileHandle)) { if (!is_null($this->_fileHandle)) {
fclose($this->_fileHandle); fclose($this->_fileHandle);

View File

@ -2,7 +2,7 @@
/** /**
* PHPExcel * PHPExcel
* *
* Copyright (c) 2006 - 2010 PHPExcel * Copyright (c) 2006 - 2012 PHPExcel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,7 @@
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 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## * @version ##VERSION##, ##DATE##
*/ */
@ -31,13 +31,31 @@
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Database table name
*
* @var string
*/
private $_TableName = null; private $_TableName = null;
/**
* Database handle
*
* @var resource
*/
private $_DBHandle = null; 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -174,6 +192,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(PHPExcel_Worksheet $parent) {
@ -188,6 +207,11 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
} // function copyCellCollection() } // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) { if(!is_null($this->_currentObject)) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -201,6 +225,11 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
} // function unsetWorksheetCells() } // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent) { public function __construct(PHPExcel_Worksheet $parent) {
parent::__construct($parent); parent::__construct($parent);
if (is_null($this->_DBHandle)) { if (is_null($this->_DBHandle)) {
@ -216,6 +245,9 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
} // function __construct() } // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() { public function __destruct() {
$this->_DBHandle = null; $this->_DBHandle = null;
} // function __destruct() } // function __destruct()

View File

@ -2,7 +2,7 @@
/** /**
* PHPExcel * PHPExcel
* *
* Copyright (c) 2006 - 2010 PHPExcel * Copyright (c) 2006 - 2012 PHPExcel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,7 +20,7 @@
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 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## * @version ##VERSION##, ##DATE##
*/ */
@ -31,13 +31,31 @@
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Database table name
*
* @var string
*/
private $_TableName = null; private $_TableName = null;
/**
* Database handle
*
* @var resource
*/
private $_DBHandle = null; 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -178,6 +196,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(PHPExcel_Worksheet $parent) {
@ -192,6 +211,11 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
} // function copyCellCollection() } // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) { if(!is_null($this->_currentObject)) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -205,6 +229,11 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
} // function unsetWorksheetCells() } // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent) { public function __construct(PHPExcel_Worksheet $parent) {
parent::__construct($parent); parent::__construct($parent);
if (is_null($this->_DBHandle)) { if (is_null($this->_DBHandle)) {
@ -220,6 +249,9 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
} // function __construct() } // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() { public function __destruct() {
if (!is_null($this->_DBHandle)) { if (!is_null($this->_DBHandle)) {
$this->_DBHandle->close(); $this->_DBHandle->close();

View File

@ -35,11 +35,28 @@
*/ */
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { 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; private $_cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $_cacheTime = 600; 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 Exception
*/
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -89,7 +106,6 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed 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 * @param string $pCoord Coordinate address of the cell to check
* @return void
* @return boolean * @return boolean
*/ */
public function isDataSet($pCoord) { public function isDataSet($pCoord) {
@ -168,6 +184,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @return void
*/ */
public function copyCellCollection(PHPExcel_Worksheet $parent) { public function copyCellCollection(PHPExcel_Worksheet $parent) {
@ -195,6 +212,11 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
} // function copyCellCollection() } // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() { public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) { if(!is_null($this->_currentObject)) {
$this->_currentObject->detach(); $this->_currentObject->detach();
@ -211,6 +233,12 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
} // function unsetWorksheetCells() } // 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) { public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
@ -224,6 +252,9 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
} // function __construct() } // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() { public function __destruct() {
$cacheList = $this->getCellList(); $cacheList = $this->getCellList();
foreach($cacheList as $cellID) { foreach($cacheList as $cellID) {

View File

@ -28,7 +28,7 @@
/** /**
* PHPExcel_IOFactory * PHPExcel_CachedObjectStorageFactory
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel_CachedObjectStorage
@ -49,11 +49,26 @@ class PHPExcel_CachedObjectStorageFactory
const cache_to_sqlite3 = 'SQLite3'; 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
*
* @var string[]
*/
private static $_storageMethods = array( private static $_storageMethods = array(
self::cache_in_memory, self::cache_in_memory,
self::cache_in_memory_gzip, self::cache_in_memory_gzip,
@ -69,6 +84,11 @@ class PHPExcel_CachedObjectStorageFactory
); );
/**
* Default arguments for each cache storage method
*
* @var array of mixed array
*/
private static $_storageMethodDefaultParameters = array( private static $_storageMethodDefaultParameters = array(
self::cache_in_memory => array( self::cache_in_memory => array(
), ),
@ -97,9 +117,19 @@ class PHPExcel_CachedObjectStorageFactory
); );
/**
* Arguments for the active cache storage method
*
* @var array of mixed array
*/
private static $_storageMethodParameters = array(); private static $_storageMethodParameters = array();
/**
* Return the current cache storage method
*
* @return string|NULL
**/
public static function getCacheStorageMethod() public static function getCacheStorageMethod()
{ {
if (self::$_cacheStorageMethod !== NULL) { if (self::$_cacheStorageMethod !== NULL) {
@ -109,6 +139,11 @@ class PHPExcel_CachedObjectStorageFactory
} // function getCacheStorageMethod() } // function getCacheStorageMethod()
/**
* Return the current cache storage class
*
* @return PHPExcel_CachedObjectStorage_ICache|NULL
**/
public static function getCacheStorageClass() public static function getCacheStorageClass()
{ {
if (self::$_cacheStorageClass !== NULL) { if (self::$_cacheStorageClass !== NULL) {
@ -118,12 +153,22 @@ class PHPExcel_CachedObjectStorageFactory
} // function getCacheStorageClass() } // function getCacheStorageClass()
/**
* Return the list of all possible cache storage methods
*
* @return string[]
**/
public static function getAllCacheStorageMethods() public static function getAllCacheStorageMethods()
{ {
return self::$_storageMethods; return self::$_storageMethods;
} // function getCacheStorageMethods() } // function getCacheStorageMethods()
/**
* Return the list of all available cache storage methods
*
* @return string[]
**/
public static function getCacheStorageMethods() public static function getCacheStorageMethods()
{ {
$activeMethods = array(); $activeMethods = array();
@ -137,6 +182,14 @@ class PHPExcel_CachedObjectStorageFactory
} // function getCacheStorageMethods() } // function getCacheStorageMethods()
/**
* Identify the cache storage method to use
*
* @param string $method Name of the method to use for cell cacheing
* @param array of mixed $arguments Additional arguments to pass to the cell caching class
* when instantiating
* @return boolean
**/
public static function initialize($method = self::cache_in_memory, $arguments = array()) public static function initialize($method = self::cache_in_memory, $arguments = array())
{ {
if (!in_array($method,self::$_storageMethods)) { if (!in_array($method,self::$_storageMethods)) {
@ -144,7 +197,8 @@ class PHPExcel_CachedObjectStorageFactory
} }
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method; $cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
if (!call_user_func(array($cacheStorageClass,'cacheMethodIsAvailable'))) { if (!call_user_func(array( $cacheStorageClass,
'cacheMethodIsAvailable'))) {
return FALSE; return FALSE;
} }
@ -163,6 +217,12 @@ class PHPExcel_CachedObjectStorageFactory
} // function initialize() } // function initialize()
/**
* Initialise the cache storage
*
* @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet
* @return PHPExcel_CachedObjectStorage_ICache
**/
public static function getInstance(PHPExcel_Worksheet $parent) public static function getInstance(PHPExcel_Worksheet $parent)
{ {
$cacheMethodIsAvailable = TRUE; $cacheMethodIsAvailable = TRUE;
@ -171,7 +231,9 @@ class PHPExcel_CachedObjectStorageFactory
} }
if ($cacheMethodIsAvailable) { if ($cacheMethodIsAvailable) {
$instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]); $instance = new self::$_cacheStorageClass( $parent,
self::$_storageMethodParameters[self::$_cacheStorageMethod]
);
if ($instance !== NULL) { if ($instance !== NULL) {
return $instance; return $instance;
} }

View File

@ -101,6 +101,7 @@ class PHPExcel_Cell
/** /**
* Send notification to the cache controller * Send notification to the cache controller
*
* @return void * @return void
**/ **/
public function notifyCacheController() { public function notifyCacheController() {