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->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 {

View File

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

View File

@ -32,6 +32,7 @@ Fixed in develop branch:
- 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

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);
}
}