From 91de8c54e491100c161b0bc188712edd51695f83 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Tue, 20 Nov 2012 23:55:18 +0000 Subject: [PATCH] Modified applyFromArray() method of PHPExcel_Style to use PHPExcel::cellXfExists() call instead of expensive hash test. --- Classes/PHPExcel/Style.php | 2 +- Examples/runall.php | 2 + changelog.txt | 25 ++++---- .../Classes/PHPExcel/Shared/FileTest.php | 58 +++++++++++++++++++ 4 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 unitTests/Classes/PHPExcel/Shared/FileTest.php diff --git a/Classes/PHPExcel/Style.php b/Classes/PHPExcel/Style.php index bf512a2b..4451910b 100644 --- a/Classes/PHPExcel/Style.php +++ b/Classes/PHPExcel/Style.php @@ -402,7 +402,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp $newStyle = clone $style; $newStyle->applyFromArray($pStyles); - if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) { + if ($workbook->cellXfExists($newStyle)) { // there is already such cell Xf in our collection $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); } else { diff --git a/Examples/runall.php b/Examples/runall.php index be3c73f6..ad8488b5 100644 --- a/Examples/runall.php +++ b/Examples/runall.php @@ -84,6 +84,8 @@ $aTests = array( , '34chartupdate.php' , '35chartrender.php' , '36chartreadwriteHTML.php' + , '37page_layout_view.php' + , '40duplicateStyle.php' , 'OOCalcReader.php' , 'SylkReader.php' , 'Excel2003XMLReader.php' diff --git a/changelog.txt b/changelog.txt index b5d49565..a1b8d132 100644 --- a/changelog.txt +++ b/changelog.txt @@ -24,18 +24,19 @@ Fixed in develop branch: -- Feature: (MBaker) Include charts option for HTML Writer -- Bugfix: (Asker) Work item 18777 - Error in PHPEXCEL/Calculation.php script on line 2976 (stack pop check) -- Bugfix: (MBaker) Work item 18794 - CSV files without a file extension being identified as HTML -- Bugfix: (AndreKR) Work item GH-66 - Wrong check for maximum number of rows in Excel5 Writer -- Bugfix: (MBaker) Work item GH-67 - Cache directory for DiscISAM cache storage cannot be set -- General: (kea) Work item GH-69 - Improved AdvancedValueBinder for currency -- General: (MBaker) Work items 17936 and 17840 - Fix for environments where there is no access to /tmp but to upload_tmp_dir - Provided an option to set the sys_get_temp_dir() call to use the upload_tmp_dir; though by default the standard temp directory will still be used -- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows -- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges -- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't -- Bugfix: (Progi1984)Work item GH-22 - Sheet View in Excel5 Writer +- Feature: (MBaker) Include charts option for HTML Writer +- Bugfix: (Asker) Work item 18777 - Error in PHPEXCEL/Calculation.php script on line 2976 (stack pop check) +- Bugfix: (MBaker) Work item 18794 - CSV files without a file extension being identified as HTML +- Bugfix: (AndreKR) Work item GH-66 - Wrong check for maximum number of rows in Excel5 Writer +- Bugfix: (MBaker) Work item GH-67 - Cache directory for DiscISAM cache storage cannot be set +- General: (kea) Work item GH-69 - Improved AdvancedValueBinder for currency +- General: (MBaker) Work items 17936 and 17840 - Fix for environments where there is no access to /tmp but to upload_tmp_dir + Provided an option to set the sys_get_temp_dir() call to use the upload_tmp_dir; though by default the standard temp directory will still be used +- General: (amironov ) Work item GH-84 - Search style by identity in PHPExcel_Worksheet::duplicateStyle() +- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows +- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges +- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't +- Bugfix: (Progi1984) Work item GH-22 - Sheet View in Excel5 Writer -------------------------------------------------------------------------------- BREAKING CHANGE! As part of the planned changes for handling array formulae in diff --git a/unitTests/Classes/PHPExcel/Shared/FileTest.php b/unitTests/Classes/PHPExcel/Shared/FileTest.php new file mode 100644 index 00000000..a71a4358 --- /dev/null +++ b/unitTests/Classes/PHPExcel/Shared/FileTest.php @@ -0,0 +1,58 @@ +assertEquals($expectedResult, $result); + } + + public function testSetUseUploadTempDirectory() + { + $useUploadTempDirectoryValues = array( + TRUE, + FALSE, + ); + + foreach($useUploadTempDirectoryValues as $useUploadTempDirectoryValue) { + call_user_func(array('PHPExcel_Shared_File','setUseUploadTempDirectory'),$useUploadTempDirectoryValue); + + $result = call_user_func(array('PHPExcel_Shared_File','getUseUploadTempDirectory')); + $this->assertEquals($useUploadTempDirectoryValue, $result); + } + } + + public function testSysGetTempDir() + { + $expectedResult = 'C:\Users\Mark\AppData\Local\Temp'; + + $result = call_user_func(array('PHPExcel_Shared_File','sys_get_temp_dir')); + $this->assertEquals($expectedResult, $result); + } + + public function testSysGetTempDirUpload() + { + $expectedResult = 'C:\xampp\tmp'; + + call_user_func(array('PHPExcel_Shared_File','setUseUploadTempDirectory'),TRUE); + + $result = call_user_func(array('PHPExcel_Shared_File','sys_get_temp_dir')); + $this->assertEquals($expectedResult, $result); + } + +}