Minor case-sensitivity bugfix to getCell when cell reference is a worksheet!cell

Work on PSR2 Coding standards
This commit is contained in:
MarkBaker 2015-05-04 23:36:20 +01:00
parent e83c359c7c
commit b3d2db79ea
13 changed files with 3126 additions and 3130 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Style
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{ {
/** /**
@ -40,63 +32,63 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
* *
* @var PHPExcel_Style_Font * @var PHPExcel_Style_Font
*/ */
protected $_font; protected $font;
/** /**
* Fill * Fill
* *
* @var PHPExcel_Style_Fill * @var PHPExcel_Style_Fill
*/ */
protected $_fill; protected $fill;
/** /**
* Borders * Borders
* *
* @var PHPExcel_Style_Borders * @var PHPExcel_Style_Borders
*/ */
protected $_borders; protected $borders;
/** /**
* Alignment * Alignment
* *
* @var PHPExcel_Style_Alignment * @var PHPExcel_Style_Alignment
*/ */
protected $_alignment; protected $alignment;
/** /**
* Number Format * Number Format
* *
* @var PHPExcel_Style_NumberFormat * @var PHPExcel_Style_NumberFormat
*/ */
protected $_numberFormat; protected $numberFormat;
/** /**
* Conditional styles * Conditional styles
* *
* @var PHPExcel_Style_Conditional[] * @var PHPExcel_Style_Conditional[]
*/ */
protected $_conditionalStyles; protected $conditionalStyles;
/** /**
* Protection * Protection
* *
* @var PHPExcel_Style_Protection * @var PHPExcel_Style_Protection
*/ */
protected $_protection; protected $protection;
/** /**
* Index of style in collection. Only used for real style. * Index of style in collection. Only used for real style.
* *
* @var int * @var int
*/ */
protected $_index; protected $index;
/** /**
* Use Quote Prefix when displaying in cell editor. Only used for real style. * Use Quote Prefix when displaying in cell editor. Only used for real style.
* *
* @var boolean * @var boolean
*/ */
protected $_quotePrefix = false; protected $quotePrefix = false;
/** /**
* Create a new PHPExcel_Style * Create a new PHPExcel_Style
@ -111,25 +103,25 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
public function __construct($isSupervisor = false, $isConditional = false) public function __construct($isSupervisor = false, $isConditional = false)
{ {
// Supervisor? // Supervisor?
$this->_isSupervisor = $isSupervisor; $this->isSupervisor = $isSupervisor;
// Initialise values // Initialise values
$this->_conditionalStyles = array(); $this->conditionalStyles = array();
$this->_font = new PHPExcel_Style_Font($isSupervisor, $isConditional); $this->font = new PHPExcel_Style_Font($isSupervisor, $isConditional);
$this->_fill = new PHPExcel_Style_Fill($isSupervisor, $isConditional); $this->fill = new PHPExcel_Style_Fill($isSupervisor, $isConditional);
$this->_borders = new PHPExcel_Style_Borders($isSupervisor, $isConditional); $this->borders = new PHPExcel_Style_Borders($isSupervisor, $isConditional);
$this->_alignment = new PHPExcel_Style_Alignment($isSupervisor, $isConditional); $this->alignment = new PHPExcel_Style_Alignment($isSupervisor, $isConditional);
$this->_numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor, $isConditional); $this->numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor, $isConditional);
$this->_protection = new PHPExcel_Style_Protection($isSupervisor, $isConditional); $this->protection = new PHPExcel_Style_Protection($isSupervisor, $isConditional);
// bind parent if we are a supervisor // bind parent if we are a supervisor
if ($isSupervisor) { if ($isSupervisor) {
$this->_font->bindParent($this); $this->font->bindParent($this);
$this->_fill->bindParent($this); $this->fill->bindParent($this);
$this->_borders->bindParent($this); $this->borders->bindParent($this);
$this->_alignment->bindParent($this); $this->alignment->bindParent($this);
$this->_numberFormat->bindParent($this); $this->numberFormat->bindParent($this);
$this->_protection->bindParent($this); $this->protection->bindParent($this);
} }
} }
@ -150,7 +142,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
$xfIndex = 0; $xfIndex = 0;
} }
return $this->_parent->getCellXfByIndex($xfIndex); return $this->parent->getCellXfByIndex($xfIndex);
} }
/** /**
@ -160,7 +152,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getParent() public function getParent()
{ {
return $this->_parent; return $this->parent;
} }
/** /**
@ -217,7 +209,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
public function applyFromArray($pStyles = null, $pAdvanced = true) public function applyFromArray($pStyles = null, $pAdvanced = true)
{ {
if (is_array($pStyles)) { if (is_array($pStyles)) {
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$pRange = $this->getSelectedCells(); $pRange = $this->getSelectedCells();
@ -248,9 +240,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
} }
// ADVANCED MODE: // ADVANCED MODE:
if ($pAdvanced && isset($pStyles['borders'])) { if ($pAdvanced && isset($pStyles['borders'])) {
// 'allborders' is a shorthand property for 'outline' and 'inside' and // 'allborders' is a shorthand property for 'outline' and 'inside' and
// it applies to components that have not been set explicitly // it applies to components that have not been set explicitly
if (isset($pStyles['borders']['allborders'])) { if (isset($pStyles['borders']['allborders'])) {
@ -261,7 +251,6 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
} }
unset($pStyles['borders']['allborders']); // not needed any more unset($pStyles['borders']['allborders']); // not needed any more
} }
// 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left' // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left'
// it applies to components that have not been set explicitly // it applies to components that have not been set explicitly
if (isset($pStyles['borders']['outline'])) { if (isset($pStyles['borders']['outline'])) {
@ -272,7 +261,6 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
} }
unset($pStyles['borders']['outline']); // not needed any more unset($pStyles['borders']['outline']); // not needed any more
} }
// 'inside' is a shorthand property for 'vertical' and 'horizontal' // 'inside' is a shorthand property for 'vertical' and 'horizontal'
// it applies to components that have not been set explicitly // it applies to components that have not been set explicitly
if (isset($pStyles['borders']['inside'])) { if (isset($pStyles['borders']['inside'])) {
@ -283,7 +271,6 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
} }
unset($pStyles['borders']['inside']); // not needed any more unset($pStyles['borders']['inside']); // not needed any more
} }
// width and height characteristics of selection, 1, 2, or 3 (for 3 or more) // width and height characteristics of selection, 1, 2, or 3 (for 3 or more)
$xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3); $xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3);
$yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3); $yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3);
@ -294,34 +281,28 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
$colStart = ($x == 3) ? $colStart = ($x == 3) ?
PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]) PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0])
: PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1); : PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1);
// end column index for region // end column index for region
$colEnd = ($x == 1) ? $colEnd = ($x == 1) ?
PHPExcel_Cell::stringFromColumnIndex($rangeStart[0]) PHPExcel_Cell::stringFromColumnIndex($rangeStart[0])
: PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x); : PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x);
for ($y = 1; $y <= $yMax; ++$y) { for ($y = 1; $y <= $yMax; ++$y) {
// which edges are touching the region // which edges are touching the region
$edges = array(); $edges = array();
// are we at left edge
if ($x == 1) { if ($x == 1) {
// are we at left edge
$edges[] = 'left'; $edges[] = 'left';
} }
// are we at right edge
if ($x == $xMax) { if ($x == $xMax) {
// are we at right edge
$edges[] = 'right'; $edges[] = 'right';
} }
// are we at top edge?
if ($y == 1) { if ($y == 1) {
// are we at top edge?
$edges[] = 'top'; $edges[] = 'top';
} }
// are we at bottom edge?
if ($y == $yMax) { if ($y == $yMax) {
// are we at bottom edge?
$edges[] = 'bottom'; $edges[] = 'bottom';
} }
@ -375,7 +356,6 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
} }
// SIMPLE MODE: // SIMPLE MODE:
// Selection type, inspect // Selection type, inspect
if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) { if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) {
$selectionType = 'COLUMN'; $selectionType = 'COLUMN';
@ -393,7 +373,6 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
$oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true; $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true;
} }
break; break;
case 'ROW': case 'ROW':
$oldXfIndexes = array(); $oldXfIndexes = array();
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
@ -404,7 +383,6 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
} }
} }
break; break;
case 'CELL': case 'CELL':
$oldXfIndexes = array(); $oldXfIndexes = array();
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
@ -483,7 +461,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
$this->getProtection()->applyFromArray($pStyles['protection']); $this->getProtection()->applyFromArray($pStyles['protection']);
} }
if (array_key_exists('quotePrefix', $pStyles)) { if (array_key_exists('quotePrefix', $pStyles)) {
$this->_quotePrefix = $pStyles['quotePrefix']; $this->quotePrefix = $pStyles['quotePrefix'];
} }
} }
} else { } else {
@ -499,7 +477,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getFill() public function getFill()
{ {
return $this->_fill; return $this->fill;
} }
/** /**
@ -509,7 +487,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getFont() public function getFont()
{ {
return $this->_font; return $this->font;
} }
/** /**
@ -520,7 +498,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function setFont(PHPExcel_Style_Font $font) public function setFont(PHPExcel_Style_Font $font)
{ {
$this->_font = $font; $this->font = $font;
return $this; return $this;
} }
@ -531,7 +509,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getBorders() public function getBorders()
{ {
return $this->_borders; return $this->borders;
} }
/** /**
@ -541,7 +519,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getAlignment() public function getAlignment()
{ {
return $this->_alignment; return $this->alignment;
} }
/** /**
@ -551,7 +529,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getNumberFormat() public function getNumberFormat()
{ {
return $this->_numberFormat; return $this->numberFormat;
} }
/** /**
@ -585,7 +563,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getProtection() public function getProtection()
{ {
return $this->_protection; return $this->protection;
} }
/** /**
@ -595,10 +573,10 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getQuotePrefix() public function getQuotePrefix()
{ {
if ($this->_isSupervisor) { if ($this->isSupervisor) {
return $this->getSharedComponent()->getQuotePrefix(); return $this->getSharedComponent()->getQuotePrefix();
} }
return $this->_quotePrefix; return $this->quotePrefix;
} }
/** /**
@ -611,11 +589,11 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
if ($pValue == '') { if ($pValue == '') {
$pValue = false; $pValue = false;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = array('quotePrefix' => $pValue); $styleArray = array('quotePrefix' => $pValue);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_quotePrefix = (boolean) $pValue; $this->quotePrefix = (boolean) $pValue;
} }
return $this; return $this;
} }
@ -628,20 +606,20 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
public function getHashCode() public function getHashCode()
{ {
$hashConditionals = ''; $hashConditionals = '';
foreach ($this->_conditionalStyles as $conditional) { foreach ($this->conditionalStyles as $conditional) {
$hashConditionals .= $conditional->getHashCode(); $hashConditionals .= $conditional->getHashCode();
} }
return md5( return md5(
$this->_fill->getHashCode() $this->fill->getHashCode() .
. $this->_font->getHashCode() $this->font->getHashCode() .
. $this->_borders->getHashCode() $this->borders->getHashCode() .
. $this->_alignment->getHashCode() $this->alignment->getHashCode() .
. $this->_numberFormat->getHashCode() $this->numberFormat->getHashCode() .
. $hashConditionals $hashConditionals .
. $this->_protection->getHashCode() $this->protection->getHashCode() .
. ($this->_quotePrefix ? 't' : 'f') ($this->quotePrefix ? 't' : 'f') .
. __CLASS__ __CLASS__
); );
} }
@ -652,7 +630,7 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function getIndex() public function getIndex()
{ {
return $this->_index; return $this->index;
} }
/** /**
@ -662,7 +640,6 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp
*/ */
public function setIndex($pValue) public function setIndex($pValue)
{ {
$this->_index = $pValue; $this->index = $pValue;
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style_Alignment
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +24,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Style_Alignment
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{ {
/* Horizontal alignment styles */ /* Horizontal alignment styles */
@ -62,49 +53,49 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* *
* @var string * @var string
*/ */
protected $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; protected $horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
/** /**
* Vertical alignment * Vertical alignment
* *
* @var string * @var string
*/ */
protected $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; protected $vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
/** /**
* Text rotation * Text rotation
* *
* @var integer * @var integer
*/ */
protected $_textRotation = 0; protected $textRotation = 0;
/** /**
* Wrap text * Wrap text
* *
* @var boolean * @var boolean
*/ */
protected $_wrapText = FALSE; protected $wrapText = false;
/** /**
* Shrink to fit * Shrink to fit
* *
* @var boolean * @var boolean
*/ */
protected $_shrinkToFit = FALSE; protected $shrinkToFit = false;
/** /**
* Indent - only possible with horizontal alignment left and right * Indent - only possible with horizontal alignment left and right
* *
* @var integer * @var integer
*/ */
protected $_indent = 0; protected $indent = 0;
/** /**
* Read order * Read order
* *
* @var integer * @var integer
*/ */
protected $_readorder = 0; protected $readorder = 0;
/** /**
* Create a new PHPExcel_Style_Alignment * Create a new PHPExcel_Style_Alignment
@ -116,15 +107,15 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* 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?
parent::__construct($isSupervisor); parent::__construct($isSupervisor);
if ($isConditional) { if ($isConditional) {
$this->_horizontal = NULL; $this->horizontal = null;
$this->_vertical = NULL; $this->vertical = null;
$this->_textRotation = NULL; $this->textRotation = null;
} }
} }
@ -136,7 +127,7 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
*/ */
public function getSharedComponent() public function getSharedComponent()
{ {
return $this->_parent->getSharedComponent()->getAlignment(); return $this->parent->getSharedComponent()->getAlignment();
} }
/** /**
@ -168,9 +159,10 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* @throws PHPExcel_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()) $this->getActiveSheet()->getStyle($this->getSelectedCells())
->applyFromArray($this->getStyleArray($pStyles)); ->applyFromArray($this->getStyleArray($pStyles));
} else { } else {
@ -207,11 +199,12 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* *
* @return string * @return string
*/ */
public function getHorizontal() { public function getHorizontal()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getHorizontal(); return $this->getSharedComponent()->getHorizontal();
} }
return $this->_horizontal; return $this->horizontal;
} }
/** /**
@ -220,17 +213,17 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* @param string $pValue * @param string $pValue
* @return PHPExcel_Style_Alignment * @return PHPExcel_Style_Alignment
*/ */
public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) { public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; $pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('horizontal' => $pValue)); $styleArray = $this->getStyleArray(array('horizontal' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} } else {
else { $this->horizontal = $pValue;
$this->_horizontal = $pValue;
} }
return $this; return $this;
} }
@ -240,11 +233,12 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* *
* @return string * @return string
*/ */
public function getVertical() { public function getVertical()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getVertical(); return $this->getSharedComponent()->getVertical();
} }
return $this->_vertical; return $this->vertical;
} }
/** /**
@ -253,16 +247,17 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* @param string $pValue * @param string $pValue
* @return PHPExcel_Style_Alignment * @return PHPExcel_Style_Alignment
*/ */
public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM) { public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; $pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('vertical' => $pValue)); $styleArray = $this->getStyleArray(array('vertical' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_vertical = $pValue; $this->vertical = $pValue;
} }
return $this; return $this;
} }
@ -272,11 +267,12 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* *
* @return int * @return int
*/ */
public function getTextRotation() { public function getTextRotation()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getTextRotation(); return $this->getSharedComponent()->getTextRotation();
} }
return $this->_textRotation; return $this->textRotation;
} }
/** /**
@ -286,7 +282,8 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Style_Alignment * @return PHPExcel_Style_Alignment
*/ */
public function setTextRotation($pValue = 0) { public function setTextRotation($pValue = 0)
{
// Excel2007 value 255 => PHPExcel value -165 // Excel2007 value 255 => PHPExcel value -165
if ($pValue == 255) { if ($pValue == 255) {
$pValue = -165; $pValue = -165;
@ -294,11 +291,11 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
// Set rotation // Set rotation
if (($pValue >= -90 && $pValue <= 90) || $pValue == -165) { if (($pValue >= -90 && $pValue <= 90) || $pValue == -165) {
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('rotation' => $pValue)); $styleArray = $this->getStyleArray(array('rotation' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_textRotation = $pValue; $this->textRotation = $pValue;
} }
} else { } else {
throw new PHPExcel_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.");
@ -312,11 +309,12 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* *
* @return boolean * @return boolean
*/ */
public function getWrapText() { public function getWrapText()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getWrapText(); return $this->getSharedComponent()->getWrapText();
} }
return $this->_wrapText; return $this->wrapText;
} }
/** /**
@ -325,15 +323,16 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* @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));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_wrapText = $pValue; $this->wrapText = $pValue;
} }
return $this; return $this;
} }
@ -343,11 +342,12 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* *
* @return boolean * @return boolean
*/ */
public function getShrinkToFit() { public function getShrinkToFit()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getShrinkToFit(); return $this->getSharedComponent()->getShrinkToFit();
} }
return $this->_shrinkToFit; return $this->shrinkToFit;
} }
/** /**
@ -356,15 +356,16 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* @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));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_shrinkToFit = $pValue; $this->shrinkToFit = $pValue;
} }
return $this; return $this;
} }
@ -374,11 +375,12 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* *
* @return int * @return int
*/ */
public function getIndent() { public function getIndent()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getIndent(); return $this->getSharedComponent()->getIndent();
} }
return $this->_indent; return $this->indent;
} }
/** /**
@ -387,7 +389,8 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* @param int $pValue * @param int $pValue
* @return PHPExcel_Style_Alignment * @return PHPExcel_Style_Alignment
*/ */
public function setIndent($pValue = 0) { public function setIndent($pValue = 0)
{
if ($pValue > 0) { if ($pValue > 0) {
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && if ($this->getHorizontal() != self::HORIZONTAL_GENERAL &&
$this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_LEFT &&
@ -395,11 +398,11 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
$pValue = 0; // indent not supported $pValue = 0; // indent not supported
} }
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('indent' => $pValue)); $styleArray = $this->getStyleArray(array('indent' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_indent = $pValue; $this->indent = $pValue;
} }
return $this; return $this;
} }
@ -409,11 +412,12 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* *
* @return integer * @return integer
*/ */
public function getReadorder() { public function getReadorder()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getReadorder(); return $this->getSharedComponent()->getReadorder();
} }
return $this->_readorder; return $this->readorder;
} }
/** /**
@ -422,15 +426,16 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* @param int $pValue * @param int $pValue
* @return PHPExcel_Style_Alignment * @return PHPExcel_Style_Alignment
*/ */
public function setReadorder($pValue = 0) { public function setReadorder($pValue = 0)
{
if ($pValue < 0 || $pValue > 2) { if ($pValue < 0 || $pValue > 2) {
$pValue = 0; $pValue = 0;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('readorder' => $pValue)); $styleArray = $this->getStyleArray(array('readorder' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_readorder = $pValue; $this->readorder = $pValue;
} }
return $this; return $this;
} }
@ -440,20 +445,20 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getHashCode(); return $this->getSharedComponent()->getHashCode();
} }
return md5( return md5(
$this->_horizontal $this->horizontal .
. $this->_vertical $this->vertical .
. $this->_textRotation $this->textRotation .
. ($this->_wrapText ? 't' : 'f') ($this->wrapText ? 't' : 'f') .
. ($this->_shrinkToFit ? 't' : 'f') ($this->shrinkToFit ? 't' : 'f') .
. $this->_indent $this->indent .
. $this->_readorder $this->readorder .
. __CLASS__ __CLASS__
); );
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style_Border
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Style_Border
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{ {
/* Border style */ /* Border style */
@ -56,21 +48,21 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
* *
* @var string * @var string
*/ */
protected $_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
*/ */
protected $_color; protected $color;
/** /**
* Parent property name * Parent property name
* *
* @var string * @var string
*/ */
protected $_parentPropertyName; protected $parentPropertyName;
/** /**
* Create a new PHPExcel_Style_Border * Create a new PHPExcel_Style_Border
@ -82,17 +74,17 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
* 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?
parent::__construct($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);
// bind parent if we are a supervisor // bind parent if we are a supervisor
if ($isSupervisor) { if ($isSupervisor) {
$this->_color->bindParent($this, '_color'); $this->color->bindParent($this, 'color');
} }
} }
@ -103,10 +95,10 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
* @param string $parentPropertyName * @param string $parentPropertyName
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
*/ */
public function bindParent($parent, $parentPropertyName=NULL) public function bindParent($parent, $parentPropertyName = null)
{ {
$this->_parent = $parent; $this->parent = $parent;
$this->_parentPropertyName = $parentPropertyName; $this->parentPropertyName = $parentPropertyName;
return $this; return $this;
} }
@ -119,25 +111,24 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
*/ */
public function getSharedComponent() public function getSharedComponent()
{ {
switch ($this->_parentPropertyName) { switch ($this->parentPropertyName) {
case '_allBorders': case 'allBorders':
case '_horizontal': case 'horizontal':
case '_inside': case 'inside':
case '_outline': case 'outline':
case '_vertical': case 'vertical':
throw new PHPExcel_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(); break; return $this->parent->getSharedComponent()->getBottom();
case '_diagonal': case 'diagonal':
return $this->_parent->getSharedComponent()->getDiagonal(); break; return $this->parent->getSharedComponent()->getDiagonal();
case '_left': case 'left':
return $this->_parent->getSharedComponent()->getLeft(); break; return $this->parent->getSharedComponent()->getLeft();
case '_right': case 'right':
return $this->_parent->getSharedComponent()->getRight(); break; return $this->parent->getSharedComponent()->getRight();
case '_top': case 'top':
return $this->_parent->getSharedComponent()->getTop(); break; return $this->parent->getSharedComponent()->getTop();
} }
} }
@ -149,29 +140,21 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
*/ */
public function getStyleArray($array) public function getStyleArray($array)
{ {
switch ($this->_parentPropertyName) { switch ($this->parentPropertyName) {
case '_allBorders': case 'allBorders':
$key = 'allborders'; break; case 'bottom':
case '_bottom': case 'diagonal':
$key = 'bottom'; break; case 'horizontal':
case '_diagonal': case 'inside':
$key = 'diagonal'; break; case 'left':
case '_horizontal': case 'outline':
$key = 'horizontal'; break; case 'right':
case '_inside': case 'top':
$key = 'inside'; break; case 'vertical':
case '_left': $key = strtolower('vertical');
$key = 'left'; break; break;
case '_outline':
$key = 'outline'; break;
case '_right':
$key = 'right'; break;
case '_top':
$key = 'top'; break;
case '_vertical':
$key = 'vertical'; break;
} }
return $this->_parent->getStyleArray(array($key => $array)); return $this->parent->getStyleArray(array($key => $array));
} }
/** /**
@ -192,9 +175,10 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
*/ */
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 (isset($pStyles['style'])) { if (isset($pStyles['style'])) {
@ -215,11 +199,12 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
* *
* @return string * @return string
*/ */
public function getBorderStyle() { public function getBorderStyle()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getBorderStyle(); return $this->getSharedComponent()->getBorderStyle();
} }
return $this->_borderStyle; return $this->borderStyle;
} }
/** /**
@ -230,18 +215,19 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
* and TRUE to PHPExcel_Style_Border::BORDER_MEDIUM * 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 (empty($pValue)) { if (empty($pValue)) {
$pValue = PHPExcel_Style_Border::BORDER_NONE; $pValue = PHPExcel_Style_Border::BORDER_NONE;
} elseif (is_bool($pValue) && $pValue) { } elseif (is_bool($pValue) && $pValue) {
$pValue = PHPExcel_Style_Border::BORDER_MEDIUM; $pValue = PHPExcel_Style_Border::BORDER_MEDIUM;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('style' => $pValue)); $styleArray = $this->getStyleArray(array('style' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_borderStyle = $pValue; $this->borderStyle = $pValue;
} }
return $this; return $this;
} }
@ -251,8 +237,9 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
* *
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
public function getColor() { public function getColor()
return $this->_color; {
return $this->color;
} }
/** /**
@ -262,15 +249,16 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
* @throws PHPExcel_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)
{
// make sure parameter is a real color and not a supervisor // make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB())); $styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_color = $color; $this->color = $color;
} }
return $this; return $this;
} }
@ -280,15 +268,15 @@ class PHPExcel_Style_Border extends PHPExcel_Style_Supervisor implements PHPExce
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getHashCode(); return $this->getSharedComponent()->getHashCode();
} }
return md5( return md5(
$this->_borderStyle $this->borderStyle .
. $this->_color->getHashCode() $this->color->getHashCode() .
. __CLASS__ __CLASS__
); );
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style_Borders
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Style_Borders
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{ {
/* Diagonal directions */ /* Diagonal directions */
@ -46,77 +38,77 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* *
* @var PHPExcel_Style_Border * @var PHPExcel_Style_Border
*/ */
protected $_left; protected $left;
/** /**
* Right * Right
* *
* @var PHPExcel_Style_Border * @var PHPExcel_Style_Border
*/ */
protected $_right; protected $right;
/** /**
* Top * Top
* *
* @var PHPExcel_Style_Border * @var PHPExcel_Style_Border
*/ */
protected $_top; protected $top;
/** /**
* Bottom * Bottom
* *
* @var PHPExcel_Style_Border * @var PHPExcel_Style_Border
*/ */
protected $_bottom; protected $bottom;
/** /**
* Diagonal * Diagonal
* *
* @var PHPExcel_Style_Border * @var PHPExcel_Style_Border
*/ */
protected $_diagonal; protected $diagonal;
/** /**
* DiagonalDirection * DiagonalDirection
* *
* @var int * @var int
*/ */
protected $_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
*/ */
protected $_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
*/ */
protected $_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
*/ */
protected $_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
*/ */
protected $_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
*/ */
protected $_horizontal; protected $horizontal;
/** /**
* Create a new PHPExcel_Style_Borders * Create a new PHPExcel_Style_Borders
@ -128,39 +120,39 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* 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?
parent::__construct($isSupervisor); parent::__construct($isSupervisor);
// Initialise values // Initialise values
$this->_left = new PHPExcel_Style_Border($isSupervisor, $isConditional); $this->left = new PHPExcel_Style_Border($isSupervisor, $isConditional);
$this->_right = new PHPExcel_Style_Border($isSupervisor, $isConditional); $this->right = new PHPExcel_Style_Border($isSupervisor, $isConditional);
$this->_top = new PHPExcel_Style_Border($isSupervisor, $isConditional); $this->top = new PHPExcel_Style_Border($isSupervisor, $isConditional);
$this->_bottom = new PHPExcel_Style_Border($isSupervisor, $isConditional); $this->bottom = new PHPExcel_Style_Border($isSupervisor, $isConditional);
$this->_diagonal = new PHPExcel_Style_Border($isSupervisor, $isConditional); $this->diagonal = new PHPExcel_Style_Border($isSupervisor, $isConditional);
$this->_diagonalDirection = PHPExcel_Style_Borders::DIAGONAL_NONE; $this->diagonalDirection = PHPExcel_Style_Borders::DIAGONAL_NONE;
// 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');
$this->_right->bindParent($this, '_right'); $this->right->bindParent($this, 'right');
$this->_top->bindParent($this, '_top'); $this->top->bindParent($this, 'top');
$this->_bottom->bindParent($this, '_bottom'); $this->bottom->bindParent($this, 'bottom');
$this->_diagonal->bindParent($this, '_diagonal'); $this->diagonal->bindParent($this, 'diagonal');
$this->_allBorders->bindParent($this, '_allBorders'); $this->allBorders->bindParent($this, 'allBorders');
$this->_outline->bindParent($this, '_outline'); $this->outline->bindParent($this, 'outline');
$this->_inside->bindParent($this, '_inside'); $this->inside->bindParent($this, 'inside');
$this->_vertical->bindParent($this, '_vertical'); $this->vertical->bindParent($this, 'vertical');
$this->_horizontal->bindParent($this, '_horizontal'); $this->horizontal->bindParent($this, 'horizontal');
} }
} }
@ -172,7 +164,7 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
*/ */
public function getSharedComponent() public function getSharedComponent()
{ {
return $this->_parent->getSharedComponent()->getBorders(); return $this->parent->getSharedComponent()->getBorders();
} }
/** /**
@ -224,9 +216,10 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Style_Borders * @return PHPExcel_Style_Borders
*/ */
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('left', $pStyles)) { if (array_key_exists('left', $pStyles)) {
@ -265,8 +258,9 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* *
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
*/ */
public function getLeft() { public function getLeft()
return $this->_left; {
return $this->left;
} }
/** /**
@ -274,8 +268,9 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* *
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
*/ */
public function getRight() { public function getRight()
return $this->_right; {
return $this->right;
} }
/** /**
@ -283,8 +278,9 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* *
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
*/ */
public function getTop() { public function getTop()
return $this->_top; {
return $this->top;
} }
/** /**
@ -292,8 +288,9 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* *
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
*/ */
public function getBottom() { public function getBottom()
return $this->_bottom; {
return $this->bottom;
} }
/** /**
@ -301,8 +298,9 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* *
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
*/ */
public function getDiagonal() { public function getDiagonal()
return $this->_diagonal; {
return $this->diagonal;
} }
/** /**
@ -311,11 +309,12 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function getAllBorders() { public function getAllBorders()
if (!$this->_isSupervisor) { {
if (!$this->isSupervisor) {
throw new PHPExcel_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;
} }
/** /**
@ -324,11 +323,12 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* @return boolean * @return boolean
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function getOutline() { public function getOutline()
if (!$this->_isSupervisor) { {
if (!$this->isSupervisor) {
throw new PHPExcel_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;
} }
/** /**
@ -337,11 +337,12 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* @return boolean * @return boolean
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function getInside() { public function getInside()
if (!$this->_isSupervisor) { {
if (!$this->isSupervisor) {
throw new PHPExcel_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;
} }
/** /**
@ -350,11 +351,12 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function getVertical() { public function getVertical()
if (!$this->_isSupervisor) { {
if (!$this->isSupervisor) {
throw new PHPExcel_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;
} }
/** /**
@ -363,11 +365,12 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* @return PHPExcel_Style_Border * @return PHPExcel_Style_Border
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function getHorizontal() { public function getHorizontal()
if (!$this->_isSupervisor) { {
if (!$this->isSupervisor) {
throw new PHPExcel_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;
} }
/** /**
@ -375,11 +378,12 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* *
* @return int * @return int
*/ */
public function getDiagonalDirection() { public function getDiagonalDirection()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getDiagonalDirection(); return $this->getSharedComponent()->getDiagonalDirection();
} }
return $this->_diagonalDirection; return $this->diagonalDirection;
} }
/** /**
@ -388,15 +392,16 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* @param int $pValue * @param int $pValue
* @return PHPExcel_Style_Borders * @return PHPExcel_Style_Borders
*/ */
public function setDiagonalDirection($pValue = PHPExcel_Style_Borders::DIAGONAL_NONE) { public function setDiagonalDirection($pValue = PHPExcel_Style_Borders::DIAGONAL_NONE)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = PHPExcel_Style_Borders::DIAGONAL_NONE; $pValue = PHPExcel_Style_Borders::DIAGONAL_NONE;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('diagonaldirection' => $pValue)); $styleArray = $this->getStyleArray(array('diagonaldirection' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_diagonalDirection = $pValue; $this->diagonalDirection = $pValue;
} }
return $this; return $this;
} }
@ -406,19 +411,19 @@ class PHPExcel_Style_Borders extends PHPExcel_Style_Supervisor implements PHPExc
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getHashcode(); return $this->getSharedComponent()->getHashcode();
} }
return md5( return md5(
$this->getLeft()->getHashCode() $this->getLeft()->getHashCode() .
. $this->getRight()->getHashCode() $this->getRight()->getHashCode() .
. $this->getTop()->getHashCode() $this->getTop()->getHashCode() .
. $this->getBottom()->getHashCode() $this->getBottom()->getHashCode() .
. $this->getDiagonal()->getHashCode() $this->getDiagonal()->getHashCode() .
. $this->getDiagonalDirection() $this->getDiagonalDirection() .
. __CLASS__ __CLASS__
); );
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style_Color
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Style_Color
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{ {
/* Colors */ /* Colors */
@ -52,21 +44,21 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* *
* @var array * @var array
*/ */
protected static $_indexedColors; protected static $indexedColors;
/** /**
* ARGB - Alpha RGB * ARGB - Alpha RGB
* *
* @var string * @var string
*/ */
protected $_argb = NULL; protected $argb = null;
/** /**
* Parent property name * Parent property name
* *
* @var string * @var string
*/ */
protected $_parentPropertyName; protected $parentPropertyName;
/** /**
@ -80,14 +72,14 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* 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?
parent::__construct($isSupervisor); parent::__construct($isSupervisor);
// Initialise values // Initialise values
if (!$isConditional) { if (!$isConditional) {
$this->_argb = $pARGB; $this->argb = $pARGB;
} }
} }
@ -98,10 +90,10 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* @param string $parentPropertyName * @param string $parentPropertyName
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
public function bindParent($parent, $parentPropertyName=NULL) public function bindParent($parent, $parentPropertyName = null)
{ {
$this->_parent = $parent; $this->parent = $parent;
$this->_parentPropertyName = $parentPropertyName; $this->parentPropertyName = $parentPropertyName;
return $this; return $this;
} }
@ -113,13 +105,13 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
*/ */
public function getSharedComponent() public function getSharedComponent()
{ {
switch ($this->_parentPropertyName) { switch ($this->parentPropertyName) {
case '_endColor': case 'endColor':
return $this->_parent->getSharedComponent()->getEndColor(); break; return $this->parent->getSharedComponent()->getEndColor();
case '_color': case 'color':
return $this->_parent->getSharedComponent()->getColor(); break; return $this->parent->getSharedComponent()->getColor();
case '_startColor': case 'startColor':
return $this->_parent->getSharedComponent()->getStartColor(); break; return $this->parent->getSharedComponent()->getStartColor();
} }
} }
@ -131,19 +123,19 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
*/ */
public function getStyleArray($array) public function getStyleArray($array)
{ {
switch ($this->_parentPropertyName) { switch ($this->parentPropertyName) {
case '_endColor': case 'endColor':
$key = 'endcolor'; $key = 'endcolor';
break; break;
case '_color': case 'color':
$key = 'color'; $key = 'color';
break; break;
case '_startColor': case 'startColor':
$key = 'startcolor'; $key = 'startcolor';
break; break;
} }
return $this->_parent->getStyleArray(array($key => $array)); return $this->parent->getStyleArray(array($key => $array));
} }
/** /**
@ -157,9 +149,10 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
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('rgb', $pStyles)) { if (array_key_exists('rgb', $pStyles)) {
@ -180,11 +173,12 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* *
* @return string * @return string
*/ */
public function getARGB() { public function getARGB()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getARGB(); return $this->getSharedComponent()->getARGB();
} }
return $this->_argb; return $this->argb;
} }
/** /**
@ -193,15 +187,16 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* @param string $pValue * @param string $pValue
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
public function setARGB($pValue = PHPExcel_Style_Color::COLOR_BLACK) { public function setARGB($pValue = PHPExcel_Style_Color::COLOR_BLACK)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = PHPExcel_Style_Color::COLOR_BLACK; $pValue = PHPExcel_Style_Color::COLOR_BLACK;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('argb' => $pValue)); $styleArray = $this->getStyleArray(array('argb' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_argb = $pValue; $this->argb = $pValue;
} }
return $this; return $this;
} }
@ -211,11 +206,12 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* *
* @return string * @return string
*/ */
public function getRGB() { public function getRGB()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getRGB(); return $this->getSharedComponent()->getRGB();
} }
return substr($this->_argb, 2); return substr($this->argb, 2);
} }
/** /**
@ -224,15 +220,16 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* @param string $pValue RGB value * @param string $pValue RGB value
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
public function setRGB($pValue = '000000') { public function setRGB($pValue = '000000')
{
if ($pValue == '') { if ($pValue == '') {
$pValue = '000000'; $pValue = '000000';
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('argb' => 'FF' . $pValue)); $styleArray = $this->getStyleArray(array('argb' => 'FF' . $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_argb = 'FF' . $pValue; $this->argb = 'FF' . $pValue;
} }
return $this; return $this;
} }
@ -247,10 +244,12 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* decimal value * decimal value
* @return string The extracted colour component * @return string The extracted colour component
*/ */
private static function _getColourComponent($RGB,$offset,$hex=TRUE) { private static function getColourComponent($RGB, $offset, $hex = true)
{
$colour = substr($RGB, $offset, 2); $colour = substr($RGB, $offset, 2);
if (!$hex) if (!$hex) {
$colour = hexdec($colour); $colour = hexdec($colour);
}
return $colour; return $colour;
} }
@ -262,8 +261,9 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* decimal value * decimal value
* @return string The red colour component * @return string The red colour component
*/ */
public static function getRed($RGB,$hex=TRUE) { public static function getRed($RGB, $hex = true)
return self::_getColourComponent($RGB, strlen($RGB) - 6, $hex); {
return self::getColourComponent($RGB, strlen($RGB) - 6, $hex);
} }
/** /**
@ -274,8 +274,9 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* decimal value * decimal value
* @return string The green colour component * @return string The green colour component
*/ */
public static function getGreen($RGB,$hex=TRUE) { public static function getGreen($RGB, $hex = true)
return self::_getColourComponent($RGB, strlen($RGB) - 4, $hex); {
return self::getColourComponent($RGB, strlen($RGB) - 4, $hex);
} }
/** /**
@ -286,8 +287,9 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* decimal value * decimal value
* @return string The blue colour component * @return string The blue colour component
*/ */
public static function getBlue($RGB,$hex=TRUE) { public static function getBlue($RGB, $hex = true)
return self::_getColourComponent($RGB, strlen($RGB) - 2, $hex); {
return self::getColourComponent($RGB, strlen($RGB) - 2, $hex);
} }
/** /**
@ -297,12 +299,13 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* @param float $adjustPercentage The percentage by which to adjust the colour as a float from -1 to 1 * @param float $adjustPercentage The percentage by which to adjust the colour as a float from -1 to 1
* @return string The adjusted colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE) * @return string The adjusted colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)
*/ */
public static function changeBrightness($hex, $adjustPercentage) { public static function changeBrightness($hex, $adjustPercentage)
{
$rgba = (strlen($hex) == 8); $rgba = (strlen($hex) == 8);
$red = self::getRed($hex, FALSE); $red = self::getRed($hex, false);
$green = self::getGreen($hex, FALSE); $green = self::getGreen($hex, false);
$blue = self::getBlue($hex, FALSE); $blue = self::getBlue($hex, false);
if ($adjustPercentage > 0) { if ($adjustPercentage > 0) {
$red += (255 - $red) * $adjustPercentage; $red += (255 - $red) * $adjustPercentage;
$green += (255 - $green) * $adjustPercentage; $green += (255 - $green) * $adjustPercentage;
@ -313,14 +316,24 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
$blue += $blue * $adjustPercentage; $blue += $blue * $adjustPercentage;
} }
if ($red < 0) $red = 0; if ($red < 0) {
elseif ($red > 255) $red = 255; $red = 0;
if ($green < 0) $green = 0; } elseif ($red > 255) {
elseif ($green > 255) $green = 255; $red = 255;
if ($blue < 0) $blue = 0; }
elseif ($blue > 255) $blue = 255; if ($green < 0) {
$green = 0;
} elseif ($green > 255) {
$green = 255;
}
if ($blue < 0) {
$blue = 0;
} elseif ($blue > 255) {
$blue = 255;
}
$rgb = strtoupper( str_pad(dechex($red), 2, '0', 0) . $rgb = strtoupper(
str_pad(dechex($red), 2, '0', 0) .
str_pad(dechex($green), 2, '0', 0) . str_pad(dechex($green), 2, '0', 0) .
str_pad(dechex($blue), 2, '0', 0) str_pad(dechex($blue), 2, '0', 0)
); );
@ -335,13 +348,14 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* should be returned if the indexed colour doesn't exist * should be returned if the indexed colour doesn't exist
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
public static function indexedColor($pIndex, $background=FALSE) { public static function indexedColor($pIndex, $background = false)
{
// Clean parameter // Clean parameter
$pIndex = intval($pIndex); $pIndex = intval($pIndex);
// Indexed colors // Indexed colors
if (is_null(self::$_indexedColors)) { if (is_null(self::$indexedColors)) {
self::$_indexedColors = array( self::$indexedColors = array(
1 => 'FF000000', // System Colour #1 - Black 1 => 'FF000000', // System Colour #1 - Black
2 => 'FFFFFFFF', // System Colour #2 - White 2 => 'FFFFFFFF', // System Colour #2 - White
3 => 'FFFF0000', // System Colour #3 - Red 3 => 'FFFF0000', // System Colour #3 - Red
@ -401,14 +415,14 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
); );
} }
if (array_key_exists($pIndex, self::$_indexedColors)) { if (array_key_exists($pIndex, self::$indexedColors)) {
return new PHPExcel_Style_Color(self::$_indexedColors[$pIndex]); return new PHPExcel_Style_Color(self::$indexedColors[$pIndex]);
} }
if ($background) { if ($background) {
return new PHPExcel_Style_Color('FFFFFFFF'); return new PHPExcel_Style_Color(self::COLOR_WHITE);
} }
return new PHPExcel_Style_Color('FF000000'); return new PHPExcel_Style_Color(self::COLOR_BLACK);
} }
/** /**
@ -416,14 +430,14 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getHashCode(); return $this->getSharedComponent()->getHashCode();
} }
return md5( return md5(
$this->_argb $this->argb .
. __CLASS__ __CLASS__
); );
} }
} }

View File

@ -60,35 +60,35 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* *
* @var int * @var int
*/ */
private $_conditionType; private $conditionType;
/** /**
* Operator type * Operator type
* *
* @var int * @var int
*/ */
private $_operatorType; private $operatorType;
/** /**
* Text * Text
* *
* @var string * @var string
*/ */
private $_text; private $text;
/** /**
* Condition * Condition
* *
* @var string[] * @var string[]
*/ */
private $_condition = array(); private $condition = array();
/** /**
* Style * Style
* *
* @var PHPExcel_Style * @var PHPExcel_Style
*/ */
private $_style; private $style;
/** /**
* Create a new PHPExcel_Style_Conditional * Create a new PHPExcel_Style_Conditional
@ -96,11 +96,11 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->_conditionType = PHPExcel_Style_Conditional::CONDITION_NONE; $this->conditionType = PHPExcel_Style_Conditional::CONDITION_NONE;
$this->_operatorType = PHPExcel_Style_Conditional::OPERATOR_NONE; $this->operatorType = PHPExcel_Style_Conditional::OPERATOR_NONE;
$this->_text = null; $this->text = null;
$this->_condition = array(); $this->condition = array();
$this->_style = new PHPExcel_Style(FALSE, TRUE); $this->style = new PHPExcel_Style(false, true);
} }
/** /**
@ -108,8 +108,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getConditionType() { public function getConditionType()
return $this->_conditionType; {
return $this->conditionType;
} }
/** /**
@ -118,8 +119,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* @param string $pValue PHPExcel_Style_Conditional condition type * @param string $pValue PHPExcel_Style_Conditional condition type
* @return PHPExcel_Style_Conditional * @return PHPExcel_Style_Conditional
*/ */
public function setConditionType($pValue = PHPExcel_Style_Conditional::CONDITION_NONE) { public function setConditionType($pValue = PHPExcel_Style_Conditional::CONDITION_NONE)
$this->_conditionType = $pValue; {
$this->conditionType = $pValue;
return $this; return $this;
} }
@ -128,8 +130,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getOperatorType() { public function getOperatorType()
return $this->_operatorType; {
return $this->operatorType;
} }
/** /**
@ -138,8 +141,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* @param string $pValue PHPExcel_Style_Conditional operator type * @param string $pValue PHPExcel_Style_Conditional operator type
* @return PHPExcel_Style_Conditional * @return PHPExcel_Style_Conditional
*/ */
public function setOperatorType($pValue = PHPExcel_Style_Conditional::OPERATOR_NONE) { public function setOperatorType($pValue = PHPExcel_Style_Conditional::OPERATOR_NONE)
$this->_operatorType = $pValue; {
$this->operatorType = $pValue;
return $this; return $this;
} }
@ -148,8 +152,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* *
* @return string * @return string
*/ */
public function getText() { public function getText()
return $this->_text; {
return $this->text;
} }
/** /**
@ -158,8 +163,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* @param string $value * @param string $value
* @return PHPExcel_Style_Conditional * @return PHPExcel_Style_Conditional
*/ */
public function setText($value = null) { public function setText($value = null)
$this->_text = $value; {
$this->text = $value;
return $this; return $this;
} }
@ -169,9 +175,10 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* @deprecated Deprecated, use getConditions instead * @deprecated Deprecated, use getConditions instead
* @return string * @return string
*/ */
public function getCondition() { public function getCondition()
if (isset($this->_condition[0])) { {
return $this->_condition[0]; if (isset($this->condition[0])) {
return $this->condition[0];
} }
return ''; return '';
@ -184,9 +191,11 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* @param string $pValue Condition * @param string $pValue Condition
* @return PHPExcel_Style_Conditional * @return PHPExcel_Style_Conditional
*/ */
public function setCondition($pValue = '') { public function setCondition($pValue = '')
if (!is_array($pValue)) {
if (!is_array($pValue)) {
$pValue = array($pValue); $pValue = array($pValue);
}
return $this->setConditions($pValue); return $this->setConditions($pValue);
} }
@ -196,8 +205,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* *
* @return string[] * @return string[]
*/ */
public function getConditions() { public function getConditions()
return $this->_condition; {
return $this->condition;
} }
/** /**
@ -206,11 +216,12 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* @param string[] $pValue Condition * @param string[] $pValue Condition
* @return PHPExcel_Style_Conditional * @return PHPExcel_Style_Conditional
*/ */
public function setConditions($pValue) { public function setConditions($pValue)
if (!is_array($pValue)) {
if (!is_array($pValue)) {
$pValue = array($pValue); $pValue = array($pValue);
}
$this->_condition = $pValue; $this->condition = $pValue;
return $this; return $this;
} }
@ -220,8 +231,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* @param string $pValue Condition * @param string $pValue Condition
* @return PHPExcel_Style_Conditional * @return PHPExcel_Style_Conditional
*/ */
public function addCondition($pValue = '') { public function addCondition($pValue = '')
$this->_condition[] = $pValue; {
$this->condition[] = $pValue;
return $this; return $this;
} }
@ -230,8 +242,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* *
* @return PHPExcel_Style * @return PHPExcel_Style
*/ */
public function getStyle() { public function getStyle()
return $this->_style; {
return $this->style;
} }
/** /**
@ -241,8 +254,9 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Style_Conditional * @return PHPExcel_Style_Conditional
*/ */
public function setStyle(PHPExcel_Style $pValue = null) { public function setStyle(PHPExcel_Style $pValue = null)
$this->_style = $pValue; {
$this->style = $pValue;
return $this; return $this;
} }
@ -251,20 +265,22 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
return md5( return md5(
$this->_conditionType $this->conditionType .
. $this->_operatorType $this->operatorType .
. implode(';', $this->_condition) implode(';', $this->condition) .
. $this->_style->getHashCode() $this->style->getHashCode() .
. __CLASS__ __CLASS__
); );
} }
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style_Fill
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Style_Fill
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{ {
/* Fill types */ /* Fill types */
@ -63,28 +55,28 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @var string * @var string
*/ */
protected $_fillType = PHPExcel_Style_Fill::FILL_NONE; protected $fillType = PHPExcel_Style_Fill::FILL_NONE;
/** /**
* Rotation * Rotation
* *
* @var double * @var double
*/ */
protected $_rotation = 0; protected $rotation = 0;
/** /**
* Start color * Start color
* *
* @var PHPExcel_Style_Color * @var PHPExcel_Style_Color
*/ */
protected $_startColor; protected $startColor;
/** /**
* End color * End color
* *
* @var PHPExcel_Style_Color * @var PHPExcel_Style_Color
*/ */
protected $_endColor; protected $endColor;
/** /**
* Create a new PHPExcel_Style_Fill * Create a new PHPExcel_Style_Fill
@ -96,22 +88,22 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* 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?
parent::__construct($isSupervisor); parent::__construct($isSupervisor);
// Initialise values // Initialise values
if ($isConditional) { if ($isConditional) {
$this->_fillType = NULL; $this->fillType = null;
} }
$this->_startColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_WHITE, $isSupervisor, $isConditional); $this->startColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_WHITE, $isSupervisor, $isConditional);
$this->_endColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor, $isConditional); $this->endColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor, $isConditional);
// bind parent if we are a supervisor // bind parent if we are a supervisor
if ($isSupervisor) { if ($isSupervisor) {
$this->_startColor->bindParent($this, '_startColor'); $this->startColor->bindParent($this, 'startColor');
$this->_endColor->bindParent($this, '_endColor'); $this->endColor->bindParent($this, 'endColor');
} }
} }
@ -123,7 +115,7 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
*/ */
public function getSharedComponent() public function getSharedComponent()
{ {
return $this->_parent->getSharedComponent()->getFill(); return $this->parent->getSharedComponent()->getFill();
} }
/** /**
@ -159,9 +151,10 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Style_Fill * @return PHPExcel_Style_Fill
*/ */
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('type', $pStyles)) { if (array_key_exists('type', $pStyles)) {
@ -191,11 +184,12 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return string * @return string
*/ */
public function getFillType() { public function getFillType()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getFillType(); return $this->getSharedComponent()->getFillType();
} }
return $this->_fillType; return $this->fillType;
} }
/** /**
@ -204,12 +198,13 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* @param string $pValue PHPExcel_Style_Fill fill type * @param string $pValue PHPExcel_Style_Fill fill type
* @return PHPExcel_Style_Fill * @return PHPExcel_Style_Fill
*/ */
public function setFillType($pValue = PHPExcel_Style_Fill::FILL_NONE) { public function setFillType($pValue = PHPExcel_Style_Fill::FILL_NONE)
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('type' => $pValue)); $styleArray = $this->getStyleArray(array('type' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_fillType = $pValue; $this->fillType = $pValue;
} }
return $this; return $this;
} }
@ -219,11 +214,12 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return double * @return double
*/ */
public function getRotation() { public function getRotation()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getRotation(); return $this->getSharedComponent()->getRotation();
} }
return $this->_rotation; return $this->rotation;
} }
/** /**
@ -232,12 +228,13 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* @param double $pValue * @param double $pValue
* @return PHPExcel_Style_Fill * @return PHPExcel_Style_Fill
*/ */
public function setRotation($pValue = 0) { public function setRotation($pValue = 0)
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('rotation' => $pValue)); $styleArray = $this->getStyleArray(array('rotation' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_rotation = $pValue; $this->rotation = $pValue;
} }
return $this; return $this;
} }
@ -247,8 +244,9 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
public function getStartColor() { public function getStartColor()
return $this->_startColor; {
return $this->startColor;
} }
/** /**
@ -258,15 +256,16 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* @throws PHPExcel_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)
{
// make sure parameter is a real color and not a supervisor // make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStartColor()->getStyleArray(array('argb' => $color->getARGB())); $styleArray = $this->getStartColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_startColor = $color; $this->startColor = $color;
} }
return $this; return $this;
} }
@ -276,8 +275,9 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
public function getEndColor() { public function getEndColor()
return $this->_endColor; {
return $this->endColor;
} }
/** /**
@ -287,15 +287,16 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* @throws PHPExcel_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)
{
// make sure parameter is a real color and not a supervisor // make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getEndColor()->getStyleArray(array('argb' => $color->getARGB())); $styleArray = $this->getEndColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_endColor = $color; $this->endColor = $color;
} }
return $this; return $this;
} }
@ -305,17 +306,17 @@ class PHPExcel_Style_Fill extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getHashCode(); return $this->getSharedComponent()->getHashCode();
} }
return md5( return md5(
$this->getFillType() $this->getFillType() .
. $this->getRotation() $this->getRotation() .
. $this->getStartColor()->getHashCode() $this->getStartColor()->getHashCode() .
. $this->getEndColor()->getHashCode() $this->getEndColor()->getHashCode() .
. __CLASS__ __CLASS__
); );
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style_Font
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Style_Font
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{ {
/* Underline types */ /* Underline types */
@ -47,63 +39,63 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @var string * @var string
*/ */
protected $_name = 'Calibri'; protected $name = 'Calibri';
/** /**
* Font Size * Font Size
* *
* @var float * @var float
*/ */
protected $_size = 11; protected $size = 11;
/** /**
* Bold * Bold
* *
* @var boolean * @var boolean
*/ */
protected $_bold = FALSE; protected $bold = false;
/** /**
* Italic * Italic
* *
* @var boolean * @var boolean
*/ */
protected $_italic = FALSE; protected $italic = false;
/** /**
* Superscript * Superscript
* *
* @var boolean * @var boolean
*/ */
protected $_superScript = FALSE; protected $superScript = false;
/** /**
* Subscript * Subscript
* *
* @var boolean * @var boolean
*/ */
protected $_subScript = FALSE; protected $subScript = false;
/** /**
* Underline * Underline
* *
* @var string * @var string
*/ */
protected $_underline = self::UNDERLINE_NONE; protected $underline = self::UNDERLINE_NONE;
/** /**
* Strikethrough * Strikethrough
* *
* @var boolean * @var boolean
*/ */
protected $_strikethrough = FALSE; protected $strikethrough = false;
/** /**
* Foreground color * Foreground color
* *
* @var PHPExcel_Style_Color * @var PHPExcel_Style_Color
*/ */
protected $_color; protected $color;
/** /**
* Create a new PHPExcel_Style_Font * Create a new PHPExcel_Style_Font
@ -115,28 +107,28 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* 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?
parent::__construct($isSupervisor); parent::__construct($isSupervisor);
// Initialise values // Initialise values
if ($isConditional) { if ($isConditional) {
$this->_name = NULL; $this->name = null;
$this->_size = NULL; $this->size = null;
$this->_bold = NULL; $this->bold = null;
$this->_italic = NULL; $this->italic = null;
$this->_superScript = NULL; $this->superScript = null;
$this->_subScript = NULL; $this->subScript = null;
$this->_underline = NULL; $this->underline = null;
$this->_strikethrough = NULL; $this->strikethrough = null;
$this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor, $isConditional); $this->color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor, $isConditional);
} else { } else {
$this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor); $this->color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor);
} }
// bind parent if we are a supervisor // bind parent if we are a supervisor
if ($isSupervisor) { if ($isSupervisor) {
$this->_color->bindParent($this, '_color'); $this->color->bindParent($this, 'color');
} }
} }
@ -148,7 +140,7 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
*/ */
public function getSharedComponent() public function getSharedComponent()
{ {
return $this->_parent->getSharedComponent()->getFont(); return $this->parent->getSharedComponent()->getFont();
} }
/** /**
@ -184,9 +176,10 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
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('name', $pStyles)) { if (array_key_exists('name', $pStyles)) {
@ -228,11 +221,12 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return string * @return string
*/ */
public function getName() { public function getName()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getName(); return $this->getSharedComponent()->getName();
} }
return $this->_name; return $this->name;
} }
/** /**
@ -241,15 +235,16 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* @param string $pValue * @param string $pValue
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function setName($pValue = 'Calibri') { public function setName($pValue = 'Calibri')
{
if ($pValue == '') { if ($pValue == '') {
$pValue = 'Calibri'; $pValue = 'Calibri';
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('name' => $pValue)); $styleArray = $this->getStyleArray(array('name' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_name = $pValue; $this->name = $pValue;
} }
return $this; return $this;
} }
@ -259,11 +254,12 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return double * @return double
*/ */
public function getSize() { public function getSize()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getSize(); return $this->getSharedComponent()->getSize();
} }
return $this->_size; return $this->size;
} }
/** /**
@ -272,15 +268,16 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* @param double $pValue * @param double $pValue
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function setSize($pValue = 10) { public function setSize($pValue = 10)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = 10; $pValue = 10;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('size' => $pValue)); $styleArray = $this->getStyleArray(array('size' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_size = $pValue; $this->size = $pValue;
} }
return $this; return $this;
} }
@ -290,11 +287,12 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
public function getBold() { public function getBold()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getBold(); return $this->getSharedComponent()->getBold();
} }
return $this->_bold; return $this->bold;
} }
/** /**
@ -303,15 +301,16 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function setBold($pValue = false) { public function setBold($pValue = false)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = false; $pValue = false;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('bold' => $pValue)); $styleArray = $this->getStyleArray(array('bold' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_bold = $pValue; $this->bold = $pValue;
} }
return $this; return $this;
} }
@ -321,11 +320,12 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
public function getItalic() { public function getItalic()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getItalic(); return $this->getSharedComponent()->getItalic();
} }
return $this->_italic; return $this->italic;
} }
/** /**
@ -334,15 +334,16 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function setItalic($pValue = false) { public function setItalic($pValue = false)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = false; $pValue = false;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('italic' => $pValue)); $styleArray = $this->getStyleArray(array('italic' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_italic = $pValue; $this->italic = $pValue;
} }
return $this; return $this;
} }
@ -352,11 +353,12 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
public function getSuperScript() { public function getSuperScript()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getSuperScript(); return $this->getSharedComponent()->getSuperScript();
} }
return $this->_superScript; return $this->superScript;
} }
/** /**
@ -365,16 +367,17 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function setSuperScript($pValue = false) { public function setSuperScript($pValue = false)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = false; $pValue = false;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('superScript' => $pValue)); $styleArray = $this->getStyleArray(array('superScript' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_superScript = $pValue; $this->superScript = $pValue;
$this->_subScript = !$pValue; $this->subScript = !$pValue;
} }
return $this; return $this;
} }
@ -384,11 +387,12 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
public function getSubScript() { public function getSubScript()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getSubScript(); return $this->getSharedComponent()->getSubScript();
} }
return $this->_subScript; return $this->subScript;
} }
/** /**
@ -397,16 +401,17 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function setSubScript($pValue = false) { public function setSubScript($pValue = false)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = false; $pValue = false;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('subScript' => $pValue)); $styleArray = $this->getStyleArray(array('subScript' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_subScript = $pValue; $this->subScript = $pValue;
$this->_superScript = !$pValue; $this->superScript = !$pValue;
} }
return $this; return $this;
} }
@ -416,11 +421,12 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return string * @return string
*/ */
public function getUnderline() { public function getUnderline()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getUnderline(); return $this->getSharedComponent()->getUnderline();
} }
return $this->_underline; return $this->underline;
} }
/** /**
@ -431,17 +437,18 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* false equates to UNDERLINE_NONE * false equates to UNDERLINE_NONE
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function setUnderline($pValue = self::UNDERLINE_NONE) { public function setUnderline($pValue = self::UNDERLINE_NONE)
{
if (is_bool($pValue)) { if (is_bool($pValue)) {
$pValue = ($pValue) ? self::UNDERLINE_SINGLE : self::UNDERLINE_NONE; $pValue = ($pValue) ? self::UNDERLINE_SINGLE : self::UNDERLINE_NONE;
} elseif ($pValue == '') { } elseif ($pValue == '') {
$pValue = self::UNDERLINE_NONE; $pValue = self::UNDERLINE_NONE;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('underline' => $pValue)); $styleArray = $this->getStyleArray(array('underline' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_underline = $pValue; $this->underline = $pValue;
} }
return $this; return $this;
} }
@ -451,11 +458,12 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
public function getStrikethrough() { public function getStrikethrough()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getStrikethrough(); return $this->getSharedComponent()->getStrikethrough();
} }
return $this->_strikethrough; return $this->strikethrough;
} }
/** /**
@ -464,15 +472,16 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_Style_Font * @return PHPExcel_Style_Font
*/ */
public function setStrikethrough($pValue = false) { public function setStrikethrough($pValue = false)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = false; $pValue = false;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('strike' => $pValue)); $styleArray = $this->getStyleArray(array('strike' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_strikethrough = $pValue; $this->strikethrough = $pValue;
} }
return $this; return $this;
} }
@ -482,8 +491,9 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return PHPExcel_Style_Color * @return PHPExcel_Style_Color
*/ */
public function getColor() { public function getColor()
return $this->_color; {
return $this->color;
} }
/** /**
@ -493,15 +503,16 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* @throws PHPExcel_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)
{
// make sure parameter is a real color and not a supervisor // make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB())); $styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_color = $color; $this->color = $color;
} }
return $this; return $this;
} }
@ -511,22 +522,22 @@ class PHPExcel_Style_Font extends PHPExcel_Style_Supervisor implements PHPExcel_
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getHashCode(); return $this->getSharedComponent()->getHashCode();
} }
return md5( return md5(
$this->_name $this->name .
. $this->_size $this->size .
. ($this->_bold ? 't' : 'f') ($this->bold ? 't' : 'f') .
. ($this->_italic ? 't' : 'f') ($this->italic ? 't' : 'f') .
. ($this->_superScript ? 't' : 'f') ($this->superScript ? 't' : 'f') .
. ($this->_subScript ? 't' : 'f') ($this->subScript ? 't' : 'f') .
. $this->_underline $this->underline .
. ($this->_strikethrough ? 't' : 'f') ($this->strikethrough ? 't' : 'f') .
. $this->_color->getHashCode() $this->color->getHashCode() .
. __CLASS__ __CLASS__
); );
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style_NumberFormat
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Style_NumberFormat
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{ {
/* Pre-defined formats */ /* Pre-defined formats */
@ -80,28 +72,28 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
* *
* @var array * @var array
*/ */
protected 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
*/ */
protected static $_flippedBuiltInFormats; protected static $flippedBuiltInFormats;
/** /**
* Format Code * Format Code
* *
* @var string * @var string
*/ */
protected $_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
*/ */
protected $_builtInFormatCode = 0; protected $builtInFormatCode = 0;
/** /**
* Create a new PHPExcel_Style_NumberFormat * Create a new PHPExcel_Style_NumberFormat
@ -113,14 +105,14 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
* 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?
parent::__construct($isSupervisor); parent::__construct($isSupervisor);
if ($isConditional) { if ($isConditional) {
$this->_formatCode = NULL; $this->formatCode = null;
$this->_builtInFormatCode = FALSE; $this->builtInFormatCode = false;
} }
} }
@ -132,7 +124,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
*/ */
public function getSharedComponent() public function getSharedComponent()
{ {
return $this->_parent->getSharedComponent()->getNumberFormat(); return $this->parent->getSharedComponent()->getNumberFormat();
} }
/** /**
@ -164,7 +156,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
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('code', $pStyles)) { if (array_key_exists('code', $pStyles)) {
@ -184,14 +176,13 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
*/ */
public function getFormatCode() public function getFormatCode()
{ {
if ($this->_isSupervisor) { if ($this->isSupervisor) {
return $this->getSharedComponent()->getFormatCode(); return $this->getSharedComponent()->getFormatCode();
} }
if ($this->_builtInFormatCode !== false) if ($this->builtInFormatCode !== false) {
{ return self::builtInFormatCode($this->builtInFormatCode);
return self::builtInFormatCode($this->_builtInFormatCode);
} }
return $this->_formatCode; return $this->formatCode;
} }
/** /**
@ -205,12 +196,12 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
if ($pValue == '') { if ($pValue == '') {
$pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; $pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
} }
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('code' => $pValue)); $styleArray = $this->getStyleArray(array('code' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_formatCode = $pValue; $this->formatCode = $pValue;
$this->_builtInFormatCode = self::builtInFormatCodeIndex($pValue); $this->builtInFormatCode = self::builtInFormatCodeIndex($pValue);
} }
return $this; return $this;
} }
@ -222,10 +213,10 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
*/ */
public function getBuiltInFormatCode() public function getBuiltInFormatCode()
{ {
if ($this->_isSupervisor) { if ($this->isSupervisor) {
return $this->getSharedComponent()->getBuiltInFormatCode(); return $this->getSharedComponent()->getBuiltInFormatCode();
} }
return $this->_builtInFormatCode; return $this->builtInFormatCode;
} }
/** /**
@ -237,12 +228,12 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
public function setBuiltInFormatCode($pValue = 0) public function setBuiltInFormatCode($pValue = 0)
{ {
if ($this->_isSupervisor) { if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('code' => self::builtInFormatCode($pValue))); $styleArray = $this->getStyleArray(array('code' => self::builtInFormatCode($pValue)));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_builtInFormatCode = $pValue; $this->builtInFormatCode = $pValue;
$this->_formatCode = self::builtInFormatCode($pValue); $this->formatCode = self::builtInFormatCode($pValue);
} }
return $this; return $this;
} }
@ -253,62 +244,62 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
private static function fillBuiltInFormatCodes() private static function fillBuiltInFormatCodes()
{ {
// Built-in format codes // Built-in format codes
if (is_null(self::$_builtInFormats)) { if (is_null(self::$builtInFormats)) {
self::$_builtInFormats = array(); self::$builtInFormats = array();
// General // General
self::$_builtInFormats[0] = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; self::$builtInFormats[0] = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
self::$_builtInFormats[1] = '0'; self::$builtInFormats[1] = '0';
self::$_builtInFormats[2] = '0.00'; self::$builtInFormats[2] = '0.00';
self::$_builtInFormats[3] = '#,##0'; self::$builtInFormats[3] = '#,##0';
self::$_builtInFormats[4] = '#,##0.00'; self::$builtInFormats[4] = '#,##0.00';
self::$_builtInFormats[9] = '0%'; self::$builtInFormats[9] = '0%';
self::$_builtInFormats[10] = '0.00%'; self::$builtInFormats[10] = '0.00%';
self::$_builtInFormats[11] = '0.00E+00'; self::$builtInFormats[11] = '0.00E+00';
self::$_builtInFormats[12] = '# ?/?'; self::$builtInFormats[12] = '# ?/?';
self::$_builtInFormats[13] = '# ??/??'; self::$builtInFormats[13] = '# ??/??';
self::$_builtInFormats[14] = 'mm-dd-yy'; self::$builtInFormats[14] = 'mm-dd-yy';
self::$_builtInFormats[15] = 'd-mmm-yy'; self::$builtInFormats[15] = 'd-mmm-yy';
self::$_builtInFormats[16] = 'd-mmm'; self::$builtInFormats[16] = 'd-mmm';
self::$_builtInFormats[17] = 'mmm-yy'; self::$builtInFormats[17] = 'mmm-yy';
self::$_builtInFormats[18] = 'h:mm AM/PM'; self::$builtInFormats[18] = 'h:mm AM/PM';
self::$_builtInFormats[19] = 'h:mm:ss AM/PM'; self::$builtInFormats[19] = 'h:mm:ss AM/PM';
self::$_builtInFormats[20] = 'h:mm'; self::$builtInFormats[20] = 'h:mm';
self::$_builtInFormats[21] = 'h:mm:ss'; self::$builtInFormats[21] = 'h:mm:ss';
self::$_builtInFormats[22] = 'm/d/yy h:mm'; self::$builtInFormats[22] = 'm/d/yy h:mm';
self::$_builtInFormats[37] = '#,##0 ;(#,##0)'; self::$builtInFormats[37] = '#,##0 ;(#,##0)';
self::$_builtInFormats[38] = '#,##0 ;[Red](#,##0)'; self::$builtInFormats[38] = '#,##0 ;[Red](#,##0)';
self::$_builtInFormats[39] = '#,##0.00;(#,##0.00)'; self::$builtInFormats[39] = '#,##0.00;(#,##0.00)';
self::$_builtInFormats[40] = '#,##0.00;[Red](#,##0.00)'; self::$builtInFormats[40] = '#,##0.00;[Red](#,##0.00)';
self::$_builtInFormats[44] = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)'; self::$builtInFormats[44] = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)';
self::$_builtInFormats[45] = 'mm:ss'; self::$builtInFormats[45] = 'mm:ss';
self::$_builtInFormats[46] = '[h]:mm:ss'; self::$builtInFormats[46] = '[h]:mm:ss';
self::$_builtInFormats[47] = 'mmss.0'; self::$builtInFormats[47] = 'mmss.0';
self::$_builtInFormats[48] = '##0.0E+0'; self::$builtInFormats[48] = '##0.0E+0';
self::$_builtInFormats[49] = '@'; self::$builtInFormats[49] = '@';
// CHT // CHT
self::$_builtInFormats[27] = '[$-404]e/m/d'; self::$builtInFormats[27] = '[$-404]e/m/d';
self::$_builtInFormats[30] = 'm/d/yy'; self::$builtInFormats[30] = 'm/d/yy';
self::$_builtInFormats[36] = '[$-404]e/m/d'; self::$builtInFormats[36] = '[$-404]e/m/d';
self::$_builtInFormats[50] = '[$-404]e/m/d'; self::$builtInFormats[50] = '[$-404]e/m/d';
self::$_builtInFormats[57] = '[$-404]e/m/d'; self::$builtInFormats[57] = '[$-404]e/m/d';
// THA // THA
self::$_builtInFormats[59] = 't0'; self::$builtInFormats[59] = 't0';
self::$_builtInFormats[60] = 't0.00'; self::$builtInFormats[60] = 't0.00';
self::$_builtInFormats[61] = 't#,##0'; self::$builtInFormats[61] = 't#,##0';
self::$_builtInFormats[62] = 't#,##0.00'; self::$builtInFormats[62] = 't#,##0.00';
self::$_builtInFormats[67] = 't0%'; self::$builtInFormats[67] = 't0%';
self::$_builtInFormats[68] = 't0.00%'; self::$builtInFormats[68] = 't0.00%';
self::$_builtInFormats[69] = 't# ?/?'; self::$builtInFormats[69] = 't# ?/?';
self::$_builtInFormats[70] = 't# ??/??'; self::$builtInFormats[70] = 't# ??/??';
// Flip array (for faster lookups) // Flip array (for faster lookups)
self::$_flippedBuiltInFormats = array_flip(self::$_builtInFormats); self::$flippedBuiltInFormats = array_flip(self::$builtInFormats);
} }
} }
@ -327,8 +318,8 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
self::fillBuiltInFormatCodes(); self::fillBuiltInFormatCodes();
// Lookup format code // Lookup format code
if (isset(self::$_builtInFormats[$pIndex])) { if (isset(self::$builtInFormats[$pIndex])) {
return self::$_builtInFormats[$pIndex]; return self::$builtInFormats[$pIndex];
} }
return ''; return '';
@ -346,8 +337,8 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
self::fillBuiltInFormatCodes(); self::fillBuiltInFormatCodes();
// Lookup format code // Lookup format code
if (isset(self::$_flippedBuiltInFormats[$formatCode])) { if (isset(self::$flippedBuiltInFormats[$formatCode])) {
return self::$_flippedBuiltInFormats[$formatCode]; return self::$flippedBuiltInFormats[$formatCode];
} }
return false; return false;
@ -360,13 +351,13 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
*/ */
public function getHashCode() public function getHashCode()
{ {
if ($this->_isSupervisor) { if ($this->isSupervisor) {
return $this->getSharedComponent()->getHashCode(); return $this->getSharedComponent()->getHashCode();
} }
return md5( return md5(
$this->_formatCode $this->formatCode .
. $this->_builtInFormatCode $this->builtInFormatCode .
. __CLASS__ __CLASS__
); );
} }
@ -375,7 +366,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
* *
* @var array * @var array
*/ */
private static $_dateFormatReplacements = array( private static $dateFormatReplacements = array(
// first remove escapes related to non-format characters // first remove escapes related to non-format characters
'\\' => '', '\\' => '',
// 12-hour suffix // 12-hour suffix
@ -418,7 +409,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
* *
* @var array * @var array
*/ */
private static $_dateFormatReplacements24 = array( private static $dateFormatReplacements24 = array(
'hh' => 'H', 'hh' => 'H',
'h' => 'G' 'h' => 'G'
); );
@ -427,12 +418,12 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
* *
* @var array * @var array
*/ */
private static $_dateFormatReplacements12 = array( private static $dateFormatReplacements12 = array(
'hh' => 'h', 'hh' => 'h',
'h' => 'g' 'h' => 'g'
); );
private static function _formatAsDate(&$value, &$format) private static function formatAsDate(&$value, &$format)
{ {
// dvc: convert Excel formats to PHP date formats // dvc: convert Excel formats to PHP date formats
@ -444,18 +435,20 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
// OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case // OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case
$format = strtolower($format); $format = strtolower($format);
$format = strtr($format,self::$_dateFormatReplacements); $format = strtr($format, self::$dateFormatReplacements);
if (!strpos($format,'A')) { // 24-hour time format if (!strpos($format, 'A')) {
$format = strtr($format,self::$_dateFormatReplacements24); // 24-hour time format
} else { // 12-hour time format $format = strtr($format, self::$dateFormatReplacements24);
$format = strtr($format,self::$_dateFormatReplacements12); } else {
// 12-hour time format
$format = strtr($format, self::$dateFormatReplacements12);
} }
$dateObj = PHPExcel_Shared_Date::ExcelToPHPObject($value); $dateObj = PHPExcel_Shared_Date::ExcelToPHPObject($value);
$value = $dateObj->format($format); $value = $dateObj->format($format);
} }
private static function _formatAsPercentage(&$value, &$format) private static function formatAsPercentage(&$value, &$format)
{ {
if ($format === self::FORMAT_PERCENTAGE) { if ($format === self::FORMAT_PERCENTAGE) {
$value = round((100 * $value), 0) . '%'; $value = round((100 * $value), 0) . '%';
@ -473,7 +466,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
} }
} }
private static function _formatAsFraction(&$value, &$format) private static function formatAsFraction(&$value, &$format)
{ {
$sign = ($value < 0) ? '-' : ''; $sign = ($value < 0) ? '-' : '';
@ -498,14 +491,15 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
} }
} }
private static function _complexNumberFormatMask($number, $mask, $level = 0) { private static function complexNumberFormatMask($number, $mask, $level = 0)
{
$sign = ($number < 0.0); $sign = ($number < 0.0);
$number = abs($number); $number = abs($number);
if (strpos($mask, '.') !== false) { if (strpos($mask, '.') !== false) {
$numbers = explode('.', $number . '.0'); $numbers = explode('.', $number . '.0');
$masks = explode('.', $mask . '.0'); $masks = explode('.', $mask . '.0');
$result1 = self::_complexNumberFormatMask($numbers[0], $masks[0], 1); $result1 = self::complexNumberFormatMask($numbers[0], $masks[0], 1);
$result2 = strrev(self::_complexNumberFormatMask(strrev($numbers[1]), strrev($masks[1]), 1)); $result2 = strrev(self::complexNumberFormatMask(strrev($numbers[1]), strrev($masks[1]), 1));
return (($sign) ? '-' : '') . $result1 . '.' . $result2; return (($sign) ? '-' : '') . $result1 . '.' . $result2;
} }
@ -547,7 +541,9 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
public static function toFormattedString($value = '0', $format = PHPExcel_Style_NumberFormat::FORMAT_GENERAL, $callBack = null) public static function toFormattedString($value = '0', $format = PHPExcel_Style_NumberFormat::FORMAT_GENERAL, $callBack = null)
{ {
// For now we do not treat strings although section 4 of a format code affects strings // For now we do not treat strings although section 4 of a format code affects strings
if (!is_numeric($value)) return $value; if (!is_numeric($value)) {
return $value;
}
// For 'General' format code, we just pass the value although this is not entirely the way Excel does it, // For 'General' format code, we just pass the value although this is not entirely the way Excel does it,
// it seems to round numbers to a total of 10 digits. // it seems to round numbers to a total of 10 digits.
@ -569,26 +565,22 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
case 1: case 1:
$format = $sections[0]; $format = $sections[0];
break; break;
case 2: case 2:
$format = ($value >= 0) ? $sections[0] : $sections[1]; $format = ($value >= 0) ? $sections[0] : $sections[1];
$value = abs($value); // Use the absolute value $value = abs($value); // Use the absolute value
break; break;
case 3: case 3:
$format = ($value > 0) ? $format = ($value > 0) ?
$sections[0] : ( ($value < 0) ? $sections[0] : ( ($value < 0) ?
$sections[1] : $sections[2]); $sections[1] : $sections[2]);
$value = abs($value); // Use the absolute value $value = abs($value); // Use the absolute value
break; break;
case 4: case 4:
$format = ($value > 0) ? $format = ($value > 0) ?
$sections[0] : ( ($value < 0) ? $sections[0] : ( ($value < 0) ?
$sections[1] : $sections[2]); $sections[1] : $sections[2]);
$value = abs($value); // Use the absolute value $value = abs($value); // Use the absolute value
break; break;
default: default:
// something is wrong, just use first section // something is wrong, just use first section
$format = $sections[0]; $format = $sections[0];
@ -604,9 +596,9 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
// Let's begin inspecting the format and converting the value to a formatted string // Let's begin inspecting the format and converting the value to a formatted string
if (preg_match('/^(\[\$[A-Z]*-[0-9A-F]*\])*[hmsdy]/i', $format)) { // datetime format if (preg_match('/^(\[\$[A-Z]*-[0-9A-F]*\])*[hmsdy]/i', $format)) { // datetime format
self::_formatAsDate($value, $format); self::formatAsDate($value, $format);
} elseif (preg_match('/%$/', $format)) { // % number format } elseif (preg_match('/%$/', $format)) { // % number format
self::_formatAsPercentage($value, $format); self::formatAsPercentage($value, $format);
} else { } else {
if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) { if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) {
$value = 'EUR ' . sprintf('%1.2f', $value); $value = 'EUR ' . sprintf('%1.2f', $value);
@ -648,7 +640,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
if (preg_match('/#?.*\?\/\?/', $format, $m)) { if (preg_match('/#?.*\?\/\?/', $format, $m)) {
//echo 'Format mask is fractional '.$format.' <br />'; //echo 'Format mask is fractional '.$format.' <br />';
if ($value != (int)$value) { if ($value != (int)$value) {
self::_formatAsFraction($value, $format); self::formatAsFraction($value, $format);
} }
} else { } else {
@ -672,10 +664,10 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
$minWidth = strlen($left) + strlen($dec) + strlen($right); $minWidth = strlen($left) + strlen($dec) + strlen($right);
if ($useThousands) { if ($useThousands) {
$value = number_format( $value = number_format(
$value $value,
, strlen($right) strlen($right),
, PHPExcel_Shared_String::getDecimalSeparator() PHPExcel_Shared_String::getDecimalSeparator(),
, PHPExcel_Shared_String::getThousandsSeparator() PHPExcel_Shared_String::getThousandsSeparator()
); );
$value = preg_replace($number_regex, $value, $format); $value = preg_replace($number_regex, $value, $format);
} else { } else {
@ -683,7 +675,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
// Scientific format // Scientific format
$value = sprintf('%5.2E', $value); $value = sprintf('%5.2E', $value);
} elseif (preg_match('/0([^\d\.]+)0/', $format)) { } elseif (preg_match('/0([^\d\.]+)0/', $format)) {
$value = self::_complexNumberFormatMask($value, $format); $value = self::complexNumberFormatMask($value, $format);
} else { } else {
$sprintf_pattern = "%0$minWidth." . strlen($right) . "f"; $sprintf_pattern = "%0$minWidth." . strlen($right) . "f";
$value = sprintf($sprintf_pattern, $value); $value = sprintf($sprintf_pattern, $value);
@ -713,5 +705,4 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
return $value; return $value;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style_Protection
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -22,16 +23,7 @@
* @package PHPExcel_Style * @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.4.5, 2007-08-23 * @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Style_Protection
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{ {
@ -45,14 +37,14 @@ class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHP
* *
* @var string * @var string
*/ */
protected $_locked; protected $locked;
/** /**
* Hidden * Hidden
* *
* @var string * @var string
*/ */
protected $_hidden; protected $hidden;
/** /**
* Create a new PHPExcel_Style_Protection * Create a new PHPExcel_Style_Protection
@ -64,15 +56,15 @@ class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHP
* 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?
parent::__construct($isSupervisor); parent::__construct($isSupervisor);
// Initialise values // Initialise values
if (!$isConditional) { if (!$isConditional) {
$this->_locked = self::PROTECTION_INHERIT; $this->locked = self::PROTECTION_INHERIT;
$this->_hidden = self::PROTECTION_INHERIT; $this->hidden = self::PROTECTION_INHERIT;
} }
} }
@ -84,7 +76,7 @@ class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHP
*/ */
public function getSharedComponent() public function getSharedComponent()
{ {
return $this->_parent->getSharedComponent()->getProtection(); return $this->parent->getSharedComponent()->getProtection();
} }
/** /**
@ -114,9 +106,10 @@ class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHP
* @throws PHPExcel_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 (isset($pStyles['locked'])) { if (isset($pStyles['locked'])) {
@ -137,11 +130,12 @@ class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHP
* *
* @return string * @return string
*/ */
public function getLocked() { public function getLocked()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getLocked(); return $this->getSharedComponent()->getLocked();
} }
return $this->_locked; return $this->locked;
} }
/** /**
@ -150,12 +144,13 @@ class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHP
* @param string $pValue * @param string $pValue
* @return PHPExcel_Style_Protection * @return PHPExcel_Style_Protection
*/ */
public function setLocked($pValue = self::PROTECTION_INHERIT) { public function setLocked($pValue = self::PROTECTION_INHERIT)
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('locked' => $pValue)); $styleArray = $this->getStyleArray(array('locked' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_locked = $pValue; $this->locked = $pValue;
} }
return $this; return $this;
} }
@ -165,11 +160,12 @@ class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHP
* *
* @return string * @return string
*/ */
public function getHidden() { public function getHidden()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getHidden(); return $this->getSharedComponent()->getHidden();
} }
return $this->_hidden; return $this->hidden;
} }
/** /**
@ -178,12 +174,13 @@ class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHP
* @param string $pValue * @param string $pValue
* @return PHPExcel_Style_Protection * @return PHPExcel_Style_Protection
*/ */
public function setHidden($pValue = self::PROTECTION_INHERIT) { public function setHidden($pValue = self::PROTECTION_INHERIT)
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(array('hidden' => $pValue)); $styleArray = $this->getStyleArray(array('hidden' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else { } else {
$this->_hidden = $pValue; $this->hidden = $pValue;
} }
return $this; return $this;
} }
@ -193,15 +190,15 @@ class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHP
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
if ($this->_isSupervisor) { {
if ($this->isSupervisor) {
return $this->getSharedComponent()->getHashCode(); return $this->getSharedComponent()->getHashCode();
} }
return md5( return md5(
$this->_locked $this->locked .
. $this->_hidden $this->hidden .
. __CLASS__ __CLASS__
); );
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Style_Supervisor
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Style_Supervisor
*
* @category PHPExcel
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_Style_Supervisor abstract class PHPExcel_Style_Supervisor
{ {
/** /**
@ -40,14 +32,14 @@ abstract class PHPExcel_Style_Supervisor
* *
* @var boolean * @var boolean
*/ */
protected $_isSupervisor; protected $isSupervisor;
/** /**
* Parent. Only used for supervisor * Parent. Only used for supervisor
* *
* @var PHPExcel_Style * @var PHPExcel_Style
*/ */
protected $_parent; protected $parent;
/** /**
* Create a new PHPExcel_Style_Alignment * Create a new PHPExcel_Style_Alignment
@ -56,10 +48,10 @@ abstract class PHPExcel_Style_Supervisor
* 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) public function __construct($isSupervisor = false)
{ {
// Supervisor? // Supervisor?
$this->_isSupervisor = $isSupervisor; $this->isSupervisor = $isSupervisor;
} }
/** /**
@ -68,9 +60,9 @@ abstract class PHPExcel_Style_Supervisor
* @param PHPExcel $parent * @param PHPExcel $parent
* @return PHPExcel_Style_Supervisor * @return PHPExcel_Style_Supervisor
*/ */
public function bindParent($parent, $parentPropertyName=NULL) public function bindParent($parent, $parentPropertyName = null)
{ {
$this->_parent = $parent; $this->parent = $parent;
return $this; return $this;
} }
@ -81,7 +73,7 @@ abstract class PHPExcel_Style_Supervisor
*/ */
public function getIsSupervisor() public function getIsSupervisor()
{ {
return $this->_isSupervisor; return $this->isSupervisor;
} }
/** /**
@ -91,7 +83,7 @@ abstract class PHPExcel_Style_Supervisor
*/ */
public function getActiveSheet() public function getActiveSheet()
{ {
return $this->_parent->getActiveSheet(); return $this->parent->getActiveSheet();
} }
/** /**
@ -119,10 +111,11 @@ abstract class PHPExcel_Style_Supervisor
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if ((is_object($value)) && ($key != '_parent')) { if ((is_object($value)) && ($key != 'parent')) {
$this->$key = clone $value; $this->$key = clone $value;
} else { } else {
$this->$key = $value; $this->$key = $value;

View File

@ -1152,16 +1152,15 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function getCell($pCoordinate = 'A1') public function getCell($pCoordinate = 'A1')
{ {
$pCoordinate = strtoupper($pCoordinate);
// Check cell collection // Check cell collection
if ($this->_cellCollection->isDataSet($pCoordinate)) { if ($this->_cellCollection->isDataSet(strtoupper($pCoordinate))) {
return $this->_cellCollection->getCacheData($pCoordinate); return $this->_cellCollection->getCacheData($pCoordinate);
} }
// Worksheet reference? // Worksheet reference?
if (strpos($pCoordinate, '!') !== false) { if (strpos($pCoordinate, '!') !== false) {
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true); $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
return $this->_parent->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]); return $this->_parent->getSheetByName($worksheetReference[0])->getCell(strtoupper($worksheetReference[1]));
} }
// Named range? // Named range?
@ -2658,7 +2657,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
} }
if ($returnRange) { if ($returnRange) {
return array( trim(substr($pRange, 0, $sep),"'"), return array(
trim(substr($pRange, 0, $sep),"'"),
substr($pRange, $sep + 1) substr($pRange, $sep + 1)
); );
} }

View File

@ -46,7 +46,6 @@ $callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',') $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',')
->setEnclosure('"') ->setEnclosure('"')
->setLineEnding("\r\n")
->setSheetIndex(0) ->setSheetIndex(0)
->save(str_replace('.php', '.csv', __FILE__)); ->save(str_replace('.php', '.csv', __FILE__));
$callEndTime = microtime(true); $callEndTime = microtime(true);
@ -61,7 +60,6 @@ echo date('H:i:s') , " Read from CSV format" , EOL;
$callStartTime = microtime(true); $callStartTime = microtime(true);
$objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',') $objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',')
->setEnclosure('"') ->setEnclosure('"')
->setLineEnding("\r\n")
->setSheetIndex(0); ->setSheetIndex(0);
$objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__)); $objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__));