diff --git a/Classes/PHPExcel/Chart/Renderer/jpgraph.php b/Classes/PHPExcel/Chart/Renderer/jpgraph.php index e03001e..e0b6b91 100644 --- a/Classes/PHPExcel/Chart/Renderer/jpgraph.php +++ b/Classes/PHPExcel/Chart/Renderer/jpgraph.php @@ -107,13 +107,11 @@ class PHPExcel_Chart_Renderer_jpgraph $testCurrentIndex = 0; foreach($datasetLabels as $i => $datasetLabel) { - array_reverse($datasetLabel); - if (is_array($datasetLabel)) { if ($rotation == 'bar') { - $datasetLabel = array_reverse($datasetLabel); $datasetLabels[$i] = implode(" ",$datasetLabel); } else { + $datasetLabel = array_reverse($datasetLabel); $datasetLabels[$i] = implode("\n",$datasetLabel); } } else { diff --git a/Classes/PHPExcel/Style.php b/Classes/PHPExcel/Style.php index 6afd157..bf512a2 100644 --- a/Classes/PHPExcel/Style.php +++ b/Classes/PHPExcel/Style.php @@ -33,77 +33,63 @@ * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style implements PHPExcel_IComparable +class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /** * Font * * @var PHPExcel_Style_Font */ - private $_font; + protected $_font; /** * Fill * * @var PHPExcel_Style_Fill */ - private $_fill; + protected $_fill; /** * Borders * * @var PHPExcel_Style_Borders */ - private $_borders; + protected $_borders; /** * Alignment * * @var PHPExcel_Style_Alignment */ - private $_alignment; + protected $_alignment; /** * Number Format * * @var PHPExcel_Style_NumberFormat */ - private $_numberFormat; + protected $_numberFormat; /** * Conditional styles * * @var PHPExcel_Style_Conditional[] */ - private $_conditionalStyles; + protected $_conditionalStyles; /** * Protection * * @var PHPExcel_Style_Protection */ - private $_protection; - - /** - * Style supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for style supervisor - * - * @var PHPExcel - */ - private $_parent; + protected $_protection; /** * Index of style in collection. Only used for real style. * * @var int */ - private $_index; + protected $_index; /** * Create a new PHPExcel_Style @@ -140,28 +126,6 @@ class PHPExcel_Style implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel $parent - * @return PHPExcel_Style - */ - public function bindParent($parent) - { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -182,38 +146,6 @@ class PHPExcel_Style implements PHPExcel_IComparable return $this->_parent->getCellXfByIndex($xfIndex); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->_parent->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->_parent->getActiveSheet()->getActiveCell(); - } - /** * Get parent. Only used for style supervisor * @@ -668,17 +600,4 @@ class PHPExcel_Style implements PHPExcel_IComparable $this->_index = $pValue; } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/Classes/PHPExcel/Style/Alignment.php b/Classes/PHPExcel/Style/Alignment.php index fe85cb8..1e0d261 100644 --- a/Classes/PHPExcel/Style/Alignment.php +++ b/Classes/PHPExcel/Style/Alignment.php @@ -33,7 +33,7 @@ * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Alignment implements PHPExcel_IComparable +class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Horizontal alignment styles */ const HORIZONTAL_GENERAL = 'general'; @@ -54,63 +54,42 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * * @var string */ - private $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; + protected $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; /** * Vertical * * @var string */ - private $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; + protected $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; /** * Text rotation * * @var int */ - private $_textRotation = 0; + protected $_textRotation = 0; /** * Wrap text * * @var boolean */ - private $_wrapText = false; + protected $_wrapText = FALSE; /** * Shrink to fit * * @var boolean */ - private $_shrinkToFit = false; + protected $_shrinkToFit = FALSE; /** * Indent - only possible with horizontal alignment left and right * * @var int */ - private $_indent = 0; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_indent = 0; /** * Create a new PHPExcel_Style_Alignment @@ -122,10 +101,10 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); if ($isConditional) { $this->_horizontal = NULL; @@ -134,28 +113,6 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel $parent - * @return PHPExcel_Style_Alignment - */ - public function bindParent($parent) - { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -167,38 +124,6 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getAlignment(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -219,41 +144,42 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, * 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, * 'rotation' => 0, - * 'wrap' => true + * 'wrap' => TRUE * ) * ); * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Alignment */ - public function applyFromArray($pStyles = null) { + public function applyFromArray($pStyles = NULL) { if (is_array($pStyles)) { if ($this->_isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); + $this->getActiveSheet()->getStyle($this->getSelectedCells()) + ->applyFromArray($this->getStyleArray($pStyles)); } else { - if (array_key_exists('horizontal', $pStyles)) { + if (isset($pStyles['horizontal'])) { $this->setHorizontal($pStyles['horizontal']); } - if (array_key_exists('vertical', $pStyles)) { + if (isset($pStyles['vertical'])) { $this->setVertical($pStyles['vertical']); } - if (array_key_exists('rotation', $pStyles)) { + if (isset($pStyles['rotation'])) { $this->setTextRotation($pStyles['rotation']); } - if (array_key_exists('wrap', $pStyles)) { + if (isset($pStyles['wrap'])) { $this->setWrapText($pStyles['wrap']); } - if (array_key_exists('shrinkToFit', $pStyles)) { + if (isset($pStyles['shrinkToFit'])) { $this->setShrinkToFit($pStyles['shrinkToFit']); } - if (array_key_exists('indent', $pStyles)) { + if (isset($pStyles['indent'])) { $this->setIndent($pStyles['indent']); } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -339,7 +265,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * Set TextRotation * * @param int $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Alignment */ public function setTextRotation($pValue = 0) { @@ -357,7 +283,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable $this->_textRotation = $pValue; } } else { - throw new Exception("Text rotation should be a value between -90 and 90."); + throw new PHPExcel_Exception("Text rotation should be a value between -90 and 90."); } return $this; @@ -381,9 +307,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * @param boolean $pValue * @return PHPExcel_Style_Alignment */ - public function setWrapText($pValue = false) { + public function setWrapText($pValue = FALSE) { if ($pValue == '') { - $pValue = false; + $pValue = FALSE; } if ($this->_isSupervisor) { $styleArray = $this->getStyleArray(array('wrap' => $pValue)); @@ -412,9 +338,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable * @param boolean $pValue * @return PHPExcel_Style_Alignment */ - public function setShrinkToFit($pValue = false) { + public function setShrinkToFit($pValue = FALSE) { if ($pValue == '') { - $pValue = false; + $pValue = FALSE; } if ($this->_isSupervisor) { $styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue)); @@ -445,7 +371,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable */ public function setIndent($pValue = 0) { if ($pValue > 0) { - if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) { + if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && + $this->getHorizontal() != self::HORIZONTAL_LEFT && + $this->getHorizontal() != self::HORIZONTAL_RIGHT) { $pValue = 0; // indent not supported } } @@ -478,17 +406,4 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/Classes/PHPExcel/Style/Border.php b/Classes/PHPExcel/Style/Border.php index a409e1c..52aa76e 100644 --- a/Classes/PHPExcel/Style/Border.php +++ b/Classes/PHPExcel/Style/Border.php @@ -33,7 +33,7 @@ * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Border implements PHPExcel_IComparable +class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Border style */ const BORDER_NONE = 'none'; @@ -56,35 +56,21 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable * * @var string */ - private $_borderStyle = PHPExcel_Style_Border::BORDER_NONE; + protected $_borderStyle = PHPExcel_Style_Border::BORDER_NONE; /** * Border color * * @var PHPExcel_Style_Color */ - private $_color; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style_Borders - */ - private $_parent; + protected $_color; /** * Parent property name * * @var string */ - private $_parentPropertyName; + protected $_parentPropertyName; /** * Create a new PHPExcel_Style_Border @@ -96,10 +82,10 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values $this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor); @@ -124,22 +110,12 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable return $this; } - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor * * @return PHPExcel_Style_Border - * @throws Exception + * @throws PHPExcel_Exception */ public function getSharedComponent() { @@ -149,64 +125,22 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable case '_inside': case '_outline': case '_vertical': - throw new Exception('Cannot get shared component for a pseudo-border.'); + throw new PHPExcel_Exception('Cannot get shared component for a pseudo-border.'); break; - case '_bottom': - return $this->_parent->getSharedComponent()->getBottom(); - break; - + return $this->_parent->getSharedComponent()->getBottom(); break; case '_diagonal': - return $this->_parent->getSharedComponent()->getDiagonal(); - break; - + return $this->_parent->getSharedComponent()->getDiagonal(); break; case '_left': - return $this->_parent->getSharedComponent()->getLeft(); - break; - + return $this->_parent->getSharedComponent()->getLeft(); break; case '_right': - return $this->_parent->getSharedComponent()->getRight(); - break; - + return $this->_parent->getSharedComponent()->getRight(); break; case '_top': - return $this->_parent->getSharedComponent()->getTop(); - break; + return $this->_parent->getSharedComponent()->getTop(); break; } } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -217,44 +151,25 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable { switch ($this->_parentPropertyName) { case '_allBorders': - $key = 'allborders'; - break; - + $key = 'allborders'; break; case '_bottom': - $key = 'bottom'; - break; - + $key = 'bottom'; break; case '_diagonal': - $key = 'diagonal'; - break; - + $key = 'diagonal'; break; case '_horizontal': - $key = 'horizontal'; - break; - + $key = 'horizontal'; break; case '_inside': - $key = 'inside'; - break; - + $key = 'inside'; break; case '_left': - $key = 'left'; - break; - + $key = 'left'; break; case '_outline': - $key = 'outline'; - break; - + $key = 'outline'; break; case '_right': - $key = 'right'; - break; - + $key = 'right'; break; case '_top': - $key = 'top'; - break; - + $key = 'top'; break; case '_vertical': - $key = 'vertical'; - break; + $key = 'vertical'; break; } return $this->_parent->getStyleArray(array($key => $array)); } @@ -274,7 +189,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Border */ public function applyFromArray($pStyles = null) { @@ -282,15 +197,15 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable if ($this->_isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - if (array_key_exists('style', $pStyles)) { + if (isset($pStyles['style'])) { $this->setBorderStyle($pStyles['style']); } - if (array_key_exists('color', $pStyles)) { + if (isset($pStyles['color'])) { $this->getColor()->applyFromArray($pStyles['color']); } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -310,13 +225,17 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable /** * Set Border style * - * @param string $pValue + * @param string|boolean $pValue + * When passing a boolean, FALSE equates PHPExcel_Style_Border::BORDER_NONE + * and TRUE to PHPExcel_Style_Border::BORDER_MEDIUM * @return PHPExcel_Style_Border */ public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) { - if ($pValue == '') { + if (empty($pValue)) { $pValue = PHPExcel_Style_Border::BORDER_NONE; + } elseif(is_bool($pValue) && $pValue) { + $pValue = PHPExcel_Style_Border::BORDER_MEDIUM; } if ($this->_isSupervisor) { $styleArray = $this->getStyleArray(array('style' => $pValue)); @@ -340,7 +259,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable * Set Border Color * * @param PHPExcel_Style_Color $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Border */ public function setColor(PHPExcel_Style_Color $pValue = null) { @@ -372,17 +291,4 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/Classes/PHPExcel/Style/Borders.php b/Classes/PHPExcel/Style/Borders.php index 295daa2..9c79ed8 100644 --- a/Classes/PHPExcel/Style/Borders.php +++ b/Classes/PHPExcel/Style/Borders.php @@ -33,7 +33,7 @@ * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Borders implements PHPExcel_IComparable +class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Diagonal directions */ const DIAGONAL_NONE = 0; @@ -46,98 +46,77 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * * @var PHPExcel_Style_Border */ - private $_left; + protected $_left; /** * Right * * @var PHPExcel_Style_Border */ - private $_right; + protected $_right; /** * Top * * @var PHPExcel_Style_Border */ - private $_top; + protected $_top; /** * Bottom * * @var PHPExcel_Style_Border */ - private $_bottom; + protected $_bottom; /** * Diagonal * * @var PHPExcel_Style_Border */ - private $_diagonal; + protected $_diagonal; /** * DiagonalDirection * * @var int */ - private $_diagonalDirection; + protected $_diagonalDirection; /** * All borders psedo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_allBorders; + protected $_allBorders; /** * Outline psedo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_outline; + protected $_outline; /** * Inside psedo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_inside; + protected $_inside; /** * Vertical pseudo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_vertical; + protected $_vertical; /** * Horizontal pseudo-border. Only applies to supervisor. * * @var PHPExcel_Style_Border */ - private $_horizontal; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_horizontal; /** * Create a new PHPExcel_Style_Borders @@ -149,10 +128,10 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values $this->_left = new PHPExcel_Style_Border($isSupervisor, $isConditional); @@ -165,11 +144,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable // Specially for supervisor if ($isSupervisor) { // Initialize pseudo-borders - $this->_allBorders = new PHPExcel_Style_Border(true); - $this->_outline = new PHPExcel_Style_Border(true); - $this->_inside = new PHPExcel_Style_Border(true); - $this->_vertical = new PHPExcel_Style_Border(true); - $this->_horizontal = new PHPExcel_Style_Border(true); + $this->_allBorders = new PHPExcel_Style_Border(TRUE); + $this->_outline = new PHPExcel_Style_Border(TRUE); + $this->_inside = new PHPExcel_Style_Border(TRUE); + $this->_vertical = new PHPExcel_Style_Border(TRUE); + $this->_horizontal = new PHPExcel_Style_Border(TRUE); // bind parent if we are a supervisor $this->_left->bindParent($this, '_left'); @@ -185,28 +164,6 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_Borders - */ - public function bindParent($parent) - { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -218,38 +175,6 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getBorders(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -296,7 +221,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Borders */ public function applyFromArray($pStyles = null) { @@ -330,7 +255,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -384,11 +309,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get AllBorders (pseudo-border). Only applies to supervisor. * * @return PHPExcel_Style_Border - * @throws Exception + * @throws PHPExcel_Exception */ public function getAllBorders() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_allBorders; } @@ -397,11 +322,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get Outline (pseudo-border). Only applies to supervisor. * * @return boolean - * @throws Exception + * @throws PHPExcel_Exception */ public function getOutline() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_outline; } @@ -410,11 +335,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get Inside (pseudo-border). Only applies to supervisor. * * @return boolean - * @throws Exception + * @throws PHPExcel_Exception */ public function getInside() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_inside; } @@ -423,11 +348,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get Vertical (pseudo-border). Only applies to supervisor. * * @return PHPExcel_Style_Border - * @throws Exception + * @throws PHPExcel_Exception */ public function getVertical() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_vertical; } @@ -436,11 +361,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable * Get Horizontal (pseudo-border). Only applies to supervisor. * * @return PHPExcel_Style_Border - * @throws Exception + * @throws PHPExcel_Exception */ public function getHorizontal() { if (!$this->_isSupervisor) { - throw new Exception('Can only get pseudo-border for supervisor.'); + throw new PHPExcel_Exception('Can only get pseudo-border for supervisor.'); } return $this->_horizontal; } @@ -496,17 +421,4 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/Classes/PHPExcel/Style/Color.php b/Classes/PHPExcel/Style/Color.php index 89c919b..c8607d4 100644 --- a/Classes/PHPExcel/Style/Color.php +++ b/Classes/PHPExcel/Style/Color.php @@ -33,7 +33,7 @@ * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Color implements PHPExcel_IComparable +class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Colors */ const COLOR_BLACK = 'FF000000'; @@ -52,35 +52,21 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * * @var array */ - private static $_indexedColors; + protected static $_indexedColors; /** * ARGB - Alpha RGB * * @var string */ - private $_argb = NULL; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var mixed - */ - private $_parent; + protected $_argb = NULL; /** * Parent property name * * @var string */ - private $_parentPropertyName; + protected $_parentPropertyName; /** @@ -94,10 +80,10 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($pARGB = PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor = false, $isConditional = false) + public function __construct($pARGB = PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values if (!$isConditional) { @@ -119,16 +105,6 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable return $this; } - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -147,38 +123,6 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable } } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -210,7 +154,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Color */ public function applyFromArray($pStyles = NULL) { @@ -226,7 +170,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -494,17 +438,4 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/Classes/PHPExcel/Style/Fill.php b/Classes/PHPExcel/Style/Fill.php index 5817a43..f76b0e9 100644 --- a/Classes/PHPExcel/Style/Fill.php +++ b/Classes/PHPExcel/Style/Fill.php @@ -33,7 +33,7 @@ * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Fill implements PHPExcel_IComparable +class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Fill types */ const FILL_NONE = 'none'; @@ -63,49 +63,28 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * * @var string */ - private $_fillType = PHPExcel_Style_Fill::FILL_NONE; + protected $_fillType = PHPExcel_Style_Fill::FILL_NONE; /** * Rotation * * @var double */ - private $_rotation = 0; + protected $_rotation = 0; /** * Start color * * @var PHPExcel_Style_Color */ - private $_startColor; + protected $_startColor; /** * End color * * @var PHPExcel_Style_Color */ - private $_endColor; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_endColor; /** * Create a new PHPExcel_Style_Fill @@ -117,10 +96,10 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values if ($isConditional) { @@ -136,28 +115,6 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_Fill - */ - public function bindParent($parent) - { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -169,38 +126,6 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getFill(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -231,7 +156,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Fill */ public function applyFromArray($pStyles = null) { @@ -256,7 +181,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -330,7 +255,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * Set Start Color * * @param PHPExcel_Style_Color $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Fill */ public function setStartColor(PHPExcel_Style_Color $pValue = null) { @@ -359,7 +284,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable * Set End Color * * @param PHPExcel_Style_Color $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Fill */ public function setEndColor(PHPExcel_Style_Color $pValue = null) { @@ -393,17 +318,4 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/Classes/PHPExcel/Style/Font.php b/Classes/PHPExcel/Style/Font.php index c80e08d..a9f01fb 100644 --- a/Classes/PHPExcel/Style/Font.php +++ b/Classes/PHPExcel/Style/Font.php @@ -33,7 +33,7 @@ * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Font implements PHPExcel_IComparable +class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Underline types */ const UNDERLINE_NONE = 'none'; @@ -47,84 +47,63 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * * @var string */ - private $_name = 'Calibri'; + protected $_name = 'Calibri'; /** * Font Size * * @var float */ - private $_size = 11; + protected $_size = 11; /** * Bold * * @var boolean */ - private $_bold = false; + protected $_bold = FALSE; /** * Italic * * @var boolean */ - private $_italic = false; + protected $_italic = FALSE; /** * Superscript * * @var boolean */ - private $_superScript = false; + protected $_superScript = FALSE; /** * Subscript * * @var boolean */ - private $_subScript = false; + protected $_subScript = FALSE; /** * Underline * * @var string */ - private $_underline = self::UNDERLINE_NONE; + protected $_underline = self::UNDERLINE_NONE; /** * Strikethrough * * @var boolean */ - private $_strikethrough = false; + protected $_strikethrough = FALSE; /** * Foreground color * * @var PHPExcel_Style_Color */ - private $_color; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_color; /** * Create a new PHPExcel_Style_Font @@ -136,10 +115,10 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values if ($isConditional) { @@ -161,27 +140,6 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_Font - */ - public function bindParent($parent) - { - $this->_parent = $parent; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -193,38 +151,6 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getFont(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -242,12 +168,12 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * * $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray( * array( - * 'name' => 'Arial', - * 'bold' => true, - * 'italic' => false, + * 'name' => 'Arial', + * 'bold' => TRUE, + * 'italic' => FALSE, * 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE, - * 'strike' => false, - * 'color' => array( + * 'strike' => FALSE, + * 'color' => array( * 'rgb' => '808080' * ) * ) @@ -255,7 +181,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Font */ public function applyFromArray($pStyles = null) { @@ -292,7 +218,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -501,7 +427,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * Set Underline * * @param string|boolean $pValue PHPExcel_Style_Font underline type - * If a boolean is passed, then true equates to UNDERLINE_SINGLE, + * If a boolean is passed, then TRUE equates to UNDERLINE_SINGLE, * false equates to UNDERLINE_NONE * @return PHPExcel_Style_Font */ @@ -520,27 +446,6 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable return $this; } - /** - * Get Striketrough - * - * @deprecated Use getStrikethrough() instead. - * @return boolean - */ - public function getStriketrough() { - return $this->getStrikethrough(); - } - - /** - * Set Striketrough - * - * @deprecated Use setStrikethrough() instead. - * @param boolean $pValue - * @return PHPExcel_Style_Font - */ - public function setStriketrough($pValue = false) { - return $this->setStrikethrough($pValue); - } - /** * Get Strikethrough * @@ -585,7 +490,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable * Set Color * * @param PHPExcel_Style_Color $pValue - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Font */ public function setColor(PHPExcel_Style_Color $pValue = null) { @@ -624,17 +529,4 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } } diff --git a/Classes/PHPExcel/Style/NumberFormat.php b/Classes/PHPExcel/Style/NumberFormat.php index 613dcae..4b899f9 100644 --- a/Classes/PHPExcel/Style/NumberFormat.php +++ b/Classes/PHPExcel/Style/NumberFormat.php @@ -33,7 +33,7 @@ * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable +class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /* Pre-defined formats */ const FORMAT_GENERAL = 'General'; @@ -80,49 +80,28 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable * * @var array */ - private static $_builtInFormats; + protected static $_builtInFormats; /** * Excel built-in number formats (flipped, for faster lookups) * * @var array */ - private static $_flippedBuiltInFormats; + protected static $_flippedBuiltInFormats; /** * Format Code * * @var string */ - private $_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; + protected $_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; /** * Built-in format Code * * @var string */ - private $_builtInFormatCode = 0; - - /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; + protected $_builtInFormatCode = 0; /** * Create a new PHPExcel_Style_NumberFormat @@ -134,37 +113,16 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); if ($isConditional) { $this->_formatCode = NULL; } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_NumberFormat - */ - public function bindParent($parent) - { - $this->_parent = $parent; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -176,38 +134,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getNumberFormat(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -231,7 +157,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_NumberFormat */ public function applyFromArray($pStyles = null) @@ -245,7 +171,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -443,21 +369,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() - { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } - /** * Search/replace values to convert Excel date/time format masks to PHP format masks * diff --git a/Classes/PHPExcel/Style/Protection.php b/Classes/PHPExcel/Style/Protection.php index 477742b..67e0bdd 100644 --- a/Classes/PHPExcel/Style/Protection.php +++ b/Classes/PHPExcel/Style/Protection.php @@ -33,7 +33,7 @@ * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Style_Protection implements PHPExcel_IComparable +class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { /** Protection styles */ const PROTECTION_INHERIT = 'inherit'; @@ -45,37 +45,16 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable * * @var string */ - private $_locked; + protected $_locked; /** * Hidden * * @var string */ - private $_hidden; + protected $_hidden; /** - * Parent Borders - * - * @var _parentPropertyName string - */ - private $_parentPropertyName; - - /** - * Supervisor? - * - * @var boolean - */ - private $_isSupervisor; - - /** - * Parent. Only used for supervisor - * - * @var PHPExcel_Style - */ - private $_parent; - - /** * Create a new PHPExcel_Style_Protection * * @param boolean $isSupervisor Flag indicating if this is a supervisor or not @@ -85,10 +64,10 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) { // Supervisor? - $this->_isSupervisor = $isSupervisor; + parent::__construct($isSupervisor); // Initialise values if (!$isConditional) { @@ -97,28 +76,6 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable } } - /** - * Bind parent. Only used for supervisor - * - * @param PHPExcel_Style $parent - * @return PHPExcel_Style_Protection - */ - public function bindParent($parent) - { - $this->_parent = $parent; - return $this; - } - - /** - * Is this a supervisor or a real style component? - * - * @return boolean - */ - public function getIsSupervisor() - { - return $this->_isSupervisor; - } - /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor @@ -130,38 +87,6 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable return $this->_parent->getSharedComponent()->getProtection(); } - /** - * Get the currently active sheet. Only used for supervisor - * - * @return PHPExcel_Worksheet - */ - public function getActiveSheet() - { - return $this->_parent->getActiveSheet(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getSelectedCells() - { - return $this->getActiveSheet()->getSelectedCells(); - } - - /** - * Get the currently active cell coordinate in currently active sheet. - * Only used for supervisor - * - * @return string E.g. 'A1' - */ - public function getActiveCell() - { - return $this->getActiveSheet()->getActiveCell(); - } - /** * Build style array from subcomponents * @@ -177,27 +102,32 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable * Apply styles from array * * - * $objPHPExcel->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray( array('locked' => true, 'hidden' => false) ); + * $objPHPExcel->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray( + * array( + * 'locked' => TRUE, + * 'hidden' => FALSE + * ) + * ); * * * @param array $pStyles Array containing style information - * @throws Exception + * @throws PHPExcel_Exception * @return PHPExcel_Style_Protection */ - public function applyFromArray($pStyles = null) { + public function applyFromArray($pStyles = NULL) { if (is_array($pStyles)) { if ($this->_isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - if (array_key_exists('locked', $pStyles)) { + if (isset($pStyles['locked'])) { $this->setLocked($pStyles['locked']); } - if (array_key_exists('hidden', $pStyles)) { + if (isset($pStyles['hidden'])) { $this->setHidden($pStyles['hidden']); } } } else { - throw new Exception("Invalid style array passed."); + throw new PHPExcel_Exception("Invalid style array passed."); } return $this; } @@ -274,17 +204,4 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable ); } - /** - * Implement PHP __clone to create a deep clone, not just a shallow copy. - */ - public function __clone() { - $vars = get_object_vars($this); - foreach ($vars as $key => $value) { - if ((is_object($value)) && ($key != '_parent')) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } }