Minor performance tweaks
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@85743 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
2cce9b754d
commit
9c2ceed08d
|
@ -208,12 +208,9 @@ class PHPExcel
|
|||
*/
|
||||
public function addSheet(PHPExcel_Worksheet $pSheet = null, $iSheetIndex = null)
|
||||
{
|
||||
if(is_null($iSheetIndex))
|
||||
{
|
||||
if($iSheetIndex === NULL) {
|
||||
$this->_workSheetCollection[] = $pSheet;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Insert the sheet at the requested index
|
||||
array_splice(
|
||||
$this->_workSheetCollection,
|
||||
|
@ -226,7 +223,6 @@ class PHPExcel
|
|||
if ($this->_activeSheetIndex >= $iSheetIndex) {
|
||||
++$this->_activeSheetIndex;
|
||||
}
|
||||
|
||||
}
|
||||
return $pSheet;
|
||||
}
|
||||
|
@ -417,7 +413,7 @@ class PHPExcel
|
|||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) {
|
||||
if (!is_null($this->getSheetByName($pSheet->getTitle()))) {
|
||||
if ($this->getSheetByName($pSheet->getTitle()) !== NULL) {
|
||||
throw new Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename the external sheet first.");
|
||||
}
|
||||
|
||||
|
@ -477,14 +473,14 @@ class PHPExcel
|
|||
public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
|
||||
$returnValue = null;
|
||||
|
||||
if ($namedRange != '' && !is_null($namedRange)) {
|
||||
if ($namedRange != '' && ($namedRange !== NULL)) {
|
||||
// first look for global defined name
|
||||
if (isset($this->_namedRanges[$namedRange])) {
|
||||
$returnValue = $this->_namedRanges[$namedRange];
|
||||
}
|
||||
|
||||
// then look for local defined name (has priority over global defined name if both names exist)
|
||||
if (!is_null($pSheet) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
|
||||
if (($pSheet !== NULL) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
|
||||
$returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange];
|
||||
}
|
||||
}
|
||||
|
@ -500,7 +496,7 @@ class PHPExcel
|
|||
* @return PHPExcel
|
||||
*/
|
||||
public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
|
||||
if (is_null($pSheet)) {
|
||||
if ($pSheet === NULL) {
|
||||
if (isset($this->_namedRanges[$namedRange])) {
|
||||
unset($this->_namedRanges[$namedRange]);
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ class PHPExcel_CachedObjectStorage_CacheBase {
|
|||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
$this->_parent = $parent;
|
||||
if ((!is_null($this->_currentObject)) && (is_object($this->_currentObject))) {
|
||||
if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
|
||||
$this->_currentObject->attach($parent);
|
||||
}
|
||||
} // function copyCellCollection()
|
||||
|
|
|
@ -66,7 +66,7 @@ class PHPExcel_CachedObjectStorageFactory {
|
|||
|
||||
|
||||
public static function getCacheStorageMethod() {
|
||||
if (!is_null(self::$_cacheStorageMethod)) {
|
||||
if (self::$_cacheStorageMethod !== NULL) {
|
||||
return self::$_cacheStorageMethod;
|
||||
}
|
||||
return null;
|
||||
|
@ -74,7 +74,7 @@ class PHPExcel_CachedObjectStorageFactory {
|
|||
|
||||
|
||||
public static function getCacheStorageClass() {
|
||||
if (!is_null(self::$_cacheStorageClass)) {
|
||||
if (self::$_cacheStorageClass !== NULL) {
|
||||
return self::$_cacheStorageClass;
|
||||
}
|
||||
return null;
|
||||
|
@ -115,7 +115,7 @@ class PHPExcel_CachedObjectStorageFactory {
|
|||
}
|
||||
}
|
||||
|
||||
if (is_null(self::$_cacheStorageMethod)) {
|
||||
if (self::$_cacheStorageMethod === NULL) {
|
||||
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
||||
self::$_cacheStorageMethod = $method;
|
||||
}
|
||||
|
@ -125,13 +125,13 @@ class PHPExcel_CachedObjectStorageFactory {
|
|||
|
||||
public static function getInstance(PHPExcel_Worksheet $parent) {
|
||||
$cacheMethodIsAvailable = TRUE;
|
||||
if (is_null(self::$_cacheStorageMethod)) {
|
||||
if (self::$_cacheStorageMethod === NULL) {
|
||||
$cacheMethodIsAvailable = self::initialize();
|
||||
}
|
||||
|
||||
if ($cacheMethodIsAvailable) {
|
||||
$instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]);
|
||||
if (!is_null($instance)) {
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1710,7 +1710,7 @@ class PHPExcel_Calculation {
|
|||
* @return PHPExcel_Calculation
|
||||
*/
|
||||
public static function getInstance() {
|
||||
if (!isset(self::$_instance) || is_null(self::$_instance)) {
|
||||
if (!isset(self::$_instance) || (self::$_instance === NULL)) {
|
||||
self::$_instance = new PHPExcel_Calculation();
|
||||
}
|
||||
|
||||
|
@ -1726,7 +1726,7 @@ class PHPExcel_Calculation {
|
|||
* @return null
|
||||
*/
|
||||
public static function flushInstance() {
|
||||
if (isset(self::$_instance) && !is_null(self::$_instance)) {
|
||||
if (isset(self::$_instance) && (self::$_instance !== NULL)) {
|
||||
self::$_instance->clearCalculationCache();
|
||||
}
|
||||
} // function flushInstance()
|
||||
|
@ -2000,7 +2000,7 @@ class PHPExcel_Calculation {
|
|||
private static $functionReplaceToLocale = null;
|
||||
|
||||
public function _translateFormulaToLocale($formula) {
|
||||
if (is_null(self::$functionReplaceFromExcel)) {
|
||||
if (self::$functionReplaceFromExcel === NULL) {
|
||||
self::$functionReplaceFromExcel = array();
|
||||
foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
|
||||
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui';
|
||||
|
@ -2011,7 +2011,7 @@ class PHPExcel_Calculation {
|
|||
|
||||
}
|
||||
|
||||
if (is_null(self::$functionReplaceToLocale)) {
|
||||
if (self::$functionReplaceToLocale === NULL) {
|
||||
self::$functionReplaceToLocale = array();
|
||||
foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
|
||||
self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2';
|
||||
|
@ -2029,7 +2029,7 @@ class PHPExcel_Calculation {
|
|||
private static $functionReplaceToExcel = null;
|
||||
|
||||
public function _translateFormulaToEnglish($formula) {
|
||||
if (is_null(self::$functionReplaceFromLocale)) {
|
||||
if (self::$functionReplaceFromLocale === NULL) {
|
||||
self::$functionReplaceFromLocale = array();
|
||||
foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
|
||||
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui';
|
||||
|
@ -2039,7 +2039,7 @@ class PHPExcel_Calculation {
|
|||
}
|
||||
}
|
||||
|
||||
if (is_null(self::$functionReplaceToExcel)) {
|
||||
if (self::$functionReplaceToExcel === NULL) {
|
||||
self::$functionReplaceToExcel = array();
|
||||
foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
|
||||
self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2';
|
||||
|
|
|
@ -316,7 +316,7 @@ class PHPExcel_Cell
|
|||
*/
|
||||
public function setCalculatedValue($pValue = null)
|
||||
{
|
||||
if (!is_null($pValue)) {
|
||||
if ($pValue !== NULL) {
|
||||
$this->_calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ class PHPExcel_DocumentProperties
|
|||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCreated($pValue = null) {
|
||||
if (is_null($pValue)) {
|
||||
if ($pValue === NULL) {
|
||||
$pValue = time();
|
||||
} elseif (is_string($pValue)) {
|
||||
if (is_numeric($pValue)) {
|
||||
|
@ -226,7 +226,7 @@ class PHPExcel_DocumentProperties
|
|||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setModified($pValue = null) {
|
||||
if (is_null($pValue)) {
|
||||
if ($pValue === NULL) {
|
||||
$pValue = time();
|
||||
} elseif (is_string($pValue)) {
|
||||
if (is_numeric($pValue)) {
|
||||
|
@ -439,12 +439,12 @@ class PHPExcel_DocumentProperties
|
|||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
|
||||
if ((is_null($propertyType)) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
|
||||
if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
|
||||
self::PROPERTY_TYPE_FLOAT,
|
||||
self::PROPERTY_TYPE_STRING,
|
||||
self::PROPERTY_TYPE_DATE,
|
||||
self::PROPERTY_TYPE_BOOLEAN)))) {
|
||||
if (is_null($propertyValue)) {
|
||||
if ($propertyValue === NULL) {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
} elseif (is_float($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_FLOAT;
|
||||
|
|
|
@ -139,7 +139,7 @@ class PHPExcel_IOFactory
|
|||
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
|
||||
|
||||
$instance = new $className($phpExcel);
|
||||
if (!is_null($instance)) {
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ class PHPExcel_IOFactory
|
|||
$classFile = str_replace('{0}', $readerType, $searchLocation['path']);
|
||||
|
||||
$instance = new $className();
|
||||
if (!is_null($instance)) {
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class PHPExcel_NamedRange
|
|||
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
||||
{
|
||||
// Validate data
|
||||
if (is_null($pName) || is_null($pWorksheet)|| is_null($pRange)) {
|
||||
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
|
||||
throw new Exception('Parameters can not be null.');
|
||||
}
|
||||
|
||||
|
@ -111,17 +111,17 @@ class PHPExcel_NamedRange
|
|||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setName($value = null) {
|
||||
if (!is_null($value)) {
|
||||
if ($value !== NULL) {
|
||||
// Old title
|
||||
$oldTitle = $this->_name;
|
||||
|
||||
// Re-attach
|
||||
if (!is_null($this->_worksheet)) {
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
|
||||
}
|
||||
$this->_name = $value;
|
||||
|
||||
if (!is_null($this->_worksheet)) {
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_worksheet->getParent()->addNamedRange($this);
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ class PHPExcel_NamedRange
|
|||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setWorksheet(PHPExcel_Worksheet $value = null) {
|
||||
if (!is_null($value)) {
|
||||
if ($value !== NULL) {
|
||||
$this->_worksheet = $value;
|
||||
}
|
||||
return $this;
|
||||
|
@ -170,7 +170,7 @@ class PHPExcel_NamedRange
|
|||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setRange($value = null) {
|
||||
if (!is_null($value)) {
|
||||
if ($value !== NULL) {
|
||||
$this->_range = $value;
|
||||
}
|
||||
return $this;
|
||||
|
|
|
@ -500,7 +500,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
|
|||
break;
|
||||
}
|
||||
// echo 'Data value is '.$dataValue.'<br />';
|
||||
// if (!is_null($hyperlink)) {
|
||||
// if ($hyperlink !== NULL) {
|
||||
// echo 'Hyperlink is '.$hyperlink.'<br />';
|
||||
// }
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
|
|||
// echo 'Adjusted Formula: '.$cellDataFormula.'<br />';
|
||||
}
|
||||
|
||||
if (!is_null($type)) {
|
||||
if ($type !== NULL) {
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
|
||||
if ($hasCalculatedValue) {
|
||||
// echo 'Forumla result is '.$dataValue.'<br />';
|
||||
|
@ -535,7 +535,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
|
|||
($cellDataOfficeAttributes['value-type'] == 'time')) {
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rowID)->getNumberFormat()->setFormatCode($formatting);
|
||||
}
|
||||
if (!is_null($hyperlink)) {
|
||||
if ($hyperlink !== NULL) {
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->getHyperlink()->setUrl($hyperlink);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
|||
$this->_richTextElements = array();
|
||||
|
||||
// Rich-Text string attached to cell?
|
||||
if (!is_null($pCell)) {
|
||||
if ($pCell !== NULL) {
|
||||
// Add cell text and style
|
||||
if ($pCell->getValue() != "") {
|
||||
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
|
||||
|
|
|
@ -80,7 +80,7 @@ class PHPExcel_Shared_File
|
|||
}
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
if ($returnValue == '' || ($returnValue === NULL)) {
|
||||
$pathArray = explode('/' , $pFilename);
|
||||
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
|
|
|
@ -79,7 +79,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
|||
if (is_resource($filename)) {
|
||||
$this->_FILEH_ = $filename;
|
||||
} else if ($filename == '-' || $filename == '') {
|
||||
if (is_null($this->_tmp_dir))
|
||||
if ($this->_tmp_dir === NULL)
|
||||
$this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir();
|
||||
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
|
||||
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
|
||||
|
|
|
@ -175,7 +175,7 @@ class PHPExcel_Shared_OLERead {
|
|||
*/
|
||||
public function getStream($stream)
|
||||
{
|
||||
if (is_null($stream)) {
|
||||
if ($stream === NULL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
|
|||
$this->openMemory();
|
||||
} else {
|
||||
// Create temporary filename
|
||||
if (is_null($pTemporaryStorageFolder))
|
||||
if ($pTemporaryStorageFolder === NULL)
|
||||
$pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir();
|
||||
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
|
||||
|
||||
|
|
|
@ -1076,7 +1076,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
|
||||
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
|
||||
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
|
||||
if (!is_null($namedRange)) {
|
||||
if ($namedRange !== NULL) {
|
||||
$pCoordinate = $namedRange->getRange();
|
||||
if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
|
||||
if (!$namedRange->getLocalOnly()) {
|
||||
|
@ -2278,7 +2278,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||
*/
|
||||
public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
||||
$namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
|
||||
if (!is_null($namedRange)) {
|
||||
if ($namedRange !== NULL) {
|
||||
$pWorkSheet = $namedRange->getWorksheet();
|
||||
$pCellRange = $namedRange->getRange();
|
||||
|
||||
|
@ -2551,7 +2551,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||
*/
|
||||
public function getTabColor()
|
||||
{
|
||||
if (is_null($this->_tabColor))
|
||||
if ($this->_tabColor === NULL)
|
||||
$this->_tabColor = new PHPExcel_Style_Color();
|
||||
|
||||
return $this->_tabColor;
|
||||
|
@ -2577,7 +2577,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||
*/
|
||||
public function isTabColorSet()
|
||||
{
|
||||
return !is_null($this->_tabColor);
|
||||
return ($this->_tabColor !== NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
|
|||
*/
|
||||
public function createStringTable($pSheet = null, $pExistingTable = null)
|
||||
{
|
||||
if (!is_null($pSheet)) {
|
||||
if ($pSheet !== NULL) {
|
||||
// Create string lookup table
|
||||
$aStringTable = array();
|
||||
$cellCollection = null;
|
||||
|
@ -64,14 +64,14 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
|
|||
$cell = $pSheet->getCell($cellID);
|
||||
$cellValue = $cell->getValue();
|
||||
if (!is_object($cellValue) &&
|
||||
!is_null($cellValue) &&
|
||||
($cellValue !== NULL) &&
|
||||
$cellValue !== '' &&
|
||||
!isset($aFlippedStringTable[$cellValue]) &&
|
||||
($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL)) {
|
||||
$aStringTable[] = $cellValue;
|
||||
$aFlippedStringTable[$cellValue] = true;
|
||||
} elseif ($cellValue instanceof PHPExcel_RichText &&
|
||||
!is_null($cellValue) &&
|
||||
($cellValue !== NULL) &&
|
||||
!isset($aFlippedStringTable[$cellValue->getHashCode()])) {
|
||||
$aStringTable[] = $cellValue;
|
||||
$aFlippedStringTable[$cellValue->getHashCode()] = true;
|
||||
|
|
Loading…
Reference in New Issue