Fixes to style duplication

This commit is contained in:
Mark Baker 2013-08-15 23:28:51 +01:00
parent b726b23411
commit 44f953b69d
2 changed files with 17 additions and 17 deletions

View File

@ -422,7 +422,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
$newStyle = clone $style; $newStyle = clone $style;
$newStyle->applyFromArray($pStyles); $newStyle->applyFromArray($pStyles);
if ($workbook->cellXfExists($newStyle)) { if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
// 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 {
@ -595,9 +595,9 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getQuotePrefix() public function getQuotePrefix()
{ {
if ($this->_isSupervisor) { if ($this->_isSupervisor) {
return $this->getSharedComponent()->getQuotePrefix(); return $this->getSharedComponent()->getQuotePrefix();
} }
return $this->_quotePrefix; return $this->_quotePrefix;
} }
@ -608,16 +608,16 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function setQuotePrefix($pValue) public function setQuotePrefix($pValue)
{ {
if ($pValue == '') { if ($pValue == '') {
$pValue = false; $pValue = false;
} }
if ($this->_isSupervisor) { if ($this->_isSupervisor) {
$styleArray = array('quotePrefix' => $pValue); $styleArray = array('quotePrefix' => $pValue);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_quotePrefix = (boolean) $pValue; $this->_quotePrefix = (boolean) $pValue;
} }
return $this; return $this;
} }
/** /**

View File

@ -1476,9 +1476,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Add the style to the workbook if necessary // Add the style to the workbook if necessary
$workbook = $this->_parent; $workbook = $this->_parent;
if ($this->_parent->cellXfExists($pCellStyle)) { if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) {
// there is already this cell Xf in our collection // there is already such cell Xf in our collection
$xfIndex = $pCellStyle->getIndex(); $xfIndex = $existingStyle->getIndex();
} else { } else {
// we don't have such a cell Xf, need to add // we don't have such a cell Xf, need to add
$workbook->addCellXf($pCellStyle); $workbook->addCellXf($pCellStyle);