mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-24 01:00:05 +00:00
Refactoring of style classes to use an abstract supervisor
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
|
||||
{
|
||||
/* Pre-defined formats */
|
||||
const FORMAT_GENERAL = 'General';
|
||||
@@ -80,49 +80,28 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_builtInFormats;
|
||||
protected static $_builtInFormats;
|
||||
|
||||
/**
|
||||
* Excel built-in number formats (flipped, for faster lookups)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_flippedBuiltInFormats;
|
||||
protected static $_flippedBuiltInFormats;
|
||||
|
||||
/**
|
||||
* Format Code
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
|
||||
protected $_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
|
||||
|
||||
/**
|
||||
* Built-in format Code
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_builtInFormatCode = 0;
|
||||
|
||||
/**
|
||||
* Parent Borders
|
||||
*
|
||||
* @var _parentPropertyName string
|
||||
*/
|
||||
private $_parentPropertyName;
|
||||
|
||||
/**
|
||||
* Supervisor?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_isSupervisor;
|
||||
|
||||
/**
|
||||
* Parent. Only used for supervisor
|
||||
*
|
||||
* @var PHPExcel_Style
|
||||
*/
|
||||
private $_parent;
|
||||
protected $_builtInFormatCode = 0;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Style_NumberFormat
|
||||
@@ -134,37 +113,16 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
* Leave this value at default unless you understand exactly what
|
||||
* its ramifications are
|
||||
*/
|
||||
public function __construct($isSupervisor = false, $isConditional = false)
|
||||
public function __construct($isSupervisor = FALSE, $isConditional = FALSE)
|
||||
{
|
||||
// Supervisor?
|
||||
$this->_isSupervisor = $isSupervisor;
|
||||
parent::__construct($isSupervisor);
|
||||
|
||||
if ($isConditional) {
|
||||
$this->_formatCode = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind parent. Only used for supervisor
|
||||
*
|
||||
* @param PHPExcel_Style $parent
|
||||
* @return PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function bindParent($parent)
|
||||
{
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a supervisor or a real style component?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsSupervisor()
|
||||
{
|
||||
return $this->_isSupervisor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shared style component for the currently active cell in currently active sheet.
|
||||
* Only used for style supervisor
|
||||
@@ -176,38 +134,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
return $this->_parent->getSharedComponent()->getNumberFormat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently active sheet. Only used for supervisor
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getActiveSheet()
|
||||
{
|
||||
return $this->_parent->getActiveSheet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently active cell coordinate in currently active sheet.
|
||||
* Only used for supervisor
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently active cell coordinate in currently active sheet.
|
||||
* Only used for supervisor
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build style array from subcomponents
|
||||
*
|
||||
@@ -231,7 +157,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function applyFromArray($pStyles = null)
|
||||
@@ -245,7 +171,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Invalid style array passed.");
|
||||
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -443,21 +369,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if ((is_object($value)) && ($key != '_parent')) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search/replace values to convert Excel date/time format masks to PHP format masks
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user