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/DocumentProperties.php | 299 ++ .../survey/export/libs/PHPPowerPoint/HashTable.php | 220 ++ .../export/libs/PHPPowerPoint/IComparable.php | 62 + .../survey/export/libs/PHPPowerPoint/IOFactory.php | 187 ++ .../export/libs/PHPPowerPoint/Reader/IReader.php | 53 + .../libs/PHPPowerPoint/Reader/Serialized.php | 125 + admin/survey/export/libs/PHPPowerPoint/Shape.php | 358 +++ .../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 +++ .../export/libs/PHPPowerPoint/Shared/Drawing.php | 109 + .../export/libs/PHPPowerPoint/Shared/File.php | 98 + .../export/libs/PHPPowerPoint/Shared/Font.php | 67 + .../export/libs/PHPPowerPoint/Shared/String.php | 270 ++ .../export/libs/PHPPowerPoint/Shared/XMLWriter.php | 141 + .../libs/PHPPowerPoint/Shared/ZipStreamWrapper.php | 182 ++ admin/survey/export/libs/PHPPowerPoint/Slide.php | 261 ++ .../export/libs/PHPPowerPoint/Slide/Layout.php | 50 + .../export/libs/PHPPowerPoint/SlideIterator.php | 118 + .../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 ++++ .../export/libs/PHPPowerPoint/Writer/IWriter.php | 45 + .../libs/PHPPowerPoint/Writer/PowerPoint2007.php | 411 +++ .../Writer/PowerPoint2007/ContentTypes.php | 219 ++ .../Writer/PowerPoint2007/DocProps.php | 218 ++ .../Writer/PowerPoint2007/Drawing.php | 94 + .../Writer/PowerPoint2007/LayoutPack.php | 124 + .../Writer/PowerPoint2007/LayoutPack/Default.php | 2983 ++++++++++++++++++++ .../Writer/PowerPoint2007/Presentation.php | 151 + .../PHPPowerPoint/Writer/PowerPoint2007/Rels.php | 347 +++ .../PHPPowerPoint/Writer/PowerPoint2007/Slide.php | 520 ++++ .../PHPPowerPoint/Writer/PowerPoint2007/Theme.php | 1215 ++++++++ .../Writer/PowerPoint2007/WriterPart.php | 72 + .../libs/PHPPowerPoint/Writer/Serialized.php | 187 ++ 44 files changed, 12811 insertions(+) create mode 100644 admin/survey/export/libs/PHPPowerPoint/DocumentProperties.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/HashTable.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/IComparable.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/IOFactory.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Reader/IReader.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Reader/Serialized.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shape.php 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 create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/Drawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/File.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/Font.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/String.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/XMLWriter.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Shared/ZipStreamWrapper.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Slide.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Slide/Layout.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/SlideIterator.php 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 create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/IWriter.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/ContentTypes.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/DocProps.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Drawing.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/Default.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Presentation.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Rels.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Slide.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Theme.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php create mode 100644 admin/survey/export/libs/PHPPowerPoint/Writer/Serialized.php (limited to 'admin/survey/export/libs') diff --git a/admin/survey/export/libs/PHPPowerPoint/DocumentProperties.php b/admin/survey/export/libs/PHPPowerPoint/DocumentProperties.php new file mode 100644 index 0000000..78d7977 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/DocumentProperties.php @@ -0,0 +1,299 @@ +_creator = 'Unknown Creator'; + $this->_lastModifiedBy = $this->_creator; + $this->_created = time(); + $this->_modified = time(); + $this->_title = "Untitled Presentation"; + $this->_subject = ''; + $this->_description = ''; + $this->_keywords = ''; + $this->_category = ''; + } + + /** + * Get Creator + * + * @return string + */ + public function getCreator() { + return $this->_creator; + } + + /** + * Set Creator + * + * @param string $pValue + */ + public function setCreator($pValue = '') { + $this->_creator = $pValue; + } + + /** + * Get Last Modified By + * + * @return string + */ + public function getLastModifiedBy() { + return $this->_lastModifiedBy; + } + + /** + * Set Last Modified By + * + * @param string $pValue + */ + public function setLastModifiedBy($pValue = '') { + $this->_lastModifiedBy = $pValue; + } + + /** + * Get Created + * + * @return datetime + */ + public function getCreated() { + return $this->_created; + } + + /** + * Set Created + * + * @param datetime $pValue + */ + public function setCreated($pValue = null) { + if (is_null($pValue)) { + $pValue = time(); + } + $this->_created = $pValue; + } + + /** + * Get Modified + * + * @return datetime + */ + public function getModified() { + return $this->_modified; + } + + /** + * Set Modified + * + * @param datetime $pValue + */ + public function setModified($pValue = null) { + if (is_null($pValue)) { + $pValue = time(); + } + $this->_modified = $pValue; + } + + /** + * Get Title + * + * @return string + */ + public function getTitle() { + return $this->_title; + } + + /** + * Set Title + * + * @param string $pValue + */ + public function setTitle($pValue = '') { + $this->_title = $pValue; + } + + /** + * Get Description + * + * @return string + */ + public function getDescription() { + return $this->_description; + } + + /** + * Set Description + * + * @param string $pValue + */ + public function setDescription($pValue = '') { + $this->_description = $pValue; + } + + /** + * Get Subject + * + * @return string + */ + public function getSubject() { + return $this->_subject; + } + + /** + * Set Subject + * + * @param string $pValue + */ + public function setSubject($pValue = '') { + $this->_subject = $pValue; + } + + /** + * Get Keywords + * + * @return string + */ + public function getKeywords() { + return $this->_keywords; + } + + /** + * Set Keywords + * + * @param string $pValue + */ + public function setKeywords($pValue = '') { + $this->_keywords = $pValue; + } + + /** + * Get Category + * + * @return string + */ + public function getCategory() { + return $this->_category; + } + + /** + * Set Category + * + * @param string $pValue + */ + public function setCategory($pValue = '') { + $this->_category = $pValue; + } + + /** + * 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/HashTable.php b/admin/survey/export/libs/PHPPowerPoint/HashTable.php new file mode 100644 index 0000000..7eb1b27 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/HashTable.php @@ -0,0 +1,220 @@ +addFromSource($pSource); + } + } + + /** + * Add HashTable items from source + * + * @param PHPPowerPoint_IComparable[] $pSource Source array to create HashTable from + * @throws Exception + */ + public function addFromSource($pSource = null) { + // Check if an array was passed + if ($pSource == null) { + return; + } else if (!is_array($pSource)) { + throw new Exception('Invalid array parameter passed.'); + } + + foreach ($pSource as $item) { + $this->add($item); + } + } + + /** + * Add HashTable item + * + * @param PHPPowerPoint_IComparable $pSource Item to add + * @throws Exception + */ + public function add(PHPPowerPoint_IComparable $pSource = null) { + // Determine hashcode + $hashCode = null; + $hashIndex = $pSource->getHashIndex(); + if ( is_null ( $hashIndex ) ) { + $hashCode = $pSource->getHashCode(); + } else if ( isset ( $this->_keyMap[$hashIndex] ) ) { + $hashCode = $this->_keyMap[$hashIndex]; + } else { + $hashCode = $pSource->getHashCode(); + } + + // Add value + if (!isset($this->_items[ $hashCode ])) { + $this->_items[ $hashCode ] = $pSource; + $index = count($this->_items) - 1; + $this->_keyMap[ $index ] = $hashCode; + $pSource->setHashIndex( $index ); + } else { + $pSource->setHashIndex( $this->_items[ $hashCode ]->getHashIndex() ); + } + } + + /** + * Remove HashTable item + * + * @param PHPPowerPoint_IComparable $pSource Item to remove + * @throws Exception + */ + public function remove(PHPPowerPoint_IComparable $pSource = null) { + if (isset($this->_items[ $pSource->getHashCode() ])) { + unset($this->_items[ $pSource->getHashCode() ]); + + $deleteKey = -1; + foreach ($this->_keyMap as $key => $value) { + if ($deleteKey >= 0) { + $this->_keyMap[$key - 1] = $value; + } + + if ($value == $pSource->getHashCode()) { + $deleteKey = $key; + } + } + unset($this->_keyMap[ count($this->_keyMap) - 1 ]); + } + } + + /** + * Clear HashTable + * + */ + public function clear() { + $this->_items = array(); + $this->_keyMap = array(); + } + + /** + * Count + * + * @return int + */ + public function count() { + return count($this->_items); + } + + /** + * Get index for hash code + * + * @param string $pHashCode + * @return int Index + */ + public function getIndexForHashCode($pHashCode = '') { + return array_search($pHashCode, $this->_keyMap); + } + + /** + * Get by index + * + * @param int $pIndex + * @return PHPPowerPoint_IComparable + * + */ + public function getByIndex($pIndex = 0) { + if (isset($this->_keyMap[$pIndex])) { + return $this->getByHashCode( $this->_keyMap[$pIndex] ); + } + + return null; + } + + /** + * Get by hashcode + * + * @param string $pHashCode + * @return PHPPowerPoint_IComparable + * + */ + public function getByHashCode($pHashCode = '') { + if (isset($this->_items[$pHashCode])) { + return $this->_items[$pHashCode]; + } + + return null; + } + + /** + * HashTable to array + * + * @return PHPPowerPoint_IComparable[] + */ + public function toArray() { + return $this->_items; + } + + /** + * 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; + } + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/IComparable.php b/admin/survey/export/libs/PHPPowerPoint/IComparable.php new file mode 100644 index 0000000..3870d55 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/IComparable.php @@ -0,0 +1,62 @@ + 'IWriter', 'path' => 'PHPPowerPoint/Writer/{0}.php', 'class' => 'PHPPowerPoint_Writer_{0}' ), + array( 'type' => 'IReader', 'path' => 'PHPPowerPoint/Reader/{0}.php', 'class' => 'PHPPowerPoint_Reader_{0}' ) + ); + + /** + * Autoresolve classes + * + * @var array + */ + private static $_autoResolveClasses = array( + 'Serialized' + ); + + /** + * Private constructor for PHPPowerPoint_IOFactory + */ + private function __construct() { } + + /** + * Get search locations + * + * @return array + */ + public static function getSearchLocations() { + return self::$_searchLocations; + } + + /** + * Set search locations + * + * @param array $value + * @throws Exception + */ + public static function setSearchLocations($value) { + if (is_array($value)) { + self::$_searchLocations = $value; + } else { + throw new Exception('Invalid parameter passed.'); + } + } + + /** + * Add search location + * + * @param string $type Example: IWriter + * @param string $location Example: PHPPowerPoint/Writer/{0}.php + * @param string $classname Example: PHPPowerPoint_Writer_{0} + */ + public static function addSearchLocation($type = '', $location = '', $classname = '') { + self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname ); + } + + /** + * Create PHPPowerPoint_Writer_IWriter + * + * @param PHPPowerPoint $PHPPowerPoint + * @param string $writerType Example: PowerPoint2007 + * @return PHPPowerPoint_Writer_IWriter + */ + public static function createWriter(PHPPowerPoint $PHPPowerPoint, $writerType = '') { + // Search type + $searchType = 'IWriter'; + + // Include class + foreach (self::$_searchLocations as $searchLocation) { + if ($searchLocation['type'] == $searchType) { + $className = str_replace('{0}', $writerType, $searchLocation['class']); + $classFile = str_replace('{0}', $writerType, $searchLocation['path']); + + if (!class_exists($className)) { + require_once($classFile); + } + + $instance = new $className($PHPPowerPoint); + if (!is_null($instance)) { + return $instance; + } + } + } + + // Nothing found... + throw new Exception("No $searchType found for type $writerType"); + } + + /** + * Create PHPPowerPoint_Reader_IReader + * + * @param string $readerType Example: PowerPoint2007 + * @return PHPPowerPoint_Reader_IReader + */ + public static function createReader($readerType = '') { + // Search type + $searchType = 'IReader'; + + // Include class + foreach (self::$_searchLocations as $searchLocation) { + if ($searchLocation['type'] == $searchType) { + $className = str_replace('{0}', $readerType, $searchLocation['class']); + $classFile = str_replace('{0}', $readerType, $searchLocation['path']); + + if (!class_exists($className)) { + require_once($classFile); + } + + $instance = new $className(); + if (!is_null($instance)) { + return $instance; + } + } + } + + // Nothing found... + throw new Exception("No $searchType found for type $readerType"); + } + + /** + * Loads PHPPowerPoint from file using automatic PHPPowerPoint_Reader_IReader resolution + * + * @param string $pFileName + * @return PHPPowerPoint + * @throws Exception + */ + public static function load($pFilename) { + // Try loading using self::$_autoResolveClasses + foreach (self::$_autoResolveClasses as $autoResolveClass) { + $reader = self::createReader($autoResolveClass); + if ($reader->canRead($pFilename)) { + return $reader->load($pFilename); + } + } + + throw new Exception("Could not automatically determine PHPPowerPoint_Reader_IReader for file."); + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Reader/IReader.php b/admin/survey/export/libs/PHPPowerPoint/Reader/IReader.php new file mode 100644 index 0000000..b6e7ae3 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Reader/IReader.php @@ -0,0 +1,53 @@ +fileSupportsUnserializePHPPowerPoint($pFilename); + } + + /** + * Loads PHPPowerPoint Serialized file + * + * @param string $pFilename + * @return PHPPowerPoint + * @throws Exception + */ + public function load($pFilename) + { + // Check if file exists + if (!file_exists($pFilename)) { + throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + // Unserialize... First make sure the file supports it! + if (!$this->fileSupportsUnserializePHPPowerPoint($pFilename)) { + throw new Exception("Invalid file format for PHPPowerPoint_Reader_Serialized: " . $pFilename . "."); + } + + return $this->_loadSerialized($pFilename); + } + + /** + * Load PHPPowerPoint Serialized file + * + * @param string $pFilename + * @return PHPPowerPoint + */ + private function _loadSerialized($pFilename) { + $xmlData = simplexml_load_string(file_get_contents("zip://$pFilename#PHPPowerPoint.xml")); + $excel = unserialize(base64_decode((string)$xmlData->data)); + + // Update media links + for ($i = 0; $i < $excel->getSlideCount(); ++$i) { + for ($j = 0; $j < $excel->getSlide($i)->getShapeCollection()->count(); ++$j) { + if ($excel->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPExcl_Shape_BaseDrawing) { + $imgTemp =& $excel->getSlide($i)->getShapeCollection()->offsetGet($j); + $imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false); + } + } + } + + return $excel; + } + + /** + * Does a file support UnserializePHPPowerPoint ? + * + * @param string $pFilename + * @throws Exception + * @return boolean + */ + public function fileSupportsUnserializePHPPowerPoint($pFilename = '') { + // Check if file exists + if (!file_exists($pFilename)) { + throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); + } + + // File exists, does it contain PHPPowerPoint.xml? + return PHPPowerPoint_Shared_File::file_exists("zip://$pFilename#PHPPowerPoint.xml"); + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Shape.php b/admin/survey/export/libs/PHPPowerPoint/Shape.php new file mode 100644 index 0000000..8ad3b0f --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shape.php @@ -0,0 +1,358 @@ +_slide = null; + $this->_offsetX = 0; + $this->_offsetY = 0; + $this->_width = 0; + $this->_height = 0; + $this->_rotation = 0; + $this->_fill = new PHPPowerPoint_Style_Fill(); + $this->_shadow = new PHPPowerPoint_Shape_Shadow(); + } + + /** + * Get Slide + * + * @return PHPPowerPoint_Slide + */ + public function getSlide() { + return $this->_slide; + } + + /** + * Set Slide + * + * @param PHPPowerPoint_Slide $pValue + * @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide? + * @throws Exception + */ + public function setSlide(PHPPowerPoint_slide $pValue = null, $pOverrideOld = false) { + if (is_null($this->_slide)) { + // Add drawing to PHPPowerPoint_Slide + $this->_slide = $pValue; + $this->_slide->getShapeCollection()->append($this); + } else { + if ($pOverrideOld) { + // Remove drawing from old PHPPowerPoint_Slide + $iterator = $this->_slide->getShapeCollection()->getIterator(); + + while ($iterator->valid()) { + if ($iterator->current()->getHashCode() == $this->getHashCode()) { + $this->_slide->getShapeCollection()->offsetUnset( $iterator->key() ); + $this->_slide = null; + break; + } + } + + // Set new PHPPowerPoint_Slide + $this->setSlide($pValue); + } else { + throw new Exception("A PHPPowerPoint_Slide has already been assigned. Shapes can only exist on one PHPPowerPoint_Slide."); + } + } + } + + /** + * Get OffsetX + * + * @return int + */ + public function getOffsetX() { + return $this->_offsetX; + } + + /** + * Set OffsetX + * + * @param int $pValue + */ + public function setOffsetX($pValue = 0) { + $this->_offsetX = $pValue; + } + + /** + * Get OffsetY + * + * @return int + */ + public function getOffsetY() { + return $this->_offsetY; + } + + /** + * Set OffsetY + * + * @param int $pValue + */ + public function setOffsetY($pValue = 0) { + $this->_offsetY = $pValue; + } + + /** + * Get Width + * + * @return int + */ + public function getWidth() { + return $this->_width; + } + + /** + * Set Width + * + * @param int $pValue + */ + public function setWidth($pValue = 0) { + $this->_width = $pValue; + } + + /** + * Get Height + * + * @return int + */ + public function getHeight() { + return $this->_height; + } + + /** + * Set Height + * + * @param int $pValue + */ + public function setHeight($pValue = 0) { + $this->_height = $pValue; + } + + /** + * Set width and height with proportional resize + * + * @param int $width + * @param int $height + * @example $objDrawing->setWidthAndHeight(160,120); + */ + public function setWidthAndHeight($width = 0, $height = 0) { + $this->_width = $width; + $this->_height = $height; + } + + /** + * Get Rotation + * + * @return int + */ + public function getRotation() { + return $this->_rotation; + } + + /** + * Set Rotation + * + * @param int $pValue + */ + public function setRotation($pValue = 0) { + $this->_rotation = $pValue; + } + + /** + * Get Fill + * + * @return PHPPowerPoint_Style_Fill + */ + public function getFill() { + return $this->_fill; + } + + /** + * Get Shadow + * + * @return PHPPowerPoint_Shape_Shadow + */ + public function getShadow() { + return $this->_shadow; + } + + /** + * Set Shadow + * + * @param PHPPowerPoint_Shape_Shadow $pValue + * @throws Exception + */ + public function setShadow(PHPPowerPoint_Shape_Shadow $pValue = null) { + $this->_shadow = $pValue; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_slide->getHashCode() + . $this->_offsetX + . $this->_offsetY + . $this->_width + . $this->_height + . $this->_rotation + . $this->getFill()->getHashCode() + . $this->_shadow->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/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; + } + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Shared/Drawing.php b/admin/survey/export/libs/PHPPowerPoint/Shared/Drawing.php new file mode 100644 index 0000000..e3727fc --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shared/Drawing.php @@ -0,0 +1,109 @@ +open($zipFile) === true) { + $returnValue = ($zip->getFromName($archiveFile) !== false); + $zip->close(); + return $returnValue; + } else { + return false; + } + } else { + // Regular file_exists + return file_exists($pFilename); + } + } + + /** + * Returns canonicalized absolute pathname, also for ZIP archives + * + * @param string $pFilename + * @return string + */ + public static function realpath($pFilename) { + // Returnvalue + $returnValue = ''; + + // Try using realpath() + $returnValue = realpath($pFilename); + + // Found something? + if ($returnValue == '' || is_null($returnValue)) { + $pathArray = split('/' , $pFilename); + while(in_array('..', $pathArray) && $pathArray[0] != '..') { + for ($i = 0; $i < count($pathArray); ++$i) { + if ($pathArray[$i] == '..' && $i > 0) { + unset($pathArray[$i]); + unset($pathArray[$i - 1]); + break; + } + } + } + $returnValue = implode('/', $pathArray); + } + + // Return + return $returnValue; + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Shared/Font.php b/admin/survey/export/libs/PHPPowerPoint/Shared/Font.php new file mode 100644 index 0000000..342146a --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shared/Font.php @@ -0,0 +1,67 @@ +) + * element or in the shared string element. + * + * @param string $value Value to unescape + * @return string + */ + public static function ControlCharacterOOXML2PHP($value = '') { + if(empty(self::$_controlCharacters)) { + self::_buildControlCharacters(); + } + + return str_replace( array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value ); + } + + /** + * Convert from PHP control character to OpenXML escaped control character + * + * Excel 2007 team: + * ---------------- + * That's correct, control characters are stored directly in the shared-strings table. + * We do encode characters that cannot be represented in XML using the following escape sequence: + * _xHHHH_ where H represents a hexadecimal character in the character's value... + * So you could end up with something like _x0008_ in a string (either in a cell value () + * element or in the shared string element. + * + * @param string $value Value to escape + * @return string + */ + public static function ControlCharacterPHP2OOXML($value = '') { + if(empty(self::$_controlCharacters)) { + self::_buildControlCharacters(); + } + + return str_replace( array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value ); + } + + /** + * Check if a string contains UTF8 data + * + * @param string $value + * @return boolean + */ + public static function IsUTF8($value = '') { + return utf8_encode(utf8_decode($value)) === $value; + } + + /** + * Formats a numeric value as a string for output in various output writers + * + * @param mixed $value + * @return string + */ + public static function FormatNumber($value) { + return number_format($value, 2, '.', ''); + } + + /** + * Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) + * Writes the string using uncompressed notation, no rich text, no Asian phonetics + * If mbstring extension is not available, ASCII is assumed, and compressed notation is used + * although this will give wrong results for non-ASCII strings + * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 + * + * @param string $value UTF-8 encoded string + * @return string + */ + public static function UTF8toBIFF8UnicodeShort($value) + { + // character count + $ln = self::CountCharacters($value, 'UTF-8'); + + // option flags + $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? + 0x0001 : 0x0000; + + // characters + $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); + + $data = pack('CC', $ln, $opt) . $chars; + return $data; + } + + /** + * Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) + * Writes the string using uncompressed notation, no rich text, no Asian phonetics + * If mbstring extension is not available, ASCII is assumed, and compressed notation is used + * although this will give wrong results for non-ASCII strings + * see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3 + * + * @param string $value UTF-8 encoded string + * @return string + */ + public static function UTF8toBIFF8UnicodeLong($value) + { + // character count + $ln = self::CountCharacters($value, 'UTF-8'); + + // option flags + $opt = (self::getIsMbstringEnabled() || self::getIsIconvEnabled()) ? + 0x0001 : 0x0000; + + // characters + $chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); + + $data = pack('vC', $ln, $opt) . $chars; + return $data; + } + + /** + * Convert string from one encoding to another. First try mbstring, then iconv, or no convertion + * + * @param string $value + * @param string $to Encoding to convert to, e.g. 'UTF-8' + * @param string $from Encoding to convert from, e.g. 'UTF-16LE' + * @return string + */ + public static function ConvertEncoding($value, $to, $from) + { + if (self::getIsMbstringEnabled()) { + $value = mb_convert_encoding($value, $to, $from); + return $value; + } + + if (self::getIsIconvEnabled()) { + $value = iconv($from, $to, $value); + return $value; + } + + // else, no conversion + return $value; + } + + /** + * Get character count. First try mbstring, then iconv, finally strlen + * + * @param string $value + * @param string $enc Encoding + * @return int Character count + */ + public static function CountCharacters($value, $enc = 'UTF-8') + { + if (self::getIsMbstringEnabled()) { + $count = mb_strlen($value, $enc); + return $count; + } + + if (self::getIsIconvEnabled()) { + $count = iconv_strlen($value, $enc); + return $count; + } + + // else strlen + $count = strlen($value); + return $count; + } + +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Shared/XMLWriter.php b/admin/survey/export/libs/PHPPowerPoint/Shared/XMLWriter.php new file mode 100644 index 0000000..da434a5 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shared/XMLWriter.php @@ -0,0 +1,141 @@ +_xmlWriter = new XMLWriter(); + + // Open temporary storage + if ($pTemporaryStorage == self::STORAGE_MEMORY) { + $this->_xmlWriter->openMemory(); + } else { + // Create temporary filename + $this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml'); + + // Open storage + if ($this->_xmlWriter->openUri($this->_tempFileName) === false) { + // Fallback to memory... + $this->_xmlWriter->openMemory(); + } + } + + // Set default values + $this->_xmlWriter->setIndent(true); + } + + /** + * Destructor + */ + public function __destruct() { + // Desctruct XMLWriter + unset($this->_xmlWriter); + + // Unlink temporary files + if ($this->_tempFileName != '') { + @unlink($this->_tempFileName); + } + } + + /** + * Get written data + * + * @return $data + */ + public function getData() { + if ($this->_tempFileName == '') { + return $this->_xmlWriter->outputMemory(true); + } else { + $this->_xmlWriter->flush(); + return file_get_contents($this->_tempFileName); + } + } + + /** + * Catch function calls (and pass them to internal XMLWriter) + * + * @param unknown_type $function + * @param unknown_type $args + */ + public function __call($function, $args) { + try { + @call_user_func_array(array($this->_xmlWriter, $function), $args); + } catch (Exception $ex) { + // Do nothing! + } + } + + /** + * Fallback method for writeRaw, introduced in PHP 5.2 + * + * @param string $text + * @return string + */ + public function writeRaw($text) + { + if (isset($this->_xmlWriter) && is_object($this->_xmlWriter) && (method_exists($this->_xmlWriter, 'writeRaw'))) { + return $this->_xmlWriter->writeRaw($text); + } + + return $this->text($text); + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Shared/ZipStreamWrapper.php b/admin/survey/export/libs/PHPPowerPoint/Shared/ZipStreamWrapper.php new file mode 100644 index 0000000..1d5a5f5 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Shared/ZipStreamWrapper.php @@ -0,0 +1,182 @@ +_archive = new ZipArchive(); + $this->_archive->open($url['host']); + + $this->_fileNameInArchive = $url['fragment']; + $this->_position = 0; + $this->_data = $this->_archive->getFromName( $this->_fileNameInArchive ); + + return true; + } + + /** + * Stat stream + */ + public function stream_stat() { + return $this->_archive->statName( $this->_fileNameInArchive ); + } + + /** + * Read stream + */ + function stream_read($count) { + $ret = substr($this->_data, $this->_position, $count); + $this->_position += strlen($ret); + return $ret; + } + + /** + * Tell stream + */ + public function stream_tell() { + return $this->_position; + } + + /** + * EOF stream + */ + public function stream_eof() { + return $this->_position >= strlen($this->_data); + } + + /** + * Seek stream + */ + public function stream_seek($offset, $whence) { + switch ($whence) { + case SEEK_SET: + if ($offset < strlen($this->_data) && $offset >= 0) { + $this->_position = $offset; + return true; + } else { + return false; + } + break; + + case SEEK_CUR: + if ($offset >= 0) { + $this->_position += $offset; + return true; + } else { + return false; + } + break; + + case SEEK_END: + if (strlen($this->_data) + $offset >= 0) { + $this->_position = strlen($this->_data) + $offset; + return true; + } else { + return false; + } + break; + + default: + return false; + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Slide.php b/admin/survey/export/libs/PHPPowerPoint/Slide.php new file mode 100644 index 0000000..6037cbe --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Slide.php @@ -0,0 +1,261 @@ +_parent = $pParent; + + // Shape collection + $this->_shapeCollection = new ArrayObject(); + + // Set identifier + $this->_identifier = md5(rand(0,9999) . time()); + } + + /** + * Get collection of shapes + * + * @return PHPPowerPoint_Shape[] + */ + public function getShapeCollection() + { + return $this->_shapeCollection; + } + + /** + * Add shape to slide + * + * @param PHPPowerPoint_Shape $shape + */ + public function addShape(PHPPowerPoint_Shape $shape) + { + $shape->setSlide($this); + } + + /** + * Create rich text shape + * + * @return PHPPowerPoint_Shape_RichText + */ + public function createRichTextShape() + { + $shape = new PHPPowerPoint_Shape_RichText(); + $this->addShape($shape); + return $shape; + } + + /** + * Create drawing shape + * + * @return PHPPowerPoint_Shape_Drawing + */ + public function createDrawingShape() + { + $shape = new PHPPowerPoint_Shape_Drawing(); + $this->addShape($shape); + return $shape; + } + + /** + * Get parent + * + * @return PHPPowerPoint + */ + public function getParent() { + return $this->_parent; + } + + /** + * Re-bind parent + * + * @param PHPPowerPoint $parent + */ + public function rebindParent(PHPPowerPoint $parent) { + $this->_parent->removeSlideByIndex( + $this->_parent->getIndex($this) + ); + $this->_parent = $parent; + } + + /** + * Get slide layout + * + * @return string + */ + public function getSlideLayout() { + return $this->_slideLayout; + } + + /** + * Set slide layout + * + * @param string $layout + */ + public function setSlideLayout($layout = PHPPowerPoint_Slide_Layout::BLANK) { + $this->_slideLayout = $layout; + } + + /** + * Get hash code + * + * @return string Hash code + */ + public function getHashCode() { + return md5( + $this->_identifier + . __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; + } + + /** + * Copy slide (!= clone!) + * + * @return PHPPowerPoint_Slide + */ + public function copy() { + $copied = clone $this; + + return $copied; + } + + /** + * Implement PHP __clone to create a deep clone, not just a shallow copy. + */ + public function __clone() { + foreach ($this as $key => $val) { + if (is_object($val) || (is_array($val))) { + $this->{$key} = unserialize(serialize($val)); + } + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Slide/Layout.php b/admin/survey/export/libs/PHPPowerPoint/Slide/Layout.php new file mode 100644 index 0000000..46548c8 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Slide/Layout.php @@ -0,0 +1,50 @@ +_subject = $subject; + } + + /** + * Destructor + */ + public function __destruct() { + unset($this->_subject); + } + + /** + * Rewind iterator + */ + public function rewind() { + $this->_position = 0; + } + + /** + * Current PHPPowerPoint_Slide + * + * @return PHPPowerPoint_Slide + */ + public function current() { + return $this->_subject->getSlide($this->_position); + } + + /** + * Current key + * + * @return int + */ + public function key() { + return $this->_position; + } + + /** + * Next value + */ + public function next() { + ++$this->_position; + } + + /** + * More PHPPowerPoint_Slide instances available? + * + * @return boolean + */ + public function valid() { + return $this->_position < $this->_subject->getSlideCount(); + } +} 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; + } + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/IWriter.php b/admin/survey/export/libs/PHPPowerPoint/Writer/IWriter.php new file mode 100644 index 0000000..51bd757 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/IWriter.php @@ -0,0 +1,45 @@ +setPHPPowerPoint($pPHPPowerPoint); + + // Set up disk caching location + $this->_diskCachingDirectory = './'; + + // Set layout pack + $this->_layoutPack = new PHPPowerPoint_Writer_PowerPoint2007_LayoutPack_Default(); + + // Initialise writer parts + $this->_writerParts['contenttypes'] = new PHPPowerPoint_Writer_PowerPoint2007_ContentTypes(); + $this->_writerParts['docprops'] = new PHPPowerPoint_Writer_PowerPoint2007_DocProps(); + $this->_writerParts['rels'] = new PHPPowerPoint_Writer_PowerPoint2007_Rels(); + $this->_writerParts['theme'] = new PHPPowerPoint_Writer_PowerPoint2007_Theme(); + $this->_writerParts['presentation'] = new PHPPowerPoint_Writer_PowerPoint2007_Presentation(); + $this->_writerParts['slide'] = new PHPPowerPoint_Writer_PowerPoint2007_Slide(); + $this->_writerParts['drawing'] = new PHPPowerPoint_Writer_PowerPoint2007_Drawing(); + + // Assign parent IWriter + foreach ($this->_writerParts as $writer) { + $writer->setParentWriter($this); + } + + // Set HashTable variables + $this->_drawingHashTable = new PHPPowerPoint_HashTable(); + } + + /** + * Get writer part + * + * @param string $pPartName Writer part name + * @return PHPPowerPoint_Writer_PowerPoint2007_WriterPart + */ + function getWriterPart($pPartName = '') { + if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { + return $this->_writerParts[strtolower($pPartName)]; + } else { + return null; + } + } + + /** + * Save PHPPowerPoint to file + * + * @param string $pFileName + * @throws Exception + */ + public function save($pFilename = null) + { + if (!is_null($this->_presentation)) { + // If $pFilename is php://output or php://stdout, make it a temporary file... + $originalFilename = $pFilename; + if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { + $pFilename = @tempnam('./', 'phppttmp'); + if ($pFilename == '') { + $pFilename = $originalFilename; + } + } + + // Create drawing dictionary + $this->_drawingHashTable->addFromSource( $this->getWriterPart('Drawing')->allDrawings($this->_presentation) ); + + // Create new ZIP file and open it for writing + $objZip = new ZipArchive(); + + // Try opening the ZIP file + if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { + if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { + throw new Exception("Could not open " . $pFilename . " for writing."); + } + } + + // Add [Content_Types].xml to ZIP file + $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_presentation)); + + // Add relationships to ZIP file + $objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_presentation)); + $objZip->addFromString('ppt/_rels/presentation.xml.rels', $this->getWriterPart('Rels')->writePresentationRelationships($this->_presentation)); + + // Add document properties to ZIP file + $objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_presentation)); + $objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_presentation)); + + // Add theme to ZIP file + $objZip->addFromString('ppt/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_presentation)); + + // Add slide master to ZIP file + $masterSlide = $this->getLayoutPack()->getMasterSlide(); + $objZip->addFromString('ppt/slideMasters/_rels/slideMaster1.xml.rels', $this->getWriterPart('Rels')->writeSlideMasterRelationships()); + $objZip->addFromString('ppt/slideMasters/slideMaster1.xml', $masterSlide['body']); + + // Add slide layouts to ZIP file + $slideLayouts = $this->getLayoutPack()->getLayouts(); + for ($i = 0; $i < count($slideLayouts); ++$i) { + $objZip->addFromString('ppt/slideLayouts/_rels/slideLayout' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeSlideLayoutRelationships()); + $objZip->addFromString('ppt/slideLayouts/slideLayout' . ($i + 1) . '.xml', $slideLayouts[$i]['body']); + } + + // Add presentation to ZIP file + $objZip->addFromString('ppt/presentation.xml', $this->getWriterPart('Presentation')->writePresentation($this->_presentation)); + + // Add slides (drawings, ...) + for ($i = 0; $i < $this->_presentation->getSlideCount(); ++$i) { + // Add slide + $objZip->addFromString('ppt/slides/slide' . ($i + 1) . '.xml', $this->getWriterPart('Slide')->writeSlide($this->_presentation->getSlide($i))); + } + + // Add slide relationships (drawings, ...) + for ($i = 0; $i < $this->_presentation->getSlideCount(); ++$i) { + // Add relationships + $objZip->addFromString('ppt/slides/_rels/slide' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeSlideRelationships($this->_presentation->getSlide($i), ($i + 1))); + } + + // Add media + for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) { + if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_Drawing) { + $imageContents = null; + $imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath(); + + if (strpos($imagePath, 'zip://') !== false) { + $imagePath = substr($imagePath, 6); + $imagePathSplitted = explode('#', $imagePath); + + $imageZip = new ZipArchive(); + $imageZip->open($imagePathSplitted[0]); + $imageContents = $imageZip->getFromName($imagePathSplitted[1]); + $imageZip->close(); + unset($imageZip); + } else { + $imageContents = file_get_contents($imagePath); + } + + $objZip->addFromString('ppt/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); + } else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_MemoryDrawing) { + ob_start(); + call_user_func( + $this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(), + $this->getDrawingHashTable()->getByIndex($i)->getImageResource() + ); + $imageContents = ob_get_contents(); + ob_end_clean(); + + $objZip->addFromString('ppt/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); + } + } + + // Close file + if ($objZip->close() === false) { + throw new Exception("Could not close zip file $pFilename."); + } + + // If a temporary file was used, copy it to the correct file stream + if ($originalFilename != $pFilename) { + if (copy($pFilename, $originalFilename) === false) { + throw new Exception("Could not copy temporary zip file $pFilename to $originalFilename."); + } + @unlink($pFilename); + } + } else { + throw new Exception("PHPPowerPoint object unassigned."); + } + } + + /** + * Get PHPPowerPoint object + * + * @return PHPPowerPoint + * @throws Exception + */ + public function getPHPPowerPoint() { + if (!is_null($this->_presentation)) { + return $this->_presentation; + } else { + throw new Exception("No PHPPowerPoint assigned."); + } + } + + /** + * Get PHPPowerPoint object + * + * @param PHPPowerPoint $pPHPPowerPoint PHPPowerPoint object + * @throws Exception + */ + public function setPHPPowerPoint(PHPPowerPoint $pPHPPowerPoint = null) { + $this->_presentation = $pPHPPowerPoint; + } + + /** + * Get PHPPowerPoint_Worksheet_BaseDrawing HashTable + * + * @return PHPPowerPoint_HashTable + */ + public function getDrawingHashTable() { + return $this->_drawingHashTable; + } + + /** + * Get Office2003 compatibility + * + * @return boolean + */ + public function getOffice2003Compatibility() { + return $this->_office2003compatibility; + } + + /** + * Set Pre-Calculate Formulas + * + * @param boolean $pValue Office2003 compatibility? + */ + public function setOffice2003Compatibility($pValue = false) { + $this->_office2003compatibility = $pValue; + } + + /** + * Get use disk caching where possible? + * + * @return boolean + */ + public function getUseDiskCaching() { + return $this->_useDiskCaching; + } + + /** + * Set use disk caching where possible? + * + * @param boolean $pValue + * @param string $pDirectory Disk caching directory + * @throws Exception Exception when directory does not exist + */ + public function setUseDiskCaching($pValue = false, $pDirectory = null) { + $this->_useDiskCaching = $pValue; + + if (!is_null($pDirectory)) { + if (is_dir($pDirectory)) { + $this->_diskCachingDirectory = $pDirectory; + } else { + throw new Exception("Directory does not exist: $pDirectory"); + } + } + } + + /** + * Get disk caching directory + * + * @return string + */ + public function getDiskCachingDirectory() { + return $this->_diskCachingDirectory; + } + + /** + * Get layout pack to use + * + * @return PHPPowerPoint_Writer_PowerPoint2007_LayoutPack + */ + public function getLayoutPack() { + return $this->_layoutPack; + } + + /** + * Set layout pack to use + * + * @param PHPPowerPoint_Writer_PowerPoint2007_LayoutPack $pValue + */ + public function setLayoutPack(PHPPowerPoint_Writer_PowerPoint2007_LayoutPack $pValue = null) { + $this->_layoutPack = $pValue; + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/ContentTypes.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/ContentTypes.php new file mode 100644 index 0000000..ed50033 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/ContentTypes.php @@ -0,0 +1,219 @@ +getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // Types + $objWriter->startElement('Types'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); + + // Rels + $this->_writeDefaultContentType( + $objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml' + ); + + // XML + $this->_writeDefaultContentType( + $objWriter, 'xml', 'application/xml' + ); + + // Theme + $this->_writeOverrideContentType( + $objWriter, '/ppt/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml' + ); + + // Presentation + $this->_writeOverrideContentType( + $objWriter, '/ppt/presentation.xml', 'application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml' + ); + + // DocProps + $this->_writeOverrideContentType( + $objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml' + ); + + $this->_writeOverrideContentType( + $objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml' + ); + + // Slide master + $this->_writeOverrideContentType( + $objWriter, '/ppt/slideMasters/slideMaster1.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml' + ); + + // Slide layouts + $slideLayouts = $this->getParentWriter()->getLayoutPack()->getLayouts(); + for ($i = 0; $i < count($slideLayouts); ++$i) { + $this->_writeOverrideContentType( + $objWriter, '/ppt/slideLayouts/slideLayout' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml' + ); + } + + // Slides + $slideCount = $pPHPPowerPoint->getSlideCount(); + for ($i = 0; $i < $slideCount; ++$i) { + $this->_writeOverrideContentType( + $objWriter, '/ppt/slides/slide' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slide+xml' + ); + } + + // Add media content-types + $aMediaContentTypes = array(); + $mediaCount = $this->getParentWriter()->getDrawingHashTable()->count(); + for ($i = 0; $i < $mediaCount; ++$i) { + $extension = ''; + $mimeType = ''; + + if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_Drawing) { + $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension()); + $mimeType = $this->_getImageMimeType( $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath() ); + } else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPPowerPoint_Shape_MemoryDrawing) { + $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType()); + $extension = explode('/', $extension); + $extension = $extension[1]; + + $mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType(); + } + + if (!isset( $aMediaContentTypes[$extension]) ) { + $aMediaContentTypes[$extension] = $mimeType; + + $this->_writeDefaultContentType( + $objWriter, $extension, $mimeType + ); + } + } + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Get image mime type + * + * @param string $pFile Filename + * @return string Mime Type + * @throws Exception + */ + private function _getImageMimeType($pFile = '') + { + if (PHPPowerPoint_Shared_File::file_exists($pFile)) { + $image = getimagesize($pFile); + return image_type_to_mime_type($image[2]); + } else { + throw new Exception("File $pFile does not exist"); + } + } + + /** + * Write Default content type + * + * @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception + */ + private function _writeDefaultContentType(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') + { + if ($pPartname != '' && $pContentType != '') { + // Write content type + $objWriter->startElement('Default'); + $objWriter->writeAttribute('Extension', $pPartname); + $objWriter->writeAttribute('ContentType', $pContentType); + $objWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } + + /** + * Write Override content type + * + * @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer + * @param string $pPartname Part name + * @param string $pContentType Content type + * @throws Exception + */ + private function _writeOverrideContentType(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') + { + if ($pPartname != '' && $pContentType != '') { + // Write content type + $objWriter->startElement('Override'); + $objWriter->writeAttribute('PartName', $pPartname); + $objWriter->writeAttribute('ContentType', $pContentType); + $objWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/DocProps.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/DocProps.php new file mode 100644 index 0000000..403ca03 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/DocProps.php @@ -0,0 +1,218 @@ +getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // Properties + $objWriter->startElement('Properties'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); + $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); + + // Application + $objWriter->writeElement('Application', 'Microsoft Office PowerPoint'); + + // Slides + $objWriter->writeElement('Slides', $pPHPPowerPoint->getSlideCount()); + + // ScaleCrop + $objWriter->writeElement('ScaleCrop', 'false'); + + // HeadingPairs + $objWriter->startElement('HeadingPairs'); + + // Vector + $objWriter->startElement('vt:vector'); + $objWriter->writeAttribute('size', '4'); + $objWriter->writeAttribute('baseType', 'variant'); + + // Variant + $objWriter->startElement('vt:variant'); + $objWriter->writeElement('vt:lpstr', 'Theme'); + $objWriter->endElement(); + + // Variant + $objWriter->startElement('vt:variant'); + $objWriter->writeElement('vt:i4', '1'); + $objWriter->endElement(); + + // Variant + $objWriter->startElement('vt:variant'); + $objWriter->writeElement('vt:lpstr', 'Slide Titles'); + $objWriter->endElement(); + + // Variant + $objWriter->startElement('vt:variant'); + $objWriter->writeElement('vt:i4', '1'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // TitlesOfParts + $objWriter->startElement('TitlesOfParts'); + + // Vector + $objWriter->startElement('vt:vector'); + $objWriter->writeAttribute('size', '1'); + $objWriter->writeAttribute('baseType', 'lpstr'); + + $objWriter->writeElement('vt:lpstr', 'Office Theme'); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // Company + $objWriter->writeElement('Company', 'Microsoft Corporation'); + + // LinksUpToDate + $objWriter->writeElement('LinksUpToDate', 'false'); + + // SharedDoc + $objWriter->writeElement('SharedDoc', 'false'); + + // HyperlinksChanged + $objWriter->writeElement('HyperlinksChanged', 'false'); + + // AppVersion + $objWriter->writeElement('AppVersion', '12.0000'); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write docProps/core.xml to XML format + * + * @param PHPPowerPoint $pPHPPowerPoint + * @return string XML Output + * @throws Exception + */ + public function writeDocPropsCore(PHPPowerPoint $pPHPPowerPoint = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // cp:coreProperties + $objWriter->startElement('cp:coreProperties'); + $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); + $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); + $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); + $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); + $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); + + // dc:creator + $objWriter->writeElement('dc:creator', $pPHPPowerPoint->getProperties()->getCreator()); + + // cp:lastModifiedBy + $objWriter->writeElement('cp:lastModifiedBy', $pPHPPowerPoint->getProperties()->getLastModifiedBy()); + + // dcterms:created + $objWriter->startElement('dcterms:created'); + $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); + $objWriter->writeRaw(date(DATE_W3C, $pPHPPowerPoint->getProperties()->getCreated())); + $objWriter->endElement(); + + // dcterms:modified + $objWriter->startElement('dcterms:modified'); + $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); + $objWriter->writeRaw(date(DATE_W3C, $pPHPPowerPoint->getProperties()->getModified())); + $objWriter->endElement(); + + // dc:title + $objWriter->writeElement('dc:title', $pPHPPowerPoint->getProperties()->getTitle()); + + // dc:description + $objWriter->writeElement('dc:description', $pPHPPowerPoint->getProperties()->getDescription()); + + // dc:subject + $objWriter->writeElement('dc:subject', $pPHPPowerPoint->getProperties()->getSubject()); + + // cp:keywords + $objWriter->writeElement('cp:keywords', $pPHPPowerPoint->getProperties()->getKeywords()); + + // cp:category + $objWriter->writeElement('cp:category', $pPHPPowerPoint->getProperties()->getCategory()); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Drawing.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Drawing.php new file mode 100644 index 0000000..e1491b9 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Drawing.php @@ -0,0 +1,94 @@ +getSlideCount(); + for ($i = 0; $i < $slideCount; ++$i) { + // Loop trough images and add to array + $iterator = $pPHPPowerPoint->getSlide($i)->getShapeCollection()->getIterator(); + while ($iterator->valid()) { + if ($iterator->current() instanceof PHPPowerPoint_Shape_BaseDrawing) { + $aDrawings[] = $iterator->current(); + } + + $iterator->next(); + } + } + + return $aDrawings; + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack.php new file mode 100644 index 0000000..4448547 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack.php @@ -0,0 +1,124 @@ +_masterSlide; + } + + /** + * Get array of slide layouts. + * + * These are all an array consisting of: + * - name (string) + * - body (string) + * + * @return array + */ + public function getLayouts() + { + return $this->_layouts; + } + + /** + * Find specific slide layout. + * + * This is an array consisting of: + * - name (string) + * - body (string) + * + * @return array + * @throws Exception + */ + public function findLayout($name = '') + { + foreach ($this->_layouts as $layout) + { + if ($layout['name'] == $name) + { + return $layout; + } + } + + throw new Exception("Could not find slide layout $name in current layout pack."); + } + + /** + * Find specific slide layout index. + * + * @return int + * @throws Exception + */ + public function findLayoutIndex($name = '') + { + $i = 0; + foreach ($this->_layouts as $layout) + { + if ($layout['name'] == $name) + { + return $i; + } + + ++$i; + } + + throw new Exception("Could not find slide layout $name in current layout pack."); + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/Default.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/Default.php new file mode 100644 index 0000000..46df209 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/LayoutPack/Default.php @@ -0,0 +1,2983 @@ +_masterSlide = array( + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + Second level + + + + + + + Third level + + + + + + + Fourth level + + + + + + + Fifth level + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <#> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::TITLE_SLIDE + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::TITLE_SLIDE, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master subtitle style + + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::TITLE_AND_CONTENT + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::TITLE_AND_CONTENT, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + Second level + + + + + + + Third level + + + + + + + Fourth level + + + + + + + Fifth level + + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::SECTION_HEADER + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::SECTION_HEADER, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::TWO_CONTENT + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::TWO_CONTENT, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + Second level + + + + + + + Third level + + + + + + + Fourth level + + + + + + + Fifth level + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + Second level + + + + + + + Third level + + + + + + + Fourth level + + + + + + + Fifth level + + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::COMPARISON + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::COMPARISON, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + Second level + + + + + + + Third level + + + + + + + Fourth level + + + + + + + Fifth level + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + Second level + + + + + + + Third level + + + + + + + Fourth level + + + + + + + Fifth level + + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::TITLE_ONLY + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::TITLE_ONLY, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::BLANK + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::BLANK, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::CONTENT_WITH_CAPTION + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::CONTENT_WITH_CAPTION, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + Second level + + + + + + + Third level + + + + + + + Fourth level + + + + + + + Fifth level + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::PICTURE_WITH_CAPTION + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::PICTURE_WITH_CAPTION, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::TITLE_AND_VERTICAL_TEXT + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::TITLE_AND_VERTICAL_TEXT, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + Second level + + + + + + + Third level + + + + + + + Fourth level + + + + + + + Fifth level + + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + + // Layouts - PHPPowerPoint_Slide_Layout::VERTICAL_TITLE_AND_TEXT + $this->_layouts[] = array( + 'name' => PHPPowerPoint_Slide_Layout::VERTICAL_TITLE_AND_TEXT, + 'body' => ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master title style + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click to edit Master text styles + + + + + + + Second level + + + + + + + Third level + + + + + + + Fourth level + + + + + + + Fifth level + + + + + + + + + + + + + + + + + + + + + + + 16/04/2009 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?#? + + + + + + + + + + +'); + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Presentation.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Presentation.php new file mode 100644 index 0000000..6badaa9 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Presentation.php @@ -0,0 +1,151 @@ +getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // p:presentation + $objWriter->startElement('p:presentation'); + $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); + $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main'); + + // p:sldMasterIdLst + $objWriter->startElement('p:sldMasterIdLst'); + + // p:sldMasterId + $objWriter->startElement('p:sldMasterId'); + $objWriter->writeAttribute('id', '2147483648'); + $objWriter->writeAttribute('r:id', 'rId1'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // p:sldIdLst + $objWriter->startElement('p:sldIdLst'); + $this->_writeSlides($objWriter, $pPHPPowerPoint); + $objWriter->endElement(); + + // p:sldSz + $objWriter->startElement('p:sldSz'); + $objWriter->writeAttribute('cx', '9144000'); + $objWriter->writeAttribute('cy', '6858000'); + $objWriter->endElement(); + + // p:notesSz + $objWriter->startElement('p:notesSz'); + $objWriter->writeAttribute('cx', '6858000'); + $objWriter->writeAttribute('cy', '9144000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write slides + * + * @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer + * @param PHPPowerPoint $pPHPPowerPoint + * @throws Exception + */ + private function _writeSlides(PHPPowerPoint_Shared_XMLWriter $objWriter = null, PHPPowerPoint $pPHPPowerPoint = null) + { + // Write slides + $slideCount = $pPHPPowerPoint->getSlideCount(); + for ($i = 0; $i < $slideCount; ++$i) { + // p:sldId + $this->_writeSlide( + $objWriter, + ($i + 256), + ($i + 1 + 2) + ); + } + } + + /** + * Write slide + * + * @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer + * @param int $pSlideId Slide id + * @param int $pRelId Relationship ID + * @throws Exception + */ + private function _writeSlide(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pSlideId = 1, $pRelId = 1) + { + // p:sldId + $objWriter->startElement('p:sldId'); + $objWriter->writeAttribute('id', $pSlideId); + $objWriter->writeAttribute('r:id', 'rId' . $pRelId); + $objWriter->endElement(); + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Rels.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Rels.php new file mode 100644 index 0000000..cdab556 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Rels.php @@ -0,0 +1,347 @@ +getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + // Relationship docProps/app.xml + $this->_writeRelationship( + $objWriter, + 3, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + 'docProps/app.xml' + ); + + // Relationship docProps/core.xml + $this->_writeRelationship( + $objWriter, + 2, + 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + 'docProps/core.xml' + ); + + // Relationship ppt/presentation.xml + $this->_writeRelationship( + $objWriter, + 1, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + 'ppt/presentation.xml' + ); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write presentation relationships to XML format + * + * @param PHPPowerPoint $pPHPPowerPoint + * @return string XML Output + * @throws Exception + */ + public function writePresentationRelationships(PHPPowerPoint $pPHPPowerPoint = null) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + // Relationship slideMasters/slideMaster1.xml + $this->_writeRelationship( + $objWriter, + 1, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster', + 'slideMasters/slideMaster1.xml' + ); + + // Relationship theme/theme1.xml + $this->_writeRelationship( + $objWriter, + 2, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + 'theme/theme1.xml' + ); + + // Relationships with slides + $slideCount = $pPHPPowerPoint->getSlideCount(); + for ($i = 0; $i < $slideCount; ++$i) { + $this->_writeRelationship( + $objWriter, + ($i + 1 + 2), + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', + 'slides/slide' . ($i + 1) . '.xml' + ); + } + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write slide master relationships to XML format + * + * @return string XML Output + * @throws Exception + */ + public function writeSlideMasterRelationships() + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + // Write slideLayout relationships + $layoutPack = $this->getParentWriter()->getLayoutPack(); + for ($i = 0; $i < count($layoutPack->getLayouts()); ++$i) { + $this->_writeRelationship( + $objWriter, + $i + 1, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout', + '../slideLayouts/slideLayout' . ($i + 1) . '.xml' + ); + } + + // Relationship theme/theme1.xml + $this->_writeRelationship( + $objWriter, + count($layoutPack->getLayouts()) + 1, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + '../theme/theme1.xml' + ); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write slide layout relationships to XML format + * + * @return string XML Output + * @throws Exception + */ + public function writeSlideLayoutRelationships() + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + // Write slideMaster relationship + $this->_writeRelationship( + $objWriter, + 1, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster', + '../slideMasters/slideMaster1.xml' + ); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write slide relationships to XML format + * + * Numbering is as follows: + * rId1 - Drawings + * + * @param PHPPowerPoint_Slide $pSlide + * @param int $pSlideId + * @return string XML Output + * @throws Exception + */ + public function writeSlideRelationships(PHPPowerPoint_Slide $pSlide = null, $pSlideId = 1) + { + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // Relationships + $objWriter->startElement('Relationships'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + // Starting relation id + $relId = 1; + + // Write slideLayout relationship + $layoutPack = $this->getParentWriter()->getLayoutPack(); + $layoutIndex = $layoutPack->findlayoutIndex( $pSlide->getSlideLayout() ); + + $this->_writeRelationship( + $objWriter, + $relId++, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout', + '../slideLayouts/slideLayout' . ($layoutIndex + 1) . '.xml' + ); + + // Write drawing relationships? + if ($pSlide->getShapeCollection()->count() > 0) { + // Loop trough images and write relationships + $iterator = $pSlide->getShapeCollection()->getIterator(); + while ($iterator->valid()) { + if ($iterator->current() instanceof PHPPowerPoint_Shape_Drawing + || $iterator->current() instanceof PHPPowerPoint_Shape_MemoryDrawing) { + // Write relationship for image drawing + $this->_writeRelationship( + $objWriter, + $relId, + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', + '../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename()) + ); + } + + $iterator->next(); + ++$relId; + } + } + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write Override content type + * + * @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer + * @param int $pId Relationship ID. rId will be prepended! + * @param string $pType Relationship type + * @param string $pTarget Relationship target + * @param string $pTargetMode Relationship target mode + * @throws Exception + */ + private function _writeRelationship(PHPPowerPoint_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') + { + if ($pType != '' && $pTarget != '') { + // Write relationship + $objWriter->startElement('Relationship'); + $objWriter->writeAttribute('Id', 'rId' . $pId); + $objWriter->writeAttribute('Type', $pType); + $objWriter->writeAttribute('Target', $pTarget); + + if ($pTargetMode != '') { + $objWriter->writeAttribute('TargetMode', $pTargetMode); + } + + $objWriter->endElement(); + } else { + throw new Exception("Invalid parameters passed."); + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Slide.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Slide.php new file mode 100644 index 0000000..45c0e4a --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Slide.php @@ -0,0 +1,520 @@ +getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // p:sld + $objWriter->startElement('p:sld'); + $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); + $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + $objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main'); + + // p:cSld + $objWriter->startElement('p:cSld'); + + // p:spTree + $objWriter->startElement('p:spTree'); + + // p:nvGrpSpPr + $objWriter->startElement('p:nvGrpSpPr'); + + // p:cNvPr + $objWriter->startElement('p:cNvPr'); + $objWriter->writeAttribute('id', '1'); + $objWriter->writeAttribute('name', ''); + $objWriter->endElement(); + + // p:cNvGrpSpPr + $objWriter->writeElement('p:cNvGrpSpPr', null); + + // p:nvPr + $objWriter->writeElement('p:nvPr', null); + + $objWriter->endElement(); + + // p:grpSpPr + $objWriter->startElement('p:grpSpPr'); + + // a:xfrm + $objWriter->startElement('a:xfrm'); + + // a:off + $objWriter->startElement('a:off'); + $objWriter->writeAttribute('x', '0'); + $objWriter->writeAttribute('y', '0'); + $objWriter->endElement(); + + // a:ext + $objWriter->startElement('a:ext'); + $objWriter->writeAttribute('cx', '0'); + $objWriter->writeAttribute('cy', '0'); + $objWriter->endElement(); + + // a:chOff + $objWriter->startElement('a:chOff'); + $objWriter->writeAttribute('x', '0'); + $objWriter->writeAttribute('y', '0'); + $objWriter->endElement(); + + // a:chExt + $objWriter->startElement('a:chExt'); + $objWriter->writeAttribute('cx', '0'); + $objWriter->writeAttribute('cy', '0'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // Loop shapes + $shapeId = 0; + $relationId = 1; + $shapes = $pSlide->getShapeCollection(); + foreach ($shapes as $shape) + { + // Increment $shapeId + ++$shapeId; + + // Check type + if ($shape instanceof PHPPowerPoint_Shape_BaseDrawing) + { + // Picture --> $relationId + ++$relationId; + + $this->_writePic($objWriter, $shape, $shapeId, $relationId); + } + else if ($shape instanceof PHPPowerPoint_Shape_RichText) + { + $this->_writeTxt($objWriter, $shape, $shapeId); + } + } + + $objWriter->endElement(); + + $objWriter->endElement(); + + // p:clrMapOvr + $objWriter->startElement('p:clrMapOvr'); + + // a:masterClrMapping + $objWriter->writeElement('a:masterClrMapping', ''); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } + + /** + * Write pic + * + * @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer + * @param PHPPowerPoint_Shape_BaseDrawing $shape + * @param int $shapeId + * @param int $relationId + * @throws Exception + */ + private function _writePic(PHPPowerPoint_Shared_XMLWriter $objWriter = null, PHPPowerPoint_Shape_BaseDrawing $shape = null, $shapeId, $relationId) + { + // p:pic + $objWriter->startElement('p:pic'); + + // p:nvPicPr + $objWriter->startElement('p:nvPicPr'); + + // p:cNvPr + $objWriter->startElement('p:cNvPr'); + $objWriter->writeAttribute('id', $shapeId); + $objWriter->writeAttribute('name', $shape->getName()); + $objWriter->writeAttribute('descr', $shape->getDescription()); + $objWriter->endElement(); + + // p:cNvPicPr + $objWriter->startElement('p:cNvPicPr'); + + // a:picLocks + $objWriter->startElement('a:picLocks'); + $objWriter->writeAttribute('noChangeAspect', '1'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // p:nvPr + $objWriter->writeElement('p:nvPr', null); + + $objWriter->endElement(); + + // p:blipFill + $objWriter->startElement('p:blipFill'); + + // a:blip + $objWriter->startElement('a:blip'); + $objWriter->writeAttribute('r:embed', 'rId' . $relationId); + $objWriter->endElement(); + + // a:stretch + $objWriter->startElement('a:stretch'); + $objWriter->writeElement('a:fillRect', null); + $objWriter->endElement(); + + $objWriter->endElement(); + + // p:spPr + $objWriter->startElement('p:spPr'); + + // a:xfrm + $objWriter->startElement('a:xfrm'); + $objWriter->writeAttribute('rot', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getRotation())); + + // a:off + $objWriter->startElement('a:off'); + $objWriter->writeAttribute('x', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetX())); + $objWriter->writeAttribute('y', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetY())); + $objWriter->endElement(); + + // a:ext + $objWriter->startElement('a:ext'); + $objWriter->writeAttribute('cx', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getWidth())); + $objWriter->writeAttribute('cy', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getHeight())); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:prstGeom + $objWriter->startElement('a:prstGeom'); + $objWriter->writeAttribute('prst', 'rect'); + + // a:avLst + $objWriter->writeElement('a:avLst', null); + + $objWriter->endElement(); + + if ($shape->getShadow()->getVisible()) { + // a:effectLst + $objWriter->startElement('a:effectLst'); + + // a:outerShdw + $objWriter->startElement('a:outerShdw'); + $objWriter->writeAttribute('blurRad', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getBlurRadius())); + $objWriter->writeAttribute('dist', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getDistance())); + $objWriter->writeAttribute('dir', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getShadow()->getDirection())); + $objWriter->writeAttribute('algn', $shape->getShadow()->getAlignment()); + $objWriter->writeAttribute('rotWithShape', '0'); + + // a:srgbClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', $shape->getShadow()->getColor()->getRGB()); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $shape->getShadow()->getAlpha() * 1000); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + /** + * Write txt + * + * @param PHPPowerPoint_Shared_XMLWriter $objWriter XML Writer + * @param PHPPowerPoint_Shape_RichText $shape + * @param int $shapeId + * @throws Exception + */ + private function _writeTxt(PHPPowerPoint_Shared_XMLWriter $objWriter = null, PHPPowerPoint_Shape_RichText $shape = null, $shapeId) + { + // p:sp + $objWriter->startElement('p:sp'); + + // p:nvSpPr + $objWriter->startElement('p:nvSpPr'); + + // p:cNvPr + $objWriter->startElement('p:cNvPr'); + $objWriter->writeAttribute('id', $shapeId); + $objWriter->writeAttribute('name', ''); + $objWriter->endElement(); + + // p:cNvSpPr + $objWriter->startElement('p:cNvSpPr'); + $objWriter->writeAttribute('txBox', '1'); + $objWriter->endElement(); + + // p:nvPr + $objWriter->writeElement('p:nvPr', null); + + $objWriter->endElement(); + + // p:spPr + $objWriter->startElement('p:spPr'); + + // a:xfrm + $objWriter->startElement('a:xfrm'); + $objWriter->writeAttribute('rot', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getRotation())); + + // a:off + $objWriter->startElement('a:off'); + $objWriter->writeAttribute('x', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetX())); + $objWriter->writeAttribute('y', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getOffsetY())); + $objWriter->endElement(); + + // a:ext + $objWriter->startElement('a:ext'); + $objWriter->writeAttribute('cx', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getWidth())); + $objWriter->writeAttribute('cy', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getHeight())); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:prstGeom + $objWriter->startElement('a:prstGeom'); + $objWriter->writeAttribute('prst', 'rect'); + $objWriter->endElement(); + + // a:noFill + $objWriter->writeElement('a:noFill', null); + + if ($shape->getShadow()->getVisible()) { + // a:effectLst + $objWriter->startElement('a:effectLst'); + + // a:outerShdw + $objWriter->startElement('a:outerShdw'); + $objWriter->writeAttribute('blurRad', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getBlurRadius())); + $objWriter->writeAttribute('dist', PHPPowerPoint_Shared_Drawing::pixelsToEMU($shape->getShadow()->getDistance())); + $objWriter->writeAttribute('dir', PHPPowerPoint_Shared_Drawing::degreesToAngle($shape->getShadow()->getDirection())); + $objWriter->writeAttribute('algn', $shape->getShadow()->getAlignment()); + $objWriter->writeAttribute('rotWithShape', '0'); + + // a:srgbClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', $shape->getShadow()->getColor()->getRGB()); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', $shape->getShadow()->getAlpha() * 1000); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + $objWriter->endElement(); + + // p:txBody + $objWriter->startElement('p:txBody'); + + // a:bodyPr + $objWriter->startElement('a:bodyPr'); + $objWriter->writeAttribute('wrap', 'square'); + $objWriter->writeAttribute('rtlCol', '0'); + + // a:spAutoFit + $objWriter->writeElement('a:spAutoFit', null); + + $objWriter->endElement(); + + // a:lstStyle + $objWriter->writeElement('a:lstStyle', null); + + // a:p + $objWriter->startElement('a:p'); + + // a:pPr + $objWriter->startElement('a:pPr'); + $objWriter->writeAttribute('algn', $shape->getAlignment()->getHorizontal()); + $objWriter->writeAttribute('fontAlgn', $shape->getAlignment()->getVertical()); + $objWriter->writeAttribute('indent', $shape->getAlignment()->getIndent()); + $objWriter->writeAttribute('lvl', $shape->getAlignment()->getLevel()); + $objWriter->endElement(); + + // Loop trough rich text elements + $elements = $shape->getRichTextElements(); + foreach ($elements as $element) { + if ($element instanceof PHPPowerPoint_Shape_RichText_Break) { + // a:br + $objWriter->writeElement('a:br', null); + } + elseif ($element instanceof PHPPowerPoint_Shape_RichText_Run + || $element instanceof PHPPowerPoint_Shape_RichText_TextElement) + { + // a:r + $objWriter->startElement('a:r'); + + // a:rPr + if ($element instanceof PHPPowerPoint_Shape_RichText_Run) { + // a:rPr + $objWriter->startElement('a:rPr'); + + // Bold + $objWriter->writeAttribute('b', ($element->getFont()->getBold() ? 'true' : 'false')); + + // Italic + $objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 'true' : 'false')); + + // Strikethrough + $objWriter->writeAttribute('strike', ($element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike')); + + // Size + $objWriter->writeAttribute('sz', ($element->getFont()->getSize() * 100)); + + // Underline + $objWriter->writeAttribute('u', $element->getFont()->getUnderline()); + + // Superscript / subscript + if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) { + if ($element->getFont()->getSuperScript()) { + $objWriter->writeAttribute('baseline', '30000'); + } else if ($element->getFont()->getSubScript()) { + $objWriter->writeAttribute('baseline', '-25000'); + } + } + + // Color - a:solidFill + $objWriter->startElement('a:solidFill'); + + // a:srgbClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', $element->getFont()->getColor()->getRGB()); + $objWriter->endElement(); + + $objWriter->endElement(); + + // Font - a:latin + $objWriter->startElement('a:latin'); + $objWriter->writeAttribute('typeface', $element->getFont()->getName()); + $objWriter->endElement(); + + $objWriter->endElement(); + } + + // t + $objWriter->startElement('a:t'); + $objWriter->writeRaw(PHPPowerPoint_Shared_String::ControlCharacterPHP2OOXML( htmlspecialchars($element->getText()) )); + $objWriter->endElement(); + + $objWriter->endElement(); + } + } + + + $objWriter->endElement(); + + $objWriter->endElement(); + + + /* + + + + + + */ + + $objWriter->endElement(); + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Theme.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Theme.php new file mode 100644 index 0000000..088934e --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/Theme.php @@ -0,0 +1,1215 @@ +getParentWriter()->getUseDiskCaching()) { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); + } + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // a:theme + $objWriter->startElement('a:theme'); + $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); + $objWriter->writeAttribute('name', 'Office Theme'); + + // a:themeElements + $objWriter->startElement('a:themeElements'); + + { + // a:clrScheme + $objWriter->startElement('a:clrScheme'); + $objWriter->writeAttribute('name', 'Office'); + + // a:dk1 + $objWriter->startElement('a:dk1'); + + // a:sysClr + $objWriter->startElement('a:sysClr'); + $objWriter->writeAttribute('val', 'windowText'); + $objWriter->writeAttribute('lastClr', '000000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:lt1 + $objWriter->startElement('a:lt1'); + + // a:sysClr + $objWriter->startElement('a:sysClr'); + $objWriter->writeAttribute('val', 'window'); + $objWriter->writeAttribute('lastClr', 'FFFFFF'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:dk2 + $objWriter->startElement('a:dk2'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '1F497D'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:lt2 + $objWriter->startElement('a:lt2'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', 'EEECE1'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:accent1 + $objWriter->startElement('a:accent1'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '4F81BD'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:accent2 + $objWriter->startElement('a:accent2'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', 'C0504D'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:accent3 + $objWriter->startElement('a:accent3'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '9BBB59'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:accent4 + $objWriter->startElement('a:accent4'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '8064A2'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:accent5 + $objWriter->startElement('a:accent5'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '4BACC6'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:accent6 + $objWriter->startElement('a:accent6'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', 'F79646'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:hlink + $objWriter->startElement('a:hlink'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '0000FF'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:folHlink + $objWriter->startElement('a:folHlink'); + + // a:sysClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '800080'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + { + // a:fontScheme + $objWriter->startElement('a:fontScheme'); + $objWriter->writeAttribute('name', 'Office'); + + // a:majorFont + $objWriter->startElement('a:majorFont'); + + // a:latin + $objWriter->startElement('a:latin'); + $objWriter->writeAttribute('typeface', 'Calibri'); + $objWriter->endElement(); + + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', ''); + $objWriter->endElement(); + + // a:cs + $objWriter->startElement('a:cs'); + $objWriter->writeAttribute('typeface', ''); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Jpan'); + $objWriter->writeAttribute('typeface', '?? ?????'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Hang'); + $objWriter->writeAttribute('typeface', '?? ??'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Hans'); + $objWriter->writeAttribute('typeface', '??'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Hant'); + $objWriter->writeAttribute('typeface', '????'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Arab'); + $objWriter->writeAttribute('typeface', 'Times New Roman'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Hebr'); + $objWriter->writeAttribute('typeface', 'Times New Roman'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Thai'); + $objWriter->writeAttribute('typeface', 'Angsana New'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Ethi'); + $objWriter->writeAttribute('typeface', 'Nyala'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Beng'); + $objWriter->writeAttribute('typeface', 'Vrinda'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Gujr'); + $objWriter->writeAttribute('typeface', 'Shruti'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Khmr'); + $objWriter->writeAttribute('typeface', 'MoolBoran'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Knda'); + $objWriter->writeAttribute('typeface', 'Tunga'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Guru'); + $objWriter->writeAttribute('typeface', 'Raavi'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Cans'); + $objWriter->writeAttribute('typeface', 'Euphemia'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Cher'); + $objWriter->writeAttribute('typeface', 'Plantagenet Cherokee'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Yiii'); + $objWriter->writeAttribute('typeface', 'Microsoft Yi Baiti'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Tibt'); + $objWriter->writeAttribute('typeface', 'Microsoft Himalaya'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Thaa'); + $objWriter->writeAttribute('typeface', 'MV Boli'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Deva'); + $objWriter->writeAttribute('typeface', 'Mangal'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Telu'); + $objWriter->writeAttribute('typeface', 'Gautami'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Taml'); + $objWriter->writeAttribute('typeface', 'Latha'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Syrc'); + $objWriter->writeAttribute('typeface', 'Estrangelo Edessa'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Orya'); + $objWriter->writeAttribute('typeface', 'Kalinga'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Mlym'); + $objWriter->writeAttribute('typeface', 'Kartika'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Laoo'); + $objWriter->writeAttribute('typeface', 'DokChampa'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Sinh'); + $objWriter->writeAttribute('typeface', 'Iskoola Pota'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Mong'); + $objWriter->writeAttribute('typeface', 'Mongolian Baiti'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Viet'); + $objWriter->writeAttribute('typeface', 'Times New Roman'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Uigh'); + $objWriter->writeAttribute('typeface', 'Microsoft Uighur'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:minorFont + $objWriter->startElement('a:minorFont'); + + // a:latin + $objWriter->startElement('a:latin'); + $objWriter->writeAttribute('typeface', 'Calibri'); + $objWriter->endElement(); + + // a:ea + $objWriter->startElement('a:ea'); + $objWriter->writeAttribute('typeface', ''); + $objWriter->endElement(); + + // a:cs + $objWriter->startElement('a:cs'); + $objWriter->writeAttribute('typeface', ''); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Jpan'); + $objWriter->writeAttribute('typeface', '?? ?????'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Hang'); + $objWriter->writeAttribute('typeface', '?? ??'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Hans'); + $objWriter->writeAttribute('typeface', '??'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Hant'); + $objWriter->writeAttribute('typeface', '????'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Arab'); + $objWriter->writeAttribute('typeface', 'Arial'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Hebr'); + $objWriter->writeAttribute('typeface', 'Arial'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Thai'); + $objWriter->writeAttribute('typeface', 'Cordia New'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Ethi'); + $objWriter->writeAttribute('typeface', 'Nyala'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Beng'); + $objWriter->writeAttribute('typeface', 'Vrinda'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Gujr'); + $objWriter->writeAttribute('typeface', 'Shruti'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Khmr'); + $objWriter->writeAttribute('typeface', 'DaunPenh'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Knda'); + $objWriter->writeAttribute('typeface', 'Tunga'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Guru'); + $objWriter->writeAttribute('typeface', 'Raavi'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Cans'); + $objWriter->writeAttribute('typeface', 'Euphemia'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Cher'); + $objWriter->writeAttribute('typeface', 'Plantagenet Cherokee'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Yiii'); + $objWriter->writeAttribute('typeface', 'Microsoft Yi Baiti'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Tibt'); + $objWriter->writeAttribute('typeface', 'Microsoft Himalaya'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Thaa'); + $objWriter->writeAttribute('typeface', 'MV Boli'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Deva'); + $objWriter->writeAttribute('typeface', 'Mangal'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Telu'); + $objWriter->writeAttribute('typeface', 'Gautami'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Taml'); + $objWriter->writeAttribute('typeface', 'Latha'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Syrc'); + $objWriter->writeAttribute('typeface', 'Estrangelo Edessa'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Orya'); + $objWriter->writeAttribute('typeface', 'Kalinga'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Mlym'); + $objWriter->writeAttribute('typeface', 'Kartika'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Laoo'); + $objWriter->writeAttribute('typeface', 'DokChampa'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Sinh'); + $objWriter->writeAttribute('typeface', 'Iskoola Pota'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Mong'); + $objWriter->writeAttribute('typeface', 'Mongolian Baiti'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Viet'); + $objWriter->writeAttribute('typeface', 'Arial'); + $objWriter->endElement(); + + // a:font + $objWriter->startElement('a:font'); + $objWriter->writeAttribute('script', 'Uigh'); + $objWriter->writeAttribute('typeface', 'Microsoft Uighur'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + { + // a:fmtScheme + $objWriter->startElement('a:fmtScheme'); + $objWriter->writeAttribute('name', 'Office'); + + // a:fillStyleLst + $objWriter->startElement('a:fillStyleLst'); + + // a:solidFill + $objWriter->startElement('a:solidFill'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gradFill + $objWriter->startElement('a:gradFill'); + $objWriter->writeAttribute('rotWithShape', '1'); + + // a:gsLst + $objWriter->startElement('a:gsLst'); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '0'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:tint + $objWriter->startElement('a:tint'); + $objWriter->writeAttribute('val', '50000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '300000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '35000'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:tint + $objWriter->startElement('a:tint'); + $objWriter->writeAttribute('val', '37000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '300000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '100000'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:tint + $objWriter->startElement('a:tint'); + $objWriter->writeAttribute('val', '15000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '350000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:lin + $objWriter->startElement('a:lin'); + $objWriter->writeAttribute('ang', '16200000'); + $objWriter->writeAttribute('scaled', '1'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gradFill + $objWriter->startElement('a:gradFill'); + $objWriter->writeAttribute('rotWithShape', '1'); + + // a:gsLst + $objWriter->startElement('a:gsLst'); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '0'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:shade + $objWriter->startElement('a:shade'); + $objWriter->writeAttribute('val', '51000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '130000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '80000'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:shade + $objWriter->startElement('a:shade'); + $objWriter->writeAttribute('val', '93000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '130000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '100000'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:shade + $objWriter->startElement('a:shade'); + $objWriter->writeAttribute('val', '94000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '135000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:lin + $objWriter->startElement('a:lin'); + $objWriter->writeAttribute('ang', '16200000'); + $objWriter->writeAttribute('scaled', '0'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:lnStyleLst + $objWriter->startElement('a:lnStyleLst'); + + // a:ln + $objWriter->startElement('a:ln'); + $objWriter->writeAttribute('w', '9525'); + $objWriter->writeAttribute('cap', 'flat'); + $objWriter->writeAttribute('cmpd', 'sng'); + $objWriter->writeAttribute('algn', 'ctr'); + + // a:solidFill + $objWriter->startElement('a:solidFill'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:shade + $objWriter->startElement('a:shade'); + $objWriter->writeAttribute('val', '95000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '105000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:prstDash + $objWriter->startElement('a:prstDash'); + $objWriter->writeAttribute('val', 'solid'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:ln + $objWriter->startElement('a:ln'); + $objWriter->writeAttribute('w', '25400'); + $objWriter->writeAttribute('cap', 'flat'); + $objWriter->writeAttribute('cmpd', 'sng'); + $objWriter->writeAttribute('algn', 'ctr'); + + // a:solidFill + $objWriter->startElement('a:solidFill'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:prstDash + $objWriter->startElement('a:prstDash'); + $objWriter->writeAttribute('val', 'solid'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:ln + $objWriter->startElement('a:ln'); + $objWriter->writeAttribute('w', '38100'); + $objWriter->writeAttribute('cap', 'flat'); + $objWriter->writeAttribute('cmpd', 'sng'); + $objWriter->writeAttribute('algn', 'ctr'); + + // a:solidFill + $objWriter->startElement('a:solidFill'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:prstDash + $objWriter->startElement('a:prstDash'); + $objWriter->writeAttribute('val', 'solid'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + + + // a:effectStyleLst + $objWriter->startElement('a:effectStyleLst'); + + // a:effectStyle + $objWriter->startElement('a:effectStyle'); + + // a:effectLst + $objWriter->startElement('a:effectLst'); + + // a:outerShdw + $objWriter->startElement('a:outerShdw'); + $objWriter->writeAttribute('blurRad', '40000'); + $objWriter->writeAttribute('dist', '20000'); + $objWriter->writeAttribute('dir', '5400000'); + $objWriter->writeAttribute('rotWithShape', '0'); + + // a:srgbClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '000000'); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', '38000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:effectStyle + $objWriter->startElement('a:effectStyle'); + + // a:effectLst + $objWriter->startElement('a:effectLst'); + + // a:outerShdw + $objWriter->startElement('a:outerShdw'); + $objWriter->writeAttribute('blurRad', '40000'); + $objWriter->writeAttribute('dist', '23000'); + $objWriter->writeAttribute('dir', '5400000'); + $objWriter->writeAttribute('rotWithShape', '0'); + + // a:srgbClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '000000'); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', '35000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:effectStyle + $objWriter->startElement('a:effectStyle'); + + // a:effectLst + $objWriter->startElement('a:effectLst'); + + // a:outerShdw + $objWriter->startElement('a:outerShdw'); + $objWriter->writeAttribute('blurRad', '40000'); + $objWriter->writeAttribute('dist', '23000'); + $objWriter->writeAttribute('dir', '5400000'); + $objWriter->writeAttribute('rotWithShape', '0'); + + // a:srgbClr + $objWriter->startElement('a:srgbClr'); + $objWriter->writeAttribute('val', '000000'); + + // a:alpha + $objWriter->startElement('a:alpha'); + $objWriter->writeAttribute('val', '35000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:scene3d + $objWriter->startElement('a:scene3d'); + + // a:camera + $objWriter->startElement('a:camera'); + $objWriter->writeAttribute('prst', 'orthographicFront'); + + // a:rot + $objWriter->startElement('a:rot'); + $objWriter->writeAttribute('lat', '0'); + $objWriter->writeAttribute('lon', '0'); + $objWriter->writeAttribute('rev', '0'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:lightRig + $objWriter->startElement('a:lightRig'); + $objWriter->writeAttribute('rig', 'threePt'); + $objWriter->writeAttribute('dir', 't'); + + // a:rot + $objWriter->startElement('a:rot'); + $objWriter->writeAttribute('lat', '0'); + $objWriter->writeAttribute('lon', '0'); + $objWriter->writeAttribute('rev', '1200000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:sp3d + $objWriter->startElement('a:sp3d'); + + // a:bevelT + $objWriter->startElement('a:bevelT'); + $objWriter->writeAttribute('w', '63500'); + $objWriter->writeAttribute('h', '25400'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:bgFillStyleLst + $objWriter->startElement('a:bgFillStyleLst'); + + // a:solidFill + $objWriter->startElement('a:solidFill'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gradFill + $objWriter->startElement('a:gradFill'); + $objWriter->writeAttribute('rotWithShape', '1'); + + // a:gsLst + $objWriter->startElement('a:gsLst'); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '0'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:tint + $objWriter->startElement('a:tint'); + $objWriter->writeAttribute('val', '40000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '350000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '40000'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:tint + $objWriter->startElement('a:tint'); + $objWriter->writeAttribute('val', '45000'); + $objWriter->endElement(); + + // a:shade + $objWriter->startElement('a:shade'); + $objWriter->writeAttribute('val', '99000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '350000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '100000'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:shade + $objWriter->startElement('a:shade'); + $objWriter->writeAttribute('val', '20000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '255000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:path + $objWriter->startElement('a:path'); + $objWriter->writeAttribute('path', 'circle'); + + // a:fillToRect + $objWriter->startElement('a:fillToRect'); + $objWriter->writeAttribute('l', '50000'); + $objWriter->writeAttribute('t', '-80000'); + $objWriter->writeAttribute('r', '50000'); + $objWriter->writeAttribute('b', '180000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gradFill + $objWriter->startElement('a:gradFill'); + $objWriter->writeAttribute('rotWithShape', '1'); + + // a:gsLst + $objWriter->startElement('a:gsLst'); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '0'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:tint + $objWriter->startElement('a:tint'); + $objWriter->writeAttribute('val', '80000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '300000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:gs + $objWriter->startElement('a:gs'); + $objWriter->writeAttribute('pos', '100000'); + + // a:schemeClr + $objWriter->startElement('a:schemeClr'); + $objWriter->writeAttribute('val', 'phClr'); + + // a:shade + $objWriter->startElement('a:shade'); + $objWriter->writeAttribute('val', '30000'); + $objWriter->endElement(); + + // a:satMod + $objWriter->startElement('a:satMod'); + $objWriter->writeAttribute('val', '200000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + // a:path + $objWriter->startElement('a:path'); + $objWriter->writeAttribute('path', 'circle'); + + // a:fillToRect + $objWriter->startElement('a:fillToRect'); + $objWriter->writeAttribute('l', '50000'); + $objWriter->writeAttribute('t', '50000'); + $objWriter->writeAttribute('r', '50000'); + $objWriter->writeAttribute('b', '50000'); + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + + $objWriter->endElement(); + } + + $objWriter->endElement(); + + // a:objectDefaults + $objWriter->writeElement('a:objectDefaults', null); + + // a:extraClrSchemeLst + $objWriter->writeElement('a:extraClrSchemeLst', null); + + $objWriter->endElement(); + + // Return + return $objWriter->getData(); + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php new file mode 100644 index 0000000..0175fe4 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php @@ -0,0 +1,72 @@ +_parentWriter = $pWriter; + } + + /** + * Get parent IWriter object + * + * @return PHPPowerPoint_Writer_IWriter + * @throws Exception + */ + public function getParentWriter() { + if (!is_null($this->_parentWriter)) { + return $this->_parentWriter; + } else { + throw new Exception("No parent PHPPowerPoint_Writer_IWriter assigned."); + } + } +} diff --git a/admin/survey/export/libs/PHPPowerPoint/Writer/Serialized.php b/admin/survey/export/libs/PHPPowerPoint/Writer/Serialized.php new file mode 100644 index 0000000..edc9596 --- /dev/null +++ b/admin/survey/export/libs/PHPPowerPoint/Writer/Serialized.php @@ -0,0 +1,187 @@ +setPHPPowerPoint($pPHPPowerPoint); + } + + /** + * Save PHPPowerPoint to file + * + * @param string $pFileName + * @throws Exception + */ + public function save($pFilename = null) + { + if (!is_null($this->_presentation)) { + // Create new ZIP file and open it for writing + $objZip = new ZipArchive(); + + // Try opening the ZIP file + if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { + if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { + throw new Exception("Could not open " . $pFilename . " for writing."); + } + } + + // Add media + $slideCount = $this->_presentation->getSlideCount(); + for ($i = 0; $i < $slideCount; ++$i) { + for ($j = 0; $j < $this->_presentation->getSlide($i)->getShapeCollection()->count(); ++$j) { + if ($this->_presentation->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPPowerPoint_Shape_BaseDrawing) { + $imgTemp = $this->_presentation->getSlide($i)->getShapeCollection()->offsetGet($j); + $objZip->addFromString('media/' . $imgTemp->getFilename(), file_get_contents($imgTemp->getPath())); + } + } + } + + // Add PHPPowerPoint.xml to the document, which represents a PHP serialized PHPPowerPoint object + $objZip->addFromString('PHPPowerPoint.xml', $this->_writeSerialized($this->_presentation, $pFilename)); + + // Close file + if ($objZip->close() === false) { + throw new Exception("Could not close zip file $pFilename."); + } + } else { + throw new Exception("PHPPowerPoint object unassigned."); + } + } + + /** + * Get PHPPowerPoint object + * + * @return PHPPowerPoint + * @throws Exception + */ + public function getPHPPowerPoint() { + if (!is_null($this->_presentation)) { + return $this->_presentation; + } else { + throw new Exception("No PHPPowerPoint assigned."); + } + } + + /** + * Get PHPPowerPoint object + * + * @param PHPPowerPoint $pPHPPowerPoint PHPPowerPoint object + * @throws Exception + */ + public function setPHPPowerPoint(PHPPowerPoint $pPHPPowerPoint = null) { + $this->_presentation = $pPHPPowerPoint; + } + + /** + * Serialize PHPPowerPoint object to XML + * + * @param PHPPowerPoint $pPHPPowerPoint + * @param string $pFilename + * @return string XML Output + * @throws Exception + */ + private function _writeSerialized(PHPPowerPoint $pPHPPowerPoint = null, $pFilename = '') + { + // Clone $pPHPPowerPoint + $pPHPPowerPoint = clone $pPHPPowerPoint; + + // Update media links + $slideCount = $pPHPPowerPoint->getSlideCount(); + for ($i = 0; $i < $slideCount; ++$i) { + for ($j = 0; $j < $pPHPPowerPoint->getSlide($i)->getShapeCollection()->count(); ++$j) { + if ($pPHPPowerPoint->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof PHPPowerPoint_Shape_BaseDrawing) { + $imgTemp =& $pPHPPowerPoint->getSlide($i)->getShapeCollection()->offsetGet($j); + $imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false); + } + } + } + + // Create XML writer + $objWriter = new xmlWriter(); + $objWriter->openMemory(); + $objWriter->setIndent(true); + + // XML header + $objWriter->startDocument('1.0','UTF-8','yes'); + + // PHPPowerPoint + $objWriter->startElement('PHPPowerPoint'); + $objWriter->writeAttribute('version', '0.1.0'); + + // Comment + $objWriter->writeComment('This file has been generated using PHPPowerPoint v0.1.0 (http://www.codeplex.com/PHPPowerPoint). It contains a base64 encoded serialized version of the PHPPowerPoint internal object.'); + + // Data + $objWriter->startElement('data'); + $objWriter->writeCData( base64_encode(serialize($pPHPPowerPoint)) ); + $objWriter->endElement(); + + $objWriter->endElement(); + + // Return + return $objWriter->outputMemory(true); + } +} -- cgit v1.2.3