mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 00:00:43 +00:00
General performance improvements, and specific improvements in the CSV Reader
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@65064 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
@@ -19,10 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* PHPExcel_Style_Alignment
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
@@ -54,42 +54,42 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_horizontal;
|
||||
private $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
|
||||
/**
|
||||
* Vertical
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_vertical;
|
||||
private $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||
|
||||
/**
|
||||
* Text rotation
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_textRotation;
|
||||
private $_textRotation = 0;
|
||||
|
||||
/**
|
||||
* Wrap text
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_wrapText;
|
||||
private $_wrapText = false;
|
||||
|
||||
/**
|
||||
* Shrink to fit
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_shrinkToFit;
|
||||
private $_shrinkToFit = false;
|
||||
|
||||
/**
|
||||
* Indent - only possible with horizontal alignment left and right
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_indent;
|
||||
private $_indent = 0;
|
||||
|
||||
/**
|
||||
* Parent Borders
|
||||
@@ -112,22 +112,14 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function __construct($isSupervisor = false)
|
||||
{
|
||||
// Supervisor?
|
||||
/**
|
||||
* Create a new PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function __construct($isSupervisor = false)
|
||||
{
|
||||
// Supervisor?
|
||||
$this->_isSupervisor = $isSupervisor;
|
||||
|
||||
// Initialise values
|
||||
$this->_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
$this->_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||
$this->_textRotation = 0;
|
||||
$this->_wrapText = false;
|
||||
$this->_shrinkToFit = false;
|
||||
$this->_indent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind parent. Only used for supervisor
|
||||
@@ -205,24 +197,24 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
return array('alignment' => $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray(
|
||||
* array(
|
||||
* 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
||||
* 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
||||
* 'rotation' => 0,
|
||||
* 'wrap' => true
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray(
|
||||
* array(
|
||||
* 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
||||
* 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
||||
* 'rotation' => 0,
|
||||
* 'wrap' => true
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
@@ -253,28 +245,28 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Horizontal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontal() {
|
||||
/**
|
||||
* Get Horizontal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontal() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getHorizontal();
|
||||
}
|
||||
return $this->_horizontal;
|
||||
}
|
||||
return $this->_horizontal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Horizontal
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
}
|
||||
/**
|
||||
* Set Horizontal
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
}
|
||||
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('horizontal' => $pValue));
|
||||
@@ -284,30 +276,30 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
$this->_horizontal = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Vertical
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVertical() {
|
||||
/**
|
||||
* Get Vertical
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVertical() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getVertical();
|
||||
}
|
||||
return $this->_vertical;
|
||||
}
|
||||
return $this->_vertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Vertical
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||
}
|
||||
/**
|
||||
* Set Vertical
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||
}
|
||||
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('vertical' => $pValue));
|
||||
@@ -316,70 +308,70 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
$this->_vertical = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TextRotation
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTextRotation() {
|
||||
/**
|
||||
* Get TextRotation
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTextRotation() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getTextRotation();
|
||||
}
|
||||
return $this->_textRotation;
|
||||
}
|
||||
return $this->_textRotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TextRotation
|
||||
*
|
||||
* @param int $pValue
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setTextRotation($pValue = 0) {
|
||||
/**
|
||||
* Set TextRotation
|
||||
*
|
||||
* @param int $pValue
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setTextRotation($pValue = 0) {
|
||||
// Excel2007 value 255 => PHPExcel value -165
|
||||
if ($pValue == 255) {
|
||||
$pValue = -165;
|
||||
}
|
||||
if ($pValue == 255) {
|
||||
$pValue = -165;
|
||||
}
|
||||
|
||||
// Set rotation
|
||||
if ( ($pValue >= -90 && $pValue <= 90) || $pValue == -165 ) {
|
||||
if ( ($pValue >= -90 && $pValue <= 90) || $pValue == -165 ) {
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('rotation' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_textRotation = $pValue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Text rotation should be a value between -90 and 90.");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Text rotation should be a value between -90 and 90.");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Wrap Text
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getWrapText() {
|
||||
/**
|
||||
* Get Wrap Text
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getWrapText() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getWrapText();
|
||||
}
|
||||
return $this->_wrapText;
|
||||
}
|
||||
return $this->_wrapText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Wrap Text
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setWrapText($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
/**
|
||||
* Set Wrap Text
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setWrapText($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('wrap' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
@@ -387,30 +379,30 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
$this->_wrapText = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Shrink to fit
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShrinkToFit() {
|
||||
/**
|
||||
* Get Shrink to fit
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getShrinkToFit() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getShrinkToFit();
|
||||
}
|
||||
return $this->_shrinkToFit;
|
||||
}
|
||||
return $this->_shrinkToFit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Shrink to fit
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setShrinkToFit($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
/**
|
||||
* Set Shrink to fit
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setShrinkToFit($pValue = false) {
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
@@ -418,27 +410,27 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
$this->_shrinkToFit = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent() {
|
||||
/**
|
||||
* Get indent
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getIndent();
|
||||
}
|
||||
return $this->_indent;
|
||||
}
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set indent
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setIndent($pValue = 0) {
|
||||
/**
|
||||
* Set indent
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setIndent($pValue = 0) {
|
||||
if ($pValue > 0) {
|
||||
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) {
|
||||
$pValue = 0; // indent not supported
|
||||
@@ -451,7 +443,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
$this->_indent = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
@@ -462,16 +454,16 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getHashCode();
|
||||
}
|
||||
return md5(
|
||||
$this->_horizontal
|
||||
. $this->_vertical
|
||||
. $this->_textRotation
|
||||
. ($this->_wrapText ? 't' : 'f')
|
||||
. ($this->_shrinkToFit ? 't' : 'f')
|
||||
return md5(
|
||||
$this->_horizontal
|
||||
. $this->_vertical
|
||||
. $this->_textRotation
|
||||
. ($this->_wrapText ? 't' : 'f')
|
||||
. ($this->_shrinkToFit ? 't' : 'f')
|
||||
. $this->_indent
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
|
||||
Reference in New Issue
Block a user