diff --git a/Classes/PHPExcel.php b/Classes/PHPExcel.php index ff6a10d7..4116b6c4 100644 --- a/Classes/PHPExcel.php +++ b/Classes/PHPExcel.php @@ -177,6 +177,14 @@ class PHPExcel return $this->_calculationEngine; } // function getCellCacheController() + /** + * Code to execute when this worksheet is unset() + * + */ + function __destruct() { + $this->disconnectWorksheets(); + } + /** * Get properties * diff --git a/Classes/PHPExcel/Chart/PlotArea.php b/Classes/PHPExcel/Chart/PlotArea.php index ec9aee83..2a092ce7 100644 --- a/Classes/PHPExcel/Chart/PlotArea.php +++ b/Classes/PHPExcel/Chart/PlotArea.php @@ -110,7 +110,7 @@ class PHPExcel_Chart_PlotArea /** * Set Plot Series * - * @param array of PHPExcel_Chart_DataSeries + * @param [PHPExcel_Chart_DataSeries] */ public function setPlotSeries($plotSeries = array()) { $this->_plotSeries = $plotSeries; diff --git a/Classes/PHPExcel/Comment.php b/Classes/PHPExcel/Comment.php index cb846292..47db7ecd 100644 --- a/Classes/PHPExcel/Comment.php +++ b/Classes/PHPExcel/Comment.php @@ -21,7 +21,7 @@ * @category PHPExcel * @package PHPExcel * @copyright Copyright (c) 2006 - 2012 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 ##VERSION##, ##DATE## */ @@ -35,68 +35,68 @@ */ class PHPExcel_Comment implements PHPExcel_IComparable { - /** - * Author - * - * @var string - */ - private $_author; + /** + * Author + * + * @var string + */ + private $_author; - /** - * Rich text comment - * - * @var PHPExcel_RichText - */ - private $_text; + /** + * Rich text comment + * + * @var PHPExcel_RichText + */ + private $_text; - /** - * Comment width (CSS style, i.e. XXpx or YYpt) - * - * @var string - */ - private $_width = '96pt'; + /** + * Comment width (CSS style, i.e. XXpx or YYpt) + * + * @var string + */ + private $_width = '96pt'; - /** - * Left margin (CSS style, i.e. XXpx or YYpt) - * - * @var string - */ - private $_marginLeft = '59.25pt'; + /** + * Left margin (CSS style, i.e. XXpx or YYpt) + * + * @var string + */ + private $_marginLeft = '59.25pt'; - /** - * Top margin (CSS style, i.e. XXpx or YYpt) - * - * @var string - */ - private $_marginTop = '1.5pt'; + /** + * Top margin (CSS style, i.e. XXpx or YYpt) + * + * @var string + */ + private $_marginTop = '1.5pt'; - /** - * Visible - * - * @var boolean - */ - private $_visible = false; + /** + * Visible + * + * @var boolean + */ + private $_visible = false; - /** - * Comment height (CSS style, i.e. XXpx or YYpt) - * - * @var string - */ - private $_height = '55.5pt'; + /** + * Comment height (CSS style, i.e. XXpx or YYpt) + * + * @var string + */ + private $_height = '55.5pt'; - /** - * Comment fill color - * - * @var PHPExcel_Style_Color - */ - private $_fillColor; + /** + * Comment fill color + * + * @var PHPExcel_Style_Color + */ + private $_fillColor; - /** - * Alignment - * - * @var string - */ - private $_alignment; + /** + * Alignment + * + * @var string + */ + private $_alignment; /** * Create a new PHPExcel_Comment @@ -105,11 +105,11 @@ class PHPExcel_Comment implements PHPExcel_IComparable */ public function __construct() { - // Initialise variables - $this->_author = 'Author'; - $this->_text = new PHPExcel_RichText(); - $this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1'); - $this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; + // Initialise variables + $this->_author = 'Author'; + $this->_text = new PHPExcel_RichText(); + $this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1'); + $this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; } /** @@ -118,7 +118,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return string */ public function getAuthor() { - return $this->_author; + return $this->_author; } /** @@ -127,10 +127,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @param string $pValue * @return PHPExcel_Comment */ - public function setAuthor($pValue = '') { - $this->_author = $pValue; - return $this; - } + public function setAuthor($pValue = '') { + $this->_author = $pValue; + return $this; + } /** * Get Rich text comment @@ -138,7 +138,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return PHPExcel_RichText */ public function getText() { - return $this->_text; + return $this->_text; } /** @@ -148,8 +148,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return PHPExcel_Comment */ public function setText(PHPExcel_RichText $pValue) { - $this->_text = $pValue; - return $this; + $this->_text = $pValue; + return $this; } /** @@ -268,8 +268,8 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return PHPExcel_Comment */ public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) { - $this->_alignment = $pValue; - return $this; + $this->_alignment = $pValue; + return $this; } /** @@ -278,40 +278,40 @@ class PHPExcel_Comment implements PHPExcel_IComparable * @return string */ public function getAlignment() { - return $this->_alignment; + return $this->_alignment; } - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - return md5( - $this->_author - . $this->_text->getHashCode() - . $this->_width - . $this->_height - . $this->_marginLeft - . $this->_marginTop - . ($this->_visible ? 1 : 0) - . $this->_fillColor->getHashCode() - . $this->_alignment - . __CLASS__ - ); + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_author + . $this->_text->getHashCode() + . $this->_width + . $this->_height + . $this->_marginLeft + . $this->_marginTop + . ($this->_visible ? 1 : 0) + . $this->_fillColor->getHashCode() + . $this->_alignment + . __CLASS__ + ); } - /** - * 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)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } + /** + * 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)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } } diff --git a/Classes/PHPExcel/DocumentProperties.php b/Classes/PHPExcel/DocumentProperties.php index 6bde10fc..952fa7df 100644 --- a/Classes/PHPExcel/DocumentProperties.php +++ b/Classes/PHPExcel/DocumentProperties.php @@ -18,571 +18,570 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PHPExcel - * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @category PHPExcel + * @package PHPExcel + * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## */ /** * PHPExcel_DocumentProperties * - * @category PHPExcel - * @package PHPExcel - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) + * @category PHPExcel + * @package PHPExcel + * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_DocumentProperties { - /** constants */ - const PROPERTY_TYPE_BOOLEAN = 'b'; - const PROPERTY_TYPE_INTEGER = 'i'; - const PROPERTY_TYPE_FLOAT = 'f'; - const PROPERTY_TYPE_DATE = 'd'; - const PROPERTY_TYPE_STRING = 's'; - const PROPERTY_TYPE_UNKNOWN = 'u'; + /** constants */ + const PROPERTY_TYPE_BOOLEAN = 'b'; + const PROPERTY_TYPE_INTEGER = 'i'; + const PROPERTY_TYPE_FLOAT = 'f'; + const PROPERTY_TYPE_DATE = 'd'; + const PROPERTY_TYPE_STRING = 's'; + const PROPERTY_TYPE_UNKNOWN = 'u'; + + /** + * Creator + * + * @var string + */ + private $_creator = 'Unknown Creator'; + + /** + * LastModifiedBy + * + * @var string + */ + private $_lastModifiedBy; + + /** + * Created + * + * @var datetime + */ + private $_created; + + /** + * Modified + * + * @var datetime + */ + private $_modified; + + /** + * Title + * + * @var string + */ + private $_title = 'Untitled Spreadsheet'; + + /** + * Description + * + * @var string + */ + private $_description = ''; + + /** + * Subject + * + * @var string + */ + private $_subject = ''; + + /** + * Keywords + * + * @var string + */ + private $_keywords = ''; + + /** + * Category + * + * @var string + */ + private $_category = ''; + + /** + * Manager + * + * @var string + */ + private $_manager = ''; + + /** + * Company + * + * @var string + */ + private $_company = 'Microsoft Corporation'; + + /** + * Custom Properties + * + * @var string + */ + private $_customProperties = array(); - /** - * Creator - * - * @var string - */ - private $_creator = 'Unknown Creator'; + /** + * Create a new PHPExcel_DocumentProperties + */ + public function __construct() + { + // Initialise values + $this->_lastModifiedBy = $this->_creator; + $this->_created = time(); + $this->_modified = time(); + } - /** - * LastModifiedBy - * - * @var string - */ - private $_lastModifiedBy; + /** + * Get Creator + * + * @return string + */ + public function getCreator() { + return $this->_creator; + } - /** - * Created - * - * @var datetime - */ - private $_created; + /** + * Set Creator + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setCreator($pValue = '') { + $this->_creator = $pValue; + return $this; + } - /** - * Modified - * - * @var datetime - */ - private $_modified; + /** + * Get Last Modified By + * + * @return string + */ + public function getLastModifiedBy() { + return $this->_lastModifiedBy; + } - /** - * Title - * - * @var string - */ - private $_title = 'Untitled Spreadsheet'; + /** + * Set Last Modified By + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setLastModifiedBy($pValue = '') { + $this->_lastModifiedBy = $pValue; + return $this; + } - /** - * Description - * - * @var string - */ - private $_description = ''; + /** + * Get Created + * + * @return datetime + */ + public function getCreated() { + return $this->_created; + } - /** - * Subject - * - * @var string - */ - private $_subject = ''; + /** + * Set Created + * + * @param datetime $pValue + * @return PHPExcel_DocumentProperties + */ + public function setCreated($pValue = null) { + if ($pValue === NULL) { + $pValue = time(); + } elseif (is_string($pValue)) { + if (is_numeric($pValue)) { + $pValue = intval($pValue); + } else { + $pValue = strtotime($pValue); + } + } - /** - * Keywords - * - * @var string - */ - private $_keywords = ''; + $this->_created = $pValue; + return $this; + } - /** - * Category - * - * @var string - */ - private $_category = ''; + /** + * Get Modified + * + * @return datetime + */ + public function getModified() { + return $this->_modified; + } - /** - * Manager - * - * @var string - */ - private $_manager = ''; + /** + * Set Modified + * + * @param datetime $pValue + * @return PHPExcel_DocumentProperties + */ + public function setModified($pValue = null) { + if ($pValue === NULL) { + $pValue = time(); + } elseif (is_string($pValue)) { + if (is_numeric($pValue)) { + $pValue = intval($pValue); + } else { + $pValue = strtotime($pValue); + } + } - /** - * Company - * - * @var string - */ - private $_company = 'Microsoft Corporation'; + $this->_modified = $pValue; + return $this; + } - /** - * Custom Properties - * - * @var string - */ - private $_customProperties = array(); + /** + * Get Title + * + * @return string + */ + public function getTitle() { + return $this->_title; + } + /** + * Set Title + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setTitle($pValue = '') { + $this->_title = $pValue; + return $this; + } - /** - * Create a new PHPExcel_DocumentProperties - */ - public function __construct() - { - // Initialise values - $this->_lastModifiedBy = $this->_creator; - $this->_created = time(); - $this->_modified = time(); - } + /** + * Get Description + * + * @return string + */ + public function getDescription() { + return $this->_description; + } - /** - * Get Creator - * - * @return string - */ - public function getCreator() { - return $this->_creator; - } + /** + * Set Description + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setDescription($pValue = '') { + $this->_description = $pValue; + return $this; + } - /** - * Set Creator - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setCreator($pValue = '') { - $this->_creator = $pValue; - return $this; - } + /** + * Get Subject + * + * @return string + */ + public function getSubject() { + return $this->_subject; + } - /** - * Get Last Modified By - * - * @return string - */ - public function getLastModifiedBy() { - return $this->_lastModifiedBy; - } + /** + * Set Subject + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setSubject($pValue = '') { + $this->_subject = $pValue; + return $this; + } - /** - * Set Last Modified By - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setLastModifiedBy($pValue = '') { - $this->_lastModifiedBy = $pValue; - return $this; - } + /** + * Get Keywords + * + * @return string + */ + public function getKeywords() { + return $this->_keywords; + } - /** - * Get Created - * - * @return datetime - */ - public function getCreated() { - return $this->_created; - } + /** + * Set Keywords + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setKeywords($pValue = '') { + $this->_keywords = $pValue; + return $this; + } - /** - * Set Created - * - * @param datetime $pValue - * @return PHPExcel_DocumentProperties - */ - public function setCreated($pValue = null) { - if ($pValue === NULL) { - $pValue = time(); - } elseif (is_string($pValue)) { - if (is_numeric($pValue)) { - $pValue = intval($pValue); - } else { - $pValue = strtotime($pValue); - } - } + /** + * Get Category + * + * @return string + */ + public function getCategory() { + return $this->_category; + } - $this->_created = $pValue; - return $this; - } + /** + * Set Category + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setCategory($pValue = '') { + $this->_category = $pValue; + return $this; + } - /** - * Get Modified - * - * @return datetime - */ - public function getModified() { - return $this->_modified; - } + /** + * Get Company + * + * @return string + */ + public function getCompany() { + return $this->_company; + } - /** - * Set Modified - * - * @param datetime $pValue - * @return PHPExcel_DocumentProperties - */ - public function setModified($pValue = null) { - if ($pValue === NULL) { - $pValue = time(); - } elseif (is_string($pValue)) { - if (is_numeric($pValue)) { - $pValue = intval($pValue); - } else { - $pValue = strtotime($pValue); - } - } + /** + * Set Company + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setCompany($pValue = '') { + $this->_company = $pValue; + return $this; + } - $this->_modified = $pValue; - return $this; - } + /** + * Get Manager + * + * @return string + */ + public function getManager() { + return $this->_manager; + } - /** - * Get Title - * - * @return string - */ - public function getTitle() { - return $this->_title; - } + /** + * Set Manager + * + * @param string $pValue + * @return PHPExcel_DocumentProperties + */ + public function setManager($pValue = '') { + $this->_manager = $pValue; + return $this; + } - /** - * Set Title - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setTitle($pValue = '') { - $this->_title = $pValue; - return $this; - } + /** + * Get a List of Custom Property Names + * + * @return array of string + */ + public function getCustomProperties() { + return array_keys($this->_customProperties); + } - /** - * Get Description - * - * @return string - */ - public function getDescription() { - return $this->_description; - } + /** + * Check if a Custom Property is defined + * + * @param string $propertyName + * @return boolean + */ + public function isCustomPropertySet($propertyName) { + return isset($this->_customProperties[$propertyName]); + } - /** - * Set Description - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setDescription($pValue = '') { - $this->_description = $pValue; - return $this; - } + /** + * Get a Custom Property Value + * + * @param string $propertyName + * @return string + */ + public function getCustomPropertyValue($propertyName) { + if (isset($this->_customProperties[$propertyName])) { + return $this->_customProperties[$propertyName]['value']; + } - /** - * Get Subject - * - * @return string - */ - public function getSubject() { - return $this->_subject; - } + } - /** - * Set Subject - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setSubject($pValue = '') { - $this->_subject = $pValue; - return $this; - } + /** + * Get a Custom Property Type + * + * @param string $propertyName + * @return string + */ + public function getCustomPropertyType($propertyName) { + if (isset($this->_customProperties[$propertyName])) { + return $this->_customProperties[$propertyName]['type']; + } - /** - * Get Keywords - * - * @return string - */ - public function getKeywords() { - return $this->_keywords; - } + } - /** - * Set Keywords - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setKeywords($pValue = '') { - $this->_keywords = $pValue; - return $this; - } + /** + * Set a Custom Property + * + * @param string $propertyName + * @param mixed $propertyValue + * @param string $propertyType + * 'i' : Integer + * 'f' : Floating Point + * 's' : String + * 'd' : Date/Time + * 'b' : Boolean + * @return PHPExcel_DocumentProperties + */ + public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) { + if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER, + self::PROPERTY_TYPE_FLOAT, + self::PROPERTY_TYPE_STRING, + self::PROPERTY_TYPE_DATE, + self::PROPERTY_TYPE_BOOLEAN)))) { + if ($propertyValue === NULL) { + $propertyType = self::PROPERTY_TYPE_STRING; + } elseif (is_float($propertyValue)) { + $propertyType = self::PROPERTY_TYPE_FLOAT; + } elseif(is_int($propertyValue)) { + $propertyType = self::PROPERTY_TYPE_INTEGER; + } elseif (is_bool($propertyValue)) { + $propertyType = self::PROPERTY_TYPE_BOOLEAN; + } else { + $propertyType = self::PROPERTY_TYPE_STRING; + } + } - /** - * Get Category - * - * @return string - */ - public function getCategory() { - return $this->_category; - } + $this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType); + return $this; + } - /** - * Set Category - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setCategory($pValue = '') { - $this->_category = $pValue; - return $this; - } + /** + * 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)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } - /** - * Get Company - * - * @return string - */ - public function getCompany() { - return $this->_company; - } + public static function convertProperty($propertyValue,$propertyType) { + switch ($propertyType) { + case 'empty' : // Empty + return ''; + break; + case 'null' : // Null + return NULL; + break; + case 'i1' : // 1-Byte Signed Integer + case 'i2' : // 2-Byte Signed Integer + case 'i4' : // 4-Byte Signed Integer + case 'i8' : // 8-Byte Signed Integer + case 'int' : // Integer + return (int) $propertyValue; + break; + case 'ui1' : // 1-Byte Unsigned Integer + case 'ui2' : // 2-Byte Unsigned Integer + case 'ui4' : // 4-Byte Unsigned Integer + case 'ui8' : // 8-Byte Unsigned Integer + case 'uint' : // Unsigned Integer + return abs((int) $propertyValue); + break; + case 'r4' : // 4-Byte Real Number + case 'r8' : // 8-Byte Real Number + case 'decimal' : // Decimal + return (float) $propertyValue; + break; + case 'lpstr' : // LPSTR + case 'lpwstr' : // LPWSTR + case 'bstr' : // Basic String + return $propertyValue; + break; + case 'date' : // Date and Time + case 'filetime' : // File Time + return strtotime($propertyValue); + break; + case 'bool' : // Boolean + return ($propertyValue == 'true') ? True : False; + break; + case 'cy' : // Currency + case 'error' : // Error Status Code + case 'vector' : // Vector + case 'array' : // Array + case 'blob' : // Binary Blob + case 'oblob' : // Binary Blob Object + case 'stream' : // Binary Stream + case 'ostream' : // Binary Stream Object + case 'storage' : // Binary Storage + case 'ostorage' : // Binary Storage Object + case 'vstream' : // Binary Versioned Stream + case 'clsid' : // Class ID + case 'cf' : // Clipboard Data + return $propertyValue; + break; + } + return $propertyValue; + } - /** - * Set Company - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setCompany($pValue = '') { - $this->_company = $pValue; - return $this; - } - - /** - * Get Manager - * - * @return string - */ - public function getManager() { - return $this->_manager; - } - - /** - * Set Manager - * - * @param string $pValue - * @return PHPExcel_DocumentProperties - */ - public function setManager($pValue = '') { - $this->_manager = $pValue; - return $this; - } - - /** - * Get a List of Custom Property Names - * - * @return array of string - */ - public function getCustomProperties() { - return array_keys($this->_customProperties); - } - - /** - * Check if a Custom Property is defined - * - * @param string $propertyName - * @return boolean - */ - public function isCustomPropertySet($propertyName) { - return isset($this->_customProperties[$propertyName]); - } - - /** - * Get a Custom Property Value - * - * @param string $propertyName - * @return string - */ - public function getCustomPropertyValue($propertyName) { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['value']; - } - - } - - /** - * Get a Custom Property Type - * - * @param string $propertyName - * @return string - */ - public function getCustomPropertyType($propertyName) { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['type']; - } - - } - - /** - * Set a Custom Property - * - * @param string $propertyName - * @param mixed $propertyValue - * @param string $propertyType - * 'i' : Integer - * 'f' : Floating Point - * 's' : String - * 'd' : Date/Time - * 'b' : Boolean - * @return PHPExcel_DocumentProperties - */ - public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) { - if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER, - self::PROPERTY_TYPE_FLOAT, - self::PROPERTY_TYPE_STRING, - self::PROPERTY_TYPE_DATE, - self::PROPERTY_TYPE_BOOLEAN)))) { - if ($propertyValue === NULL) { - $propertyType = self::PROPERTY_TYPE_STRING; - } elseif (is_float($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_FLOAT; - } elseif(is_int($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_INTEGER; - } elseif (is_bool($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_BOOLEAN; - } else { - $propertyType = self::PROPERTY_TYPE_STRING; - } - } - - $this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType); - return $this; - } - - /** - * 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)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } - - public static function convertProperty($propertyValue,$propertyType) { - switch ($propertyType) { - case 'empty' : // Empty - return ''; - break; - case 'null' : // Null - return NULL; - break; - case 'i1' : // 1-Byte Signed Integer - case 'i2' : // 2-Byte Signed Integer - case 'i4' : // 4-Byte Signed Integer - case 'i8' : // 8-Byte Signed Integer - case 'int' : // Integer - return (int) $propertyValue; - break; - case 'ui1' : // 1-Byte Unsigned Integer - case 'ui2' : // 2-Byte Unsigned Integer - case 'ui4' : // 4-Byte Unsigned Integer - case 'ui8' : // 8-Byte Unsigned Integer - case 'uint' : // Unsigned Integer - return abs((int) $propertyValue); - break; - case 'r4' : // 4-Byte Real Number - case 'r8' : // 8-Byte Real Number - case 'decimal' : // Decimal - return (float) $propertyValue; - break; - case 'lpstr' : // LPSTR - case 'lpwstr' : // LPWSTR - case 'bstr' : // Basic String - return $propertyValue; - break; - case 'date' : // Date and Time - case 'filetime' : // File Time - return strtotime($propertyValue); - break; - case 'bool' : // Boolean - return ($propertyValue == 'true') ? True : False; - break; - case 'cy' : // Currency - case 'error' : // Error Status Code - case 'vector' : // Vector - case 'array' : // Array - case 'blob' : // Binary Blob - case 'oblob' : // Binary Blob Object - case 'stream' : // Binary Stream - case 'ostream' : // Binary Stream Object - case 'storage' : // Binary Storage - case 'ostorage' : // Binary Storage Object - case 'vstream' : // Binary Versioned Stream - case 'clsid' : // Class ID - case 'cf' : // Clipboard Data - return $propertyValue; - break; - } - return $propertyValue; - } - - public static function convertPropertyType($propertyType) { - switch ($propertyType) { - case 'i1' : // 1-Byte Signed Integer - case 'i2' : // 2-Byte Signed Integer - case 'i4' : // 4-Byte Signed Integer - case 'i8' : // 8-Byte Signed Integer - case 'int' : // Integer - case 'ui1' : // 1-Byte Unsigned Integer - case 'ui2' : // 2-Byte Unsigned Integer - case 'ui4' : // 4-Byte Unsigned Integer - case 'ui8' : // 8-Byte Unsigned Integer - case 'uint' : // Unsigned Integer - return self::PROPERTY_TYPE_INTEGER; - break; - case 'r4' : // 4-Byte Real Number - case 'r8' : // 8-Byte Real Number - case 'decimal' : // Decimal - return self::PROPERTY_TYPE_FLOAT; - break; - case 'empty' : // Empty - case 'null' : // Null - case 'lpstr' : // LPSTR - case 'lpwstr' : // LPWSTR - case 'bstr' : // Basic String - return self::PROPERTY_TYPE_STRING; - break; - case 'date' : // Date and Time - case 'filetime' : // File Time - return self::PROPERTY_TYPE_DATE; - break; - case 'bool' : // Boolean - return self::PROPERTY_TYPE_BOOLEAN; - break; - case 'cy' : // Currency - case 'error' : // Error Status Code - case 'vector' : // Vector - case 'array' : // Array - case 'blob' : // Binary Blob - case 'oblob' : // Binary Blob Object - case 'stream' : // Binary Stream - case 'ostream' : // Binary Stream Object - case 'storage' : // Binary Storage - case 'ostorage' : // Binary Storage Object - case 'vstream' : // Binary Versioned Stream - case 'clsid' : // Class ID - case 'cf' : // Clipboard Data - return self::PROPERTY_TYPE_UNKNOWN; - break; - } - return self::PROPERTY_TYPE_UNKNOWN; - } + public static function convertPropertyType($propertyType) { + switch ($propertyType) { + case 'i1' : // 1-Byte Signed Integer + case 'i2' : // 2-Byte Signed Integer + case 'i4' : // 4-Byte Signed Integer + case 'i8' : // 8-Byte Signed Integer + case 'int' : // Integer + case 'ui1' : // 1-Byte Unsigned Integer + case 'ui2' : // 2-Byte Unsigned Integer + case 'ui4' : // 4-Byte Unsigned Integer + case 'ui8' : // 8-Byte Unsigned Integer + case 'uint' : // Unsigned Integer + return self::PROPERTY_TYPE_INTEGER; + break; + case 'r4' : // 4-Byte Real Number + case 'r8' : // 8-Byte Real Number + case 'decimal' : // Decimal + return self::PROPERTY_TYPE_FLOAT; + break; + case 'empty' : // Empty + case 'null' : // Null + case 'lpstr' : // LPSTR + case 'lpwstr' : // LPWSTR + case 'bstr' : // Basic String + return self::PROPERTY_TYPE_STRING; + break; + case 'date' : // Date and Time + case 'filetime' : // File Time + return self::PROPERTY_TYPE_DATE; + break; + case 'bool' : // Boolean + return self::PROPERTY_TYPE_BOOLEAN; + break; + case 'cy' : // Currency + case 'error' : // Error Status Code + case 'vector' : // Vector + case 'array' : // Array + case 'blob' : // Binary Blob + case 'oblob' : // Binary Blob Object + case 'stream' : // Binary Stream + case 'ostream' : // Binary Stream Object + case 'storage' : // Binary Storage + case 'ostorage' : // Binary Storage Object + case 'vstream' : // Binary Versioned Stream + case 'clsid' : // Class ID + case 'cf' : // Clipboard Data + return self::PROPERTY_TYPE_UNKNOWN; + break; + } + return self::PROPERTY_TYPE_UNKNOWN; + } } diff --git a/Classes/PHPExcel/Exception.php b/Classes/PHPExcel/Exception.php index a4354531..8ac53865 100644 --- a/Classes/PHPExcel/Exception.php +++ b/Classes/PHPExcel/Exception.php @@ -21,8 +21,8 @@ * @category PHPExcel * @package PHPExcel * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## */ @@ -34,19 +34,19 @@ * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Exception extends Exception { - /** - * Error handler callback - * - * @param mixed $code - * @param mixed $string - * @param mixed $file - * @param mixed $line - * @param mixed $context - */ - public static function errorHandlerCallback($code, $string, $file, $line, $context) { - $e = new self($string, $code); - $e->line = $line; - $e->file = $file; - throw $e; - } + /** + * Error handler callback + * + * @param mixed $code + * @param mixed $string + * @param mixed $file + * @param mixed $line + * @param mixed $context + */ + public static function errorHandlerCallback($code, $string, $file, $line, $context) { + $e = new self($string, $code); + $e->line = $line; + $e->file = $file; + throw $e; + } } diff --git a/Classes/PHPExcel/RichText.php b/Classes/PHPExcel/RichText.php index b53bb486..09004901 100644 --- a/Classes/PHPExcel/RichText.php +++ b/Classes/PHPExcel/RichText.php @@ -21,7 +21,7 @@ * @category PHPExcel * @package PHPExcel_RichText * @copyright Copyright (c) 2006 - 2012 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 ##VERSION##, ##DATE## */ @@ -35,77 +35,77 @@ */ class PHPExcel_RichText implements PHPExcel_IComparable { - /** - * Rich text elements - * - * @var PHPExcel_RichText_ITextElement[] - */ - private $_richTextElements; + /** + * Rich text elements + * + * @var PHPExcel_RichText_ITextElement[] + */ + private $_richTextElements; /** * Create a new PHPExcel_RichText instance * - * @param PHPExcel_Cell $pParent - * @throws PHPExcel_Exception + * @param PHPExcel_Cell $pParent + * @throws PHPExcel_Exception */ public function __construct(PHPExcel_Cell $pCell = null) { - // Initialise variables - $this->_richTextElements = array(); + // Initialise variables + $this->_richTextElements = array(); - // Rich-Text string attached to cell? - if ($pCell !== NULL) { - // Add cell text and style - if ($pCell->getValue() != "") { - $objRun = new PHPExcel_RichText_Run($pCell->getValue()); - $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); - $this->addText($objRun); - } + // Rich-Text string attached to cell? + if ($pCell !== NULL) { + // Add cell text and style + if ($pCell->getValue() != "") { + $objRun = new PHPExcel_RichText_Run($pCell->getValue()); + $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); + $this->addText($objRun); + } - // Set parent value - $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING); - } + // Set parent value + $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING); + } } /** * Add text * - * @param PHPExcel_RichText_ITextElement $pText Rich text element - * @throws PHPExcel_Exception + * @param PHPExcel_RichText_ITextElement $pText Rich text element + * @throws PHPExcel_Exception * @return PHPExcel_RichText */ public function addText(PHPExcel_RichText_ITextElement $pText = null) { - $this->_richTextElements[] = $pText; - return $this; + $this->_richTextElements[] = $pText; + return $this; } /** * Create text * - * @param string $pText Text - * @return PHPExcel_RichText_TextElement - * @throws PHPExcel_Exception + * @param string $pText Text + * @return PHPExcel_RichText_TextElement + * @throws PHPExcel_Exception */ public function createText($pText = '') { - $objText = new PHPExcel_RichText_TextElement($pText); - $this->addText($objText); - return $objText; + $objText = new PHPExcel_RichText_TextElement($pText); + $this->addText($objText); + return $objText; } /** * Create text run * - * @param string $pText Text - * @return PHPExcel_RichText_Run - * @throws PHPExcel_Exception + * @param string $pText Text + * @return PHPExcel_RichText_Run + * @throws PHPExcel_Exception */ public function createTextRun($pText = '') { - $objText = new PHPExcel_RichText_Run($pText); - $this->addText($objText); - return $objText; + $objText = new PHPExcel_RichText_Run($pText); + $this->addText($objText); + return $objText; } /** @@ -115,16 +115,16 @@ class PHPExcel_RichText implements PHPExcel_IComparable */ public function getPlainText() { - // Return value - $returnValue = ''; + // Return value + $returnValue = ''; - // Loop through all PHPExcel_RichText_ITextElement - foreach ($this->_richTextElements as $text) { - $returnValue .= $text->getText(); - } + // Loop through all PHPExcel_RichText_ITextElement + foreach ($this->_richTextElements as $text) { + $returnValue .= $text->getText(); + } - // Return - return $returnValue; + // Return + return $returnValue; } /** @@ -132,8 +132,9 @@ class PHPExcel_RichText implements PHPExcel_IComparable * * @return string */ - public function __toString() { - return $this->getPlainText(); + public function __toString() + { + return $this->getPlainText(); } /** @@ -143,54 +144,56 @@ class PHPExcel_RichText implements PHPExcel_IComparable */ public function getRichTextElements() { - return $this->_richTextElements; + return $this->_richTextElements; } /** * Set Rich Text elements * - * @param PHPExcel_RichText_ITextElement[] $pElements Array of elements - * @throws PHPExcel_Exception + * @param PHPExcel_RichText_ITextElement[] $pElements Array of elements + * @throws PHPExcel_Exception * @return PHPExcel_RichText */ public function setRichTextElements($pElements = null) { - if (is_array($pElements)) { - $this->_richTextElements = $pElements; - } else { - throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); - } - return $this; + if (is_array($pElements)) { + $this->_richTextElements = $pElements; + } else { + throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); + } + return $this; } - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - $hashElements = ''; - foreach ($this->_richTextElements as $element) { - $hashElements .= $element->getHashCode(); - } + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() + { + $hashElements = ''; + foreach ($this->_richTextElements as $element) { + $hashElements .= $element->getHashCode(); + } - return md5( - $hashElements - . __CLASS__ - ); + return md5( + $hashElements + . __CLASS__ + ); } - /** - * 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)) { - $this->$key = clone $value; - } else { - $this->$key = $value; - } - } - } + /** + * 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)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } } diff --git a/Classes/PHPExcel/Settings.php b/Classes/PHPExcel/Settings.php index e6162313..eed460c3 100644 --- a/Classes/PHPExcel/Settings.php +++ b/Classes/PHPExcel/Settings.php @@ -21,312 +21,334 @@ * @category PHPExcel * @package PHPExcel_Settings * @copyright Copyright (c) 2006 - 2012 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 ##VERSION##, ##DATE## */ /** PHPExcel root directory */ if (!defined('PHPEXCEL_ROOT')) { - /** - * @ignore - */ - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../'); - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); + /** + * @ignore + */ + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../'); + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); } class PHPExcel_Settings { - /** constants */ - /** Available Zip library classes */ - const PCLZIP = 'PHPExcel_Shared_ZipArchive'; - const ZIPARCHIVE = 'ZipArchive'; + /** constants */ + /** Available Zip library classes */ + const PCLZIP = 'PHPExcel_Shared_ZipArchive'; + const ZIPARCHIVE = 'ZipArchive'; - /** Optional Chart Rendering libraries */ - const CHART_RENDERER_JPGRAPH = 'jpgraph'; + /** Optional Chart Rendering libraries */ + const CHART_RENDERER_JPGRAPH = 'jpgraph'; - /** Optional PDF Rendering libraries */ + /** Optional PDF Rendering libraries */ const PDF_RENDERER_TCPDF = 'tcPDF'; const PDF_RENDERER_DOMPDF = 'DomPDF'; - const PDF_RENDERER_MPDF = 'mPDF'; + const PDF_RENDERER_MPDF = 'mPDF'; - private static $_chartRenderers = array( - self::CHART_RENDERER_JPGRAPH, - ); + private static $_chartRenderers = array( + self::CHART_RENDERER_JPGRAPH, + ); - private static $_pdfRenderers = array( - self::PDF_RENDERER_TCPDF, - self::PDF_RENDERER_DOMPDF, - self::PDF_RENDERER_MPDF, - ); + private static $_pdfRenderers = array( + self::PDF_RENDERER_TCPDF, + self::PDF_RENDERER_DOMPDF, + self::PDF_RENDERER_MPDF, + ); - /** - * Name of the class used for Zip file management - * e.g. - * ZipArchive - * - * @var string - */ - private static $_zipClass = self::ZIPARCHIVE; + /** + * Name of the class used for Zip file management + * e.g. + * ZipArchive + * + * @var string + */ + private static $_zipClass = self::ZIPARCHIVE; - /** - * Name of the external Library used for rendering charts - * e.g. - * jpgraph - * - * @var string - */ - private static $_chartRendererName = NULL; + /** + * Name of the external Library used for rendering charts + * e.g. + * jpgraph + * + * @var string + */ + private static $_chartRendererName = NULL; - /** - * Directory Path to the external Library used for rendering charts - * - * @var string - */ - private static $_chartRendererPath = NULL; + /** + * Directory Path to the external Library used for rendering charts + * + * @var string + */ + private static $_chartRendererPath = NULL; - /** - * Name of the external Library used for rendering PDF files - * e.g. - * mPDF - * - * @var string - */ - private static $_pdfRendererName = NULL; + /** + * Name of the external Library used for rendering PDF files + * e.g. + * mPDF + * + * @var string + */ + private static $_pdfRendererName = NULL; - /** - * Directory Path to the external Library used for rendering PDF files - * - * @var string - */ - private static $_pdfRendererPath = NULL; + /** + * Directory Path to the external Library used for rendering PDF files + * + * @var string + */ + private static $_pdfRendererPath = NULL; - /** - * Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive) - * - * @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management - * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive - * @return boolean Success or failure - */ - public static function setZipClass($zipClass) { - if (($zipClass === self::PCLZIP) || - ($zipClass === self::ZIPARCHIVE)) { - self::$_zipClass = $zipClass; - return TRUE; - } - return FALSE; - } // function setZipClass() + /** + * Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive) + * + * @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management + * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive + * @return boolean Success or failure + */ + public static function setZipClass($zipClass) + { + if (($zipClass === self::PCLZIP) || + ($zipClass === self::ZIPARCHIVE)) { + self::$_zipClass = $zipClass; + return TRUE; + } + return FALSE; + } // function setZipClass() - /** - * Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive) - * for Zip file management - * - * @return string Name of the Zip handler Class that PHPExcel is configured to use - * for Zip file management - * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive - */ - public static function getZipClass() { - return self::$_zipClass; - } // function getZipClass() + /** + * Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive) + * or Zip file management + * + * @return string Name of the Zip handler Class that PHPExcel is configured to use + * for Zip file management + * e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive + */ + public static function getZipClass() + { + return self::$_zipClass; + } // function getZipClass() - /** - * Return the name of the method that is currently configured for cell cacheing - * - * @return string Name of the cacheing method - */ - public static function getCacheStorageMethod() { - return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod(); - } // function getCacheStorageMethod() + /** + * Return the name of the method that is currently configured for cell cacheing + * + * @return string Name of the cacheing method + */ + public static function getCacheStorageMethod() + { + return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod(); + } // function getCacheStorageMethod() - /** - * Return the name of the class that is currently being used for cell cacheing - * - * @return string Name of the class currently being used for cacheing - */ - public static function getCacheStorageClass() { - return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass(); - } // function getCacheStorageClass() + /** + * Return the name of the class that is currently being used for cell cacheing + * + * @return string Name of the class currently being used for cacheing + */ + public static function getCacheStorageClass() + { + return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass(); + } // function getCacheStorageClass() - /** - * Set the method that should be used for cell cacheing - * - * @param string $method Name of the cacheing method - * @param array $arguments Optional configuration arguments for the cacheing method - * @return boolean Success or failure - */ - public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, - $arguments = array()) { - return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments); - } // function setCacheStorageMethod() + /** + * Set the method that should be used for cell cacheing + * + * @param string $method Name of the cacheing method + * @param array $arguments Optional configuration arguments for the cacheing method + * @return boolean Success or failure + */ + public static function setCacheStorageMethod( + $method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, + $arguments = array() + ) + { + return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments); + } // function setCacheStorageMethod() - /** - * Set the locale code to use for formula translations and any special formatting - * - * @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk") - * @return boolean Success or failure - */ - public static function setLocale($locale='en_us') { - return PHPExcel_Calculation::getInstance()->setLocale($locale); - } // function setLocale() + /** + * Set the locale code to use for formula translations and any special formatting + * + * @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk") + * @return boolean Success or failure + */ + public static function setLocale($locale='en_us') + { + return PHPExcel_Calculation::getInstance()->setLocale($locale); + } // function setLocale() - /** - * Set details of the external library that PHPExcel should use for rendering charts - * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH - * @param string $libraryBaseDir Directory path to the library's base folder - * @return boolean Success or failure - */ - public static function setChartRenderer($libraryName, $libraryBaseDir) { - if (!self::setChartRendererName($libraryName)) - return FALSE; - return self::setChartRendererPath($libraryBaseDir); - } // function setChartRenderer() + /** + * Set details of the external library that PHPExcel should use for rendering charts + * + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH + * @param string $libraryBaseDir Directory path to the library's base folder + * + * @return boolean Success or failure + */ + public static function setChartRenderer($libraryName, $libraryBaseDir) + { + if (!self::setChartRendererName($libraryName)) + return FALSE; + return self::setChartRendererPath($libraryBaseDir); + } // function setChartRenderer() - /** - * Identify to PHPExcel the external library to use for rendering charts - * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH - * @return boolean Success or failure - */ - public static function setChartRendererName($libraryName) { - if (!in_array($libraryName,self::$_chartRenderers)) { - return FALSE; - } + /** + * Identify to PHPExcel the external library to use for rendering charts + * + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH + * + * @return boolean Success or failure + */ + public static function setChartRendererName($libraryName) + { + if (!in_array($libraryName,self::$_chartRenderers)) { + return FALSE; + } - self::$_chartRendererName = $libraryName; + self::$_chartRendererName = $libraryName; - return TRUE; - } // function setChartRendererName() + return TRUE; + } // function setChartRendererName() - /** - * Tell PHPExcel where to find the external library to use for rendering charts - * - * @param string $libraryBaseDir Directory path to the library's base folder - * @return boolean Success or failure - */ - public static function setChartRendererPath($libraryBaseDir) { - if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { - return FALSE; - } - self::$_chartRendererPath = $libraryBaseDir; + /** + * Tell PHPExcel where to find the external library to use for rendering charts + * + * @param string $libraryBaseDir Directory path to the library's base folder + * @return boolean Success or failure + */ + public static function setChartRendererPath($libraryBaseDir) + { + if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { + return FALSE; + } + self::$_chartRendererPath = $libraryBaseDir; - return TRUE; - } // function setChartRendererPath() + return TRUE; + } // function setChartRendererPath() - /** - * Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph) - * - * @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is - * currently configured to use - * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH - */ - public static function getChartRendererName() { - return self::$_chartRendererName; - } // function getChartRendererName() + /** + * Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph) + * + * @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is + * currently configured to use + * e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH + */ + public static function getChartRendererName() + { + return self::$_chartRendererName; + } // function getChartRendererName() - /** - * Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use - * - * @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is - * currently configured to use - */ - public static function getChartRendererPath() { - return self::$_chartRendererPath; - } // function getChartRendererPath() + /** + * Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use + * + * @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is + * currently configured to use + */ + public static function getChartRendererPath() + { + return self::$_chartRendererPath; + } // function getChartRendererPath() - /** - * Set details of the external library that PHPExcel should use for rendering PDF files - * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, - * PHPExcel_Settings::PDF_RENDERER_DOMPDF - * or PHPExcel_Settings::PDF_RENDERER_MPDF - * @param string $libraryBaseDir Directory path to the library's base folder - * @return boolean Success or failure - */ - public static function setPdfRenderer($libraryName, $libraryBaseDir) { - if (!self::setPdfRendererName($libraryName)) - return FALSE; - return self::setPdfRendererPath($libraryBaseDir); - } // function setPdfRenderer() + /** + * Set details of the external library that PHPExcel should use for rendering PDF files + * + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, + * PHPExcel_Settings::PDF_RENDERER_DOMPDF + * or PHPExcel_Settings::PDF_RENDERER_MPDF + * @param string $libraryBaseDir Directory path to the library's base folder + * + * @return boolean Success or failure + */ + public static function setPdfRenderer($libraryName, $libraryBaseDir) + { + if (!self::setPdfRendererName($libraryName)) + return FALSE; + return self::setPdfRendererPath($libraryBaseDir); + } // function setPdfRenderer() - /** - * Identify to PHPExcel the external library to use for rendering PDF files - * - * @param string $libraryName Internal reference name of the library - * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, - * PHPExcel_Settings::PDF_RENDERER_DOMPDF - * or PHPExcel_Settings::PDF_RENDERER_MPDF - * @return boolean Success or failure - */ - public static function setPdfRendererName($libraryName) { - if (!in_array($libraryName,self::$_pdfRenderers)) { - return FALSE; - } + /** + * Identify to PHPExcel the external library to use for rendering PDF files + * + * @param string $libraryName Internal reference name of the library + * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, + * PHPExcel_Settings::PDF_RENDERER_DOMPDF + * or PHPExcel_Settings::PDF_RENDERER_MPDF + * + * @return boolean Success or failure + */ + public static function setPdfRendererName($libraryName) + { + if (!in_array($libraryName,self::$_pdfRenderers)) { + return FALSE; + } - self::$_pdfRendererName = $libraryName; + self::$_pdfRendererName = $libraryName; - return TRUE; - } // function setPdfRendererName() + return TRUE; + } // function setPdfRendererName() - /** - * Tell PHPExcel where to find the external library to use for rendering PDF files - * - * @param string $libraryBaseDir Directory path to the library's base folder - * @return boolean Success or failure - */ - public static function setPdfRendererPath($libraryBaseDir) { - if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { - return FALSE; - } - self::$_pdfRendererPath = $libraryBaseDir; + /** + * Tell PHPExcel where to find the external library to use for rendering PDF files + * + * @param string $libraryBaseDir Directory path to the library's base folder + * @return boolean Success or failure + */ + public static function setPdfRendererPath($libraryBaseDir) + { + if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) { + return FALSE; + } + self::$_pdfRendererPath = $libraryBaseDir; - return TRUE; - } // function setPdfRendererPath() + return TRUE; + } // function setPdfRendererPath() - /** - * Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf) - * - * @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is - * currently configured to use - * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, - * PHPExcel_Settings::PDF_RENDERER_DOMPDF - * or PHPExcel_Settings::PDF_RENDERER_MPDF - */ - public static function getPdfRendererName() { - return self::$_pdfRendererName; - } // function getPdfRendererName() + /** + * Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf) + * + * @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is + * currently configured to use + * e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF, + * PHPExcel_Settings::PDF_RENDERER_DOMPDF + * or PHPExcel_Settings::PDF_RENDERER_MPDF + */ + public static function getPdfRendererName() + { + return self::$_pdfRendererName; + } // function getPdfRendererName() - /** - * Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use - * - * @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is - * currently configured to use - */ - public static function getPdfRendererPath() { - return self::$_pdfRendererPath; - } // function getPdfRendererPath() + /** + * Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use + * + * @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is + * currently configured to use + */ + public static function getPdfRendererPath() + { + return self::$_pdfRendererPath; + } // function getPdfRendererPath() } \ No newline at end of file diff --git a/Classes/PHPExcel/Shared/OLERead.php b/Classes/PHPExcel/Shared/OLERead.php index 0ce44e49..5319370d 100644 --- a/Classes/PHPExcel/Shared/OLERead.php +++ b/Classes/PHPExcel/Shared/OLERead.php @@ -252,19 +252,22 @@ class PHPExcel_Shared_OLERead { $name = str_replace("\x00", "", substr($d,0,$nameSize)); + $this->props[] = array ( 'name' => $name, 'type' => $type, 'startBlock' => $startBlock, 'size' => $size); + // tmp helper to simplify checks + $upName = strtoupper($name); + // Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook) - if (($name == 'Workbook') || ($name == 'Book') || ($name == 'WORKBOOK') || ($name == 'BOOK')) { + if (($upName === 'WORKBOOK') || ($upName === 'BOOK')) { $this->wrkbook = count($this->props) - 1; } - - // Root entry - if ($name == 'Root Entry' || $name == 'ROOT ENTRY' || $name == 'R') { + else if ( $upName === 'ROOT ENTRY' || $upName === 'R') { + // Root entry $this->rootentry = count($this->props) - 1; } diff --git a/Classes/PHPExcel/Style.php b/Classes/PHPExcel/Style.php index 15004a58..03777d91 100644 --- a/Classes/PHPExcel/Style.php +++ b/Classes/PHPExcel/Style.php @@ -21,7 +21,7 @@ * @category PHPExcel * @package PHPExcel_Style * @copyright Copyright (c) 2006 - 2012 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 ##VERSION##, ##DATE## */ @@ -35,447 +35,449 @@ */ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable { - /** - * Font - * - * @var PHPExcel_Style_Font - */ - protected $_font; + /** + * Font + * + * @var PHPExcel_Style_Font + */ + protected $_font; - /** - * Fill - * - * @var PHPExcel_Style_Fill - */ - protected $_fill; + /** + * Fill + * + * @var PHPExcel_Style_Fill + */ + protected $_fill; - /** - * Borders - * - * @var PHPExcel_Style_Borders - */ - protected $_borders; + /** + * Borders + * + * @var PHPExcel_Style_Borders + */ + protected $_borders; - /** - * Alignment - * - * @var PHPExcel_Style_Alignment - */ - protected $_alignment; + /** + * Alignment + * + * @var PHPExcel_Style_Alignment + */ + protected $_alignment; - /** - * Number Format - * - * @var PHPExcel_Style_NumberFormat - */ - protected $_numberFormat; + /** + * Number Format + * + * @var PHPExcel_Style_NumberFormat + */ + protected $_numberFormat; - /** - * Conditional styles - * - * @var PHPExcel_Style_Conditional[] - */ - protected $_conditionalStyles; + /** + * Conditional styles + * + * @var PHPExcel_Style_Conditional[] + */ + protected $_conditionalStyles; - /** - * Protection - * - * @var PHPExcel_Style_Protection - */ - protected $_protection; + /** + * Protection + * + * @var PHPExcel_Style_Protection + */ + protected $_protection; - /** - * Index of style in collection. Only used for real style. - * - * @var int - */ - protected $_index; + /** + * Index of style in collection. Only used for real style. + * + * @var int + */ + protected $_index; /** * Create a new PHPExcel_Style - * - * @param boolean $isSupervisor Flag indicating if this is a supervisor or not - * Leave this value at default unless you understand exactly what - * its ramifications are - * @param boolean $isConditional Flag indicating if this is a conditional style or not - * Leave this value at default unless you understand exactly what - * its ramifications are + * + * @param boolean $isSupervisor Flag indicating if this is a supervisor or not + * Leave this value at default unless you understand exactly what + * its ramifications are + * @param boolean $isConditional Flag indicating if this is a conditional style or not + * Leave this value at default unless you understand exactly what + * its ramifications are */ public function __construct($isSupervisor = false, $isConditional = false) { - // Supervisor? - $this->_isSupervisor = $isSupervisor; + // Supervisor? + $this->_isSupervisor = $isSupervisor; - // Initialise values - $this->_conditionalStyles = array(); - $this->_font = new PHPExcel_Style_Font($isSupervisor, $isConditional); - $this->_fill = new PHPExcel_Style_Fill($isSupervisor, $isConditional); - $this->_borders = new PHPExcel_Style_Borders($isSupervisor, $isConditional); - $this->_alignment = new PHPExcel_Style_Alignment($isSupervisor, $isConditional); - $this->_numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor, $isConditional); - $this->_protection = new PHPExcel_Style_Protection($isSupervisor, $isConditional); + // Initialise values + $this->_conditionalStyles = array(); + $this->_font = new PHPExcel_Style_Font($isSupervisor, $isConditional); + $this->_fill = new PHPExcel_Style_Fill($isSupervisor, $isConditional); + $this->_borders = new PHPExcel_Style_Borders($isSupervisor, $isConditional); + $this->_alignment = new PHPExcel_Style_Alignment($isSupervisor, $isConditional); + $this->_numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor, $isConditional); + $this->_protection = new PHPExcel_Style_Protection($isSupervisor, $isConditional); - // bind parent if we are a supervisor - if ($isSupervisor) { - $this->_font->bindParent($this); - $this->_fill->bindParent($this); - $this->_borders->bindParent($this); - $this->_alignment->bindParent($this); - $this->_numberFormat->bindParent($this); - $this->_protection->bindParent($this); - } + // bind parent if we are a supervisor + if ($isSupervisor) { + $this->_font->bindParent($this); + $this->_fill->bindParent($this); + $this->_borders->bindParent($this); + $this->_alignment->bindParent($this); + $this->_numberFormat->bindParent($this); + $this->_protection->bindParent($this); + } } - /** - * Get the shared style component for the currently active cell in currently active sheet. - * Only used for style supervisor - * - * @return PHPExcel_Style - */ - public function getSharedComponent() - { - $activeSheet = $this->getActiveSheet(); - $selectedCell = $this->getActiveCell(); // e.g. 'A1' + /** + * Get the shared style component for the currently active cell in currently active sheet. + * Only used for style supervisor + * + * @return PHPExcel_Style + */ + public function getSharedComponent() + { + $activeSheet = $this->getActiveSheet(); + $selectedCell = $this->getActiveCell(); // e.g. 'A1' - if ($activeSheet->cellExists($selectedCell)) { - $xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex(); - } else { - $xfIndex = 0; - } + if ($activeSheet->cellExists($selectedCell)) { + $xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex(); + } else { + $xfIndex = 0; + } - return $this->_parent->getCellXfByIndex($xfIndex); - } + return $this->_parent->getCellXfByIndex($xfIndex); + } - /** - * Get parent. Only used for style supervisor - * - * @return PHPExcel - */ - public function getParent() - { - return $this->_parent; - } + /** + * Get parent. Only used for style supervisor + * + * @return PHPExcel + */ + public function getParent() + { + return $this->_parent; + } /** * Apply styles from array * * * $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray( - * array( - * 'font' => array( - * 'name' => 'Arial', - * 'bold' => true, - * 'italic' => false, - * 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE, - * 'strike' => false, - * 'color' => array( - * 'rgb' => '808080' - * ) - * ), - * 'borders' => array( - * 'bottom' => array( - * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, - * 'color' => array( - * 'rgb' => '808080' - * ) - * ), - * 'top' => array( - * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, - * 'color' => array( - * 'rgb' => '808080' - * ) - * ) - * ) - * ) + * array( + * 'font' => array( + * 'name' => 'Arial', + * 'bold' => true, + * 'italic' => false, + * 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE, + * 'strike' => false, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ), + * 'borders' => array( + * 'bottom' => array( + * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ), + * 'top' => array( + * 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ) + * ) + * ) * ); * * - * @param array $pStyles Array containing style information - * @param boolean $pAdvanced Advanced mode for setting borders. - * @throws PHPExcel_Exception + * @param array $pStyles Array containing style information + * @param boolean $pAdvanced Advanced mode for setting borders. + * @throws PHPExcel_Exception * @return PHPExcel_Style */ - public function applyFromArray($pStyles = null, $pAdvanced = true) { - if (is_array($pStyles)) { - if ($this->_isSupervisor) { + public function applyFromArray($pStyles = null, $pAdvanced = true) + { + if (is_array($pStyles)) { + if ($this->_isSupervisor) { - $pRange = $this->getSelectedCells(); + $pRange = $this->getSelectedCells(); - // Uppercase coordinate - $pRange = strtoupper($pRange); + // Uppercase coordinate + $pRange = strtoupper($pRange); - // Is it a cell range or a single cell? - if (strpos($pRange, ':') === false) { - $rangeA = $pRange; - $rangeB = $pRange; - } else { - list($rangeA, $rangeB) = explode(':', $pRange); - } + // Is it a cell range or a single cell? + if (strpos($pRange, ':') === false) { + $rangeA = $pRange; + $rangeB = $pRange; + } else { + list($rangeA, $rangeB) = explode(':', $pRange); + } - // Calculate range outer borders - $rangeStart = PHPExcel_Cell::coordinateFromString($rangeA); - $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB); + // Calculate range outer borders + $rangeStart = PHPExcel_Cell::coordinateFromString($rangeA); + $rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB); - // Translate column into index - $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1; - $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1; + // Translate column into index + $rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1; + $rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1; - // Make sure we can loop upwards on rows and columns - if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { - $tmp = $rangeStart; - $rangeStart = $rangeEnd; - $rangeEnd = $tmp; - } + // Make sure we can loop upwards on rows and columns + if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { + $tmp = $rangeStart; + $rangeStart = $rangeEnd; + $rangeEnd = $tmp; + } - // ADVANCED MODE: + // ADVANCED MODE: - if ($pAdvanced && isset($pStyles['borders'])) { + if ($pAdvanced && isset($pStyles['borders'])) { - // 'allborders' is a shorthand property for 'outline' and 'inside' and - // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['allborders'])) { - foreach (array('outline', 'inside') as $component) { - if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['allborders']; - } - } - unset($pStyles['borders']['allborders']); // not needed any more - } + // 'allborders' is a shorthand property for 'outline' and 'inside' and + // it applies to components that have not been set explicitly + if (isset($pStyles['borders']['allborders'])) { + foreach (array('outline', 'inside') as $component) { + if (!isset($pStyles['borders'][$component])) { + $pStyles['borders'][$component] = $pStyles['borders']['allborders']; + } + } + unset($pStyles['borders']['allborders']); // not needed any more + } - // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left' - // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['outline'])) { - foreach (array('top', 'right', 'bottom', 'left') as $component) { - if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['outline']; - } - } - unset($pStyles['borders']['outline']); // not needed any more - } + // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left' + // it applies to components that have not been set explicitly + if (isset($pStyles['borders']['outline'])) { + foreach (array('top', 'right', 'bottom', 'left') as $component) { + if (!isset($pStyles['borders'][$component])) { + $pStyles['borders'][$component] = $pStyles['borders']['outline']; + } + } + unset($pStyles['borders']['outline']); // not needed any more + } - // 'inside' is a shorthand property for 'vertical' and 'horizontal' - // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['inside'])) { - foreach (array('vertical', 'horizontal') as $component) { - if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['inside']; - } - } - unset($pStyles['borders']['inside']); // not needed any more - } + // 'inside' is a shorthand property for 'vertical' and 'horizontal' + // it applies to components that have not been set explicitly + if (isset($pStyles['borders']['inside'])) { + foreach (array('vertical', 'horizontal') as $component) { + if (!isset($pStyles['borders'][$component])) { + $pStyles['borders'][$component] = $pStyles['borders']['inside']; + } + } + unset($pStyles['borders']['inside']); // not needed any more + } - // width and height characteristics of selection, 1, 2, or 3 (for 3 or more) - $xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3); - $yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3); + // width and height characteristics of selection, 1, 2, or 3 (for 3 or more) + $xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3); + $yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3); - // loop through up to 3 x 3 = 9 regions - for ($x = 1; $x <= $xMax; ++$x) { - // start column index for region - $colStart = ($x == 3) ? - PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]) - : PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1); + // loop through up to 3 x 3 = 9 regions + for ($x = 1; $x <= $xMax; ++$x) { + // start column index for region + $colStart = ($x == 3) ? + PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]) + : PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1); - // end column index for region - $colEnd = ($x == 1) ? - PHPExcel_Cell::stringFromColumnIndex($rangeStart[0]) - : PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x); + // end column index for region + $colEnd = ($x == 1) ? + PHPExcel_Cell::stringFromColumnIndex($rangeStart[0]) + : 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 - $edges = array(); + // which edges are touching the region + $edges = array(); - // are we at left edge - if ($x == 1) { - $edges[] = 'left'; - } + // are we at left edge + if ($x == 1) { + $edges[] = 'left'; + } - // are we at right edge - if ($x == $xMax) { - $edges[] = 'right'; - } + // are we at right edge + if ($x == $xMax) { + $edges[] = 'right'; + } - // are we at top edge? - if ($y == 1) { - $edges[] = 'top'; - } + // are we at top edge? + if ($y == 1) { + $edges[] = 'top'; + } - // are we at bottom edge? - if ($y == $yMax) { - $edges[] = 'bottom'; - } + // are we at bottom edge? + if ($y == $yMax) { + $edges[] = 'bottom'; + } - // start row index for region - $rowStart = ($y == 3) ? - $rangeEnd[1] : $rangeStart[1] + $y - 1; + // start row index for region + $rowStart = ($y == 3) ? + $rangeEnd[1] : $rangeStart[1] + $y - 1; - // end row index for region - $rowEnd = ($y == 1) ? - $rangeStart[1] : $rangeEnd[1] - $yMax + $y; + // end row index for region + $rowEnd = ($y == 1) ? + $rangeStart[1] : $rangeEnd[1] - $yMax + $y; - // build range for region - $range = $colStart . $rowStart . ':' . $colEnd . $rowEnd; + // build range for region + $range = $colStart . $rowStart . ':' . $colEnd . $rowEnd; - // retrieve relevant style array for region - $regionStyles = $pStyles; - unset($regionStyles['borders']['inside']); + // retrieve relevant style array for region + $regionStyles = $pStyles; + unset($regionStyles['borders']['inside']); - // what are the inner edges of the region when looking at the selection - $innerEdges = array_diff( array('top', 'right', 'bottom', 'left'), $edges ); + // what are the inner edges of the region when looking at the selection + $innerEdges = array_diff( array('top', 'right', 'bottom', 'left'), $edges ); - // inner edges that are not touching the region should take the 'inside' border properties if they have been set - foreach ($innerEdges as $innerEdge) { - switch ($innerEdge) { - case 'top': - case 'bottom': - // should pick up 'horizontal' border property if set - if (isset($pStyles['borders']['horizontal'])) { - $regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal']; - } else { - unset($regionStyles['borders'][$innerEdge]); - } - break; - case 'left': - case 'right': - // should pick up 'vertical' border property if set - if (isset($pStyles['borders']['vertical'])) { - $regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical']; - } else { - unset($regionStyles['borders'][$innerEdge]); - } - break; - } - } + // inner edges that are not touching the region should take the 'inside' border properties if they have been set + foreach ($innerEdges as $innerEdge) { + switch ($innerEdge) { + case 'top': + case 'bottom': + // should pick up 'horizontal' border property if set + if (isset($pStyles['borders']['horizontal'])) { + $regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal']; + } else { + unset($regionStyles['borders'][$innerEdge]); + } + break; + case 'left': + case 'right': + // should pick up 'vertical' border property if set + if (isset($pStyles['borders']['vertical'])) { + $regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical']; + } else { + unset($regionStyles['borders'][$innerEdge]); + } + break; + } + } - // apply region style to region by calling applyFromArray() in simple mode - $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStyles, false); - } - } - return $this; - } + // apply region style to region by calling applyFromArray() in simple mode + $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStyles, false); + } + } + return $this; + } - // SIMPLE MODE: + // SIMPLE MODE: - // Selection type, inspect - if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) { - $selectionType = 'COLUMN'; - } else if (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) { - $selectionType = 'ROW'; - } else { - $selectionType = 'CELL'; - } + // Selection type, inspect + if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) { + $selectionType = 'COLUMN'; + } else if (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) { + $selectionType = 'ROW'; + } else { + $selectionType = 'CELL'; + } - // First loop through columns, rows, or cells to find out which styles are affected by this operation - switch ($selectionType) { - case 'COLUMN': - $oldXfIndexes = array(); - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true; - } - break; + // First loop through columns, rows, or cells to find out which styles are affected by this operation + switch ($selectionType) { + case 'COLUMN': + $oldXfIndexes = array(); + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true; + } + break; - case 'ROW': - $oldXfIndexes = array(); - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() == null) { - $oldXfIndexes[0] = true; // row without explicit style should be formatted based on default style - } else { - $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true; - } - } - break; + case 'ROW': + $oldXfIndexes = array(); + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() == null) { + $oldXfIndexes[0] = true; // row without explicit style should be formatted based on default style + } else { + $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true; + } + } + break; - case 'CELL': - $oldXfIndexes = array(); - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true; - } - } - break; - } + case 'CELL': + $oldXfIndexes = array(); + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true; + } + } + break; + } - // clone each of the affected styles, apply the style array, and add the new styles to the workbook - $workbook = $this->getActiveSheet()->getParent(); - foreach ($oldXfIndexes as $oldXfIndex => $dummy) { - $style = $workbook->getCellXfByIndex($oldXfIndex); - $newStyle = clone $style; - $newStyle->applyFromArray($pStyles); + // clone each of the affected styles, apply the style array, and add the new styles to the workbook + $workbook = $this->getActiveSheet()->getParent(); + foreach ($oldXfIndexes as $oldXfIndex => $dummy) { + $style = $workbook->getCellXfByIndex($oldXfIndex); + $newStyle = clone $style; + $newStyle->applyFromArray($pStyles); - if ($workbook->cellXfExists($newStyle)) { - // there is already such cell Xf in our collection - $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); - } else { - // we don't have such a cell Xf, need to add - $workbook->addCellXf($newStyle); - $newXfIndexes[$oldXfIndex] = $newStyle->getIndex(); - } - } + if ($workbook->cellXfExists($newStyle)) { + // there is already such cell Xf in our collection + $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); + } else { + // we don't have such a cell Xf, need to add + $workbook->addCellXf($newStyle); + $newXfIndexes[$oldXfIndex] = $newStyle->getIndex(); + } + } - // Loop through columns, rows, or cells again and update the XF index - switch ($selectionType) { - case 'COLUMN': - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - $columnDimension = $this->getActiveSheet()->getColumnDimensionByColumn($col); - $oldXfIndex = $columnDimension->getXfIndex(); - $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]); - } - break; + // Loop through columns, rows, or cells again and update the XF index + switch ($selectionType) { + case 'COLUMN': + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + $columnDimension = $this->getActiveSheet()->getColumnDimensionByColumn($col); + $oldXfIndex = $columnDimension->getXfIndex(); + $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]); + } + break; - case 'ROW': - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $rowDimension = $this->getActiveSheet()->getRowDimension($row); - $oldXfIndex = $rowDimension->getXfIndex() === null ? - 0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style - $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]); - } - break; + case 'ROW': + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $rowDimension = $this->getActiveSheet()->getRowDimension($row); + $oldXfIndex = $rowDimension->getXfIndex() === null ? + 0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style + $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]); + } + break; - case 'CELL': - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $cell = $this->getActiveSheet()->getCellByColumnAndRow($col, $row); - $oldXfIndex = $cell->getXfIndex(); - $cell->setXfIndex($newXfIndexes[$oldXfIndex]); - } - } - break; - } + case 'CELL': + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $cell = $this->getActiveSheet()->getCellByColumnAndRow($col, $row); + $oldXfIndex = $cell->getXfIndex(); + $cell->setXfIndex($newXfIndexes[$oldXfIndex]); + } + } + break; + } - } else { - // not a supervisor, just apply the style array directly on style object - if (array_key_exists('fill', $pStyles)) { - $this->getFill()->applyFromArray($pStyles['fill']); - } - if (array_key_exists('font', $pStyles)) { - $this->getFont()->applyFromArray($pStyles['font']); - } - if (array_key_exists('borders', $pStyles)) { - $this->getBorders()->applyFromArray($pStyles['borders']); - } - if (array_key_exists('alignment', $pStyles)) { - $this->getAlignment()->applyFromArray($pStyles['alignment']); - } - if (array_key_exists('numberformat', $pStyles)) { - $this->getNumberFormat()->applyFromArray($pStyles['numberformat']); - } - if (array_key_exists('protection', $pStyles)) { - $this->getProtection()->applyFromArray($pStyles['protection']); - } - } - } else { - throw new PHPExcel_Exception("Invalid style array passed."); - } - return $this; - } + } else { + // not a supervisor, just apply the style array directly on style object + if (array_key_exists('fill', $pStyles)) { + $this->getFill()->applyFromArray($pStyles['fill']); + } + if (array_key_exists('font', $pStyles)) { + $this->getFont()->applyFromArray($pStyles['font']); + } + if (array_key_exists('borders', $pStyles)) { + $this->getBorders()->applyFromArray($pStyles['borders']); + } + if (array_key_exists('alignment', $pStyles)) { + $this->getAlignment()->applyFromArray($pStyles['alignment']); + } + if (array_key_exists('numberformat', $pStyles)) { + $this->getNumberFormat()->applyFromArray($pStyles['numberformat']); + } + if (array_key_exists('protection', $pStyles)) { + $this->getProtection()->applyFromArray($pStyles['protection']); + } + } + } else { + throw new PHPExcel_Exception("Invalid style array passed."); + } + return $this; + } /** * Get Fill * * @return PHPExcel_Style_Fill */ - public function getFill() { - return $this->_fill; + public function getFill() + { + return $this->_fill; } /** @@ -483,29 +485,31 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp * * @return PHPExcel_Style_Font */ - public function getFont() { - return $this->_font; + public function getFont() + { + return $this->_font; } - /** - * Set font - * - * @param PHPExcel_Style_Font $font - * @return PHPExcel_Style - */ - public function setFont(PHPExcel_Style_Font $font) - { - $this->_font = $font; - return $this; - } + /** + * Set font + * + * @param PHPExcel_Style_Font $font + * @return PHPExcel_Style + */ + public function setFont(PHPExcel_Style_Font $font) + { + $this->_font = $font; + return $this; + } /** * Get Borders * * @return PHPExcel_Style_Borders */ - public function getBorders() { - return $this->_borders; + public function getBorders() + { + return $this->_borders; } /** @@ -513,8 +517,9 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp * * @return PHPExcel_Style_Alignment */ - public function getAlignment() { - return $this->_alignment; + public function getAlignment() + { + return $this->_alignment; } /** @@ -522,8 +527,9 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp * * @return PHPExcel_Style_NumberFormat */ - public function getNumberFormat() { - return $this->_numberFormat; + public function getNumberFormat() + { + return $this->_numberFormat; } /** @@ -531,21 +537,23 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp * * @return PHPExcel_Style_Conditional[] */ - public function getConditionalStyles() { - return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell()); + public function getConditionalStyles() + { + return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell()); } /** * Set Conditional Styles. Only used on supervisor. * - * @param PHPExcel_Style_Conditional[] $pValue Array of condtional styles + * @param PHPExcel_Style_Conditional[] $pValue Array of condtional styles * @return PHPExcel_Style */ - public function setConditionalStyles($pValue = null) { - if (is_array($pValue)) { - $this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue); - } - return $this; + public function setConditionalStyles($pValue = null) + { + if (is_array($pValue)) { + $this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue); + } + return $this; } /** @@ -553,51 +561,53 @@ class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComp * * @return PHPExcel_Style_Protection */ - public function getProtection() { - return $this->_protection; + public function getProtection() + { + return $this->_protection; } - /** - * Get hash code - * - * @return string Hash code - */ - public function getHashCode() { - $hashConditionals = ''; - foreach ($this->_conditionalStyles as $conditional) { - $hashConditionals .= $conditional->getHashCode(); - } + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() + { + $hashConditionals = ''; + foreach ($this->_conditionalStyles as $conditional) { + $hashConditionals .= $conditional->getHashCode(); + } - return md5( - $this->_fill->getHashCode() - . $this->_font->getHashCode() - . $this->_borders->getHashCode() - . $this->_alignment->getHashCode() - . $this->_numberFormat->getHashCode() - . $hashConditionals - . $this->_protection->getHashCode() - . __CLASS__ - ); + return md5( + $this->_fill->getHashCode() + . $this->_font->getHashCode() + . $this->_borders->getHashCode() + . $this->_alignment->getHashCode() + . $this->_numberFormat->getHashCode() + . $hashConditionals + . $this->_protection->getHashCode() + . __CLASS__ + ); } - /** - * Get own index in style collection - * - * @return int - */ - public function getIndex() - { - return $this->_index; - } + /** + * Get own index in style collection + * + * @return int + */ + public function getIndex() + { + return $this->_index; + } - /** - * Set own index in style collection - * - * @param int $pValue - */ - public function setIndex($pValue) - { - $this->_index = $pValue; - } + /** + * Set own index in style collection + * + * @param int $pValue + */ + public function setIndex($pValue) + { + $this->_index = $pValue; + } } diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 5a0ea544..64ad1118 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -41,7 +41,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable const BREAK_COLUMN = 2; /* Sheet state */ - const SHEETSTATE_VISIBLE = 'visible'; + const SHEETSTATE_VISIBLE = 'visible'; const SHEETSTATE_HIDDEN = 'hidden'; const SHEETSTATE_VERYHIDDEN = 'veryHidden'; diff --git a/Classes/PHPExcel/WorksheetIterator.php b/Classes/PHPExcel/WorksheetIterator.php index b7180f61..cceec417 100644 --- a/Classes/PHPExcel/WorksheetIterator.php +++ b/Classes/PHPExcel/WorksheetIterator.php @@ -21,7 +21,7 @@ * @category PHPExcel * @package PHPExcel * @copyright Copyright (c) 2006 - 2012 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 ##VERSION##, ##DATE## */ @@ -37,41 +37,44 @@ */ class PHPExcel_WorksheetIterator implements Iterator { - /** - * Spreadsheet to iterate - * - * @var PHPExcel - */ - private $_subject; + /** + * Spreadsheet to iterate + * + * @var PHPExcel + */ + private $_subject; - /** - * Current iterator position - * - * @var int - */ - private $_position = 0; + /** + * Current iterator position + * + * @var int + */ + private $_position = 0; - /** - * Create a new worksheet iterator - * - * @param PHPExcel $subject - */ - public function __construct(PHPExcel $subject = null) { - // Set subject - $this->_subject = $subject; - } + /** + * Create a new worksheet iterator + * + * @param PHPExcel $subject + */ + public function __construct(PHPExcel $subject = null) + { + // Set subject + $this->_subject = $subject; + } - /** - * Destructor - */ - public function __destruct() { - unset($this->_subject); - } + /** + * Destructor + */ + public function __destruct() + { + unset($this->_subject); + } - /** - * Rewind iterator - */ - public function rewind() { + /** + * Rewind iterator + */ + public function rewind() + { $this->_position = 0; } @@ -80,8 +83,9 @@ class PHPExcel_WorksheetIterator implements Iterator * * @return PHPExcel_Worksheet */ - public function current() { - return $this->_subject->getSheet($this->_position); + public function current() + { + return $this->_subject->getSheet($this->_position); } /** @@ -89,14 +93,16 @@ class PHPExcel_WorksheetIterator implements Iterator * * @return int */ - public function key() { + public function key() + { return $this->_position; } /** * Next value */ - public function next() { + public function next() + { ++$this->_position; } @@ -105,7 +111,8 @@ class PHPExcel_WorksheetIterator implements Iterator * * @return boolean */ - public function valid() { + public function valid() + { return $this->_position < $this->_subject->getSheetCount(); } }