Refactoring of style classes to use an abstract supervisor
This commit is contained in:
parent
133959a971
commit
163a9ca5b9
|
@ -107,13 +107,11 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
|
|
||||||
$testCurrentIndex = 0;
|
$testCurrentIndex = 0;
|
||||||
foreach($datasetLabels as $i => $datasetLabel) {
|
foreach($datasetLabels as $i => $datasetLabel) {
|
||||||
array_reverse($datasetLabel);
|
|
||||||
|
|
||||||
if (is_array($datasetLabel)) {
|
if (is_array($datasetLabel)) {
|
||||||
if ($rotation == 'bar') {
|
if ($rotation == 'bar') {
|
||||||
$datasetLabel = array_reverse($datasetLabel);
|
|
||||||
$datasetLabels[$i] = implode(" ",$datasetLabel);
|
$datasetLabels[$i] = implode(" ",$datasetLabel);
|
||||||
} else {
|
} else {
|
||||||
|
$datasetLabel = array_reverse($datasetLabel);
|
||||||
$datasetLabels[$i] = implode("\n",$datasetLabel);
|
$datasetLabels[$i] = implode("\n",$datasetLabel);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,77 +33,63 @@
|
||||||
* @package PHPExcel_Style
|
* @package PHPExcel_Style
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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
|
* Font
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Font
|
* @var PHPExcel_Style_Font
|
||||||
*/
|
*/
|
||||||
private $_font;
|
protected $_font;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill
|
* Fill
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Fill
|
* @var PHPExcel_Style_Fill
|
||||||
*/
|
*/
|
||||||
private $_fill;
|
protected $_fill;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Borders
|
* Borders
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Borders
|
* @var PHPExcel_Style_Borders
|
||||||
*/
|
*/
|
||||||
private $_borders;
|
protected $_borders;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alignment
|
* Alignment
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Alignment
|
* @var PHPExcel_Style_Alignment
|
||||||
*/
|
*/
|
||||||
private $_alignment;
|
protected $_alignment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number Format
|
* Number Format
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_NumberFormat
|
* @var PHPExcel_Style_NumberFormat
|
||||||
*/
|
*/
|
||||||
private $_numberFormat;
|
protected $_numberFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conditional styles
|
* Conditional styles
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Conditional[]
|
* @var PHPExcel_Style_Conditional[]
|
||||||
*/
|
*/
|
||||||
private $_conditionalStyles;
|
protected $_conditionalStyles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protection
|
* Protection
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Protection
|
* @var PHPExcel_Style_Protection
|
||||||
*/
|
*/
|
||||||
private $_protection;
|
protected $_protection;
|
||||||
|
|
||||||
/**
|
|
||||||
* Style supervisor?
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private $_isSupervisor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parent. Only used for style supervisor
|
|
||||||
*
|
|
||||||
* @var PHPExcel
|
|
||||||
*/
|
|
||||||
private $_parent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of style in collection. Only used for real style.
|
* Index of style in collection. Only used for real style.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_index;
|
protected $_index;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Style
|
* 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.
|
* Get the shared style component for the currently active cell in currently active sheet.
|
||||||
* Only used for style supervisor
|
* Only used for style supervisor
|
||||||
|
@ -182,38 +146,6 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||||
return $this->_parent->getCellXfByIndex($xfIndex);
|
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
|
* Get parent. Only used for style supervisor
|
||||||
*
|
*
|
||||||
|
@ -668,17 +600,4 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||||
$this->_index = $pValue;
|
$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* @package PHPExcel_Style
|
* @package PHPExcel_Style
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/* Horizontal alignment styles */
|
||||||
const HORIZONTAL_GENERAL = 'general';
|
const HORIZONTAL_GENERAL = 'general';
|
||||||
|
@ -54,63 +54,42 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
protected $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vertical
|
* Vertical
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
protected $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text rotation
|
* Text rotation
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_textRotation = 0;
|
protected $_textRotation = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap text
|
* Wrap text
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_wrapText = false;
|
protected $_wrapText = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shrink to fit
|
* Shrink to fit
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_shrinkToFit = false;
|
protected $_shrinkToFit = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indent - only possible with horizontal alignment left and right
|
* Indent - only possible with horizontal alignment left and right
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_indent = 0;
|
protected $_indent = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_Alignment
|
* 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
|
* Leave this value at default unless you understand exactly what
|
||||||
* its ramifications are
|
* its ramifications are
|
||||||
*/
|
*/
|
||||||
public function __construct($isSupervisor = false, $isConditional = false)
|
public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
|
||||||
{
|
{
|
||||||
// Supervisor?
|
// Supervisor?
|
||||||
$this->_isSupervisor = $isSupervisor;
|
parent::__construct($isSupervisor);
|
||||||
|
|
||||||
if ($isConditional) {
|
if ($isConditional) {
|
||||||
$this->_horizontal = NULL;
|
$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.
|
* Get the shared style component for the currently active cell in currently active sheet.
|
||||||
* Only used for style supervisor
|
* Only used for style supervisor
|
||||||
|
@ -167,38 +124,6 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||||
return $this->_parent->getSharedComponent()->getAlignment();
|
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
|
* Build style array from subcomponents
|
||||||
*
|
*
|
||||||
|
@ -219,41 +144,42 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||||
* 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
* 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
||||||
* 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
* 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
||||||
* 'rotation' => 0,
|
* 'rotation' => 0,
|
||||||
* 'wrap' => true
|
* 'wrap' => TRUE
|
||||||
* )
|
* )
|
||||||
* );
|
* );
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param array $pStyles Array containing style information
|
* @param array $pStyles Array containing style information
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Alignment
|
* @return PHPExcel_Style_Alignment
|
||||||
*/
|
*/
|
||||||
public function applyFromArray($pStyles = null) {
|
public function applyFromArray($pStyles = NULL) {
|
||||||
if (is_array($pStyles)) {
|
if (is_array($pStyles)) {
|
||||||
if ($this->_isSupervisor) {
|
if ($this->_isSupervisor) {
|
||||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
$this->getActiveSheet()->getStyle($this->getSelectedCells())
|
||||||
|
->applyFromArray($this->getStyleArray($pStyles));
|
||||||
} else {
|
} else {
|
||||||
if (array_key_exists('horizontal', $pStyles)) {
|
if (isset($pStyles['horizontal'])) {
|
||||||
$this->setHorizontal($pStyles['horizontal']);
|
$this->setHorizontal($pStyles['horizontal']);
|
||||||
}
|
}
|
||||||
if (array_key_exists('vertical', $pStyles)) {
|
if (isset($pStyles['vertical'])) {
|
||||||
$this->setVertical($pStyles['vertical']);
|
$this->setVertical($pStyles['vertical']);
|
||||||
}
|
}
|
||||||
if (array_key_exists('rotation', $pStyles)) {
|
if (isset($pStyles['rotation'])) {
|
||||||
$this->setTextRotation($pStyles['rotation']);
|
$this->setTextRotation($pStyles['rotation']);
|
||||||
}
|
}
|
||||||
if (array_key_exists('wrap', $pStyles)) {
|
if (isset($pStyles['wrap'])) {
|
||||||
$this->setWrapText($pStyles['wrap']);
|
$this->setWrapText($pStyles['wrap']);
|
||||||
}
|
}
|
||||||
if (array_key_exists('shrinkToFit', $pStyles)) {
|
if (isset($pStyles['shrinkToFit'])) {
|
||||||
$this->setShrinkToFit($pStyles['shrinkToFit']);
|
$this->setShrinkToFit($pStyles['shrinkToFit']);
|
||||||
}
|
}
|
||||||
if (array_key_exists('indent', $pStyles)) {
|
if (isset($pStyles['indent'])) {
|
||||||
$this->setIndent($pStyles['indent']);
|
$this->setIndent($pStyles['indent']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Invalid style array passed.");
|
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +265,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||||
* Set TextRotation
|
* Set TextRotation
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Alignment
|
* @return PHPExcel_Style_Alignment
|
||||||
*/
|
*/
|
||||||
public function setTextRotation($pValue = 0) {
|
public function setTextRotation($pValue = 0) {
|
||||||
|
@ -357,7 +283,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||||
$this->_textRotation = $pValue;
|
$this->_textRotation = $pValue;
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
return $this;
|
||||||
|
@ -381,9 +307,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_Style_Alignment
|
* @return PHPExcel_Style_Alignment
|
||||||
*/
|
*/
|
||||||
public function setWrapText($pValue = false) {
|
public function setWrapText($pValue = FALSE) {
|
||||||
if ($pValue == '') {
|
if ($pValue == '') {
|
||||||
$pValue = false;
|
$pValue = FALSE;
|
||||||
}
|
}
|
||||||
if ($this->_isSupervisor) {
|
if ($this->_isSupervisor) {
|
||||||
$styleArray = $this->getStyleArray(array('wrap' => $pValue));
|
$styleArray = $this->getStyleArray(array('wrap' => $pValue));
|
||||||
|
@ -412,9 +338,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_Style_Alignment
|
* @return PHPExcel_Style_Alignment
|
||||||
*/
|
*/
|
||||||
public function setShrinkToFit($pValue = false) {
|
public function setShrinkToFit($pValue = FALSE) {
|
||||||
if ($pValue == '') {
|
if ($pValue == '') {
|
||||||
$pValue = false;
|
$pValue = FALSE;
|
||||||
}
|
}
|
||||||
if ($this->_isSupervisor) {
|
if ($this->_isSupervisor) {
|
||||||
$styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue));
|
$styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue));
|
||||||
|
@ -445,7 +371,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||||
*/
|
*/
|
||||||
public function setIndent($pValue = 0) {
|
public function setIndent($pValue = 0) {
|
||||||
if ($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
|
$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* @package PHPExcel_Style
|
* @package PHPExcel_Style
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/* Border style */
|
||||||
const BORDER_NONE = 'none';
|
const BORDER_NONE = 'none';
|
||||||
|
@ -56,35 +56,21 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_borderStyle = PHPExcel_Style_Border::BORDER_NONE;
|
protected $_borderStyle = PHPExcel_Style_Border::BORDER_NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Border color
|
* Border color
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Color
|
* @var PHPExcel_Style_Color
|
||||||
*/
|
*/
|
||||||
private $_color;
|
protected $_color;
|
||||||
|
|
||||||
/**
|
|
||||||
* Supervisor?
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private $_isSupervisor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parent. Only used for supervisor
|
|
||||||
*
|
|
||||||
* @var PHPExcel_Style_Borders
|
|
||||||
*/
|
|
||||||
private $_parent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent property name
|
* Parent property name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_parentPropertyName;
|
protected $_parentPropertyName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Style_Border
|
* 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
|
* Leave this value at default unless you understand exactly what
|
||||||
* its ramifications are
|
* its ramifications are
|
||||||
*/
|
*/
|
||||||
public function __construct($isSupervisor = false, $isConditional = false)
|
public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
|
||||||
{
|
{
|
||||||
// Supervisor?
|
// Supervisor?
|
||||||
$this->_isSupervisor = $isSupervisor;
|
parent::__construct($isSupervisor);
|
||||||
|
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor);
|
$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;
|
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.
|
* Get the shared style component for the currently active cell in currently active sheet.
|
||||||
* Only used for style supervisor
|
* Only used for style supervisor
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Style_Border
|
* @return PHPExcel_Style_Border
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function getSharedComponent()
|
public function getSharedComponent()
|
||||||
{
|
{
|
||||||
|
@ -149,64 +125,22 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||||
case '_inside':
|
case '_inside':
|
||||||
case '_outline':
|
case '_outline':
|
||||||
case '_vertical':
|
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;
|
break;
|
||||||
|
|
||||||
case '_bottom':
|
case '_bottom':
|
||||||
return $this->_parent->getSharedComponent()->getBottom();
|
return $this->_parent->getSharedComponent()->getBottom(); break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_diagonal':
|
case '_diagonal':
|
||||||
return $this->_parent->getSharedComponent()->getDiagonal();
|
return $this->_parent->getSharedComponent()->getDiagonal(); break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_left':
|
case '_left':
|
||||||
return $this->_parent->getSharedComponent()->getLeft();
|
return $this->_parent->getSharedComponent()->getLeft(); break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_right':
|
case '_right':
|
||||||
return $this->_parent->getSharedComponent()->getRight();
|
return $this->_parent->getSharedComponent()->getRight(); break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_top':
|
case '_top':
|
||||||
return $this->_parent->getSharedComponent()->getTop();
|
return $this->_parent->getSharedComponent()->getTop(); break;
|
||||||
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
|
* Build style array from subcomponents
|
||||||
*
|
*
|
||||||
|
@ -217,44 +151,25 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||||
{
|
{
|
||||||
switch ($this->_parentPropertyName) {
|
switch ($this->_parentPropertyName) {
|
||||||
case '_allBorders':
|
case '_allBorders':
|
||||||
$key = 'allborders';
|
$key = 'allborders'; break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_bottom':
|
case '_bottom':
|
||||||
$key = 'bottom';
|
$key = 'bottom'; break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_diagonal':
|
case '_diagonal':
|
||||||
$key = 'diagonal';
|
$key = 'diagonal'; break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_horizontal':
|
case '_horizontal':
|
||||||
$key = 'horizontal';
|
$key = 'horizontal'; break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_inside':
|
case '_inside':
|
||||||
$key = 'inside';
|
$key = 'inside'; break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_left':
|
case '_left':
|
||||||
$key = 'left';
|
$key = 'left'; break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_outline':
|
case '_outline':
|
||||||
$key = 'outline';
|
$key = 'outline'; break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_right':
|
case '_right':
|
||||||
$key = 'right';
|
$key = 'right'; break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_top':
|
case '_top':
|
||||||
$key = 'top';
|
$key = 'top'; break;
|
||||||
break;
|
|
||||||
|
|
||||||
case '_vertical':
|
case '_vertical':
|
||||||
$key = 'vertical';
|
$key = 'vertical'; break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $this->_parent->getStyleArray(array($key => $array));
|
return $this->_parent->getStyleArray(array($key => $array));
|
||||||
}
|
}
|
||||||
|
@ -274,7 +189,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param array $pStyles Array containing style information
|
* @param array $pStyles Array containing style information
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Border
|
* @return PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
public function applyFromArray($pStyles = null) {
|
public function applyFromArray($pStyles = null) {
|
||||||
|
@ -282,15 +197,15 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||||
if ($this->_isSupervisor) {
|
if ($this->_isSupervisor) {
|
||||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||||
} else {
|
} else {
|
||||||
if (array_key_exists('style', $pStyles)) {
|
if (isset($pStyles['style'])) {
|
||||||
$this->setBorderStyle($pStyles['style']);
|
$this->setBorderStyle($pStyles['style']);
|
||||||
}
|
}
|
||||||
if (array_key_exists('color', $pStyles)) {
|
if (isset($pStyles['color'])) {
|
||||||
$this->getColor()->applyFromArray($pStyles['color']);
|
$this->getColor()->applyFromArray($pStyles['color']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Invalid style array passed.");
|
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -310,13 +225,17 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||||
/**
|
/**
|
||||||
* Set Border style
|
* 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
|
* @return PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
|
public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
|
||||||
|
|
||||||
if ($pValue == '') {
|
if (empty($pValue)) {
|
||||||
$pValue = PHPExcel_Style_Border::BORDER_NONE;
|
$pValue = PHPExcel_Style_Border::BORDER_NONE;
|
||||||
|
} elseif(is_bool($pValue) && $pValue) {
|
||||||
|
$pValue = PHPExcel_Style_Border::BORDER_MEDIUM;
|
||||||
}
|
}
|
||||||
if ($this->_isSupervisor) {
|
if ($this->_isSupervisor) {
|
||||||
$styleArray = $this->getStyleArray(array('style' => $pValue));
|
$styleArray = $this->getStyleArray(array('style' => $pValue));
|
||||||
|
@ -340,7 +259,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||||
* Set Border Color
|
* Set Border Color
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Style_Color $pValue
|
* @param PHPExcel_Style_Color $pValue
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Border
|
* @return PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
public function setColor(PHPExcel_Style_Color $pValue = null) {
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* @package PHPExcel_Style
|
* @package PHPExcel_Style
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/* Diagonal directions */
|
||||||
const DIAGONAL_NONE = 0;
|
const DIAGONAL_NONE = 0;
|
||||||
|
@ -46,98 +46,77 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_left;
|
protected $_left;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Right
|
* Right
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_right;
|
protected $_right;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top
|
* Top
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_top;
|
protected $_top;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bottom
|
* Bottom
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_bottom;
|
protected $_bottom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diagonal
|
* Diagonal
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_diagonal;
|
protected $_diagonal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DiagonalDirection
|
* DiagonalDirection
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_diagonalDirection;
|
protected $_diagonalDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All borders psedo-border. Only applies to supervisor.
|
* All borders psedo-border. Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_allBorders;
|
protected $_allBorders;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outline psedo-border. Only applies to supervisor.
|
* Outline psedo-border. Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_outline;
|
protected $_outline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inside psedo-border. Only applies to supervisor.
|
* Inside psedo-border. Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_inside;
|
protected $_inside;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vertical pseudo-border. Only applies to supervisor.
|
* Vertical pseudo-border. Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_vertical;
|
protected $_vertical;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Horizontal pseudo-border. Only applies to supervisor.
|
* Horizontal pseudo-border. Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Border
|
* @var PHPExcel_Style_Border
|
||||||
*/
|
*/
|
||||||
private $_horizontal;
|
protected $_horizontal;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_Borders
|
* 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
|
* Leave this value at default unless you understand exactly what
|
||||||
* its ramifications are
|
* its ramifications are
|
||||||
*/
|
*/
|
||||||
public function __construct($isSupervisor = false, $isConditional = false)
|
public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
|
||||||
{
|
{
|
||||||
// Supervisor?
|
// Supervisor?
|
||||||
$this->_isSupervisor = $isSupervisor;
|
parent::__construct($isSupervisor);
|
||||||
|
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_left = new PHPExcel_Style_Border($isSupervisor, $isConditional);
|
$this->_left = new PHPExcel_Style_Border($isSupervisor, $isConditional);
|
||||||
|
@ -165,11 +144,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
// Specially for supervisor
|
// Specially for supervisor
|
||||||
if ($isSupervisor) {
|
if ($isSupervisor) {
|
||||||
// Initialize pseudo-borders
|
// Initialize pseudo-borders
|
||||||
$this->_allBorders = new PHPExcel_Style_Border(true);
|
$this->_allBorders = new PHPExcel_Style_Border(TRUE);
|
||||||
$this->_outline = new PHPExcel_Style_Border(true);
|
$this->_outline = new PHPExcel_Style_Border(TRUE);
|
||||||
$this->_inside = new PHPExcel_Style_Border(true);
|
$this->_inside = new PHPExcel_Style_Border(TRUE);
|
||||||
$this->_vertical = new PHPExcel_Style_Border(true);
|
$this->_vertical = new PHPExcel_Style_Border(TRUE);
|
||||||
$this->_horizontal = new PHPExcel_Style_Border(true);
|
$this->_horizontal = new PHPExcel_Style_Border(TRUE);
|
||||||
|
|
||||||
// bind parent if we are a supervisor
|
// bind parent if we are a supervisor
|
||||||
$this->_left->bindParent($this, '_left');
|
$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.
|
* Get the shared style component for the currently active cell in currently active sheet.
|
||||||
* Only used for style supervisor
|
* Only used for style supervisor
|
||||||
|
@ -218,38 +175,6 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
return $this->_parent->getSharedComponent()->getBorders();
|
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
|
* Build style array from subcomponents
|
||||||
*
|
*
|
||||||
|
@ -296,7 +221,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param array $pStyles Array containing style information
|
* @param array $pStyles Array containing style information
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Borders
|
* @return PHPExcel_Style_Borders
|
||||||
*/
|
*/
|
||||||
public function applyFromArray($pStyles = null) {
|
public function applyFromArray($pStyles = null) {
|
||||||
|
@ -330,7 +255,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Invalid style array passed.");
|
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -384,11 +309,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
* Get AllBorders (pseudo-border). Only applies to supervisor.
|
* Get AllBorders (pseudo-border). Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Style_Border
|
* @return PHPExcel_Style_Border
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function getAllBorders() {
|
public function getAllBorders() {
|
||||||
if (!$this->_isSupervisor) {
|
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;
|
return $this->_allBorders;
|
||||||
}
|
}
|
||||||
|
@ -397,11 +322,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
* Get Outline (pseudo-border). Only applies to supervisor.
|
* Get Outline (pseudo-border). Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function getOutline() {
|
public function getOutline() {
|
||||||
if (!$this->_isSupervisor) {
|
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;
|
return $this->_outline;
|
||||||
}
|
}
|
||||||
|
@ -410,11 +335,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
* Get Inside (pseudo-border). Only applies to supervisor.
|
* Get Inside (pseudo-border). Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function getInside() {
|
public function getInside() {
|
||||||
if (!$this->_isSupervisor) {
|
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;
|
return $this->_inside;
|
||||||
}
|
}
|
||||||
|
@ -423,11 +348,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
* Get Vertical (pseudo-border). Only applies to supervisor.
|
* Get Vertical (pseudo-border). Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Style_Border
|
* @return PHPExcel_Style_Border
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function getVertical() {
|
public function getVertical() {
|
||||||
if (!$this->_isSupervisor) {
|
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;
|
return $this->_vertical;
|
||||||
}
|
}
|
||||||
|
@ -436,11 +361,11 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||||
* Get Horizontal (pseudo-border). Only applies to supervisor.
|
* Get Horizontal (pseudo-border). Only applies to supervisor.
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Style_Border
|
* @return PHPExcel_Style_Border
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function getHorizontal() {
|
public function getHorizontal() {
|
||||||
if (!$this->_isSupervisor) {
|
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;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* @package PHPExcel_Style
|
* @package PHPExcel_Style
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/* Colors */
|
||||||
const COLOR_BLACK = 'FF000000';
|
const COLOR_BLACK = 'FF000000';
|
||||||
|
@ -52,35 +52,21 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $_indexedColors;
|
protected static $_indexedColors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ARGB - Alpha RGB
|
* ARGB - Alpha RGB
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_argb = NULL;
|
protected $_argb = NULL;
|
||||||
|
|
||||||
/**
|
|
||||||
* Supervisor?
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private $_isSupervisor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parent. Only used for supervisor
|
|
||||||
*
|
|
||||||
* @var mixed
|
|
||||||
*/
|
|
||||||
private $_parent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent property name
|
* Parent property name
|
||||||
*
|
*
|
||||||
* @var string
|
* @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
|
* Leave this value at default unless you understand exactly what
|
||||||
* its ramifications are
|
* 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?
|
// Supervisor?
|
||||||
$this->_isSupervisor = $isSupervisor;
|
parent::__construct($isSupervisor);
|
||||||
|
|
||||||
// Initialise values
|
// Initialise values
|
||||||
if (!$isConditional) {
|
if (!$isConditional) {
|
||||||
|
@ -119,16 +105,6 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||||
return $this;
|
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.
|
* Get the shared style component for the currently active cell in currently active sheet.
|
||||||
* Only used for style supervisor
|
* 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
|
* Build style array from subcomponents
|
||||||
*
|
*
|
||||||
|
@ -210,7 +154,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param array $pStyles Array containing style information
|
* @param array $pStyles Array containing style information
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Color
|
* @return PHPExcel_Style_Color
|
||||||
*/
|
*/
|
||||||
public function applyFromArray($pStyles = NULL) {
|
public function applyFromArray($pStyles = NULL) {
|
||||||
|
@ -226,7 +170,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Invalid style array passed.");
|
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||||
}
|
}
|
||||||
return $this;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* @package PHPExcel_Style
|
* @package PHPExcel_Style
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/* Fill types */
|
||||||
const FILL_NONE = 'none';
|
const FILL_NONE = 'none';
|
||||||
|
@ -63,49 +63,28 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_fillType = PHPExcel_Style_Fill::FILL_NONE;
|
protected $_fillType = PHPExcel_Style_Fill::FILL_NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotation
|
* Rotation
|
||||||
*
|
*
|
||||||
* @var double
|
* @var double
|
||||||
*/
|
*/
|
||||||
private $_rotation = 0;
|
protected $_rotation = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start color
|
* Start color
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Color
|
* @var PHPExcel_Style_Color
|
||||||
*/
|
*/
|
||||||
private $_startColor;
|
protected $_startColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End color
|
* End color
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Color
|
* @var PHPExcel_Style_Color
|
||||||
*/
|
*/
|
||||||
private $_endColor;
|
protected $_endColor;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_Fill
|
* 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
|
* Leave this value at default unless you understand exactly what
|
||||||
* its ramifications are
|
* its ramifications are
|
||||||
*/
|
*/
|
||||||
public function __construct($isSupervisor = false, $isConditional = false)
|
public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
|
||||||
{
|
{
|
||||||
// Supervisor?
|
// Supervisor?
|
||||||
$this->_isSupervisor = $isSupervisor;
|
parent::__construct($isSupervisor);
|
||||||
|
|
||||||
// Initialise values
|
// Initialise values
|
||||||
if ($isConditional) {
|
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.
|
* Get the shared style component for the currently active cell in currently active sheet.
|
||||||
* Only used for style supervisor
|
* Only used for style supervisor
|
||||||
|
@ -169,38 +126,6 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||||
return $this->_parent->getSharedComponent()->getFill();
|
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
|
* Build style array from subcomponents
|
||||||
*
|
*
|
||||||
|
@ -231,7 +156,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param array $pStyles Array containing style information
|
* @param array $pStyles Array containing style information
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Fill
|
* @return PHPExcel_Style_Fill
|
||||||
*/
|
*/
|
||||||
public function applyFromArray($pStyles = null) {
|
public function applyFromArray($pStyles = null) {
|
||||||
|
@ -256,7 +181,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Invalid style array passed.");
|
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -330,7 +255,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||||
* Set Start Color
|
* Set Start Color
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Style_Color $pValue
|
* @param PHPExcel_Style_Color $pValue
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Fill
|
* @return PHPExcel_Style_Fill
|
||||||
*/
|
*/
|
||||||
public function setStartColor(PHPExcel_Style_Color $pValue = null) {
|
public function setStartColor(PHPExcel_Style_Color $pValue = null) {
|
||||||
|
@ -359,7 +284,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||||
* Set End Color
|
* Set End Color
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Style_Color $pValue
|
* @param PHPExcel_Style_Color $pValue
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Fill
|
* @return PHPExcel_Style_Fill
|
||||||
*/
|
*/
|
||||||
public function setEndColor(PHPExcel_Style_Color $pValue = null) {
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* @package PHPExcel_Style
|
* @package PHPExcel_Style
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/* Underline types */
|
||||||
const UNDERLINE_NONE = 'none';
|
const UNDERLINE_NONE = 'none';
|
||||||
|
@ -47,84 +47,63 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_name = 'Calibri';
|
protected $_name = 'Calibri';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Font Size
|
* Font Size
|
||||||
*
|
*
|
||||||
* @var float
|
* @var float
|
||||||
*/
|
*/
|
||||||
private $_size = 11;
|
protected $_size = 11;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bold
|
* Bold
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_bold = false;
|
protected $_bold = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Italic
|
* Italic
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_italic = false;
|
protected $_italic = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Superscript
|
* Superscript
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_superScript = false;
|
protected $_superScript = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscript
|
* Subscript
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_subScript = false;
|
protected $_subScript = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Underline
|
* Underline
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_underline = self::UNDERLINE_NONE;
|
protected $_underline = self::UNDERLINE_NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strikethrough
|
* Strikethrough
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_strikethrough = false;
|
protected $_strikethrough = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Foreground color
|
* Foreground color
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Color
|
* @var PHPExcel_Style_Color
|
||||||
*/
|
*/
|
||||||
private $_color;
|
protected $_color;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_Font
|
* 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
|
* Leave this value at default unless you understand exactly what
|
||||||
* its ramifications are
|
* its ramifications are
|
||||||
*/
|
*/
|
||||||
public function __construct($isSupervisor = false, $isConditional = false)
|
public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
|
||||||
{
|
{
|
||||||
// Supervisor?
|
// Supervisor?
|
||||||
$this->_isSupervisor = $isSupervisor;
|
parent::__construct($isSupervisor);
|
||||||
|
|
||||||
// Initialise values
|
// Initialise values
|
||||||
if ($isConditional) {
|
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.
|
* Get the shared style component for the currently active cell in currently active sheet.
|
||||||
* Only used for style supervisor
|
* Only used for style supervisor
|
||||||
|
@ -193,38 +151,6 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||||
return $this->_parent->getSharedComponent()->getFont();
|
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
|
* Build style array from subcomponents
|
||||||
*
|
*
|
||||||
|
@ -242,12 +168,12 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||||
* <code>
|
* <code>
|
||||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray(
|
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray(
|
||||||
* array(
|
* array(
|
||||||
* 'name' => 'Arial',
|
* 'name' => 'Arial',
|
||||||
* 'bold' => true,
|
* 'bold' => TRUE,
|
||||||
* 'italic' => false,
|
* 'italic' => FALSE,
|
||||||
* 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE,
|
* 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE,
|
||||||
* 'strike' => false,
|
* 'strike' => FALSE,
|
||||||
* 'color' => array(
|
* 'color' => array(
|
||||||
* 'rgb' => '808080'
|
* 'rgb' => '808080'
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
|
@ -255,7 +181,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param array $pStyles Array containing style information
|
* @param array $pStyles Array containing style information
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Font
|
* @return PHPExcel_Style_Font
|
||||||
*/
|
*/
|
||||||
public function applyFromArray($pStyles = null) {
|
public function applyFromArray($pStyles = null) {
|
||||||
|
@ -292,7 +218,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Invalid style array passed.");
|
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -501,7 +427,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||||
* Set Underline
|
* Set Underline
|
||||||
*
|
*
|
||||||
* @param string|boolean $pValue PHPExcel_Style_Font underline type
|
* @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
|
* false equates to UNDERLINE_NONE
|
||||||
* @return PHPExcel_Style_Font
|
* @return PHPExcel_Style_Font
|
||||||
*/
|
*/
|
||||||
|
@ -520,27 +446,6 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||||
return $this;
|
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
|
* Get Strikethrough
|
||||||
*
|
*
|
||||||
|
@ -585,7 +490,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||||
* Set Color
|
* Set Color
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Style_Color $pValue
|
* @param PHPExcel_Style_Color $pValue
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Font
|
* @return PHPExcel_Style_Font
|
||||||
*/
|
*/
|
||||||
public function setColor(PHPExcel_Style_Color $pValue = null) {
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* @package PHPExcel_Style
|
* @package PHPExcel_Style
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/* Pre-defined formats */
|
||||||
const FORMAT_GENERAL = 'General';
|
const FORMAT_GENERAL = 'General';
|
||||||
|
@ -80,49 +80,28 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $_builtInFormats;
|
protected static $_builtInFormats;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel built-in number formats (flipped, for faster lookups)
|
* Excel built-in number formats (flipped, for faster lookups)
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $_flippedBuiltInFormats;
|
protected static $_flippedBuiltInFormats;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format Code
|
* Format Code
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
|
protected $_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Built-in format Code
|
* Built-in format Code
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_builtInFormatCode = 0;
|
protected $_builtInFormatCode = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_NumberFormat
|
* 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
|
* Leave this value at default unless you understand exactly what
|
||||||
* its ramifications are
|
* its ramifications are
|
||||||
*/
|
*/
|
||||||
public function __construct($isSupervisor = false, $isConditional = false)
|
public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
|
||||||
{
|
{
|
||||||
// Supervisor?
|
// Supervisor?
|
||||||
$this->_isSupervisor = $isSupervisor;
|
parent::__construct($isSupervisor);
|
||||||
|
|
||||||
if ($isConditional) {
|
if ($isConditional) {
|
||||||
$this->_formatCode = NULL;
|
$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.
|
* Get the shared style component for the currently active cell in currently active sheet.
|
||||||
* Only used for style supervisor
|
* Only used for style supervisor
|
||||||
|
@ -176,38 +134,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||||
return $this->_parent->getSharedComponent()->getNumberFormat();
|
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
|
* Build style array from subcomponents
|
||||||
*
|
*
|
||||||
|
@ -231,7 +157,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param array $pStyles Array containing style information
|
* @param array $pStyles Array containing style information
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_NumberFormat
|
* @return PHPExcel_Style_NumberFormat
|
||||||
*/
|
*/
|
||||||
public function applyFromArray($pStyles = null)
|
public function applyFromArray($pStyles = null)
|
||||||
|
@ -245,7 +171,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Invalid style array passed.");
|
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||||
}
|
}
|
||||||
return $this;
|
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
|
* Search/replace values to convert Excel date/time format masks to PHP format masks
|
||||||
*
|
*
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* @package PHPExcel_Style
|
* @package PHPExcel_Style
|
||||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/** Protection styles */
|
||||||
const PROTECTION_INHERIT = 'inherit';
|
const PROTECTION_INHERIT = 'inherit';
|
||||||
|
@ -45,37 +45,16 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_locked;
|
protected $_locked;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hidden
|
* Hidden
|
||||||
*
|
*
|
||||||
* @var string
|
* @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
|
* Create a new PHPExcel_Style_Protection
|
||||||
*
|
*
|
||||||
* @param boolean $isSupervisor Flag indicating if this is a supervisor or not
|
* @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
|
* Leave this value at default unless you understand exactly what
|
||||||
* its ramifications are
|
* its ramifications are
|
||||||
*/
|
*/
|
||||||
public function __construct($isSupervisor = false, $isConditional = false)
|
public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
|
||||||
{
|
{
|
||||||
// Supervisor?
|
// Supervisor?
|
||||||
$this->_isSupervisor = $isSupervisor;
|
parent::__construct($isSupervisor);
|
||||||
|
|
||||||
// Initialise values
|
// Initialise values
|
||||||
if (!$isConditional) {
|
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.
|
* Get the shared style component for the currently active cell in currently active sheet.
|
||||||
* Only used for style supervisor
|
* Only used for style supervisor
|
||||||
|
@ -130,38 +87,6 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
|
||||||
return $this->_parent->getSharedComponent()->getProtection();
|
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
|
* Build style array from subcomponents
|
||||||
*
|
*
|
||||||
|
@ -177,27 +102,32 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
|
||||||
* Apply styles from array
|
* Apply styles from array
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray( array('locked' => true, 'hidden' => false) );
|
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray(
|
||||||
|
* array(
|
||||||
|
* 'locked' => TRUE,
|
||||||
|
* 'hidden' => FALSE
|
||||||
|
* )
|
||||||
|
* );
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param array $pStyles Array containing style information
|
* @param array $pStyles Array containing style information
|
||||||
* @throws Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Style_Protection
|
* @return PHPExcel_Style_Protection
|
||||||
*/
|
*/
|
||||||
public function applyFromArray($pStyles = null) {
|
public function applyFromArray($pStyles = NULL) {
|
||||||
if (is_array($pStyles)) {
|
if (is_array($pStyles)) {
|
||||||
if ($this->_isSupervisor) {
|
if ($this->_isSupervisor) {
|
||||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||||
} else {
|
} else {
|
||||||
if (array_key_exists('locked', $pStyles)) {
|
if (isset($pStyles['locked'])) {
|
||||||
$this->setLocked($pStyles['locked']);
|
$this->setLocked($pStyles['locked']);
|
||||||
}
|
}
|
||||||
if (array_key_exists('hidden', $pStyles)) {
|
if (isset($pStyles['hidden'])) {
|
||||||
$this->setHidden($pStyles['hidden']);
|
$this->setHidden($pStyles['hidden']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Invalid style array passed.");
|
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||||
}
|
}
|
||||||
return $this;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue