MDL-44515 import latest PHPExcel 1.8.0

This commit is contained in:
Petr Škoda
2014-03-14 12:10:52 +08:00
parent c0e88129d1
commit 7ec0e0629c
229 changed files with 15154 additions and 14964 deletions
@@ -2,7 +2,7 @@
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,7 +20,7 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
@@ -31,7 +31,7 @@
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
@@ -54,14 +54,14 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* and the 'nullify' the current cell object
*
* @return void
* @throws Exception
* @throws PHPExcel_Exception
*/
private function _storeData() {
if ($this->_currentCellIsDirty) {
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 Exception(sqlite_error_string($this->_DBHandle->lastError()));
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
@@ -74,7 +74,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
@@ -93,7 +93,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
@@ -105,7 +105,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
if ($cellResultSet === false) {
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
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;
@@ -116,8 +116,8 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$cellResult = $cellResultSet->fetchSingle();
$this->_currentObject = unserialize($cellResult);
// Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
@@ -139,7 +139,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
if ($cellResultSet === false) {
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
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;
@@ -152,7 +152,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws Exception
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
@@ -163,22 +163,52 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
// 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 Exception(sqlite_error_string($this->_DBHandle->lastError()));
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 array of 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 Exception(sqlite_error_string($this->_DBHandle->lastError()));
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
$cellKeys = array();
foreach($cellIdsResult as $row) {
@@ -196,11 +226,14 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* @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 Exception(sqlite_error_string($this->_DBHandle->lastError()));
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
// Copy the existing cell cache file
$this->_TableName = $tableName;
@@ -238,9 +271,9 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
$this->_DBHandle = new SQLiteDatabase($_DBName);
if ($this->_DBHandle === false)
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
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 Exception(sqlite_error_string($this->_DBHandle->lastError()));
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
}
} // function __construct()
@@ -249,6 +282,9 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
* 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()