From 44f953b69d78dbd79a0d1ea37e898056b710d88f Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Thu, 15 Aug 2013 23:28:51 +0100 Subject: [PATCH] Fixes to style duplication --- Classes/PHPExcel/Style.php | 28 ++++++++++++++-------------- Classes/PHPExcel/Worksheet.php | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Classes/PHPExcel/Style.php b/Classes/PHPExcel/Style.php index 64618261..a188f719 100644 --- a/Classes/PHPExcel/Style.php +++ b/Classes/PHPExcel/Style.php @@ -422,7 +422,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp $newStyle = clone $style; $newStyle->applyFromArray($pStyles); - if ($workbook->cellXfExists($newStyle)) { + if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) { // there is already such cell Xf in our collection $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); } else { @@ -595,9 +595,9 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp */ public function getQuotePrefix() { - if ($this->_isSupervisor) { - return $this->getSharedComponent()->getQuotePrefix(); - } + if ($this->_isSupervisor) { + return $this->getSharedComponent()->getQuotePrefix(); + } return $this->_quotePrefix; } @@ -608,16 +608,16 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp */ public function setQuotePrefix($pValue) { - if ($pValue == '') { - $pValue = false; - } - if ($this->_isSupervisor) { - $styleArray = array('quotePrefix' => $pValue); - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); - } else { - $this->_quotePrefix = (boolean) $pValue; - } - return $this; + if ($pValue == '') { + $pValue = false; + } + if ($this->_isSupervisor) { + $styleArray = array('quotePrefix' => $pValue); + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); + } else { + $this->_quotePrefix = (boolean) $pValue; + } + return $this; } /** diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 4c7b239b..41b32129 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -1476,9 +1476,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable // Add the style to the workbook if necessary $workbook = $this->_parent; - if ($this->_parent->cellXfExists($pCellStyle)) { - // there is already this cell Xf in our collection - $xfIndex = $pCellStyle->getIndex(); + if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) { + // there is already such cell Xf in our collection + $xfIndex = $existingStyle->getIndex(); } else { // we don't have such a cell Xf, need to add $workbook->addCellXf($pCellStyle);