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 --- .../libs/PHPPowerPoint/Shape/BaseDrawing.php | 272 ++++++++++++++++++ .../export/libs/PHPPowerPoint/Shape/Drawing.php | 185 ++++++++++++ .../libs/PHPPowerPoint/Shape/MemoryDrawing.php | 235 +++++++++++++++ .../export/libs/PHPPowerPoint/Shape/RichText.php | 264 +++++++++++++++++ .../libs/PHPPowerPoint/Shape/RichText/Break.php | 88 ++++++ .../PHPPowerPoint/Shape/RichText/ITextElement.php | 67 +++++ .../libs/PHPPowerPoint/Shape/RichText/Run.php | 110 ++++++++ .../PHPPowerPoint/Shape/RichText/TextElement.php | 113 ++++++++ .../export/libs/PHPPowerPoint/Shape/Shadow.php | 314 +++++++++++++++++++++ 9 files changed, 1648 insertions(+) create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/BaseDrawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/Drawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/MemoryDrawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText/Break.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText/ITextElement.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText/Run.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/RichText/TextElement.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape/Shadow.php (limited to 'admin/survey/export/libs/PHPPowerPoint/Shape') diff --git a/admin/survey/export/libs/PHPPowerPoint/Shape/BaseDrawing.php b/admin/survey/export/libs/PHPPowerPoint/Shape/BaseDrawing.php new file mode 100644 index 0000000..6ce6d94 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shape/BaseDrawing.php @@ -0,0 +1,272 @@ +_name = ''; + $this->_description = ''; + $this->_resizeProportional = true; + + // Set image index + self::$_imageCounter++; + $this->_imageIndex = self::$_imageCounter; + + // Initialize parent + parent::__construct(); + } + + /** + * Get image index + * + * @return int + */ + public function getImageIndex() { + return $this->_imageIndex; + } + + /** + * Get Name + * + * @return string + */ + public function getName() { + return $this->_name; + } + + /** + * Set Name + * + * @param string $pValue + */ + public function setName($pValue = '') { + $this->_name = $pValue; + } + + /** + * Get Description + * + * @return string + */ + public function getDescription() { + return $this->_description; + } + + /** + * Set Description + * + * @param string $pValue + */ + public function setDescription($pValue = '') { + $this->_description = $pValue; + } + + /** + * Set Width + * + * @param int $pValue + */ + public function setWidth($pValue = 0) { + // Resize proportional? + if ($this->_resizeProportional && $pValue != 0) { + $ratio = $this->_height / $this->_width; + $this->_height = round($ratio * $pValue); + } + + // Set width + $this->_width = $pValue; + } + + /** + * Set Height + * + * @param int $pValue + */ + public function setHeight($pValue = 0) { + // Resize proportional? + if ($this->_resizeProportional && $pValue != 0) { + $ratio = $this->_width / $this->_height; + $this->_width = round($ratio * $pValue); + } + + // Set height + $this->_height = $pValue; + } + + /** + * Set width and height with proportional resize + * @author Vincent@luo MSN:kele_100@hotmail.com + * @param int $width + * @param int $height + * @example $objDrawing->setResizeProportional(true); + * @example $objDrawing->setWidthAndHeight(160,120); + */ + public function setWidthAndHeight($width = 0, $height = 0) { + $xratio = $width / $this->_width; + $yratio = $height / $this->_height; + if ($this->_resizeProportional && !($width == 0 || $height == 0)) { + if (($xratio * $this->_height) < $height) { + $this->_height = ceil($xratio * $this->_height); + $this->_width = $width; + } else { + $this->_width = ceil($yratio * $this->_width); + $this->_height = $height; + } + } + } + + /** + * Get ResizeProportional + * + * @return boolean + */ + public function getResizeProportional() { + return $this->_resizeProportional; + } + + /** + * Set ResizeProportional + * + * @param boolean $pValue + */ + public function setResizeProportional($pValue = true) { + $this->_resizeProportional = $pValue; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_name + . $this->_description + . parent::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/Shape/Drawing.php b/admin/survey/export/libs/PHPPowerPoint/Shape/Drawing.php new file mode 100644 index 0000000..feeab3c --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shape/Drawing.php @@ -0,0 +1,185 @@ +_path = ''; + + // Initialize parent + parent::__construct(); + } + + /** + * Get Filename + * + * @return string + */ + public function getFilename() { + return basename($this->_path); + } + + /** + * Get indexed filename (using image index) + * + * @return string + */ + public function getIndexedFilename() { + return str_replace('.' . $this->getExtension(), '', $this->getFilename()) . $this->getImageIndex() . '.' . $this->getExtension(); + } + + /** + * Get Extension + * + * @return string + */ + public function getExtension() { + $exploded = explode(".", basename($this->_path)); + return $exploded[count($exploded) - 1]; + } + + /** + * Get Path + * + * @return string + */ + public function getPath() { + return $this->_path; + } + + /** + * Set Path + * + * @param string $pValue File path + * @param boolean $pVerifyFile Verify file + * @throws Exception + */ + public function setPath($pValue = '', $pVerifyFile = true) { + if ($pVerifyFile) { + if (file_exists($pValue)) { + $this->_path = $pValue; + + if ($this->_width == 0 && $this->_height == 0) { + // Get width/height + list($this->_width, $this->_height) = getimagesize($pValue); + } + } else { + throw new Exception("File $pValue not found!"); + } + } else { + $this->_path = $pValue; + } + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_path + . parent::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/Shape/MemoryDrawing.php b/admin/survey/export/libs/PHPPowerPoint/Shape/MemoryDrawing.php new file mode 100644 index 0000000..604b671 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shape/MemoryDrawing.php @@ -0,0 +1,235 @@ +_imageResource = null; + $this->_renderingFunction = self::RENDERING_DEFAULT; + $this->_mimeType = self::MIMETYPE_DEFAULT; + $this->_uniqueName = md5(rand(0, 9999). time() . rand(0, 9999)); + + // Initialize parent + parent::__construct(); + } + + /** + * Get image resource + * + * @return resource + */ + public function getImageResource() { + return $this->_imageResource; + } + + /** + * Set image resource + * + * @param $value resource + */ + public function setImageResource($value = null) { + $this->_imageResource = $value; + + if (!is_null($this->_imageResource)) { + // Get width/height + $this->_width = imagesx($this->_imageResource); + $this->_height = imagesy($this->_imageResource); + } + } + + /** + * Get rendering function + * + * @return string + */ + public function getRenderingFunction() { + return $this->_renderingFunction; + } + + /** + * Set rendering function + * + * @param string $value + */ + public function setRenderingFunction($value = PHPPowerPoint_Slide_MemoryDrawing::RENDERING_DEFAULT) { + $this->_renderingFunction = $value; + } + + /** + * Get mime type + * + * @return string + */ + public function getMimeType() { + return $this->_mimeType; + } + + /** + * Set mime type + * + * @param string $value + */ + public function setMimeType($value = PHPPowerPoint_Slide_MemoryDrawing::MIMETYPE_DEFAULT) { + $this->_mimeType = $value; + } + + /** + * Get indexed filename (using image index) + * + * @return string + */ + public function getIndexedFilename() { + $extension = strtolower($this->getMimeType()); + $extension = explode('/', $extension); + $extension = $extension[1]; + + return $this->_uniqueName . $this->getImageIndex() . '.' . $extension; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_renderingFunction + . $this->_mimeType + . $this->_uniqueName + . parent::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/Shape/RichText.php b/admin/survey/export/libs/PHPPowerPoint/Shape/RichText.php new file mode 100644 index 0000000..ee2929c --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shape/RichText.php @@ -0,0 +1,264 @@ +_richTextElements = array(); + $this->_alignment = new PHPPowerPoint_Style_Alignment(); + + // Initialize parent + parent::__construct(); + } + + /** + * Get alignment + * + * @return PHPPowerPoint_Style_Alignment + */ + public function getAlignment() + { + return $this->_alignment; + } + + /** + * Add text + * + * @param PHPPowerPoint_Shape_RichText_ITextElement $pText Rich text element + * @throws Exception + */ + public function addText(PHPPowerPoint_Shape_RichText_ITextElement $pText = null) + { + $this->_richTextElements[] = $pText; + } + + /** + * Create text (can not be formatted !) + * + * @param string $pText Text + * @return PHPPowerPoint_Shape_RichText_TextElement + * @throws Exception + */ + public function createText($pText = '') + { + $objText = new PHPPowerPoint_Shape_RichText_TextElement($pText); + $this->addText($objText); + return $objText; + } + + /** + * Create break + * + * @return PHPPowerPoint_Shape_RichText_Break + * @throws Exception + */ + public function createBreak() + { + $objText = new PHPPowerPoint_Shape_RichText_Break(); + $this->addText($objText); + return $objText; + } + + /** + * Create text run (can be formatted) + * + * @param string $pText Text + * @return PHPPowerPoint_Shape_RichText_Run + * @throws Exception + */ + public function createTextRun($pText = '') + { + $objText = new PHPPowerPoint_Shape_RichText_Run($pText); + $this->addText($objText); + return $objText; + } + + /** + * Get plain text + * + * @return string + */ + public function getPlainText() + { + // Return value + $returnValue = ''; + + // Loop trough all PHPPowerPoint_Shape_RichText_ITextElement + foreach ($this->_richTextElements as $text) { + $returnValue .= $text->getText(); + } + + // Return + return $returnValue; + } + + /** + * Convert to string + * + * @return string + */ + public function __toString() { + return $this->getPlainText(); + } + + /** + * Get Rich Text elements + * + * @return PHPPowerPoint_Shape_RichText_ITextElement[] + */ + public function getRichTextElements() + { + return $this->_richTextElements; + } + + /** + * Set Rich Text elements + * + * @param PHPPowerPoint_Shape_RichText_ITextElement[] $pElements Array of elements + * @throws Exception + */ + public function setRichTextElements($pElements = null) + { + if (is_array($pElements)) { + $this->_richTextElements = $pElements; + } else { + throw new Exception("Invalid PHPPowerPoint_Shape_RichText_ITextElement[] array passed."); + } + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + $hashElements = ''; + foreach ($this->_richTextElements as $element) { + $hashElements .= $element->getHashCode(); + } + + return md5( + $hashElements + . __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 ($key == '_parent') continue; + + if (is_object($value)) { + $this->$key = clone $value; + } else { + $this->$key = $value; + } + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Shape/RichText/Break.php b/admin/survey/export/libs/PHPPowerPoint/Shape/RichText/Break.php new file mode 100644 index 0000000..2cef083 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shape/RichText/Break.php @@ -0,0 +1,88 @@ +setText($pText); + $this->_font = new PHPPowerPoint_Style_Font(); + } + + /** + * Get font + * + * @return PHPPowerPoint_Style_Font + */ + public function getFont() { + return $this->_font; + } + + /** + * Set font + * + * @param PHPPowerPoint_Style_Font $pFont Font + * @throws Exception + */ + public function setFont(PHPPowerPoint_Style_Font $pFont = null) { + $this->_font = $pFont; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->getText() + . $this->_font->getHashCode() + . __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; + } + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Shape/RichText/TextElement.php b/admin/survey/export/libs/PHPPowerPoint/Shape/RichText/TextElement.php new file mode 100644 index 0000000..b92f607 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shape/RichText/TextElement.php @@ -0,0 +1,113 @@ +_text = $pText; + } + + /** + * Get text + * + * @return string Text + */ + public function getText() { + return $this->_text; + } + + /** + * Set text + * + * @param $pText string Text + */ + public function setText($pText = '') { + $this->_text = $pText; + } + + /** + * Get font + * + * @return PHPPowerPoint_Style_Font + */ + public function getFont() { + return null; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_text + . __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; + } + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Shape/Shadow.php b/admin/survey/export/libs/PHPPowerPoint/Shape/Shadow.php new file mode 100644 index 0000000..c3a1e6d --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shape/Shadow.php @@ -0,0 +1,314 @@ +_visible = false; + $this->_blurRadius = 6; + $this->_distance = 2; + $this->_direction = 0; + $this->_alignment = self::SHADOW_BOTTOM_RIGHT; + $this->_color = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK); + $this->_alpha = 50; + } + + /** + * Get Visible + * + * @return boolean + */ + public function getVisible() { + return $this->_visible; + } + + /** + * Set Visible + * + * @param boolean $pValue + */ + public function setVisible($pValue = false) { + $this->_visible = $pValue; + } + + /** + * Get Blur radius + * + * @return int + */ + public function getBlurRadius() { + return $this->_blurRadius; + } + + /** + * Set Blur radius + * + * @param int $pValue + */ + public function setBlurRadius($pValue = 6) { + $this->_blurRadius = $pValue; + } + + /** + * Get Shadow distance + * + * @return int + */ + public function getDistance() { + return $this->_distance; + } + + /** + * Set Shadow distance + * + * @param int $pValue + */ + public function setDistance($pValue = 2) { + $this->_distance = $pValue; + } + + /** + * Get Shadow direction (in degrees) + * + * @return int + */ + public function getDirection() { + return $this->_direction; + } + + /** + * Set Shadow direction (in degrees) + * + * @param int $pValue + */ + public function setDirection($pValue = 0) { + $this->_direction = $pValue; + } + + /** + * Get Shadow alignment + * + * @return int + */ + public function getAlignment() { + return $this->_alignment; + } + + /** + * Set Shadow alignment + * + * @param int $pValue + */ + public function setAlignment($pValue = 0) { + $this->_alignment = $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 Alpha + * + * @return int + */ + public function getAlpha() { + return $this->_alpha; + } + + /** + * Set Alpha + * + * @param int $pValue + */ + public function setAlpha($pValue = 0) { + $this->_alpha = $pValue; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + ($this->_visible ? 't' : 'f') + . $this->_blurRadius + . $this->_distance + . $this->_direction + . $this->_alignment + . $this->_color->getHashCode() + . $this->_alpha + . __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