mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-29 16:56:03 +03:00
More work on PSR-2ing the library
This commit is contained in:
parent
33a5fbed72
commit
a453d68430
@ -67,8 +67,8 @@ class CachedObjectStorage_APC extends CachedObjectStorage_CacheBase implements C
|
|||||||
if (!apc_store(
|
if (!apc_store(
|
||||||
$this->cachePrefix.$this->currentObjectID.'.cache',
|
$this->cachePrefix.$this->currentObjectID.'.cache',
|
||||||
serialize($this->currentObject),
|
serialize($this->currentObject),
|
||||||
$this->cacheTime)
|
$this->cacheTime
|
||||||
) {
|
)) {
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
throw new Exception('Failed to store cell '.$this->currentObjectID.' in APC');
|
throw new Exception('Failed to store cell '.$this->currentObjectID.' in APC');
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,8 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
|||||||
null,
|
null,
|
||||||
$this->cacheTime
|
$this->cacheTime
|
||||||
)) {
|
)) {
|
||||||
if (!$this->memcache->add($this->cachePrefix.$this->currentObjectID.'.cache',
|
if (!$this->memcache->add(
|
||||||
|
$this->cachePrefix.$this->currentObjectID.'.cache',
|
||||||
$obj,
|
$obj,
|
||||||
null,
|
null,
|
||||||
$this->cacheTime
|
$this->cacheTime
|
||||||
@ -149,8 +150,7 @@ class CachedObjectStorage_Memcache extends CachedObjectStorage_CacheBase impleme
|
|||||||
*/
|
*/
|
||||||
public function getCacheData($pCoord)
|
public function getCacheData($pCoord)
|
||||||
{
|
{
|
||||||
if ($pCoord === $this->currentObjectID)
|
if ($pCoord === $this->currentObjectID) {
|
||||||
{
|
|
||||||
return $this->currentObject;
|
return $this->currentObject;
|
||||||
}
|
}
|
||||||
$this->storeData();
|
$this->storeData();
|
||||||
|
@ -42,7 +42,8 @@ class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implement
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function storeData() {
|
protected function storeData()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,7 +54,8 @@ class CachedObjectStorage_Memory extends CachedObjectStorage_CacheBase implement
|
|||||||
* @return PHPExcel\Cell
|
* @return PHPExcel\Cell
|
||||||
* @throws PHPExcel\Exception
|
* @throws PHPExcel\Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, Cell $cell) {
|
public function addCacheData($pCoord, Cell $cell)
|
||||||
|
{
|
||||||
$this->cellCache[$pCoord] = $cell;
|
$this->cellCache[$pCoord] = $cell;
|
||||||
|
|
||||||
// Set current entry to the new/updated entry
|
// Set current entry to the new/updated entry
|
||||||
|
@ -111,7 +111,8 @@ class CachedObjectStorage_MemoryGZip extends CachedObjectStorage_CacheBase imple
|
|||||||
*
|
*
|
||||||
* @return array of string
|
* @return array of string
|
||||||
*/
|
*/
|
||||||
public function getCellList() {
|
public function getCellList()
|
||||||
|
{
|
||||||
if ($this->currentObjectID !== null) {
|
if ($this->currentObjectID !== null) {
|
||||||
$this->storeData();
|
$this->storeData();
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace PHPExcel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel\CachedObjectStorage_PHPTemp
|
* PHPExcel\CachedObjectStorage_PHPTemp
|
||||||
*
|
*
|
||||||
|
@ -63,9 +63,12 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
|||||||
{
|
{
|
||||||
if ($this->currentCellIsDirty) {
|
if ($this->currentCellIsDirty) {
|
||||||
$this->currentObject->detach();
|
$this->currentObject->detach();
|
||||||
|
$query = "INSERT OR REPLACE INTO kvp_" . $this->TableName .
|
||||||
if (!$this->DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES('".$this->currentObjectID."','".sqlite_escape_string(serialize($this->currentObject))."')"))
|
" VALUES('" . $this->currentObjectID . "','" .
|
||||||
|
sqlite_escape_string(serialize($this->currentObject)) . "')";
|
||||||
|
if (!$this->DBHandle->queryExec($query)) {
|
||||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
|
}
|
||||||
$this->currentCellIsDirty = false;
|
$this->currentCellIsDirty = false;
|
||||||
}
|
}
|
||||||
$this->currentObjectID = $this->currentObject = null;
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
@ -166,8 +169,9 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
|||||||
|
|
||||||
// Check if the requested entry exists in the cache
|
// Check if the requested entry exists in the cache
|
||||||
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
|
||||||
if (!$this->DBHandle->queryExec($query))
|
if (!$this->DBHandle->queryExec($query)) {
|
||||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
|
}
|
||||||
|
|
||||||
$this->currentCellIsDirty = false;
|
$this->currentCellIsDirty = false;
|
||||||
}
|
}
|
||||||
@ -186,14 +190,14 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
|
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
|
||||||
$result = $this->DBHandle->exec($query);
|
if (!$this->DBHandle->exec($query)) {
|
||||||
if ($result === false)
|
|
||||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
|
|
||||||
$query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
$query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
||||||
$result = $this->DBHandle->exec($query);
|
if (!$this->DBHandle->exec($query)) {
|
||||||
if ($result === false)
|
|
||||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -211,8 +215,9 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
|||||||
|
|
||||||
$query = "SELECT id FROM kvp_".$this->TableName;
|
$query = "SELECT id FROM kvp_".$this->TableName;
|
||||||
$cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC);
|
$cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC);
|
||||||
if ($cellIdsResult === false)
|
if (!$cellIdsResult) {
|
||||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
|
}
|
||||||
|
|
||||||
$cellKeys = array();
|
$cellKeys = array();
|
||||||
foreach ($cellIdsResult as $row) {
|
foreach ($cellIdsResult as $row) {
|
||||||
@ -235,9 +240,13 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
|||||||
|
|
||||||
// Get a new id for the new table name
|
// Get a new id for the new table name
|
||||||
$tableName = str_replace('.', '_', $this->getUniqueID());
|
$tableName = str_replace('.', '_', $this->getUniqueID());
|
||||||
if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
$result = $this->DBHandle->queryExec(
|
||||||
AS SELECT * FROM kvp_'.$this->TableName))
|
'CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||||
|
AS SELECT * FROM kvp_'.$this->TableName
|
||||||
|
);
|
||||||
|
if (!$result) {
|
||||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
|
}
|
||||||
|
|
||||||
// Copy the existing cell cache file
|
// Copy the existing cell cache file
|
||||||
$this->TableName = $tableName;
|
$this->TableName = $tableName;
|
||||||
@ -274,12 +283,17 @@ class CachedObjectStorage_SQLite extends CachedObjectStorage_CacheBase implement
|
|||||||
$DBName = ':memory:';
|
$DBName = ':memory:';
|
||||||
|
|
||||||
$this->DBHandle = new SQLiteDatabase($DBName);
|
$this->DBHandle = new SQLiteDatabase($DBName);
|
||||||
if ($this->DBHandle === false)
|
if (!$this->DBHandle) {
|
||||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
|
}
|
||||||
|
$result = $this->DBHandle->queryExec(
|
||||||
|
'CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'
|
||||||
|
);
|
||||||
|
if (!$result) {
|
||||||
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
throw new Exception(sqlite_error_string($this->DBHandle->lastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy this cell collection
|
* Destroy this cell collection
|
||||||
|
@ -95,8 +95,9 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
|||||||
$this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
|
$this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
|
||||||
$this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
|
$this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
|
||||||
$result = $this->insertQuery->execute();
|
$result = $this->insertQuery->execute();
|
||||||
if ($result === false)
|
if (!$result) {
|
||||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
$this->currentCellIsDirty = false;
|
$this->currentCellIsDirty = false;
|
||||||
}
|
}
|
||||||
$this->currentObjectID = $this->currentObject = null;
|
$this->currentObjectID = $this->currentObject = null;
|
||||||
@ -198,8 +199,9 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
|||||||
// Check if the requested entry exists in the cache
|
// Check if the requested entry exists in the cache
|
||||||
$this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
$this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
|
||||||
$result = $this->deleteQuery->execute();
|
$result = $this->deleteQuery->execute();
|
||||||
if ($result === false)
|
if (!$result) {
|
||||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
|
|
||||||
$this->currentCellIsDirty = false;
|
$this->currentCellIsDirty = false;
|
||||||
}
|
}
|
||||||
@ -219,14 +221,16 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
|||||||
|
|
||||||
$this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
|
$this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
|
||||||
$result = $this->deleteQuery->execute();
|
$result = $this->deleteQuery->execute();
|
||||||
if ($result === false)
|
if (!$result) {
|
||||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
|
|
||||||
$this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
|
$this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
|
||||||
$this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
|
$this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
|
||||||
$result = $this->updateQuery->execute();
|
$result = $this->updateQuery->execute();
|
||||||
if ($result === false)
|
if (!$result) {
|
||||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -268,9 +272,12 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
|||||||
|
|
||||||
// Get a new id for the new table name
|
// Get a new id for the new table name
|
||||||
$tableName = str_replace('.', '_', $this->getUniqueID());
|
$tableName = str_replace('.', '_', $this->getUniqueID());
|
||||||
if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
if (!$this->DBHandle->exec(
|
||||||
AS SELECT * FROM kvp_'.$this->TableName))
|
'CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
|
||||||
|
AS SELECT * FROM kvp_'.$this->TableName
|
||||||
|
)) {
|
||||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
|
|
||||||
// Copy the existing cell cache file
|
// Copy the existing cell cache file
|
||||||
$this->TableName = $tableName;
|
$this->TableName = $tableName;
|
||||||
@ -307,16 +314,27 @@ class CachedObjectStorage_SQLite3 extends CachedObjectStorage_CacheBase implemen
|
|||||||
$DBName = ':memory:';
|
$DBName = ':memory:';
|
||||||
|
|
||||||
$this->DBHandle = new SQLite3($DBName);
|
$this->DBHandle = new SQLite3($DBName);
|
||||||
if ($this->DBHandle === false)
|
if (!$this->DBHandle) {
|
||||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
|
||||||
if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
|
|
||||||
throw new Exception($this->DBHandle->lastErrorMsg());
|
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||||
}
|
}
|
||||||
|
$query = 'CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)';
|
||||||
|
if (!$this->DBHandle->exec($query)) {
|
||||||
|
throw new Exception($this->DBHandle->lastErrorMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_".$this->TableName." WHERE id = :id");
|
$this->selectQuery = $this->DBHandle->prepare(
|
||||||
$this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES(:id,:data)");
|
"SELECT value FROM kvp_".$this->TableName." WHERE id = :id"
|
||||||
$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");
|
$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"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +59,7 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws PHPExcel\Exception
|
* @throws PHPExcel\Exception
|
||||||
*/
|
*/
|
||||||
protected function _storeData()
|
protected function storeData()
|
||||||
{
|
{
|
||||||
if ($this->currentCellIsDirty) {
|
if ($this->currentCellIsDirty) {
|
||||||
$this->currentObject->detach();
|
$this->currentObject->detach();
|
||||||
@ -214,7 +214,7 @@ class CachedObjectStorage_Wincache extends CachedObjectStorage_CacheBase impleme
|
|||||||
if ($cellID != $this->currentObjectID) {
|
if ($cellID != $this->currentObjectID) {
|
||||||
$success = false;
|
$success = false;
|
||||||
$obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success);
|
$obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success);
|
||||||
if ($success === false) {
|
if (!$success) {
|
||||||
// Entry no longer exists in WinCache, so clear it from the cache array
|
// Entry no longer exists in WinCache, so clear it from the cache array
|
||||||
parent::deleteCacheData($cellID);
|
parent::deleteCacheData($cellID);
|
||||||
throw new Exception('Cell entry '.$cellID.' no longer exists in Wincache');
|
throw new Exception('Cell entry '.$cellID.' no longer exists in Wincache');
|
||||||
|
@ -35,7 +35,8 @@ namespace PHPExcel;
|
|||||||
* @package PHPExcel\Calculation
|
* @package PHPExcel\Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class CalcEngine_CyclicReferenceStack {
|
class CalcEngine_CyclicReferenceStack
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The call stack for calculated cells
|
* The call stack for calculated cells
|
||||||
@ -50,7 +51,8 @@ class CalcEngine_CyclicReferenceStack {
|
|||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function count() {
|
public function count()
|
||||||
|
{
|
||||||
return count($this->stack);
|
return count($this->stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +61,8 @@ class CalcEngine_CyclicReferenceStack {
|
|||||||
*
|
*
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*/
|
*/
|
||||||
public function push($value) {
|
public function push($value)
|
||||||
|
{
|
||||||
$this->stack[] = $value;
|
$this->stack[] = $value;
|
||||||
} // function push()
|
} // function push()
|
||||||
|
|
||||||
@ -68,7 +71,8 @@ class CalcEngine_CyclicReferenceStack {
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function pop() {
|
public function pop()
|
||||||
|
{
|
||||||
return array_pop($this->stack);
|
return array_pop($this->stack);
|
||||||
} // function pop()
|
} // function pop()
|
||||||
|
|
||||||
@ -77,14 +81,16 @@ class CalcEngine_CyclicReferenceStack {
|
|||||||
*
|
*
|
||||||
* @param mixed $value The value to test
|
* @param mixed $value The value to test
|
||||||
*/
|
*/
|
||||||
public function onStack($value) {
|
public function onStack($value)
|
||||||
|
{
|
||||||
return in_array($value, $this->stack);
|
return in_array($value, $this->stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the stack
|
* Clear the stack
|
||||||
*/
|
*/
|
||||||
public function clear() {
|
public function clear()
|
||||||
|
{
|
||||||
$this->stack = array();
|
$this->stack = array();
|
||||||
} // function push()
|
} // function push()
|
||||||
|
|
||||||
@ -93,7 +99,8 @@ class CalcEngine_CyclicReferenceStack {
|
|||||||
*
|
*
|
||||||
* @return mixed[]
|
* @return mixed[]
|
||||||
*/
|
*/
|
||||||
public function showStack() {
|
public function showStack()
|
||||||
|
{
|
||||||
return $this->stack;
|
return $this->stack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ namespace PHPExcel;
|
|||||||
* @package PHPExcel\Calculation
|
* @package PHPExcel\Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class CalcEngine_Logger {
|
class CalcEngine_Logger
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Flag to determine whether a debug log should be generated by the calculation engine
|
* Flag to determine whether a debug log should be generated by the calculation engine
|
||||||
* If true, then a debug log will be generated
|
* If true, then a debug log will be generated
|
||||||
@ -43,7 +43,7 @@ class CalcEngine_Logger {
|
|||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_writeDebugLog = false;
|
private $writeDebugLog = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to determine whether a debug log should be echoed by the calculation engine
|
* Flag to determine whether a debug log should be echoed by the calculation engine
|
||||||
@ -53,21 +53,21 @@ class CalcEngine_Logger {
|
|||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_echoDebugLog = false;
|
private $echoDebugLog = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The debug log generated by the calculation engine
|
* The debug log generated by the calculation engine
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
private $_debugLog = array();
|
private $debugLog = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The calculation engine cell reference stack
|
* The calculation engine cell reference stack
|
||||||
*
|
*
|
||||||
* @var PHPExcel\CalcEngine_CyclicReferenceStack
|
* @var PHPExcel\CalcEngine_CyclicReferenceStack
|
||||||
*/
|
*/
|
||||||
private $_cellStack;
|
private $cellStack;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,8 +75,9 @@ class CalcEngine_Logger {
|
|||||||
*
|
*
|
||||||
* @param PHPExcel\CalcEngine_CyclicReferenceStack $stack
|
* @param PHPExcel\CalcEngine_CyclicReferenceStack $stack
|
||||||
*/
|
*/
|
||||||
public function __construct(CalcEngine_CyclicReferenceStack $stack) {
|
public function __construct(CalcEngine_CyclicReferenceStack $stack)
|
||||||
$this->_cellStack = $stack;
|
{
|
||||||
|
$this->cellStack = $stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,8 +85,9 @@ class CalcEngine_Logger {
|
|||||||
*
|
*
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
*/
|
*/
|
||||||
public function setWriteDebugLog($pValue = false) {
|
public function setWriteDebugLog($pValue = false)
|
||||||
$this->_writeDebugLog = $pValue;
|
{
|
||||||
|
$this->writeDebugLog = $pValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,8 +95,9 @@ class CalcEngine_Logger {
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getWriteDebugLog() {
|
public function getWriteDebugLog()
|
||||||
return $this->_writeDebugLog;
|
{
|
||||||
|
return $this->writeDebugLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,8 +105,9 @@ class CalcEngine_Logger {
|
|||||||
*
|
*
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
*/
|
*/
|
||||||
public function setEchoDebugLog($pValue = false) {
|
public function setEchoDebugLog($pValue = false)
|
||||||
$this->_echoDebugLog = $pValue;
|
{
|
||||||
|
$this->echoDebugLog = $pValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,26 +115,28 @@ class CalcEngine_Logger {
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getEchoDebugLog() {
|
public function getEchoDebugLog()
|
||||||
return $this->_echoDebugLog;
|
{
|
||||||
|
return $this->echoDebugLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write an entry to the calculation engine debug log
|
* Write an entry to the calculation engine debug log
|
||||||
*/
|
*/
|
||||||
public function writeDebugLog() {
|
public function writeDebugLog()
|
||||||
|
{
|
||||||
// Only write the debug log if logging is enabled
|
// Only write the debug log if logging is enabled
|
||||||
if ($this->_writeDebugLog) {
|
if ($this->writeDebugLog) {
|
||||||
$message = implode(func_get_args());
|
$message = implode(func_get_args());
|
||||||
$cellReference = implode(' -> ', $this->_cellStack->showStack());
|
$cellReference = implode(' -> ', $this->cellStack->showStack());
|
||||||
if ($this->_echoDebugLog) {
|
if ($this->echoDebugLog) {
|
||||||
echo $cellReference,
|
echo $cellReference,
|
||||||
($this->_cellStack->count() > 0 ? ' => ' : ''),
|
($this->cellStack->count() > 0 ? ' => ' : ''),
|
||||||
$message,
|
$message,
|
||||||
PHP_EOL;
|
PHP_EOL;
|
||||||
}
|
}
|
||||||
$this->_debugLog[] = $cellReference .
|
$this->debugLog[] = $cellReference .
|
||||||
($this->_cellStack->count() > 0 ? ' => ' : '') .
|
($this->cellStack->count() > 0 ? ' => ' : '') .
|
||||||
$message;
|
$message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,8 +144,9 @@ class CalcEngine_Logger {
|
|||||||
/**
|
/**
|
||||||
* Clear the calculation engine debug log
|
* Clear the calculation engine debug log
|
||||||
*/
|
*/
|
||||||
public function clearLog() {
|
public function clearLog()
|
||||||
$this->_debugLog = array();
|
{
|
||||||
|
$this->debugLog = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,7 +154,8 @@ class CalcEngine_Logger {
|
|||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getLog() {
|
public function getLog()
|
||||||
return $this->_debugLog;
|
{
|
||||||
|
return $this->debugLog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
* @package PHPExcel\Calculation
|
* @package PHPExcel\Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class Calculation_Exception extends Exception {
|
class Calculation_Exception extends Exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Error handler callback
|
* Error handler callback
|
||||||
*
|
*
|
||||||
@ -43,7 +44,8 @@ class Calculation_Exception extends Exception {
|
|||||||
* @param mixed $line
|
* @param mixed $line
|
||||||
* @param mixed $context
|
* @param mixed $context
|
||||||
*/
|
*/
|
||||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
|
{
|
||||||
$e = new self($string, $code);
|
$e = new self($string, $code);
|
||||||
$e->line = $line;
|
$e->line = $line;
|
||||||
$e->file = $file;
|
$e->file = $file;
|
||||||
|
@ -35,7 +35,8 @@ namespace PHPExcel;
|
|||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class Exception extends \Exception {
|
class Exception extends \Exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Error handler callback
|
* Error handler callback
|
||||||
*
|
*
|
||||||
@ -45,7 +46,8 @@ class Exception extends \Exception {
|
|||||||
* @param mixed $line
|
* @param mixed $line
|
||||||
* @param mixed $context
|
* @param mixed $context
|
||||||
*/
|
*/
|
||||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
|
{
|
||||||
$e = new self($string, $code);
|
$e = new self($string, $code);
|
||||||
$e->line = $line;
|
$e->line = $line;
|
||||||
$e->file = $file;
|
$e->file = $file;
|
||||||
|
@ -42,14 +42,14 @@ class HashTable
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $_items = array();
|
public $items = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashTable key map
|
* HashTable key map
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $_keyMap = array();
|
public $keyMap = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel\HashTable
|
* Create a new PHPExcel\HashTable
|
||||||
@ -71,7 +71,8 @@ class HashTable
|
|||||||
* @param PHPExcel\IComparable[] $pSource Source array to create HashTable from
|
* @param PHPExcel\IComparable[] $pSource Source array to create HashTable from
|
||||||
* @throws PHPExcel\Exception
|
* @throws PHPExcel\Exception
|
||||||
*/
|
*/
|
||||||
public function addFromSource($pSource = null) {
|
public function addFromSource($pSource = null)
|
||||||
|
{
|
||||||
// Check if an array was passed
|
// Check if an array was passed
|
||||||
if ($pSource == null) {
|
if ($pSource == null) {
|
||||||
return;
|
return;
|
||||||
@ -90,11 +91,12 @@ class HashTable
|
|||||||
* @param PHPExcel\IComparable $pSource Item to add
|
* @param PHPExcel\IComparable $pSource Item to add
|
||||||
* @throws PHPExcel\Exception
|
* @throws PHPExcel\Exception
|
||||||
*/
|
*/
|
||||||
public function add(IComparable $pSource = null) {
|
public function add(IComparable $pSource = null)
|
||||||
|
{
|
||||||
$hash = $pSource->getHashCode();
|
$hash = $pSource->getHashCode();
|
||||||
if (!isset($this->_items[$hash])) {
|
if (!isset($this->_items[$hash])) {
|
||||||
$this->_items[$hash] = $pSource;
|
$this->items[$hash] = $pSource;
|
||||||
$this->_keyMap[count($this->_items) - 1] = $hash;
|
$this->keyMap[count($this->items) - 1] = $hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,22 +106,23 @@ class HashTable
|
|||||||
* @param PHPExcel\IComparable $pSource Item to remove
|
* @param PHPExcel\IComparable $pSource Item to remove
|
||||||
* @throws PHPExcel\Exception
|
* @throws PHPExcel\Exception
|
||||||
*/
|
*/
|
||||||
public function remove(IComparable $pSource = null) {
|
public function remove(IComparable $pSource = null)
|
||||||
|
{
|
||||||
$hash = $pSource->getHashCode();
|
$hash = $pSource->getHashCode();
|
||||||
if (isset($this->_items[$hash])) {
|
if (isset($this->items[$hash])) {
|
||||||
unset($this->_items[$hash]);
|
unset($this->items[$hash]);
|
||||||
|
|
||||||
$deleteKey = -1;
|
$deleteKey = -1;
|
||||||
foreach ($this->_keyMap as $key => $value) {
|
foreach ($this->keyMap as $key => $value) {
|
||||||
if ($deleteKey >= 0) {
|
if ($deleteKey >= 0) {
|
||||||
$this->_keyMap[$key - 1] = $value;
|
$this->keyMap[$key - 1] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value == $hash) {
|
if ($value == $hash) {
|
||||||
$deleteKey = $key;
|
$deleteKey = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
unset($this->keyMap[count($this->keyMap) - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,9 +130,10 @@ class HashTable
|
|||||||
* Clear HashTable
|
* Clear HashTable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function clear() {
|
public function clear()
|
||||||
$this->_items = array();
|
{
|
||||||
$this->_keyMap = array();
|
$this->items = array();
|
||||||
|
$this->keyMap = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,8 +141,9 @@ class HashTable
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function count() {
|
public function count()
|
||||||
return count($this->_items);
|
{
|
||||||
|
return count($this->items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,8 +152,9 @@ class HashTable
|
|||||||
* @param string $pHashCode
|
* @param string $pHashCode
|
||||||
* @return int Index
|
* @return int Index
|
||||||
*/
|
*/
|
||||||
public function getIndexForHashCode($pHashCode = '') {
|
public function getIndexForHashCode($pHashCode = '')
|
||||||
return array_search($pHashCode, $this->_keyMap);
|
{
|
||||||
|
return array_search($pHashCode, $this->keyMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,9 +164,10 @@ class HashTable
|
|||||||
* @return PHPExcel\IComparable
|
* @return PHPExcel\IComparable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getByIndex($pIndex = 0) {
|
public function getByIndex($pIndex = 0)
|
||||||
if (isset($this->_keyMap[$pIndex])) {
|
{
|
||||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
if (isset($this->keyMap[$pIndex])) {
|
||||||
|
return $this->getByHashCode( $this->keyMap[$pIndex] );
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -173,9 +180,10 @@ class HashTable
|
|||||||
* @return PHPExcel\IComparable
|
* @return PHPExcel\IComparable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getByHashCode($pHashCode = '') {
|
public function getByHashCode($pHashCode = '')
|
||||||
if (isset($this->_items[$pHashCode])) {
|
{
|
||||||
return $this->_items[$pHashCode];
|
if (isset($this->items[$pHashCode])) {
|
||||||
|
return $this->items[$pHashCode];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -186,14 +194,16 @@ class HashTable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel\IComparable[]
|
* @return PHPExcel\IComparable[]
|
||||||
*/
|
*/
|
||||||
public function toArray() {
|
public function toArray()
|
||||||
return $this->_items;
|
{
|
||||||
|
return $this->items;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
|
{
|
||||||
$vars = get_object_vars($this);
|
$vars = get_object_vars($this);
|
||||||
foreach ($vars as $key => $value) {
|
foreach ($vars as $key => $value) {
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
|
@ -35,7 +35,8 @@ namespace PHPExcel;
|
|||||||
* @package PHPExcel\Reader
|
* @package PHPExcel\Reader
|
||||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class Reader_Exception extends Exception {
|
class Reader_Exception extends Exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Error handler callback
|
* Error handler callback
|
||||||
*
|
*
|
||||||
@ -45,7 +46,8 @@ class Reader_Exception extends Exception {
|
|||||||
* @param mixed $line
|
* @param mixed $line
|
||||||
* @param mixed $context
|
* @param mixed $context
|
||||||
*/
|
*/
|
||||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
|
{
|
||||||
$e = new self($string, $code);
|
$e = new self($string, $code);
|
||||||
$e->line = $line;
|
$e->line = $line;
|
||||||
$e->file = $file;
|
$e->file = $file;
|
||||||
|
@ -35,7 +35,8 @@ namespace PHPExcel;
|
|||||||
* @package PHPExcel\Writer
|
* @package PHPExcel\Writer
|
||||||
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class Writer_Exception extends Exception {
|
class Writer_Exception extends Exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Error handler callback
|
* Error handler callback
|
||||||
*
|
*
|
||||||
@ -45,7 +46,8 @@ class Writer_Exception extends Exception {
|
|||||||
* @param mixed $line
|
* @param mixed $line
|
||||||
* @param mixed $context
|
* @param mixed $context
|
||||||
*/
|
*/
|
||||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
|
{
|
||||||
$e = new self($string, $code);
|
$e = new self($string, $code);
|
||||||
$e->line = $line;
|
$e->line = $line;
|
||||||
$e->file = $file;
|
$e->file = $file;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -330,9 +330,9 @@ abstract class Writer_PDF_Core extends Writer_HTML
|
|||||||
protected function prepareForSave($pFilename = null)
|
protected function prepareForSave($pFilename = null)
|
||||||
{
|
{
|
||||||
// garbage collect
|
// garbage collect
|
||||||
$this->_phpExcel->garbageCollect();
|
$this->phpExcel->garbageCollect();
|
||||||
|
|
||||||
$this->_saveArrayReturnType = Calculation::getArrayReturnType();
|
$this->saveArrayReturnType = Calculation::getArrayReturnType();
|
||||||
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
|
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
@ -342,7 +342,7 @@ abstract class Writer_PDF_Core extends Writer_HTML
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set PDF
|
// Set PDF
|
||||||
$this->_isPdf = true;
|
$this->isPdf = true;
|
||||||
// Build CSS
|
// Build CSS
|
||||||
$this->buildCSS(true);
|
$this->buildCSS(true);
|
||||||
|
|
||||||
@ -360,6 +360,6 @@ abstract class Writer_PDF_Core extends Writer_HTML
|
|||||||
// Close file
|
// Close file
|
||||||
fclose($fileHandle);
|
fclose($fileHandle);
|
||||||
|
|
||||||
Calculation::setArrayReturnType($this->_saveArrayReturnType);
|
Calculation::setArrayReturnType($this->saveArrayReturnType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ class Writer_PDF_tcPDF extends Writer_PDF_Core implements Writer_IWriter
|
|||||||
$pdf->setFontSubsetting(false);
|
$pdf->setFontSubsetting(false);
|
||||||
// Set margins, converting inches to points (using 72 dpi)
|
// Set margins, converting inches to points (using 72 dpi)
|
||||||
$pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72);
|
$pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72);
|
||||||
$pdf->SetAutoPageBreak(TRUE, $printMargins->getBottom() * 72);
|
$pdf->SetAutoPageBreak(true, $printMargins->getBottom() * 72);
|
||||||
|
|
||||||
$pdf->setPrintHeader(false);
|
$pdf->setPrintHeader(false);
|
||||||
$pdf->setPrintFooter(false);
|
$pdf->setPrintFooter(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user