From 19985dbb8c0aa66dc4bf7905abc1148de909097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 11 Jan 2022 12:35:47 +0100 Subject: prvi-commit --- .../export/libs/PHPPowerPoint/Style/Alignment.php | 243 +++++++++ .../export/libs/PHPPowerPoint/Style/Color.php | 170 ++++++ .../export/libs/PHPPowerPoint/Style/Fill.php | 245 +++++++++ .../export/libs/PHPPowerPoint/Style/Font.php | 411 +++++++++++++++ .../libs/PHPPowerPoint/Style/_notused_Border.php | 331 ++++++++++++ .../libs/PHPPowerPoint/Style/_notused_Borders.php | 577 +++++++++++++++++++++ 6 files changed, 1977 insertions(+) create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/Alignment.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/Color.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/Fill.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/Font.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/_notused_Border.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Style/_notused_Borders.php (limited to 'admin/survey/export/libs/PHPPowerPoint/Style') diff --git a/admin/survey/export/libs/PHPPowerPoint/Style/Alignment.php b/admin/survey/export/libs/PHPPowerPoint/Style/Alignment.php new file mode 100644 index 0000000..996d064 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Style/Alignment.php @@ -0,0 +1,243 @@ +_horizontal = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT; + $this->_vertical = PHPPowerPoint_Style_Alignment::VERTICAL_BASE; + $this->_level = 0; + $this->_indent = 0; + } + + /** + * Get Horizontal + * + * @return string + */ + public function getHorizontal() { + return $this->_horizontal; + } + + /** + * Set Horizontal + * + * @param string $pValue + */ + public function setHorizontal($pValue = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEF) { + if ($pValue == '') { + $pValue = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT; + } + $this->_horizontal = $pValue; + } + + /** + * Get Vertical + * + * @return string + */ + public function getVertical() { + return $this->_vertical; + } + + /** + * Set Vertical + * + * @param string $pValue + */ + public function setVertical($pValue = PHPPowerPoint_Style_Alignment::VERTICAL_BASE) { + if ($pValue == '') { + $pValue = PHPPowerPoint_Style_Alignment::VERTICAL_BASE; + } + $this->_vertical = $pValue; + } + + /** + * Get Level + * + * @return int + */ + public function getLevel() { + return $this->_level; + } + + /** + * Set Level + * + * @param int $pValue Ranging 0 - 8 + * @throws Exception + */ + public function setLevel($pValue = 0) { + if ($pValue < 0 || $pValue > 8) { + throw new Exception("Invalid value: shoul be range 0 - 8."); + } + $this->_level = $pValue; + } + + /** + * Get indent + * + * @return int + */ + public function getIndent() { + return $this->_indent; + } + + /** + * Set indent + * + * @param int $pValue + */ + public function setIndent($pValue = 0) { + if ($pValue > 0) { + if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) { + $pValue = 0; // indent not supported + } + } + + $this->_indent = $pValue; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_horizontal + . $this->_vertical + . $this->_level + . $this->_indent + . __CLASS__ + ); + } + + /** + * Hash index + * + * @var string + */ + private $_hashIndex; + + /** + * Get hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @return string Hash index + */ + public function getHashIndex() { + return $this->_hashIndex; + } + + /** + * Set hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @param string $value Hash index + */ + public function setHashIndex($value) { + $this->_hashIndex = $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/admin/survey/export/libs/PHPPowerPoint/Style/Color.php b/admin/survey/export/libs/PHPPowerPoint/Style/Color.php new file mode 100644 index 0000000..4f73c31 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Style/Color.php @@ -0,0 +1,170 @@ +_argb = $pARGB; + } + + /** + * Get ARGB + * + * @return string + */ + public function getARGB() { + return $this->_argb; + } + + /** + * Set ARGB + * + * @param string $pValue + */ + public function setARGB($pValue = PHPPowerPoint_Style_Color::COLOR_BLACK) { + if ($pValue == '') { + $pValue = PHPPowerPoint_Style_Color::COLOR_BLACK; + } + $this->_argb = $pValue; + } + + /** + * Get RGB + * + * @return string + */ + public function getRGB() { + return substr($this->_argb, 2); + } + + /** + * Set RGB + * + * @param string $pValue + */ + public function setRGB($pValue = '000000') { + if ($pValue == '') { + $pValue = '000000'; + } + $this->_argb = 'FF' . $pValue; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_argb + . __CLASS__ + ); + } + + /** + * Hash index + * + * @var string + */ + private $_hashIndex; + + /** + * Get hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @return string Hash index + */ + public function getHashIndex() { + return $this->_hashIndex; + } + + /** + * Set hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @param string $value Hash index + */ + public function setHashIndex($value) { + $this->_hashIndex = $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/admin/survey/export/libs/PHPPowerPoint/Style/Fill.php b/admin/survey/export/libs/PHPPowerPoint/Style/Fill.php new file mode 100644 index 0000000..9c3120a --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Style/Fill.php @@ -0,0 +1,245 @@ +_fillType = PHPPowerPoint_Style_Fill::FILL_NONE; + $this->_rotation = 0; + $this->_startColor = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_WHITE); + $this->_endColor = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK); + } + + /** + * Get Fill Type + * + * @return string + */ + public function getFillType() { + $this->_fillType; + } + + /** + * Set Fill Type + * + * @param string $pValue PHPPowerPoint_Style_Fill fill type + */ + public function setFillType($pValue = PHPPowerPoint_Style_Fill::FILL_NONE) { + $this->_fillType = $pValue; + } + + /** + * Get Rotation + * + * @return double + */ + public function getRotation() { + return $this->_rotation; + } + + /** + * Set Rotation + * + * @param double $pValue + */ + public function setRotation($pValue = 0) { + $this->_rotation = $pValue; + } + + /** + * Get Start Color + * + * @return PHPPowerPoint_Style_Color + */ + public function getStartColor() { + // It's a get but it may lead to a modified color which we won't detect but in which case we must bind. + // So bind as an assurance. + return $this->_startColor; + } + + /** + * Set Start Color + * + * @param PHPPowerPoint_Style_Color $pValue + * @throws Exception + */ + public function setStartColor(PHPPowerPoint_Style_Color $pValue = null) { + $this->_startColor = $pValue; + } + + /** + * Get End Color + * + * @return PHPPowerPoint_Style_Color + */ + public function getEndColor() { + // It's a get but it may lead to a modified color which we won't detect but in which case we must bind. + // So bind as an assurance. + return $this->_endColor; + } + + /** + * Set End Color + * + * @param PHPPowerPoint_Style_Color $pValue + * @throws Exception + */ + public function setEndColor(PHPPowerPoint_Style_Color $pValue = null) { + $this->_endColor = $pValue; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->getFillType() + . $this->getRotation() + . $this->getStartColor()->getHashCode() + . $this->getEndColor()->getHashCode() + . __CLASS__ + ); + } + + /** + * Hash index + * + * @var string + */ + private $_hashIndex; + + /** + * Get hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @return string Hash index + */ + public function getHashIndex() { + return $this->_hashIndex; + } + + /** + * Set hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @param string $value Hash index + */ + public function setHashIndex($value) { + $this->_hashIndex = $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/admin/survey/export/libs/PHPPowerPoint/Style/Font.php b/admin/survey/export/libs/PHPPowerPoint/Style/Font.php new file mode 100644 index 0000000..8376dfb --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Style/Font.php @@ -0,0 +1,411 @@ +_name = 'Calibri'; + $this->_size = 10; + $this->_bold = false; + $this->_italic = false; + $this->_superScript = false; + $this->_subScript = false; + $this->_underline = PHPPowerPoint_Style_Font::UNDERLINE_NONE; + $this->_strikethrough = false; + $this->_color = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK); + } + + /** + * Get Name + * + * @return string + */ + public function getName() { + return $this->_name; + } + + /** + * Set Name + * + * @param string $pValue + */ + public function setName($pValue = 'Calibri') { + if ($pValue == '') { + $pValue = 'Calibri'; + } + $this->_name = $pValue; + } + + /** + * Get Size + * + * @return double + */ + public function getSize() { + return $this->_size; + } + + /** + * Set Size + * + * @param double $pValue + */ + public function setSize($pValue = 10) { + if ($pValue == '') { + $pValue = 10; + } + $this->_size = $pValue; + } + + /** + * Get Bold + * + * @return boolean + */ + public function getBold() { + return $this->_bold; + } + + /** + * Set Bold + * + * @param boolean $pValue + */ + public function setBold($pValue = false) { + if ($pValue == '') { + $pValue = false; + } + $this->_bold = $pValue; + } + + /** + * Get Italic + * + * @return boolean + */ + public function getItalic() { + return $this->_italic; + } + + /** + * Set Italic + * + * @param boolean $pValue + */ + public function setItalic($pValue = false) { + if ($pValue == '') { + $pValue = false; + } + $this->_italic = $pValue; + } + + /** + * Get SuperScript + * + * @return boolean + */ + public function getSuperScript() { + return $this->_superScript; + } + + /** + * Set SuperScript + * + * @param boolean $pValue + */ + public function setSuperScript($pValue = false) { + if ($pValue == '') { + $pValue = false; + } + $this->_superScript = $pValue; + $this->_subScript = !$pValue; + } + + /** + * Get SubScript + * + * @return boolean + */ + public function getSubScript() { + return $this->_subScript; + } + + /** + * Set SubScript + * + * @param boolean $pValue + */ + public function setSubScript($pValue = false) { + if ($pValue == '') { + $pValue = false; + } + $this->_subScript = $pValue; + $this->_superScript = !$pValue; + } + + /** + * Get Underline + * + * @return string + */ + public function getUnderline() { + return $this->_underline; + } + + /** + * Set Underline + * + * @param string $pValue PHPPowerPoint_Style_Font underline type + */ + public function setUnderline($pValue = PHPPowerPoint_Style_Font::UNDERLINE_NONE) { + if ($pValue == '') { + $pValue = PHPPowerPoint_Style_Font::UNDERLINE_NONE; + } + $this->_underline = $pValue; + } + + /** + * Get Striketrough + * + * @deprecated Use getStrikethrough() instead. + * @return boolean + */ + public function getStriketrough() { + return $this->getStrikethrough(); + } + + /** + * Set Striketrough + * + * @deprecated Use setStrikethrough() instead. + * @param boolean $pValue + */ + public function setStriketrough($pValue = false) { + $this->setStrikethrough($pValue); + } + + /** + * Get Strikethrough + * + * @return boolean + */ + public function getStrikethrough() { + return $this->_strikethrough; + } + + /** + * Set Strikethrough + * + * @param boolean $pValue + */ + public function setStrikethrough($pValue = false) { + if ($pValue == '') { + $pValue = false; + } + $this->_strikethrough = $pValue; + } + + /** + * Get Color + * + * @return PHPPowerPoint_Style_Color + */ + public function getColor() { + return $this->_color; + } + + /** + * Set Color + * + * @param PHPPowerPoint_Style_Color $pValue + * @throws Exception + */ + public function setColor(PHPPowerPoint_Style_Color $pValue = null) { + $this->_color = $pValue; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_name + . $this->_size + . ($this->_bold ? 't' : 'f') + . ($this->_italic ? 't' : 'f') + . ($this->_superScript ? 't' : 'f') + . ($this->_subScript ? 't' : 'f') + . $this->_underline + . ($this->_strikethrough ? 't' : 'f') + . $this->_color->getHashCode() + . __CLASS__ + ); + } + + /** + * Hash index + * + * @var string + */ + private $_hashIndex; + + /** + * Get hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @return string Hash index + */ + public function getHashIndex() { + return $this->_hashIndex; + } + + /** + * Set hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @param string $value Hash index + */ + public function setHashIndex($value) { + $this->_hashIndex = $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/admin/survey/export/libs/PHPPowerPoint/Style/_notused_Border.php b/admin/survey/export/libs/PHPPowerPoint/Style/_notused_Border.php new file mode 100644 index 0000000..4867328 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Style/_notused_Border.php @@ -0,0 +1,331 @@ +_borderStyle = PHPPowerPoint_Style_Border::BORDER_NONE; + $this->_borderColor = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK); + } + + /** + * Property Prepare bind + * + * Configures this object for late binding as a property of a parent object + * + * @param $parent + * @param $parentPropertyName + */ + public function propertyPrepareBind($parent, $parentPropertyName) + { + // Initialize parent PHPPowerPoint_Style for late binding. This relationship purposely ends immediately when this object + // is bound to the PHPPowerPoint_Style object pointed to so as to prevent circular references. + $this->_parent = $parent; + $this->_parentPropertyName = $parentPropertyName; + } + + /** + * Property Get Bound + * + * Returns the PHPPowerPoint_Style_Border that is actual bound to PHPPowerPoint_Style_Borders + * + * @return PHPPowerPoint_Style_Border + */ + private function propertyGetBound() { + if(!isset($this->_parent)) + return $this; // I am bound + + if($this->_parent->propertyIsBound($this->_parentPropertyName)) + { + switch($this->_parentPropertyName) // Another one is bound + { + case "_left": + return $this->_parent->getLeft(); + + case "_right": + return $this->_parent->getRight(); + + case "_top": + return $this->_parent->getTop(); + + case "_bottom": + return $this->_parent->getBottom(); + + case "_diagonal": + return $this->_parent->getDiagonal(); + + case "_vertical": + return $this->_parent->getVertical(); + + case "_horizontal": + return $this->_parent->getHorizontal(); + } + } + + return $this; // No one is bound yet + } + + /** + * Property Begin Bind + * + * If no PHPPowerPoint_Style_Border has been bound to PHPPowerPoint_Style_Borders then bind this one. Return the actual bound one. + * + * @return PHPPowerPoint_Style_Border + */ + private function propertyBeginBind() { + + if(!isset($this->_parent)) + return $this; // I am already bound + + if($this->_parent->propertyIsBound($this->_parentPropertyName)) + { + switch($this->_parentPropertyName) // Another one is already bound + { + case "_left": + return $this->_parent->getLeft(); + + case "_right": + return $this->_parent->getRight(); + + case "_top": + return $this->_parent->getTop(); + + case "_bottom": + return $this->_parent->getBottom(); + + case "_diagonal": + return $this->_parent->getDiagonal(); + + case "_vertical": + return $this->_parent->getVertical(); + + case "_horizontal": + return $this->_parent->getHorizontal(); + } + } + + $this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself + $this->_parent = null; + return $this; + } + + /** + * Apply styles from array + * + * + * $objPHPPowerPoint->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray( + * array( + * 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ) + * ); + * + * + * @param array $pStyles Array containing style information + * @throws Exception + */ + public function applyFromArray($pStyles = null) { + if (is_array($pStyles)) { + if (array_key_exists('style', $pStyles)) { + $this->setBorderStyle($pStyles['style']); + } + if (array_key_exists('color', $pStyles)) { + $this->getColor()->applyFromArray($pStyles['color']); + } + } else { + throw new Exception("Invalid style array passed."); + } + } + + /** + * Get Border style + * + * @return string + */ + public function getBorderStyle() { + return $this->propertyGetBound()->_borderStyle; + } + + /** + * Set Border style + * + * @param string $pValue + */ + public function setBorderStyle($pValue = PHPPowerPoint_Style_Border::BORDER_NONE) { + + if ($pValue == '') { + $pValue = PHPPowerPoint_Style_Border::BORDER_NONE; + } + $this->propertyBeginBind()->_borderStyle = $pValue; + } + + /** + * Get Border Color + * + * @return PHPPowerPoint_Style_Color + */ + public function getColor() { + // It's a get but it may lead to a modified color which we won't detect but in which case we must bind. + // So bind as an assurance. + return $this->propertyBeginBind()->_borderColor; + } + + /** + * Set Border Color + * + * @param PHPPowerPoint_Style_Color $pValue + * @throws Exception + */ + public function setColor(PHPPowerPoint_Style_Color $pValue = null) { + $this->propertyBeginBind()->_borderColor = $pValue; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + $property = $this->propertyGetBound(); + return md5( + $property->_borderStyle + . $property->_borderColor->getHashCode() + . __CLASS__ + ); + } + + /** + * Hash index + * + * @var string + */ + private $_hashIndex; + + /** + * Get hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @return string Hash index + */ + public function getHashIndex() { + return $this->_hashIndex; + } + + /** + * Set hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @param string $value Hash index + */ + public function setHashIndex($value) { + $this->_hashIndex = $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/admin/survey/export/libs/PHPPowerPoint/Style/_notused_Borders.php b/admin/survey/export/libs/PHPPowerPoint/Style/_notused_Borders.php new file mode 100644 index 0000000..f2ad8b7 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Style/_notused_Borders.php @@ -0,0 +1,577 @@ +_diagonalDirection = PHPPowerPoint_Style_Borders::DIAGONAL_NONE; + $this->_outline = true; + } + + /** + * Property Prepare bind + * + * Configures this object for late binding as a property of a parent object + * + * @param $parent + * @param $parentPropertyName + */ + public function propertyPrepareBind($parent, $parentPropertyName) + { + // Initialize parent PHPPowerPoint_Style for late binding. This relationship purposely ends immediately when this object + // is bound to the PHPPowerPoint_Style object pointed to so as to prevent circular references. + $this->_parent = $parent; + $this->_parentPropertyName = $parentPropertyName; + } + + /** + * Property Get Bound + * + * Returns the PHPPowerPoint_Style_Borders that is actual bound to PHPPowerPoint_Style + * + * @return PHPPowerPoint_Style_Borders + */ + private function propertyGetBound() { + if(!isset($this->_parent)) + return $this; // I am bound + + if($this->_parent->propertyIsBound($this->_parentPropertyName)) + return $this->_parent->getBorders(); // Another one is bound + + return $this; // No one is bound yet + } + + /** + * Property Begin Bind + * + * If no PHPPowerPoint_Style_Borders has been bound to PHPPowerPoint_Style then bind this one. Return the actual bound one. + * + * @return PHPPowerPoint_Style_Borders + */ + private function propertyBeginBind() { + if(!isset($this->_parent)) + return $this; // I am already bound + + if($this->_parent->propertyIsBound($this->_parentPropertyName)) + return $this->_parent->getBorders(); // Another one is already bound + + $this->_parent->propertyCompleteBind($this, $this->_parentPropertyName); // Bind myself + $this->_parent = null; + + return $this; + } + + + /** + * Property Complete Bind + * + * Complete the binding process a child property object started + * + * @param $propertyObject + * @param $propertyName Name of this property in the parent object + */ + public function propertyCompleteBind($propertyObject, $propertyName) { + switch($propertyName) { + case "_left": + $this->propertyBeginBind()->_left = $propertyObject; + break; + + case "_right": + $this->propertyBeginBind()->_right = $propertyObject; + break; + + case "_top": + $this->propertyBeginBind()->_top = $propertyObject; + break; + + case "_bottom": + $this->propertyBeginBind()->_bottom = $propertyObject; + break; + + case "_diagonal": + $this->propertyBeginBind()->_diagonal = $propertyObject; + break; + + case "_vertical": + $this->propertyBeginBind()->_vertical = $propertyObject; + break; + + case "_horizontal": + $this->propertyBeginBind()->_horizontal = $propertyObject; + break; + + default: + throw new Exception("Invalid property passed."); + } + } + + /** + * Property Is Bound + * + * Determines if a child property is bound to this one + * + * @param $propertyName Name of this property in the parent object + * + * @return boolean + */ + public function propertyIsBound($propertyName) { + switch($propertyName) { + case "_left": + return isset($this->propertyGetBound()->_left); + + case "_right": + return isset($this->propertyGetBound()->_right); + + case "_top": + return isset($this->propertyGetBound()->_top); + + case "_bottom": + return isset($this->propertyGetBound()->_bottom); + + case "_diagonal": + return isset($this->propertyGetBound()->_diagonal); + + case "_vertical": + return isset($this->propertyGetBound()->_vertical); + + case "_horizontal": + return isset($this->propertyGetBound()->_horizontal); + + default: + throw new Exception("Invalid property passed."); + } + } + + /** + * Apply styles from array + * + * + * $objPHPPowerPoint->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( + * array( + * 'bottom' => array( + * 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ), + * 'top' => array( + * 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ) + * ) + * ); + * + * + * $objPHPPowerPoint->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( + * array( + * 'allborders' => array( + * 'style' => PHPPowerPoint_Style_Border::BORDER_DASHDOT, + * 'color' => array( + * 'rgb' => '808080' + * ) + * ) + * ) + * ); + * + * + * @param array $pStyles Array containing style information + * @throws Exception + */ + public function applyFromArray($pStyles = null) { + if (is_array($pStyles)) { + if (array_key_exists('allborders', $pStyles)) { + $this->getLeft()->applyFromArray($pStyles['allborders']); + $this->getRight()->applyFromArray($pStyles['allborders']); + $this->getTop()->applyFromArray($pStyles['allborders']); + $this->getBottom()->applyFromArray($pStyles['allborders']); + } + if (array_key_exists('left', $pStyles)) { + $this->getLeft()->applyFromArray($pStyles['left']); + } + if (array_key_exists('right', $pStyles)) { + $this->getRight()->applyFromArray($pStyles['right']); + } + if (array_key_exists('top', $pStyles)) { + $this->getTop()->applyFromArray($pStyles['top']); + } + if (array_key_exists('bottom', $pStyles)) { + $this->getBottom()->applyFromArray($pStyles['bottom']); + } + if (array_key_exists('diagonal', $pStyles)) { + $this->getDiagonal()->applyFromArray($pStyles['diagonal']); + } + if (array_key_exists('vertical', $pStyles)) { + $this->getVertical()->applyFromArray($pStyles['vertical']); + } + if (array_key_exists('horizontal', $pStyles)) { + $this->getHorizontal()->applyFromArray($pStyles['horizontal']); + } + if (array_key_exists('diagonaldirection', $pStyles)) { + $this->setDiagonalDirection($pStyles['diagonaldirection']); + } + if (array_key_exists('outline', $pStyles)) { + $this->setOutline($pStyles['outline']); + } + } else { + throw new Exception("Invalid style array passed."); + } + } + + /** + * Get Left + * + * @return PHPPowerPoint_Style_Border + */ + public function getLeft() { + $property = $this->propertyGetBound(); + if(isset($property->_left)) + return $property->_left; + + $property = new PHPPowerPoint_Style_Border(); + $property->propertyPrepareBind($this, "_left"); + return $property; + } + + /** + * Get Right + * + * @return PHPPowerPoint_Style_Border + */ + public function getRight() { + $property = $this->propertyGetBound(); + if(isset($property->_right)) + return $property->_right; + + + $property = new PHPPowerPoint_Style_Border(); + $property->propertyPrepareBind($this, "_right"); + return $property; + } + + /** + * Get Top + * + * @return PHPPowerPoint_Style_Border + */ + public function getTop() { + $property = $this->propertyGetBound(); + if(isset($property->_top)) + return $property->_top; + + + $property = new PHPPowerPoint_Style_Border(); + $property->propertyPrepareBind($this, "_top"); + return $property; + } + + /** + * Get Bottom + * + * @return PHPPowerPoint_Style_Border + */ + public function getBottom() { + $property = $this->propertyGetBound(); + if(isset($property->_bottom)) + return $property->_bottom; + + $property = new PHPPowerPoint_Style_Border(); + $property->propertyPrepareBind($this, "_bottom"); + return $property; + } + + /** + * Get Diagonal + * + * @return PHPPowerPoint_Style_Border + */ + public function getDiagonal() { + $property = $this->propertyGetBound(); + if(isset($property->_diagonal)) + return $property->_diagonal; + + $property = new PHPPowerPoint_Style_Border(); + $property->propertyPrepareBind($this, "_diagonal"); + return $property; + } + + /** + * Get Vertical + * + * @return PHPPowerPoint_Style_Border + */ + public function getVertical() { + $property = $this->propertyGetBound(); + if(isset($property->_vertical)) + return $property->_vertical; + + $property = new PHPPowerPoint_Style_Border(); + $property->propertyPrepareBind($this, "_vertical"); + return $property; + } + + /** + * Get Horizontal + * + * @return PHPPowerPoint_Style_Border + */ + public function getHorizontal() { + $property = $this->propertyGetBound(); + if(isset($property->_horizontal)) + return $property->_horizontal; + + $property = new PHPPowerPoint_Style_Border(); + $property->propertyPrepareBind($this, "_horizontal"); + return $property; + } + + /** + * Get DiagonalDirection + * + * @return int + */ + public function getDiagonalDirection() { + return $this->propertyGetBound()->_diagonalDirection; + } + + /** + * Set DiagonalDirection + * + * @param int $pValue + */ + public function setDiagonalDirection($pValue = PHPPowerPoint_Style_Borders::DIAGONAL_NONE) { + if ($pValue == '') { + $pValue = PHPPowerPoint_Style_Borders::DIAGONAL_NONE; + } + $this->propertyBeginBind()->_diagonalDirection = $pValue; + } + + /** + * Get Outline + * + * @return boolean + */ + public function getOutline() { + return $this->propertyGetBound()->_outline; + } + + /** + * Set Outline + * + * @param boolean $pValue + */ + public function setOutline($pValue = true) { + if ($pValue == '') { + $pValue = true; + } + $this->propertyBeginBind()->_outline = $pValue; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + $property = $this->propertyGetBound(); + return md5( + $property->getLeft()->getHashCode() + . $property->getRight()->getHashCode() + . $property->getTop()->getHashCode() + . $property->getBottom()->getHashCode() + . $property->getDiagonal()->getHashCode() + . $property->getVertical()->getHashCode() + . $property->getHorizontal()->getHashCode() + . $property->getDiagonalDirection() + . ($property->getOutline() ? 't' : 'f') + . __CLASS__ + ); + } + + /** + * Hash index + * + * @var string + */ + private $_hashIndex; + + /** + * Get hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @return string Hash index + */ + public function getHashIndex() { + return $this->_hashIndex; + } + + /** + * Set hash index + * + * Note that this index may vary during script execution! Only reliable moment is + * while doing a write of a workbook and when changes are not allowed. + * + * @param string $value Hash index + */ + public function setHashIndex($value) { + $this->_hashIndex = $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; + } + } + } +} -- cgit v1.2.3