Modified applyFromArray() method of PHPExcel_Style to use PHPExcel::cellXfExists() call instead of expensive hash test.

This commit is contained in:
Mark Baker 2012-11-20 23:55:18 +00:00
parent d1ee820c10
commit 91de8c54e4
4 changed files with 74 additions and 13 deletions

View File

@ -402,7 +402,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
$newStyle = clone $style; $newStyle = clone $style;
$newStyle->applyFromArray($pStyles); $newStyle->applyFromArray($pStyles);
if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) { if ($workbook->cellXfExists($newStyle)) {
// there is already such cell Xf in our collection // there is already such cell Xf in our collection
$newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex();
} else { } else {

View File

@ -84,6 +84,8 @@ $aTests = array(
, '34chartupdate.php' , '34chartupdate.php'
, '35chartrender.php' , '35chartrender.php'
, '36chartreadwriteHTML.php' , '36chartreadwriteHTML.php'
, '37page_layout_view.php'
, '40duplicateStyle.php'
, 'OOCalcReader.php' , 'OOCalcReader.php'
, 'SylkReader.php' , 'SylkReader.php'
, 'Excel2003XMLReader.php' , 'Excel2003XMLReader.php'

View File

@ -24,18 +24,19 @@
Fixed in develop branch: Fixed in develop branch:
- Feature: (MBaker) Include charts option for HTML 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: (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: (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: (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 - 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: (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 - 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 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 - General: (amironov ) Work item GH-84 - Search style by identity in PHPExcel_Worksheet::duplicateStyle()
- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges - Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows
- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't - Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges
- Bugfix: (Progi1984)Work item GH-22 - Sheet View in Excel5 Writer - 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 BREAKING CHANGE! As part of the planned changes for handling array formulae in

View File

@ -0,0 +1,58 @@
<?php
require_once 'testDataFileIterator.php';
class FileTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
public function testGetUseUploadTempDirectory()
{
$expectedResult = FALSE;
$result = call_user_func(array('PHPExcel_Shared_File','getUseUploadTempDirectory'));
$this->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);
}
}