diff --git a/Classes/PhpWord.php b/Classes/PhpWord.php deleted file mode 100644 index c2986a70..00000000 --- a/Classes/PhpWord.php +++ /dev/null @@ -1,234 +0,0 @@ -_documentProperties = new DocumentProperties(); - $this->_defaultFontName = self::DEFAULT_FONT_NAME; - $this->_defaultFontSize = self::DEFAULT_FONT_SIZE; - } - - /** - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function getDocumentProperties() - { - return $this->_documentProperties; - } - - /** - * @param PhpOffice\PhpWord\DocumentProperties $documentProperties - * @return PhpOffice\PhpWord - */ - public function setDocumentProperties(DocumentProperties $documentProperties) - { - $this->_documentProperties = $documentProperties; - - return $this; - } - - /** - * @param PhpOffice\PhpWord\Section\Settings $settings - * @return PhpOffice\PhpWord\Section - */ - public function createSection($settings = null) - { - $section = new Section(\count($this->_sections) + 1, $settings); - $this->_sections[] = $section; - - return $section; - } - - /** - * @return string - */ - public function getDefaultFontName() - { - return $this->_defaultFontName; - } - - /** - * @param string $fontName - */ - public function setDefaultFontName($fontName) - { - $this->_defaultFontName = $fontName; - } - - /** - * @return string - */ - public function getDefaultFontSize() - { - return $this->_defaultFontSize; - } - - /** - * @param int $fontSize - */ - public function setDefaultFontSize($fontSize) - { - $this->_defaultFontSize = $fontSize; - } - - /** - * Set default paragraph style definition to styles.xml - * - * @param array $styles Paragraph style definition - */ - public function setDefaultParagraphStyle($styles) - { - Style::setDefaultParagraphStyle($styles); - } - - /** - * Adds a paragraph style definition to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addParagraphStyle($styleName, $styles) - { - Style::addParagraphStyle($styleName, $styles); - } - - /** - * Adds a font style definition to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addFontStyle($styleName, $styleFont, $styleParagraph = null) - { - Style::addFontStyle($styleName, $styleFont, $styleParagraph); - } - - /** - * Adds a table style definition to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) - { - Style::addTableStyle($styleName, $styleTable, $styleFirstRow); - } - - /** - * Adds a heading style definition to styles.xml - * - * @param $titleCount int - * @param $styles array - */ - public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) - { - Style::addTitleStyle($titleCount, $styleFont, $styleParagraph); - } - - /** - * Adds a hyperlink style to styles.xml - * - * @param $styleName string - * @param $styles array - */ - public function addLinkStyle($styleName, $styles) - { - Style::addLinkStyle($styleName, $styles); - } - - /** - * @return PhpOffice\PhpWord\Section[] - */ - public function getSections() - { - return $this->_sections; - } - - /** - * @param string $filename Fully qualified filename. - * @return PhpOffice\PhpWord\Template - * @throws PhpOffice\PhpWord\Exceptions\Exception - */ - public function loadTemplate($filename) - { - if (\file_exists($filename)) { - return new Template($filename); - } else { - throw new Exception("Template file {$filename} not found."); - } - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Autoloader.php b/Classes/PhpWord/Autoloader.php deleted file mode 100644 index 1a4aa3b3..00000000 --- a/Classes/PhpWord/Autoloader.php +++ /dev/null @@ -1,85 +0,0 @@ -_creator = ''; - $this->_lastModifiedBy = $this->_creator; - $this->_created = time(); - $this->_modified = time(); - $this->_title = ''; - $this->_subject = ''; - $this->_description = ''; - $this->_keywords = ''; - $this->_category = ''; - $this->_company = ''; - $this->_manager = ''; - } - - /** - * Get Creator - * - * @return string - */ - public function getCreator() - { - return $this->_creator; - } - - /** - * Set Creator - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCreator($pValue = '') - { - $this->_creator = $pValue; - return $this; - } - - /** - * Get Last Modified By - * - * @return string - */ - public function getLastModifiedBy() - { - return $this->_lastModifiedBy; - } - - /** - * Set Last Modified By - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setLastModifiedBy($pValue = '') - { - $this->_lastModifiedBy = $pValue; - return $this; - } - - /** - * Get Created - * - * @return datetime - */ - public function getCreated() - { - return $this->_created; - } - - /** - * Set Created - * - * @param datetime $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCreated($pValue = null) - { - if (is_null($pValue)) { - $pValue = time(); - } - $this->_created = $pValue; - return $this; - } - - /** - * Get Modified - * - * @return datetime - */ - public function getModified() - { - return $this->_modified; - } - - /** - * Set Modified - * - * @param datetime $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setModified($pValue = null) - { - if (is_null($pValue)) { - $pValue = time(); - } - $this->_modified = $pValue; - return $this; - } - - /** - * Get Title - * - * @return string - */ - public function getTitle() - { - return $this->_title; - } - - /** - * Set Title - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setTitle($pValue = '') - { - $this->_title = $pValue; - return $this; - } - - /** - * Get Description - * - * @return string - */ - public function getDescription() - { - return $this->_description; - } - - /** - * Set Description - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setDescription($pValue = '') - { - $this->_description = $pValue; - return $this; - } - - /** - * Get Subject - * - * @return string - */ - public function getSubject() - { - return $this->_subject; - } - - /** - * Set Subject - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setSubject($pValue = '') - { - $this->_subject = $pValue; - return $this; - } - - /** - * Get Keywords - * - * @return string - */ - public function getKeywords() - { - return $this->_keywords; - } - - /** - * Set Keywords - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setKeywords($pValue = '') - { - $this->_keywords = $pValue; - return $this; - } - - /** - * Get Category - * - * @return string - */ - public function getCategory() - { - return $this->_category; - } - - /** - * Set Category - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCategory($pValue = '') - { - $this->_category = $pValue; - return $this; - } - - /** - * Get Company - * - * @return string - */ - public function getCompany() - { - return $this->_company; - } - - /** - * Set Company - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCompany($pValue = '') - { - $this->_company = $pValue; - return $this; - } - - /** - * Get Manager - * - * @return string - */ - public function getManager() - { - return $this->_manager; - } - - /** - * Set Manager - * - * @param string $pValue - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setManager($pValue = '') - { - $this->_manager = $pValue; - return $this; - } - - /** - * Get a List of Custom Property Names - * - * @return array of string - */ - public function getCustomProperties() - { - return array_keys($this->_customProperties); - } - - /** - * Check if a Custom Property is defined - * - * @param string $propertyName - * @return boolean - */ - public function isCustomPropertySet($propertyName) - { - return isset($this->_customProperties[$propertyName]); - } - - /** - * Get a Custom Property Value - * - * @param string $propertyName - * @return string - */ - public function getCustomPropertyValue($propertyName) - { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['value']; - } - - } - - /** - * Get a Custom Property Type - * - * @param string $propertyName - * @return string - */ - public function getCustomPropertyType($propertyName) - { - if (isset($this->_customProperties[$propertyName])) { - return $this->_customProperties[$propertyName]['type']; - } - - } - - /** - * Set a Custom Property - * - * @param string $propertyName - * @param mixed $propertyValue - * @param string $propertyType - * 'i': Integer - * 'f': Floating Point - * 's': String - * 'd': Date/Time - * 'b': Boolean - * @return PhpOffice\PhpWord\DocumentProperties - */ - public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) - { - if (($propertyType === null) || (!in_array($propertyType, array( - self::PROPERTY_TYPE_INTEGER, - self::PROPERTY_TYPE_FLOAT, - self::PROPERTY_TYPE_STRING, - self::PROPERTY_TYPE_DATE, - self::PROPERTY_TYPE_BOOLEAN - )))) { - if ($propertyValue === null) { - $propertyType = self::PROPERTY_TYPE_STRING; - } elseif (is_float($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_FLOAT; - } elseif (is_int($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_INTEGER; - } elseif (is_bool($propertyValue)) { - $propertyType = self::PROPERTY_TYPE_BOOLEAN; - } else { - $propertyType = self::PROPERTY_TYPE_STRING; - } - } - - $this->_customProperties[$propertyName] = array( - 'value' => $propertyValue, - 'type' => $propertyType - ); - return $this; - } - - /** - * Convert document propery based on type - * - * @param mixed $propertyValue - * @param string $propertyType - * @return mixed - */ - public static function convertProperty($propertyValue, $propertyType) - { - switch ($propertyType) { - case 'empty': // Empty - return ''; - break; - case 'null': // Null - return null; - break; - case 'i1': // 1-Byte Signed Integer - case 'i2': // 2-Byte Signed Integer - case 'i4': // 4-Byte Signed Integer - case 'i8': // 8-Byte Signed Integer - case 'int': // Integer - return (int) $propertyValue; - break; - case 'ui1': // 1-Byte Unsigned Integer - case 'ui2': // 2-Byte Unsigned Integer - case 'ui4': // 4-Byte Unsigned Integer - case 'ui8': // 8-Byte Unsigned Integer - case 'uint': // Unsigned Integer - return abs((int) $propertyValue); - break; - case 'r4': // 4-Byte Real Number - case 'r8': // 8-Byte Real Number - case 'decimal': // Decimal - return (float) $propertyValue; - break; - case 'lpstr': // LPSTR - case 'lpwstr': // LPWSTR - case 'bstr': // Basic String - return $propertyValue; - break; - case 'date': // Date and Time - case 'filetime': // File Time - return strtotime($propertyValue); - break; - case 'bool': // Boolean - return ($propertyValue == 'true') ? true : false; - break; - case 'cy': // Currency - case 'error': // Error Status Code - case 'vector': // Vector - case 'array': // Array - case 'blob': // Binary Blob - case 'oblob': // Binary Blob Object - case 'stream': // Binary Stream - case 'ostream': // Binary Stream Object - case 'storage': // Binary Storage - case 'ostorage': // Binary Storage Object - case 'vstream': // Binary Versioned Stream - case 'clsid': // Class ID - case 'cf': // Clipboard Data - return $propertyValue; - break; - } - - return $propertyValue; - } - - /** - * Convert document property type - * - * @param string $propertyType - * @return mixed - */ - public static function convertPropertyType($propertyType) - { - switch ($propertyType) { - case 'i1': // 1-Byte Signed Integer - case 'i2': // 2-Byte Signed Integer - case 'i4': // 4-Byte Signed Integer - case 'i8': // 8-Byte Signed Integer - case 'int': // Integer - case 'ui1': // 1-Byte Unsigned Integer - case 'ui2': // 2-Byte Unsigned Integer - case 'ui4': // 4-Byte Unsigned Integer - case 'ui8': // 8-Byte Unsigned Integer - case 'uint': // Unsigned Integer - return self::PROPERTY_TYPE_INTEGER; - break; - case 'r4': // 4-Byte Real Number - case 'r8': // 8-Byte Real Number - case 'decimal': // Decimal - return self::PROPERTY_TYPE_FLOAT; - break; - case 'empty': // Empty - case 'null': // Null - case 'lpstr': // LPSTR - case 'lpwstr': // LPWSTR - case 'bstr': // Basic String - return self::PROPERTY_TYPE_STRING; - break; - case 'date': // Date and Time - case 'filetime': // File Time - return self::PROPERTY_TYPE_DATE; - break; - case 'bool': // Boolean - return self::PROPERTY_TYPE_BOOLEAN; - break; - case 'cy': // Currency - case 'error': // Error Status Code - case 'vector': // Vector - case 'array': // Array - case 'blob': // Binary Blob - case 'oblob': // Binary Blob Object - case 'stream': // Binary Stream - case 'ostream': // Binary Stream Object - case 'storage': // Binary Storage - case 'ostorage': // Binary Storage Object - case 'vstream': // Binary Versioned Stream - case 'clsid': // Class ID - case 'cf': // Clipboard Data - return self::PROPERTY_TYPE_UNKNOWN; - break; - } - return self::PROPERTY_TYPE_UNKNOWN; - } -} diff --git a/Classes/PhpWord/Exceptions/Exception.php b/Classes/PhpWord/Exceptions/Exception.php deleted file mode 100755 index 72f5cfed..00000000 --- a/Classes/PhpWord/Exceptions/Exception.php +++ /dev/null @@ -1,6 +0,0 @@ -addFromSource($pSource); - } - } - - /** - * Add HashTable items from source - * - * @param PhpOffice\PhpWord\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; - } elseif (!is_array($pSource)) { - throw new Exception('Invalid array parameter passed.'); - } - - foreach ($pSource as $item) { - $this->add($item); - } - } - - /** - * Add HashTable item - * - * @param PhpOffice\PhpWord\IComparable $pSource Item to add - * @throws Exception - */ - public function add(IComparable $pSource = null) - { - // Determine hashcode - $hashCode = null; - $hashIndex = $pSource->getHashIndex(); - if (is_null($hashIndex)) { - $hashCode = $pSource->getHashCode(); - } elseif (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 PhpOffice\PhpWord\IComparable $pSource Item to remove - * @throws Exception - */ - public function remove(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(); - } - - /** - * @return int - */ - public function count() - { - return count($this->_items); - } - - /** - * @param string $pHashCode - * @return int Index - */ - public function getIndexForHashCode($pHashCode = '') - { - return array_search($pHashCode, $this->_keyMap); - } - - /** - * @param int $pIndex - * @return PhpOffice\PhpWord\IComparable - */ - public function getByIndex($pIndex = 0) - { - if (isset($this->_keyMap[$pIndex])) { - return $this->getByHashCode($this->_keyMap[$pIndex]); - } - - return null; - } - - /** - * @param string $pHashCode - * @return PhpOffice\PhpWord\IComparable - * - */ - public function getByHashCode($pHashCode = '') - { - if (isset($this->_items[$pHashCode])) { - return $this->_items[$pHashCode]; - } - - return null; - } - - /** - * @return PhpOffice\PhpWord\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; - } - } - } -} \ No newline at end of file diff --git a/Classes/PhpWord/IOFactory.php b/Classes/PhpWord/IOFactory.php deleted file mode 100644 index c62804b6..00000000 --- a/Classes/PhpWord/IOFactory.php +++ /dev/null @@ -1,80 +0,0 @@ -load($filename); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Media.php b/Classes/PhpWord/Media.php deleted file mode 100644 index 2656b3fd..00000000 --- a/Classes/PhpWord/Media.php +++ /dev/null @@ -1,347 +0,0 @@ - array(), - 'embeddings' => array(), - 'links' => array() - ); - - /** - * Header Media Elements - * - * @var array - */ - private static $_headerMedia = array(); - - /** - * Footer Media Elements - * - * @var array - */ - private static $_footerMedia = array(); - - /** - * ObjectID Counter - * - * @var int - */ - private static $_objectId = 1325353440; - - /** - * Add new Section Media Element - * - * @param string $src - * @param string $type - * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage - * @return mixed - */ - public static function addSectionMediaElement($src, $type, MemoryImage $memoryImage = null) - { - $mediaId = md5($src); - $key = ($type === 'image') ? 'images' : 'embeddings'; - - if (!array_key_exists($mediaId, self::$_sectionMedia[$key])) { - $cImg = self::countSectionMediaElements('images'); - $cObj = self::countSectionMediaElements('embeddings'); - $rID = self::countSectionMediaElements() + 7; - - $media = array(); - - $folder = null; - $file = null; - if ($type === 'image') { - $cImg++; - //Detect if it's a memory image first by php ext and second by regex - $isMemImage = false; - if (stripos(strrev($src), strrev('.php')) === 0) { - $isMemImage = true; - } - if (!$isMemImage) { - $isMemImage = (filter_var($src, FILTER_VALIDATE_URL) !== false); - } - $extension = ''; - if ($isMemImage) { - $extension = $memoryImage->getImageExtension(); - $media['isMemImage'] = true; - $media['createfunction'] = $memoryImage->getImageCreateFunction(); - $media['imagefunction'] = $memoryImage->getImageFunction(); - } else { - $imageType = exif_imagetype($src); - if ($imageType === IMAGETYPE_JPEG) { - $extension = 'jpg'; - } elseif ($imageType === IMAGETYPE_GIF) { - $extension = 'gif'; - } elseif ($imageType === IMAGETYPE_PNG) { - $extension = 'png'; - } elseif ($imageType === IMAGETYPE_BMP) { - $extension = 'bmp'; - } elseif ($imageType === IMAGETYPE_TIFF_II || $imageType === IMAGETYPE_TIFF_MM) { - $extension = 'tif'; - } - } - - $folder = 'media'; - $file = $type . $cImg . '.' . strtolower($extension); - } elseif ($type === 'oleObject') { - $cObj++; - $folder = 'embedding'; - $file = $type . $cObj . '.bin'; - } - - $media['source'] = $src; - $media['target'] = "$folder/section_$file"; - $media['type'] = $type; - $media['rID'] = $rID; - - self::$_sectionMedia[$key][$mediaId] = $media; - - if ($type === 'oleObject') { - return array($rID, ++self::$_objectId); - } - - return $rID; - } - - if ($type === 'oleObject') { - $rID = self::$_sectionMedia[$key][$mediaId]['rID']; - return array($rID, ++self::$_objectId); - } - return self::$_sectionMedia[$key][$mediaId]['rID']; - } - - /** - * Add new Section Link Element - * - * @param string $linkSrc - * @return mixed - */ - public static function addSectionLinkElement($linkSrc) - { - $rID = self::countSectionMediaElements() + 7; - - $link = array(); - $link['target'] = $linkSrc; - $link['rID'] = $rID; - $link['type'] = 'hyperlink'; - - self::$_sectionMedia['links'][] = $link; - - return $rID; - } - - /** - * Get Section Media Elements - * - * @param string $key - * @return array - */ - public static function getSectionMediaElements($key = null) - { - if (!is_null($key)) { - return self::$_sectionMedia[$key]; - } - - $arrImages = self::$_sectionMedia['images']; - $arrObjects = self::$_sectionMedia['embeddings']; - $arrLinks = self::$_sectionMedia['links']; - return array_merge($arrImages, $arrObjects, $arrLinks); - } - - /** - * Get Section Media Elements Count - * - * @param string $key - * @return int - */ - public static function countSectionMediaElements($key = null) - { - if (!is_null($key)) { - return count(self::$_sectionMedia[$key]); - } - - $cImages = count(self::$_sectionMedia['images']); - $cObjects = count(self::$_sectionMedia['embeddings']); - $cLinks = count(self::$_sectionMedia['links']); - return ($cImages + $cObjects + $cLinks); - } - - /** - * Add new Header Media Element - * - * @param int $headerCount - * @param string $src - * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage - * @return int - */ - public static function addHeaderMediaElement($headerCount, $src, MemoryImage $memoryImage = null) - { - $mediaId = md5($src); - $key = 'header' . $headerCount; - - if (!array_key_exists($key, self::$_headerMedia)) { - self::$_headerMedia[$key] = array(); - } - - if (!array_key_exists($mediaId, self::$_headerMedia[$key])) { - $cImg = self::countHeaderMediaElements($key); - $rID = $cImg + 1; - - $cImg++; - $inf = pathinfo($src); - $isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false; - - $media = array(); - if ($isMemImage) { - $ext = $memoryImage->getImageExtension(); - $media['isMemImage'] = true; - $media['createfunction'] = $memoryImage->getImageCreateFunction(); - $media['imagefunction'] = $memoryImage->getImageFunction(); - } else { - $ext = $inf['extension']; - if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg - $ext = 'jpg'; - } - } - $file = 'image' . $cImg . '.' . strtolower($ext); - - $media['source'] = $src; - $media['target'] = 'media/' . $key . '_' . $file; - $media['type'] = 'image'; - $media['rID'] = $rID; - - self::$_headerMedia[$key][$mediaId] = $media; - - return $rID; - } - return self::$_headerMedia[$key][$mediaId]['rID']; - } - - /** - * Get Header Media Elements Count - * - * @param string $key - * @return int - */ - public static function countHeaderMediaElements($key) - { - return count(self::$_headerMedia[$key]); - } - - /** - * Get Header Media Elements - * - * @return int - */ - public static function getHeaderMediaElements() - { - return self::$_headerMedia; - } - - /** - * Add new Footer Media Element - * - * @param int $footerCount - * @param string $src - * @param PhpOffice\PhpWord\Section\MemoryImage|null $memoryImage - * @return int - */ - public static function addFooterMediaElement($footerCount, $src, MemoryImage $memoryImage = null) - { - $mediaId = md5($src); - $key = 'footer' . $footerCount; - - if (!array_key_exists($key, self::$_footerMedia)) { - self::$_footerMedia[$key] = array(); - } - - if (!array_key_exists($mediaId, self::$_footerMedia[$key])) { - $cImg = self::countFooterMediaElements($key); - $rID = $cImg + 1; - - $cImg++; - $inf = pathinfo($src); - $isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false; - - $media = array(); - if ($isMemImage) { - $ext = $memoryImage->getImageExtension(); - $media['isMemImage'] = true; - $media['createfunction'] = $memoryImage->getImageCreateFunction(); - $media['imagefunction'] = $memoryImage->getImageFunction(); - } else { - $ext = $inf['extension']; - if ($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg - $ext = 'jpg'; - } - } - $file = 'image' . $cImg . '.' . strtolower($ext); - - $media['source'] = $src; - $media['target'] = 'media/' . $key . '_' . $file; - $media['type'] = 'image'; - $media['rID'] = $rID; - - self::$_footerMedia[$key][$mediaId] = $media; - - return $rID; - } - return self::$_footerMedia[$key][$mediaId]['rID']; - } - - /** - * Get Footer Media Elements Count - * - * @param string $key - * @return int - */ - public static function countFooterMediaElements($key) - { - return count(self::$_footerMedia[$key]); - } - - /** - * Get Footer Media Elements - * - * @return int - */ - public static function getFooterMediaElements() - { - return self::$_footerMedia; - } -} diff --git a/Classes/PhpWord/Reader/AbstractReader.php b/Classes/PhpWord/Reader/AbstractReader.php deleted file mode 100644 index f92980cb..00000000 --- a/Classes/PhpWord/Reader/AbstractReader.php +++ /dev/null @@ -1,110 +0,0 @@ -readDataOnly; - return true; - } - - /** - * Set read data only - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Reader\IReader - */ - public function setReadDataOnly($pValue = true) - { - $this->readDataOnly = $pValue; - return $this; - } - - /** - * Open file for reading - * - * @param string $pFilename - * @return resource - * @throws Exception - */ - protected function openFile($pFilename) - { - // Check if file exists - if (!file_exists($pFilename) || !is_readable($pFilename)) { - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); - } - - // Open file - $this->fileHandle = fopen($pFilename, 'r'); - if ($this->fileHandle === false) { - throw new Exception("Could not open file " . $pFilename . " for reading."); - } - } - - /** - * Can the current IReader read the file? - * - * @param string $pFilename - * @return bool - */ - public function canRead($pFilename) - { - // Check if file exists - try { - $this->openFile($pFilename); - } catch (Exception $e) { - return false; - } - fclose($this->fileHandle); - return true; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Reader/IReader.php b/Classes/PhpWord/Reader/IReader.php deleted file mode 100644 index 94db13e5..00000000 --- a/Classes/PhpWord/Reader/IReader.php +++ /dev/null @@ -1,46 +0,0 @@ -open($pFilename) === true) { - // check if it is an OOXML archive - $rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels")); - if ($rels !== false) { - foreach ($rels->Relationship as $rel) { - switch ($rel["Type"]) { - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": - if (basename($rel["Target"]) == 'document.xml') { - $return = true; - } - break; - - } - } - } - $zip->close(); - } - - return $return; - } - - /** - * @param ZipArchive $archive - * @param string $fileName - * @param bool $removeNamespace - * @return mixed - */ - public function getFromZipArchive($archive, $fileName = '', $removeNamespace = false) - { - // Root-relative paths - if (strpos($fileName, '//') !== false) { - $fileName = substr($fileName, strpos($fileName, '//') + 1); - } - $fileName = File::realpath($fileName); - - // Apache POI fixes - $contents = $archive->getFromName($fileName); - if ($contents === false) { - $contents = $archive->getFromName(substr($fileName, 1)); - } - - // Remove namespaces from elements and attributes name - if ($removeNamespace) { - $contents = preg_replace('~(canRead($pFilename)) { - return null; - } - - // Initialisations - $word = new PhpWord(); - $zip = new ZipArchive(); - $zip->open($pFilename); - - // Read properties and documents - $rels = simplexml_load_string($this->getFromZipArchive($zip, "_rels/.rels")); - foreach ($rels->Relationship as $rel) { - switch ($rel["Type"]) { - // Core properties - case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties": - $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); - if (is_object($xmlCore)) { - $xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/"); - $xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/"); - $xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"); - $docProps = $word->getDocumentProperties(); - $docProps->setCreator((string)self::arrayItem($xmlCore->xpath("dc:creator"))); - $docProps->setLastModifiedBy((string)self::arrayItem($xmlCore->xpath("cp:lastModifiedBy"))); - $docProps->setCreated(strtotime(self::arrayItem($xmlCore->xpath("dcterms:created")))); - $docProps->setModified(strtotime(self::arrayItem($xmlCore->xpath("dcterms:modified")))); - $docProps->setTitle((string)self::arrayItem($xmlCore->xpath("dc:title"))); - $docProps->setDescription((string)self::arrayItem($xmlCore->xpath("dc:description"))); - $docProps->setSubject((string)self::arrayItem($xmlCore->xpath("dc:subject"))); - $docProps->setKeywords((string)self::arrayItem($xmlCore->xpath("cp:keywords"))); - $docProps->setCategory((string)self::arrayItem($xmlCore->xpath("cp:category"))); - } - break; - // Extended properties - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties": - $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); - if (is_object($xmlCore)) { - $docProps = $word->getDocumentProperties(); - if (isset($xmlCore->Company)) { - $docProps->setCompany((string)$xmlCore->Company); - } - if (isset($xmlCore->Manager)) { - $docProps->setManager((string)$xmlCore->Manager); - } - } - break; - // Custom properties - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": - $xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}")); - if (is_object($xmlCore)) { - $docProps = $word->getDocumentProperties(); - foreach ($xmlCore as $xmlProperty) { - $cellDataOfficeAttributes = $xmlProperty->attributes(); - if (isset($cellDataOfficeAttributes['name'])) { - $propertyName = (string)$cellDataOfficeAttributes['name']; - $cellDataOfficeChildren = $xmlProperty->children("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"); - $attributeType = $cellDataOfficeChildren->getName(); - $attributeValue = (string)$cellDataOfficeChildren->{$attributeType}; - $attributeValue = DocumentProperties::convertProperty($attributeValue, $attributeType); - $attributeType = DocumentProperties::convertPropertyType($attributeType); - $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType); - } - } - } - break; - // Document - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": - $dir = dirname($rel["Target"]); - $archive = "$dir/_rels/" . basename($rel["Target"]) . ".rels"; - $relsDoc = simplexml_load_string($this->getFromZipArchive($zip, $archive)); - $relsDoc->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); - $xpath = self::arrayItem( - $relsDoc->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']") - ); - $xmlDoc = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}", true)); - if (is_object($xmlDoc)) { - $section = $word->createSection(); - - foreach ($xmlDoc->body->children() as $elm) { - $elmName = $elm->getName(); - if ($elmName == 'p') { // Paragraph/section - // Create new section if section setting found - if ($elm->pPr->sectPr) { - $section->setSettings($this->loadSectionSettings($elm->pPr)); - $section = $word->createSection(); - continue; - } - // Has w:r? It's either text or textrun - if ($elm->r) { - // w:r = 1? It's a plain paragraph - if (count($elm->r) == 1) { - $section->addText( - $elm->r->t, - $this->loadFontStyle($elm->r) - ); - // w:r more than 1? It's a textrun - } else { - $textRun = $section->createTextRun(); - foreach ($elm->r as $r) { - $textRun->addText( - $r->t, - $this->loadFontStyle($r) - ); - } - } - // No, it's a textbreak - } else { - $section->addTextBreak(); - } - } elseif ($elmName == 'sectPr') { - // Last section setting - $section->setSettings($this->loadSectionSettings($xmlDoc->body)); - } - } - } - break; - } - } - - // Read styles - $docRels = simplexml_load_string($this->getFromZipArchive($zip, "word/_rels/document.xml.rels")); - foreach ($docRels->Relationship as $rel) { - switch ($rel["Type"]) { - case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles": - $xmlStyle = simplexml_load_string($this->getFromZipArchive($zip, "word/{$rel['Target']}", true)); - if (is_object($xmlStyle)) { - foreach ($xmlStyle->children() as $elm) { - if ($elm->getName() != 'style') { - continue; - } - $pStyle = null; - $fStyle = null; - $hasParagraphStyle = isset($elm->pPr); - $hasFontStyle = isset($elm->rPr); - $styleName = (string)$elm->name['val']; - if ($hasParagraphStyle) { - $pStyle = $this->loadParagraphStyle($elm); - if (!$hasFontStyle) { - $word->addParagraphStyle($styleName, $pStyle); - } - } - if ($hasFontStyle) { - $fStyle = $this->loadFontStyle($elm); - $word->addFontStyle($styleName, $fStyle, $pStyle); - } - } - } - break; - } - } - $zip->close(); - - return $word; - } - - /** - * Load section settings from SimpleXMLElement - * - * @param SimpleXMLElement $elm - * @return array|string|null - * - * @todo Implement gutter - */ - private function loadSectionSettings($elm) - { - if ($xml = $elm->sectPr) { - $setting = array(); - if ($xml->type) { - $setting['breakType'] = (string)$xml->type['val']; - } - if ($xml->pgSz) { - if (isset($xml->pgSz['w'])) { - $setting['pageSizeW'] = (int)$xml->pgSz['w']; - } - if (isset($xml->pgSz['h'])) { - $setting['pageSizeH'] = (int)$xml->pgSz['h']; - } - if (isset($xml->pgSz['orient'])) { - $setting['orientation'] = (string)$xml->pgSz['orient']; - } - } - if ($xml->pgMar) { - if (isset($xml->pgMar['top'])) { - $setting['topMargin'] = (int)$xml->pgMar['top']; - } - if (isset($xml->pgMar['left'])) { - $setting['leftMargin'] = (int)$xml->pgMar['left']; - } - if (isset($xml->pgMar['bottom'])) { - $setting['bottomMargin'] = (int)$xml->pgMar['bottom']; - } - if (isset($xml->pgMar['right'])) { - $setting['rightMargin'] = (int)$xml->pgMar['right']; - } - if (isset($xml->pgMar['header'])) { - $setting['headerHeight'] = (int)$xml->pgMar['header']; - } - if (isset($xml->pgMar['footer'])) { - $setting['footerHeight'] = (int)$xml->pgMar['footer']; - } - if (isset($xml->pgMar['gutter'])) { - // $setting['gutter'] = (int)$xml->pgMar['gutter']; - } - } - if ($xml->cols) { - if (isset($xml->cols['num'])) { - $setting['colsNum'] = (int)$xml->cols['num']; - } - if (isset($xml->cols['space'])) { - $setting['colsSpace'] = (int)$xml->cols['space']; - } - } - return $setting; - } - return null; - } - - /** - * Load paragraph style from SimpleXMLElement - * - * @param SimpleXMLElement $elm - * @return array|string|null - */ - private function loadParagraphStyle($elm) - { - if ($xml = $elm->pPr) { - if ($xml->pStyle) { - return (string)$xml->pStyle['val']; - } - $style = array(); - if ($xml->jc) { - $style['align'] = (string)$xml->jc['val']; - } - if ($xml->ind) { - if (isset($xml->ind->left)) { - $style['indent'] = (int)$xml->ind->left; - } - if (isset($xml->ind->hanging)) { - $style['hanging'] = (int)$xml->ind->hanging; - } - if (isset($xml->ind->line)) { - $style['spacing'] = (int)$xml->ind->line; - } - } - if ($xml->spacing) { - if (isset($xml->spacing['after'])) { - $style['spaceAfter'] = (int)$xml->spacing['after']; - } - if (isset($xml->spacing['before'])) { - $style['spaceBefore'] = (int)$xml->spacing['before']; - } - if (isset($xml->spacing['line'])) { - $style['spacing'] = (int)$xml->spacing['line']; - } - } - if ($xml->basedOn) { - $style['basedOn'] = (string)$xml->basedOn['val']; - } - if ($xml->next) { - $style['next'] = (string)$xml->next['val']; - } - if ($xml->widowControl) { - $style['widowControl'] = false; - } - if ($xml->keepNext) { - $style['keepNext'] = true; - } - if ($xml->keepLines) { - $style['keepLines'] = true; - } - if ($xml->pageBreakBefore) { - $style['pageBreakBefore'] = true; - } - return $style; - } - return null; - } - - /** - * Load font style from SimpleXMLElement - * - * @param SimpleXMLElement $elm - * @return array|string|null - */ - private function loadFontStyle($elm) - { - if ($xml = $elm->rPr) { - if ($xml->rStyle) { - return (string)$xml->rStyle['val']; - } - $style = array(); - if ($xml->rFonts) { - $style['name'] = (string)$xml->rFonts['ascii']; - } - if ($xml->sz) { - $style['size'] = (int)$xml->sz['val'] / 2; - } - if ($xml->color) { - $style['color'] = (string)$xml->color['val']; - } - if ($xml->b) { - $style['bold'] = true; - } - if ($xml->i) { - $style['italic'] = true; - } - if ($xml->u) { - $style['underline'] = (string)$xml->u['val']; - } - if ($xml->strike) { - $style['strikethrough'] = true; - } - if ($xml->highlight) { - $style['fgColor'] = (string)$xml->highlight['val']; - } - if ($xml->vertAlign) { - if ($xml->vertAlign['val'] == 'superscript') { - $style['superScript'] = true; - } else { - $style['subScript'] = true; - } - } - return $style; - } - return null; - } - - /** - * @param array $array - * @param mixed $key - * @return mixed|null - */ - private static function arrayItem($array, $key = 0) - { - return (isset($array[$key]) ? $array[$key] : null); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Section.php b/Classes/PhpWord/Section.php deleted file mode 100644 index 0b12f9ef..00000000 --- a/Classes/PhpWord/Section.php +++ /dev/null @@ -1,453 +0,0 @@ -_sectionCount = $sectionCount; - $this->_settings = new Settings(); - $this->setSettings($settings); - } - - /** - * Set Section Settings - * - * @param array $settings - */ - public function setSettings($settings = null) - { - if (!is_null($settings) && is_array($settings)) { - foreach ($settings as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_settings->setSettingValue($key, $value); - } - } - } - - /** - * Get Section Settings - * - * @return PhpOffice\PhpWord\Section\Settings - */ - public function getSettings() - { - return $this->_settings; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Link - */ - public function addLink($linkSrc, $linkName = null, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($linkSrc)) { - $linkSrc = utf8_encode($linkSrc); - } - if (!is_null($linkName)) { - if (!String::IsUTF8($linkName)) { - $linkName = utf8_encode($linkName); - } - } - - $link = new Link($linkSrc, $linkName, $styleFont, $styleParagraph); - $rID = Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Add a TextBreak Element - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Add a PageBreak Element - */ - public function addPageBreak() - { - $this->_elementCollection[] = new PageBreak(); - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table - */ - public function addTable($style = null) - { - $table = new Table('section', $this->_sectionCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a ListItem Element - * - * @param string $text - * @param int $depth - * @param mixed $styleFont - * @param mixed $styleList - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\ListItem - */ - public function addListItem($text, $depth = 0, $styleFont = null, $styleList = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $listItem = new ListItem($text, $depth, $styleFont, $styleList, $styleParagraph); - $this->_elementCollection[] = $listItem; - return $listItem; - } - - /** - * Add a OLE-Object Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Object - * @throws Exception - */ - public function addObject($src, $style = null) - { - $object = new Object($src, $style); - - if (!is_null($object->getSource())) { - $inf = pathinfo($src); - $ext = $inf['extension']; - if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { - $ext = substr($ext, 0, -1); - } - - $iconSrc = PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/'; - if (!file_exists($iconSrc . '_' . $ext . '.png')) { - $iconSrc = $iconSrc . '_default.png'; - } else { - $iconSrc .= '_' . $ext . '.png'; - } - - $rIDimg = Media::addSectionMediaElement($iconSrc, 'image'); - $data = Media::addSectionMediaElement($src, 'oleObject'); - $rID = $data[0]; - $objectId = $data[1]; - - $object->setRelationId($rID); - $object->setObjectId($objectId); - $object->setImageRelationId($rIDimg); - - $this->_elementCollection[] = $object; - return $object; - } - throw new Exception('Source does not exist or unsupported object type.'); - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image - * @throws Exception - */ - public function addImage($src, $style = null) - { - $image = new Image($src, $style); - - if (!is_null($image->getSource())) { - $rID = Media::addSectionMediaElement($src, 'image'); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } - throw new Exception('Source does not exist or unsupported image type.'); - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage - * @throws Exception - */ - public function addMemoryImage($link, $style = null) - { - $memoryImage = new MemoryImage($link, $style); - if (!is_null($memoryImage->getSource())) { - $rID = Media::addSectionMediaElement($link, 'image', $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } - throw new Exception('Unsupported image type.'); - } - - /** - * Add a Table-of-Contents Element - * - * @param mixed $styleFont - * @param mixed $styleTOC - * @return PhpOffice\PhpWord\TOC - */ - public function addTOC($styleFont = null, $styleTOC = null) - { - $toc = new TOC($styleFont, $styleTOC); - $this->_elementCollection[] = $toc; - return $toc; - } - - /** - * Add a Title Element - * - * @param string $text - * @param int $depth - * @return PhpOffice\PhpWord\Section\Title - */ - public function addTitle($text, $depth = 1) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $styles = Style::getStyles(); - if (array_key_exists('Heading_' . $depth, $styles)) { - $style = 'Heading' . $depth; - } else { - $style = null; - } - - $title = new Title($text, $depth, $style); - - $data = TOC::addTitle($text, $depth); - $anchor = $data[0]; - $bookmarkId = $data[1]; - - $title->setAnchor($anchor); - $title->setBookmarkId($bookmarkId); - - $this->_elementCollection[] = $title; - return $title; - } - - /** - * Create a new TextRun - * - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\TextRun - */ - public function createTextRun($styleParagraph = null) - { - $textRun = new TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Get all Elements - * - * @return array - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Create a new Header - * - * @return PhpOffice\PhpWord\Section\Header - */ - public function createHeader() - { - $header = new Header($this->_sectionCount); - $this->_headers[] = $header; - return $header; - } - - /** - * Get Headers - * - * @return array - */ - public function getHeaders() - { - return $this->_headers; - } - - /** - * Is there a header for this section that is for the first page only? - * - * If any of the Header instances have a type of Header::FIRST then this method returns true. - * False otherwise. - * - * @return Boolean - */ - public function hasDifferentFirstPage() - { - $value = array_filter($this->_headers, function (Header &$header) { - return $header->getType() == Header::FIRST; - }); - return count($value) > 0; - } - - /** - * Create a new Footer - * - * @return PhpOffice\PhpWord\Section\Footer - */ - public function createFooter() - { - $footer = new Footer($this->_sectionCount); - $this->_footer = $footer; - return $footer; - } - - /** - * Get Footer - * - * @return PhpOffice\PhpWord\Section\Footer - */ - public function getFooter() - { - return $this->_footer; - } - - /** - * Create a new Footnote Element - * - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footnote - */ - public function createFootnote($styleParagraph = null) - { - $footnote = new Footnote($styleParagraph); - $refID = Footnote::addFootnoteElement($footnote); - $footnote->setReferenceId($refID); - $this->_elementCollection[] = $footnote; - return $footnote; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Section/Footer.php b/Classes/PhpWord/Section/Footer.php deleted file mode 100644 index 8c88bd84..00000000 --- a/Classes/PhpWord/Section/Footer.php +++ /dev/null @@ -1,217 +0,0 @@ -_footerCount = $sectionCount; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add TextBreak - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Create a new TextRun - * - * @return PhpOffice\PhpWord\Section\TextRun - */ - public function createTextRun($styleParagraph = null) - { - $textRun = new TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table - */ - public function addTable($style = null) - { - $table = new Table('footer', $this->_footerCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return Image - */ - public function addImage($src, $style = null) - { - $image = new Image($src, $style); - - if (!is_null($image->getSource())) { - $rID = Media::addFooterMediaElement($this->_footerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Src does not exist or invalid image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage - */ - public function addMemoryImage($link, $style = null) - { - $memoryImage = new MemoryImage($link, $style); - if (!is_null($memoryImage->getSource())) { - $rID = Media::addFooterMediaElement($this->_footerCount, $link, $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - throw new Exception('Unsupported image type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footer\PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $ptext = new PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } - - /** - * Get Footer Relation ID - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Footer Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get all Footer Elements - * @return array - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Footer Count - */ - public function getFooterCount() - { - return $this->_footerCount; - } -} diff --git a/Classes/PhpWord/Section/Footer/PreserveText.php b/Classes/PhpWord/Section/Footer/PreserveText.php deleted file mode 100644 index fa9f8a86..00000000 --- a/Classes/PhpWord/Section/Footer/PreserveText.php +++ /dev/null @@ -1,130 +0,0 @@ -_styleFont = new Font('text'); - - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleFont->setStyleValue($key, $value); - } - } else { - $this->_styleFont = $styleFont; - } - - // Set paragraph style - if (is_array($styleParagraph)) { - $this->_styleParagraph = new Paragraph(); - - foreach ($styleParagraph as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - - $matches = preg_split('/({.*?})/', $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - if (isset($matches[0])) { - $this->_text = $matches[0]; - } - - return $this; - } - - /** - * Get Text style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public function getFontStyle() - { - return $this->_styleFont; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_styleParagraph; - } - - /** - * Get Text content - * - * @return string - */ - public function getText() - { - return $this->_text; - } -} diff --git a/Classes/PhpWord/Section/Footnote.php b/Classes/PhpWord/Section/Footnote.php deleted file mode 100644 index e5b6e6d8..00000000 --- a/Classes/PhpWord/Section/Footnote.php +++ /dev/null @@ -1,151 +0,0 @@ -_elementCollection = array(); - - // Set paragraph style - if (is_array($styleParagraph)) { - $this->_styleParagraph = new Paragraph(); - - foreach ($styleParagraph as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - } - - - /** - * Add a Text Element - * - * @var string $text - * @var mixed $styleFont - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text = null, $styleFont = null) - { - $givenText = $text; - $text = new Text($givenText, $styleFont); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $styleFont - * @return PhpOffice\PhpWord\Section\Link - */ - public function addLink($linkSrc, $linkName = null, $styleFont = null) - { - - $link = new Link($linkSrc, $linkName, $styleFont); - $rID = PhpOffice\PhpWord\Footnote::addFootnoteLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Get Footnote content - * - * @return array - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_styleParagraph; - } - - /** - * Get Footnote Reference ID - * - * @return int - */ - public function getReferenceId() - { - return $this->_refId; - } - - /** - * Set Footnote Reference ID - * - * @param int $refId - */ - public function setReferenceId($refId) - { - $this->_refId = $refId; - } -} diff --git a/Classes/PhpWord/Section/Header.php b/Classes/PhpWord/Section/Header.php deleted file mode 100644 index 6067945b..00000000 --- a/Classes/PhpWord/Section/Header.php +++ /dev/null @@ -1,299 +0,0 @@ -_headerCount = $sectionCount; - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add TextBreak - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Create a new TextRun - * - * @return PhpOffice\PhpWord\Section\TextRun - */ - public function createTextRun($styleParagraph = null) - { - $textRun = new TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Add a Table Element - * - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table - */ - public function addTable($style = null) - { - $table = new Table('header', $this->_headerCount, $style); - $this->_elementCollection[] = $table; - return $table; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image - */ - public function addImage($src, $style = null) - { - $image = new Image($src, $style); - - if (!is_null($image->getSource())) { - $rID = Media::addHeaderMediaElement($this->_headerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Src does not exist or invalid image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage - */ - public function addMemoryImage($link, $style = null) - { - $memoryImage = new MemoryImage($link, $style); - if (!is_null($memoryImage->getSource())) { - $rID = Media::addHeaderMediaElement($this->_headerCount, $link, $memoryImage); - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - throw new Exception('Unsupported image type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footer\PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $ptext = new PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } - - /** - * Add a Watermark Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image - */ - public function addWatermark($src, $style = null) - { - $image = new Image($src, $style, true); - - if (!is_null($image->getSource())) { - $rID = Media::addHeaderMediaElement($this->_headerCount, $src); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Src does not exist or invalid image type.'); - } - } - - /** - * Get Header Relation ID - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Header Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get all Header Elements - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Header Count - */ - public function getHeaderCount() - { - return $this->_headerCount; - } - - /** - * Get Header Type - */ - public function getType() - { - return $this->_type; - } - - /** - * Reset back to default - */ - public function resetType() - { - return $this->_type = self::AUTO; - } - - /** - * First page only header - */ - public function firstPage() - { - return $this->_type = self::FIRST; - } - - /** - * Even numbered Pages only - */ - public function evenPage() - { - return $this->_type = self::EVEN; - } -} diff --git a/Classes/PhpWord/Section/Image.php b/Classes/PhpWord/Section/Image.php deleted file mode 100644 index 8762e8ca..00000000 --- a/Classes/PhpWord/Section/Image.php +++ /dev/null @@ -1,177 +0,0 @@ -_src = $src; - $this->_isWatermark = $isWatermark; - $this->_style = new PhpOffice\PhpWord\Style\Image(); - - if (!is_null($style) && is_array($style)) { - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - - if (isset($style['wrappingStyle'])) { - $this->_style->setWrappingStyle($style['wrappingStyle']); - } - - if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { - $imgData = getimagesize($this->_src); - $this->_style->setWidth($imgData[0]); - $this->_style->setHeight($imgData[1]); - } - } - - /** - * Get Image style - * - * @return PhpOffice\PhpWord\Style\Image - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get Image Relation ID - * - * @return int - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Image Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get Image Source - * - * @return string - */ - public function getSource() - { - return $this->_src; - } - - /** - * Get Image Media ID - * - * @return string - */ - public function getMediaId() - { - return md5($this->_src); - } - - /** - * Get IsWatermark - * - * @return int - */ - public function getIsWatermark() - { - return $this->_isWatermark; - } - - /** - * Set IsWatermark - * - * @param bool $pValue - */ - public function setIsWatermark($pValue) - { - $this->_isWatermark = $pValue; - } -} diff --git a/Classes/PhpWord/Section/Link.php b/Classes/PhpWord/Section/Link.php deleted file mode 100644 index 5c3cc9fe..00000000 --- a/Classes/PhpWord/Section/Link.php +++ /dev/null @@ -1,174 +0,0 @@ -_linkSrc = $linkSrc; - $this->_linkName = $linkName; - - // Set font style - if (is_array($styleFont)) { - $this->_styleFont = new Font('text'); - - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleFont->setStyleValue($key, $value); - } - } else { - $this->_styleFont = $styleFont; - } - - // Set paragraph style - if (is_array($styleParagraph)) { - $this->_styleParagraph = new Paragraph(); - - foreach ($styleParagraph as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - - return $this; - } - - /** - * Get Link Relation ID - * - * @return int - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Link Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get Link source - * - * @return string - */ - public function getLinkSrc() - { - return $this->_linkSrc; - } - - /** - * Get Link name - * - * @return string - */ - public function getLinkName() - { - return $this->_linkName; - } - - /** - * Get Text style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public function getFontStyle() - { - return $this->_styleFont; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_styleParagraph; - } -} diff --git a/Classes/PhpWord/Section/ListItem.php b/Classes/PhpWord/Section/ListItem.php deleted file mode 100644 index 2aaf4c34..00000000 --- a/Classes/PhpWord/Section/ListItem.php +++ /dev/null @@ -1,101 +0,0 @@ -_style = new PhpOffice\PhpWord\Style\ListItem(); - $this->_textObject = new Text($text, $styleFont, $styleParagraph); - $this->_depth = $depth; - - if (!is_null($styleList) && is_array($styleList)) { - foreach ($styleList as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - } - - /** - * Get ListItem style - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get ListItem TextRun - */ - public function getTextObject() - { - return $this->_textObject; - } - - /** - * Get ListItem depth - */ - public function getDepth() - { - return $this->_depth; - } -} diff --git a/Classes/PhpWord/Section/MemoryImage.php b/Classes/PhpWord/Section/MemoryImage.php deleted file mode 100644 index 4d81ee87..00000000 --- a/Classes/PhpWord/Section/MemoryImage.php +++ /dev/null @@ -1,233 +0,0 @@ -_imageType = $imgData['mime']; - - $_supportedImageTypes = array('image/jpeg', 'image/gif', 'image/png'); - - if (in_array($this->_imageType, $_supportedImageTypes)) { - $this->_src = $src; - $this->_style = new Image(); - - if (!is_null($style) && is_array($style)) { - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - - if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { - $this->_style->setWidth($imgData[0]); - $this->_style->setHeight($imgData[1]); - } - - $this->_setFunctions(); - } - } - - /** - * Set Functions - */ - private function _setFunctions() - { - switch ($this->_imageType) { - case 'image/png': - $this->_imageCreateFunc = 'imagecreatefrompng'; - $this->_imageFunc = 'imagepng'; - $this->_imageExtension = 'png'; - break; - case 'image/gif': - $this->_imageCreateFunc = 'imagecreatefromgif'; - $this->_imageFunc = 'imagegif'; - $this->_imageExtension = 'gif'; - break; - case 'image/jpeg': - case 'image/jpg': - $this->_imageCreateFunc = 'imagecreatefromjpeg'; - $this->_imageFunc = 'imagejpeg'; - $this->_imageExtension = 'jpg'; - break; - } - } - - /** - * Get Image style - * - * @return PhpOffice\PhpWord\Style\Image - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get Image Relation ID - * - * @return int - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Image Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get Image Source - * - * @return string - */ - public function getSource() - { - return $this->_src; - } - - /** - * Get Image Media ID - * - * @return string - */ - public function getMediaId() - { - return md5($this->_src); - } - - /** - * Get Image Type - * - * @return string - */ - public function getImageType() - { - return $this->_imageType; - } - - /** - * Get Image Create Function - * - * @return string - */ - public function getImageCreateFunction() - { - return $this->_imageCreateFunc; - } - - /** - * Get Image Function - * - * @return string - */ - public function getImageFunction() - { - return $this->_imageFunc; - } - - /** - * Get Image Extension - * - * @return string - */ - public function getImageExtension() - { - return $this->_imageExtension; - } -} diff --git a/Classes/PhpWord/Section/Object.php b/Classes/PhpWord/Section/Object.php deleted file mode 100644 index 2569478a..00000000 --- a/Classes/PhpWord/Section/Object.php +++ /dev/null @@ -1,179 +0,0 @@ -_src = $src; - $this->_style = new Image(); - - if (!is_null($style) && is_array($style)) { - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - - return $this; - } else { - return false; - } - } - - /** - * Get Image style - * - * @return PhpOffice\PhpWord\Style\Image - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get Source - * - * @return string - */ - public function getSource() - { - return $this->_src; - } - - /** - * Get Object Relation ID - * - * @return int - */ - public function getRelationId() - { - return $this->_rId; - } - - /** - * Set Object Relation ID - * - * @param int $rId - */ - public function setRelationId($rId) - { - $this->_rId = $rId; - } - - /** - * Get Image Relation ID - * - * @return int - */ - public function getImageRelationId() - { - return $this->_rIdImg; - } - - /** - * Set Image Relation ID - * - * @param int $rId - */ - public function setImageRelationId($rId) - { - $this->_rIdImg = $rId; - } - - /** - * Get Object ID - * - * @return int - */ - public function getObjectId() - { - return $this->_objId; - } - - /** - * Set Object ID - * - * @param int $objId - */ - public function setObjectId($objId) - { - $this->_objId = $objId; - } -} diff --git a/Classes/PhpWord/Section/PageBreak.php b/Classes/PhpWord/Section/PageBreak.php deleted file mode 100644 index ebf7f31f..00000000 --- a/Classes/PhpWord/Section/PageBreak.php +++ /dev/null @@ -1,38 +0,0 @@ -_orientation = null; - $this->_marginTop = 1418; - $this->_marginLeft = 1418; - $this->_marginRight = 1418; - $this->_marginBottom = 1134; - $this->_pageSizeW = $this->_defaultPageSizeW; - $this->_pageSizeH = $this->_defaultPageSizeH; - $this->_borderTopSize = null; - $this->_borderTopColor = null; - $this->_borderLeftSize = null; - $this->_borderLeftColor = null; - $this->_borderRightSize = null; - $this->_borderRightColor = null; - $this->_borderBottomSize = null; - $this->_borderBottomColor = null; - $this->headerHeight = 720; // set default header and footer to 720 twips (.5 inches) - $this->footerHeight = 720; - $this->_colsNum = 1; - $this->_colsSpace = 720; - $this->_breakType = null; - } - - /** - * Set Setting Value - * - * @param string $key - * @param string $value - */ - public function setSettingValue($key, $value) - { - if ($key == '_orientation' && $value == 'landscape') { - $this->setLandscape(); - } elseif ($key == '_orientation' && is_null($value)) { - $this->setPortrait(); - } elseif ($key == '_borderSize') { - $this->setBorderSize($value); - } elseif ($key == '_borderColor') { - $this->setBorderColor($value); - } else { - $this->$key = $value; - } - } - - /** - * Get Margin Top - * - * @return int - */ - public function getMarginTop() - { - return $this->_marginTop; - } - - /** - * Set Margin Top - * - * @param int $pValue - */ - public function setMarginTop($pValue = '') - { - $this->_marginTop = $pValue; - return $this; - } - - /** - * Get Margin Left - * - * @return int - */ - public function getMarginLeft() - { - return $this->_marginLeft; - } - - /** - * Set Margin Left - * - * @param int $pValue - */ - public function setMarginLeft($pValue = '') - { - $this->_marginLeft = $pValue; - return $this; - } - - /** - * Get Margin Right - * - * @return int - */ - public function getMarginRight() - { - return $this->_marginRight; - } - - /** - * Set Margin Right - * - * @param int $pValue - */ - public function setMarginRight($pValue = '') - { - $this->_marginRight = $pValue; - return $this; - } - - /** - * Get Margin Bottom - * - * @return int - */ - public function getMarginBottom() - { - return $this->_marginBottom; - } - - /** - * Set Margin Bottom - * - * @param int $pValue - */ - public function setMarginBottom($pValue = '') - { - $this->_marginBottom = $pValue; - return $this; - } - - /** - * Set Landscape Orientation - */ - public function setLandscape() - { - $this->_orientation = 'landscape'; - $this->_pageSizeW = $this->_defaultPageSizeH; - $this->_pageSizeH = $this->_defaultPageSizeW; - } - - /** - * Set Portrait Orientation - */ - public function setPortrait() - { - $this->_orientation = null; - $this->_pageSizeW = $this->_defaultPageSizeW; - $this->_pageSizeH = $this->_defaultPageSizeH; - } - - /** - * Get Page Size Width - * - * @return int - */ - public function getPageSizeW() - { - return $this->_pageSizeW; - } - - /** - * Get Page Size Height - * - * @return int - */ - public function getPageSizeH() - { - return $this->_pageSizeH; - } - - /** - * Get Page Orientation - * - * @return string - */ - public function getOrientation() - { - return $this->_orientation; - } - - /** - * Set Border Size - * - * @param int $pValue - */ - public function setBorderSize($pValue = null) - { - $this->_borderTopSize = $pValue; - $this->_borderLeftSize = $pValue; - $this->_borderRightSize = $pValue; - $this->_borderBottomSize = $pValue; - } - - /** - * Get Border Size - * - * @return array - */ - public function getBorderSize() - { - $t = $this->getBorderTopSize(); - $l = $this->getBorderLeftSize(); - $r = $this->getBorderRightSize(); - $b = $this->getBorderBottomSize(); - - return array($t, $l, $r, $b); - } - - /** - * Set Border Color - * - * @param string $pValue - */ - public function setBorderColor($pValue = null) - { - $this->_borderTopColor = $pValue; - $this->_borderLeftColor = $pValue; - $this->_borderRightColor = $pValue; - $this->_borderBottomColor = $pValue; - } - - /** - * Get Border Color - * - * @return array - */ - public function getBorderColor() - { - $t = $this->getBorderTopColor(); - $l = $this->getBorderLeftColor(); - $r = $this->getBorderRightColor(); - $b = $this->getBorderBottomColor(); - - return array($t, $l, $r, $b); - } - - /** - * Set Border Top Size - * - * @param int $pValue - */ - public function setBorderTopSize($pValue = null) - { - $this->_borderTopSize = $pValue; - } - - /** - * Get Border Top Size - * - * @return int - */ - public function getBorderTopSize() - { - return $this->_borderTopSize; - } - - /** - * Set Border Top Color - * - * @param string $pValue - */ - public function setBorderTopColor($pValue = null) - { - $this->_borderTopColor = $pValue; - } - - /** - * Get Border Top Color - * - * @return string - */ - public function getBorderTopColor() - { - return $this->_borderTopColor; - } - - /** - * Set Border Left Size - * - * @param int $pValue - */ - public function setBorderLeftSize($pValue = null) - { - $this->_borderLeftSize = $pValue; - } - - /** - * Get Border Left Size - * - * @return int - */ - public function getBorderLeftSize() - { - return $this->_borderLeftSize; - } - - /** - * Set Border Left Color - * - * @param string $pValue - */ - public function setBorderLeftColor($pValue = null) - { - $this->_borderLeftColor = $pValue; - } - - /** - * Get Border Left Color - * - * @return string - */ - public function getBorderLeftColor() - { - return $this->_borderLeftColor; - } - - /** - * Set Border Right Size - * - * @param int $pValue - */ - public function setBorderRightSize($pValue = null) - { - $this->_borderRightSize = $pValue; - } - - /** - * Get Border Right Size - * - * @return int - */ - public function getBorderRightSize() - { - return $this->_borderRightSize; - } - - /** - * Set Border Right Color - * - * @param string $pValue - */ - public function setBorderRightColor($pValue = null) - { - $this->_borderRightColor = $pValue; - } - - /** - * Get Border Right Color - * - * @return string - */ - public function getBorderRightColor() - { - return $this->_borderRightColor; - } - - /** - * Set Border Bottom Size - * - * @param int $pValue - */ - public function setBorderBottomSize($pValue = null) - { - $this->_borderBottomSize = $pValue; - } - - /** - * Get Border Bottom Size - * - * @return int - */ - public function getBorderBottomSize() - { - return $this->_borderBottomSize; - } - - /** - * Set Border Bottom Color - * - * @param string $pValue - */ - public function setBorderBottomColor($pValue = null) - { - $this->_borderBottomColor = $pValue; - } - - /** - * Get Border Bottom Color - * - * @return string - */ - public function getBorderBottomColor() - { - return $this->_borderBottomColor; - } - - /** - * @param null|int $pageNumberingStart - * @return $this - */ - public function setPageNumberingStart($pageNumberingStart = null) - { - $this->pageNumberingStart = $pageNumberingStart; - return $this; - } - - /** - * @return null|int - */ - public function getPageNumberingStart() - { - return $this->pageNumberingStart; - } - - /** - * Get Header Height - * - * @return int - */ - public function getHeaderHeight() - { - return $this->headerHeight; - } - - /** - * Set Header Height - * - * @param int $pValue - */ - public function setHeaderHeight($pValue = '') - { - if (!is_numeric($pValue)) { - $pValue = 720; - } - $this->headerHeight = $pValue; - return $this; - } - - /** - * Get Footer Height - * - * @return int - */ - public function getFooterHeight() - { - return $this->footerHeight; - } - - /** - * Set Footer Height - * - * @param int $pValue - */ - public function setFooterHeight($pValue = '') - { - if (!is_numeric($pValue)) { - $pValue = 720; - } - $this->footerHeight = $pValue; - return $this; - } - - /** - * Set Section Columns Count - * - * @param int $pValue - */ - public function setColsNum($pValue = '') - { - if (!is_numeric($pValue)) { - $pValue = 1; - } - $this->_colsNum = $pValue; - return $this; - } - - /** - * Get Section Columns Count - * - * @return int - */ - public function getColsNum() - { - return $this->_colsNum; - } - - /** - * Set Section Space Between Columns - * - * @param int $pValue - */ - public function setColsSpace($pValue = '') - { - if (!is_numeric($pValue)) { - $pValue = 720; - } - $this->_colsSpace = $pValue; - return $this; - } - - /** - * Get Section Space Between Columns - * - * @return int - */ - public function getColsSpace() - { - return $this->_colsSpace; - } - - /** - * Set Break Type - * - * @param string $pValue - */ - public function setBreakType($pValue = null) - { - $this->_breakType = $pValue; - return $this; - } - - /** - * Get Break Type - * - * @return string - */ - public function getBreakType() - { - return $this->_breakType; - } -} diff --git a/Classes/PhpWord/Section/Table.php b/Classes/PhpWord/Section/Table.php deleted file mode 100644 index a06b41ac..00000000 --- a/Classes/PhpWord/Section/Table.php +++ /dev/null @@ -1,163 +0,0 @@ -_insideOf = $insideOf; - $this->_pCount = $pCount; - - if (!is_null($style)) { - if (is_array($style)) { - $this->_style = new PhpOffice\PhpWord\Style\Table(); - - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } else { - $this->_style = $style; - } - } - } - - /** - * Add a row - * - * @param int $height - */ - public function addRow($height = null, $style = null) - { - $row = new Row($this->_insideOf, $this->_pCount, $height, $style); - $this->_rows[] = $row; - return $row; - } - - /** - * Add a cell - * - * @param int $width - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table\Cell - */ - public function addCell($width = null, $style = null) - { - $i = count($this->_rows) - 1; - $cell = $this->_rows[$i]->addCell($width, $style); - return $cell; - } - - /** - * Get all rows - * - * @return array - */ - public function getRows() - { - return $this->_rows; - } - - /** - * Get table style - * - * @return PhpOffice\PhpWord\Style\Table - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Set table width - * - * @var int $width - */ - public function setWidth($width) - { - $this->_width = $width; - } - - /** - * Get table width - * - * @return int - */ - public function getWidth() - { - return $this->_width; - } -} diff --git a/Classes/PhpWord/Section/Table/Cell.php b/Classes/PhpWord/Section/Table/Cell.php deleted file mode 100644 index b0f646b4..00000000 --- a/Classes/PhpWord/Section/Table/Cell.php +++ /dev/null @@ -1,350 +0,0 @@ -_insideOf = $insideOf; - $this->_pCount = $pCount; - $this->_width = $width; - $this->_style = new PhpOffice\PhpWord\Style\Cell(); - - if (!is_null($style)) { - if (is_array($style)) { - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } else { - $this->_style = $style; - } - } - } - - /** - * Add a Text Element - * - * @param string $text - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text, $styleFont = null, $styleParagraph = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Link - */ - public function addLink($linkSrc, $linkName = null, $style = null) - { - if ($this->_insideOf == 'section') { - if (!String::IsUTF8($linkSrc)) { - $linkSrc = utf8_encode($linkSrc); - } - if (!is_null($linkName)) { - if (!String::IsUTF8($linkName)) { - $linkName = utf8_encode($linkName); - } - } - - $link = new Link($linkSrc, $linkName, $style); - $rID = Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } else { - throw new Exception('Unsupported Link header / footer reference'); - return false; - } - } - - /** - * Add TextBreak - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Add a ListItem Element - * - * @param string $text - * @param int $depth - * @param mixed $styleText - * @param mixed $styleList - * @return PhpOffice\PhpWord\Section\ListItem - */ - public function addListItem($text, $depth = 0, $styleText = null, $styleList = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $listItem = new ListItem($text, $depth, $styleText, $styleList); - $this->_elementCollection[] = $listItem; - return $listItem; - } - - /** - * Add a Image Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Image - */ - public function addImage($src, $style = null) - { - $image = new Image($src, $style); - - if (!is_null($image->getSource())) { - if ($this->_insideOf == 'section') { - $rID = Media::addSectionMediaElement($src, 'image'); - } elseif ($this->_insideOf == 'header') { - $rID = Media::addHeaderMediaElement($this->_pCount, $src); - } elseif ($this->_insideOf == 'footer') { - $rID = Media::addFooterMediaElement($this->_pCount, $src); - } - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Source does not exist or unsupported image type.'); - } - } - - /** - * Add a by PHP created Image Element - * - * @param string $link - * @param mixed $style - * @return PhpOffice\PhpWord\Section\MemoryImage - */ - public function addMemoryImage($link, $style = null) - { - $memoryImage = new MemoryImage($link, $style); - if (!is_null($memoryImage->getSource())) { - if ($this->_insideOf == 'section') { - $rID = Media::addSectionMediaElement($link, 'image', $memoryImage); - } elseif ($this->_insideOf == 'header') { - $rID = Media::addHeaderMediaElement($this->_pCount, $link, $memoryImage); - } elseif ($this->_insideOf == 'footer') { - $rID = Media::addFooterMediaElement($this->_pCount, $link, $memoryImage); - } - $memoryImage->setRelationId($rID); - - $this->_elementCollection[] = $memoryImage; - return $memoryImage; - } else { - throw new Exception('Unsupported image type.'); - } - } - - /** - * Add a OLE-Object Element - * - * @param string $src - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Object - */ - public function addObject($src, $style = null) - { - $object = new Object($src, $style); - - if (!is_null($object->getSource())) { - $inf = pathinfo($src); - $ext = $inf['extension']; - if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { - $ext = substr($ext, 0, -1); - } - - $iconSrc = PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/'; - if (!file_exists($iconSrc . '_' . $ext . '.png')) { - $iconSrc = $iconSrc . '_default.png'; - } else { - $iconSrc .= '_' . $ext . '.png'; - } - - $rIDimg = Media::addSectionMediaElement($iconSrc, 'image'); - $data = Media::addSectionMediaElement($src, 'oleObject'); - $rID = $data[0]; - $objectId = $data[1]; - - $object->setRelationId($rID); - $object->setObjectId($objectId); - $object->setImageRelationId($rIDimg); - - $this->_elementCollection[] = $object; - return $object; - } else { - throw new Exception('Source does not exist or unsupported object type.'); - } - } - - /** - * Add a PreserveText Element - * - * @param string $text - * @param mixed $styleFont - * @param mixed $styleParagraph - * @return PhpOffice\PhpWord\Section\Footer\PreserveText - */ - public function addPreserveText($text, $styleFont = null, $styleParagraph = null) - { - if ($this->_insideOf == 'footer' || $this->_insideOf == 'header') { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $ptext = new PreserveText($text, $styleFont, $styleParagraph); - $this->_elementCollection[] = $ptext; - return $ptext; - } else { - throw new Exception('addPreserveText only supported in footer/header.'); - } - } - - /** - * Create a new TextRun - * - * @return PhpOffice\PhpWord\Section\TextRun - */ - public function createTextRun($styleParagraph = null) - { - $textRun = new TextRun($styleParagraph); - $this->_elementCollection[] = $textRun; - return $textRun; - } - - /** - * Get all Elements - * - * @return array - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Cell Style - * - * @return PhpOffice\PhpWord\Style\Cell - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get Cell width - * - * @return int - */ - public function getWidth() - { - return $this->_width; - } -} diff --git a/Classes/PhpWord/Section/Table/Row.php b/Classes/PhpWord/Section/Table/Row.php deleted file mode 100644 index de9822b3..00000000 --- a/Classes/PhpWord/Section/Table/Row.php +++ /dev/null @@ -1,139 +0,0 @@ -_insideOf = $insideOf; - $this->_pCount = $pCount; - $this->_height = $height; - $this->_style = new PhpOffice\PhpWord\Style\Row(); - - if (!is_null($style)) { - if (is_array($style)) { - - foreach ($style as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_style->setStyleValue($key, $value); - } - } - } - } - - /** - * Add a cell - * - * @param int $width - * @param mixed $style - * @return PhpOffice\PhpWord\Section\Table\Cell - */ - public function addCell($width = null, $style = null) - { - $cell = new Cell($this->_insideOf, $this->_pCount, $width, $style); - $this->_cells[] = $cell; - return $cell; - } - - /** - * Get all cells - * - * @return array - */ - public function getCells() - { - return $this->_cells; - } - - /** - * Get row style - * - * @return PhpOffice\PhpWord\Style\Row - */ - public function getStyle() - { - return $this->_style; - } - - /** - * Get row height - * - * @return int - */ - public function getHeight() - { - return $this->_height; - } -} diff --git a/Classes/PhpWord/Section/Text.php b/Classes/PhpWord/Section/Text.php deleted file mode 100644 index 3e51bc86..00000000 --- a/Classes/PhpWord/Section/Text.php +++ /dev/null @@ -1,154 +0,0 @@ -setText($text); - $paragraphStyle = $this->setParagraphStyle($paragraphStyle); - $this->setFontStyle($fontStyle, $paragraphStyle); - } - - /** - * Set Text style - * - * @param null|array|PhpOffice\PhpWord\Style\Font $style - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - * @return PhpOffice\PhpWord\Style\Font - */ - public function setFontStyle($style = null, $paragraphStyle = null) - { - if ($style instanceof Font) { - $this->fontStyle = $style; - $this->setParagraphStyle($paragraphStyle); - } elseif (is_array($style)) { - $this->fontStyle = new Font('text', $paragraphStyle); - $this->fontStyle->setArrayStyle($style); - } elseif (null === $style) { - $this->fontStyle = new Font('text', $paragraphStyle); - } else { - $this->fontStyle = $style; - $this->setParagraphStyle($paragraphStyle); - } - return $this->fontStyle; - } - - /** - * Get Text style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public function getFontStyle() - { - return $this->fontStyle; - } - - /** - * Set Paragraph style - * - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style - * @return null|PhpOffice\PhpWord\Style\Paragraph - */ - public function setParagraphStyle($style = null) - { - if (is_array($style)) { - $this->paragraphStyle = new Paragraph; - $this->paragraphStyle->setArrayStyle($style); - } elseif ($style instanceof Paragraph) { - $this->paragraphStyle = $style; - } elseif (null === $style) { - $this->paragraphStyle = new Paragraph; - } else { - $this->paragraphStyle = $style; - } - return $this->paragraphStyle; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->paragraphStyle; - } - - /** - * @param string $text - * @return $this - */ - public function setText($text) - { - $this->text = $text; - return $this; - } - - /** - * Get Text content - * - * @return string - */ - public function getText() - { - return $this->text; - } -} diff --git a/Classes/PhpWord/Section/TextBreak.php b/Classes/PhpWord/Section/TextBreak.php deleted file mode 100644 index cd296c74..00000000 --- a/Classes/PhpWord/Section/TextBreak.php +++ /dev/null @@ -1,122 +0,0 @@ -setParagraphStyle($paragraphStyle); - } - if (!is_null($fontStyle)) { - $this->setFontStyle($fontStyle, $paragraphStyle); - } - } - - /** - * Set Text style - * - * @param null|array|PhpOffice\PhpWord\Style\Font $style - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - * @return PhpOffice\PhpWord\Style\Font - */ - public function setFontStyle($style = null, $paragraphStyle = null) - { - if ($style instanceof Font) { - $this->fontStyle = $style; - $this->setParagraphStyle($paragraphStyle); - } elseif (is_array($style)) { - $this->fontStyle = new Font('text', $paragraphStyle); - $this->fontStyle->setArrayStyle($style); - } else { - $this->fontStyle = $style; - $this->setParagraphStyle($paragraphStyle); - } - return $this->fontStyle; - } - - /** - * Get Text style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public function getFontStyle() - { - return $this->fontStyle; - } - - /** - * Set Paragraph style - * - * @param null|array|PhpOffice\PhpWord\Style\Paragraph $style - * @return null|PhpOffice\PhpWord\Style\Paragraph - */ - public function setParagraphStyle($style = null) - { - if (is_array($style)) { - $this->paragraphStyle = new Paragraph; - $this->paragraphStyle->setArrayStyle($style); - } elseif ($style instanceof Paragraph) { - $this->paragraphStyle = $style; - } else { - $this->paragraphStyle = $style; - } - return $this->paragraphStyle; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->paragraphStyle; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Section/TextRun.php b/Classes/PhpWord/Section/TextRun.php deleted file mode 100644 index 4cee06d6..00000000 --- a/Classes/PhpWord/Section/TextRun.php +++ /dev/null @@ -1,184 +0,0 @@ -_elementCollection = array(); - - // Set paragraph style - if (is_array($styleParagraph)) { - $this->_styleParagraph = new Paragraph(); - - foreach ($styleParagraph as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->_styleParagraph->setStyleValue($key, $value); - } - } else { - $this->_styleParagraph = $styleParagraph; - } - } - - - /** - * Add a Text Element - * - * @var string $text - * @var mixed $styleFont - * @return PhpOffice\PhpWord\Section\Text - */ - public function addText($text = null, $styleFont = null) - { - if (!String::IsUTF8($text)) { - $text = utf8_encode($text); - } - $text = new Text($text, $styleFont); - $this->_elementCollection[] = $text; - return $text; - } - - /** - * Add a Link Element - * - * @param string $linkSrc - * @param string $linkName - * @param mixed $styleFont - * @return PhpOffice\PhpWord\Section\Link - */ - public function addLink($linkSrc, $linkName = null, $styleFont = null) - { - $linkSrc = utf8_encode($linkSrc); - if (!is_null($linkName)) { - $linkName = utf8_encode($linkName); - } - - $link = new Link($linkSrc, $linkName, $styleFont); - $rID = Media::addSectionLinkElement($linkSrc); - $link->setRelationId($rID); - - $this->_elementCollection[] = $link; - return $link; - } - - /** - * Add a Image Element - * - * @param string $imageSrc - * @param mixed $styleFont - * @return PhpOffice\PhpWord\Section\Image - */ - public function addImage($imageSrc, $style = null) - { - $image = new Image($imageSrc, $style); - - if (!is_null($image->getSource())) { - $rID = Media::addSectionMediaElement($imageSrc, 'image'); - $image->setRelationId($rID); - - $this->_elementCollection[] = $image; - return $image; - } else { - throw new Exception('Source does not exist or unsupported image type.'); - } - } - - /** - * Add TextBreak - * - * @param int $count - * @param null|string|array|PhpOffice\PhpWord\Style\Font $fontStyle - * @param null|string|array|PhpOffice\PhpWord\Style\Paragraph $paragraphStyle - */ - public function addTextBreak($count = 1, $fontStyle = null, $paragraphStyle = null) - { - for ($i = 1; $i <= $count; $i++) { - $this->_elementCollection[] = new TextBreak($fontStyle, $paragraphStyle); - } - } - - /** - * Create a new Footnote Element - * - * @param string $text - * @return PhpOffice\PhpWord\Section\Footnote - */ - public function createFootnote($styleParagraph = null) - { - $footnote = new PhpOffice\PhpWord\Section\Footnote($styleParagraph); - $refID = PhpOffice\PhpWord\Footnote::addFootnoteElement($footnote); - $footnote->setReferenceId($refID); - $this->_elementCollection[] = $footnote; - return $footnote; - } - - /** - * Get TextRun content - * - * @return string - */ - public function getElements() - { - return $this->_elementCollection; - } - - /** - * Get Paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_styleParagraph; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Section/Title.php b/Classes/PhpWord/Section/Title.php deleted file mode 100644 index fdc31ac8..00000000 --- a/Classes/PhpWord/Section/Title.php +++ /dev/null @@ -1,145 +0,0 @@ -_style = $style; - } - - $this->_text = $text; - $this->_depth = $depth; - - return $this; - } - - /** - * Set Anchor - * - * @var int $anchor - */ - public function setAnchor($anchor) - { - $this->_anchor = $anchor; - } - - /** - * Get Anchor - * - * @return int - */ - public function getAnchor() - { - return $this->_anchor; - } - - /** - * Set Bookmark ID - * - * @var int $bookmarkId - */ - public function setBookmarkId($bookmarkId) - { - $this->_bookmarkId = $bookmarkId; - } - - /** - * Get Anchor - * - * @return int - */ - public function getBookmarkId() - { - return $this->_bookmarkId; - } - - /** - * Get Title Text content - * - * @return string - */ - public function getText() - { - return $this->_text; - } - - /** - * Get Title style - * - * @return string - */ - public function getStyle() - { - return $this->_style; - } -} diff --git a/Classes/PhpWord/Settings.php b/Classes/PhpWord/Settings.php deleted file mode 100644 index 8eb3a60f..00000000 --- a/Classes/PhpWord/Settings.php +++ /dev/null @@ -1,63 +0,0 @@ - 0) { - unset($pathArray[$i]); - unset($pathArray[$i - 1]); - break; - } - } - } - $returnValue = implode('/', $pathArray); - } - - // Return - return $returnValue; - } -} diff --git a/Classes/PhpWord/Shared/Font.php b/Classes/PhpWord/Shared/Font.php deleted file mode 100644 index adee50ad..00000000 --- a/Classes/PhpWord/Shared/Font.php +++ /dev/null @@ -1,90 +0,0 @@ -) - * 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 UTF-8 data - * - * @param string $value - * @return boolean - */ - public static function IsUTF8($value = '') - { - return $value === '' || preg_match('/^./su', $value) === 1; - } -} diff --git a/Classes/PhpWord/Shared/XMLWriter.php b/Classes/PhpWord/Shared/XMLWriter.php deleted file mode 100644 index 2334997f..00000000 --- a/Classes/PhpWord/Shared/XMLWriter.php +++ /dev/null @@ -1,155 +0,0 @@ -_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 xml Compatibility - $compatibility = Settings::getCompatibility(); - if ($compatibility) { - $this->_xmlWriter->setIndent(false); - $this->_xmlWriter->setIndentString(''); - } else { - $this->_xmlWriter->setIndent(true); - $this->_xmlWriter->setIndentString(' '); - } - } - - /** - * 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/Classes/PhpWord/Shared/ZipStreamWrapper.php b/Classes/PhpWord/Shared/ZipStreamWrapper.php deleted file mode 100644 index 4a8bac6c..00000000 --- a/Classes/PhpWord/Shared/ZipStreamWrapper.php +++ /dev/null @@ -1,183 +0,0 @@ -_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 - */ - public 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; - } - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Style.php b/Classes/PhpWord/Style.php deleted file mode 100644 index 387dc468..00000000 --- a/Classes/PhpWord/Style.php +++ /dev/null @@ -1,161 +0,0 @@ - $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $style->setStyleValue($key, $value); - } - - self::$_styleElements[$styleName] = $style; - } - } - - /** - * @param string $styleName - * @param array $styleFont - * @param array $styleParagraph - */ - public static function addFontStyle($styleName, $styleFont, $styleParagraph = null) - { - if (!array_key_exists($styleName, self::$_styleElements)) { - $font = new Font('text', $styleParagraph); - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $font->setStyleValue($key, $value); - } - self::$_styleElements[$styleName] = $font; - } - } - - /** - * @param string $styleName - * @param array $styles - */ - public static function addLinkStyle($styleName, $styles) - { - if (!array_key_exists($styleName, self::$_styleElements)) { - $style = new Font('link'); - foreach ($styles as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $style->setStyleValue($key, $value); - } - - self::$_styleElements[$styleName] = $style; - } - } - - /** - * @param string $styleName - * @param array $styles - */ - public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null) - { - if (!array_key_exists($styleName, self::$_styleElements)) { - $style = new TableFull($styleTable, $styleFirstRow); - - self::$_styleElements[$styleName] = $style; - } - } - - /** - * @param string $styleName - * @param array $styleFont - * @param array $styleParagraph - */ - public static function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) - { - $styleName = 'Heading_' . $titleCount; - if (!array_key_exists($styleName, self::$_styleElements)) { - $font = new Font('title', $styleParagraph); - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $font->setStyleValue($key, $value); - } - - self::$_styleElements[$styleName] = $font; - } - } - - /** - * @param array $styles Paragraph style definition - */ - public static function setDefaultParagraphStyle($styles) - { - self::addParagraphStyle('Normal', $styles); - } - - /** - * Get all styles - * - * @return PhpOffice\PhpWord\Style\Font[] - */ - public static function getStyles() - { - return self::$_styleElements; - } - - /** - * @param string - */ - public static function getStyle($styleName) - { - if (array_key_exists($styleName, self::$_styleElements)) { - return self::$_styleElements[$styleName]; - } else { - return null; - } - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Style/Cell.php b/Classes/PhpWord/Style/Cell.php deleted file mode 100644 index 23cd0c07..00000000 --- a/Classes/PhpWord/Style/Cell.php +++ /dev/null @@ -1,343 +0,0 @@ -_valign = null; - $this->_textDirection = null; - $this->_bgColor = null; - $this->_borderTopSize = null; - $this->_borderTopColor = null; - $this->_borderLeftSize = null; - $this->_borderLeftColor = null; - $this->_borderRightSize = null; - $this->_borderRightColor = null; - $this->_borderBottomSize = null; - $this->_borderBottomColor = null; - $this->_defaultBorderColor = '000000'; - } - - /** - * Set style value - * - * @var string $key - * @var mixed $value - */ - public function setStyleValue($key, $value) - { - if ($key == '_borderSize') { - $this->setBorderSize($value); - } elseif ($key == '_borderColor') { - $this->setBorderColor($value); - } else { - $this->$key = $value; - } - } - - public function getVAlign() - { - return $this->_valign; - } - - public function setVAlign($pValue = null) - { - $this->_valign = $pValue; - } - - public function getTextDirection() - { - return $this->_textDirection; - } - - public function setTextDirection($pValue = null) - { - $this->_textDirection = $pValue; - } - - public function getBgColor() - { - return $this->_bgColor; - } - - public function setBgColor($pValue = null) - { - $this->_bgColor = $pValue; - } - - public function setBorderSize($pValue = null) - { - $this->_borderTopSize = $pValue; - $this->_borderLeftSize = $pValue; - $this->_borderRightSize = $pValue; - $this->_borderBottomSize = $pValue; - } - - public function getBorderSize() - { - $t = $this->getBorderTopSize(); - $l = $this->getBorderLeftSize(); - $r = $this->getBorderRightSize(); - $b = $this->getBorderBottomSize(); - - return array($t, $l, $r, $b); - } - - public function setBorderColor($pValue = null) - { - $this->_borderTopColor = $pValue; - $this->_borderLeftColor = $pValue; - $this->_borderRightColor = $pValue; - $this->_borderBottomColor = $pValue; - } - - public function getBorderColor() - { - $t = $this->getBorderTopColor(); - $l = $this->getBorderLeftColor(); - $r = $this->getBorderRightColor(); - $b = $this->getBorderBottomColor(); - - return array($t, $l, $r, $b); - } - - public function setBorderTopSize($pValue = null) - { - $this->_borderTopSize = $pValue; - } - - public function getBorderTopSize() - { - return $this->_borderTopSize; - } - - public function setBorderTopColor($pValue = null) - { - $this->_borderTopColor = $pValue; - } - - public function getBorderTopColor() - { - return $this->_borderTopColor; - } - - public function setBorderLeftSize($pValue = null) - { - $this->_borderLeftSize = $pValue; - } - - public function getBorderLeftSize() - { - return $this->_borderLeftSize; - } - - public function setBorderLeftColor($pValue = null) - { - $this->_borderLeftColor = $pValue; - } - - public function getBorderLeftColor() - { - return $this->_borderLeftColor; - } - - public function setBorderRightSize($pValue = null) - { - $this->_borderRightSize = $pValue; - } - - public function getBorderRightSize() - { - return $this->_borderRightSize; - } - - public function setBorderRightColor($pValue = null) - { - $this->_borderRightColor = $pValue; - } - - public function getBorderRightColor() - { - return $this->_borderRightColor; - } - - - public function setBorderBottomSize($pValue = null) - { - $this->_borderBottomSize = $pValue; - } - - public function getBorderBottomSize() - { - return $this->_borderBottomSize; - } - - public function setBorderBottomColor($pValue = null) - { - $this->_borderBottomColor = $pValue; - } - - public function getBorderBottomColor() - { - return $this->_borderBottomColor; - } - - public function getDefaultBorderColor() - { - return $this->_defaultBorderColor; - } - - public function setGridSpan($pValue = null) - { - $this->_gridSpan = $pValue; - } - - public function getGridSpan() - { - return $this->_gridSpan; - } - - public function setVMerge($pValue = null) - { - $this->_vMerge = $pValue; - } - - public function getVMerge() - { - return $this->_vMerge; - } -} diff --git a/Classes/PhpWord/Style/Font.php b/Classes/PhpWord/Style/Font.php deleted file mode 100644 index 213a10cb..00000000 --- a/Classes/PhpWord/Style/Font.php +++ /dev/null @@ -1,544 +0,0 @@ -_type = $type; - - if ($paragraphStyle instanceof Paragraph) { - $this->_paragraphStyle = $paragraphStyle; - } elseif (is_array($paragraphStyle)) { - $this->_paragraphStyle = new Paragraph; - $this->_paragraphStyle->setArrayStyle($paragraphStyle); - } else { - $this->_paragraphStyle = $paragraphStyle; - } - } - - /** - * @param array $style - * @return $this - */ - public function setArrayStyle(array $style = array()) - { - foreach ($style as $key => $value) { - if ($key === 'line-height') { - $this->setLineHeight($value); - null; - } elseif (substr($key, 0, 1) !== '_') { - $key = '_' . $key; - } - $this->setStyleValue($key, $value); - } - - return $this; - } - - /** - * Set style value - * - * @param string $key - * @param mixed $value - */ - public function setStyleValue($key, $value) - { - $method = 'set' . substr($key, 1); - if (method_exists($this, $method)) { - $this->$method($value); - } - } - - /** - * Get font name - * - * @return bool - */ - public function getName() - { - return $this->_name; - } - - /** - * Set font name - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setName($pValue = PhpWord::DEFAULT_FONT_NAME) - { - if (is_null($pValue) || $pValue == '') { - $pValue = PhpWord::DEFAULT_FONT_NAME; - } - $this->_name = $pValue; - return $this; - } - - - /** - * Get font size - * - * @return int|float - */ - public function getSize() - { - return $this->_size; - } - - /** - * Set font size - * - * @param int|float $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setSize($pValue = PhpWord::DEFAULT_FONT_SIZE) - { - if (!is_numeric($pValue)) { - $pValue = PhpWord::DEFAULT_FONT_SIZE; - } - $this->_size = $pValue; - return $this; - } - - /** - * Get bold - * - * @return bool - */ - public function getBold() - { - return $this->_bold; - } - - /** - * Set bold - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setBold($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_bold = $pValue; - return $this; - } - - /** - * Get italics - * - * @return bool - */ - public function getItalic() - { - return $this->_italic; - } - - /** - * Set italics - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setItalic($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_italic = $pValue; - return $this; - } - - /** - * Get superscript - * - * @return bool - */ - public function getSuperScript() - { - return $this->_superScript; - } - - /** - * Set superscript - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setSuperScript($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_superScript = $pValue; - $this->_subScript = !$pValue; - return $this; - } - - /** - * Get superscript - * - * @return bool - */ - public function getSubScript() - { - return $this->_subScript; - } - - /** - * Set subscript - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setSubScript($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_subScript = $pValue; - $this->_superScript = !$pValue; - return $this; - } - - /** - * Get underline - * - * @return string - */ - public function getUnderline() - { - return $this->_underline; - } - - /** - * Set underline - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setUnderline($pValue = self::UNDERLINE_NONE) - { - if ($pValue == '') { - $pValue = self::UNDERLINE_NONE; - } - $this->_underline = $pValue; - return $this; - } - - /** - * Get strikethrough - * - * @return bool - */ - public function getStrikethrough() - { - return $this->_strikethrough; - } - - /** - * Set strikethrough - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setStrikethrough($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_strikethrough = $pValue; - return $this; - } - - /** - * Get font color - * - * @return string - */ - public function getColor() - { - return $this->_color; - } - - /** - * Set font color - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setColor($pValue = PhpWord::DEFAULT_FONT_COLOR) - { - if (is_null($pValue) || $pValue == '') { - $pValue = PhpWord::DEFAULT_FONT_COLOR; - } - $this->_color = $pValue; - return $this; - } - - /** - * Get foreground/highlight color - * - * @return bool - */ - public function getFgColor() - { - return $this->_fgColor; - } - - /** - * Set foreground/highlight color - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setFgColor($pValue = null) - { - $this->_fgColor = $pValue; - return $this; - } - - /** - * Get style type - * - * @return string - */ - public function getStyleType() - { - return $this->_type; - } - - /** - * Get paragraph style - * - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function getParagraphStyle() - { - return $this->_paragraphStyle; - } - - /** - * Set the line height - * - * @param int|float|string $lineHeight - * @return $this - * @throws InvalidStyleException - */ - public function setLineHeight($lineHeight) - { - if (is_string($lineHeight)) { - $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); - } - - if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) { - throw new InvalidStyleException('Line height must be a valid number'); - } - - $this->lineHeight = $lineHeight; - $this->getParagraphStyle()->setLineHeight($lineHeight); - return $this; - } - - /** - * @return int|float - */ - public function getLineHeight() - { - return $this->lineHeight; - } - - /** - * Get Font Content Type - * - * @return bool - */ - public function getHint() - { - return $this->_hint; - } - - /** - * Set Font Content Type - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Font - */ - public function setHint($pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE) - { - if (is_null($pValue) || $pValue == '') { - $pValue = PhpWord::DEFAULT_FONT_CONTENT_TYPE; - } - $this->_hint = $pValue; - return $this; - } -} diff --git a/Classes/PhpWord/Style/Image.php b/Classes/PhpWord/Style/Image.php deleted file mode 100644 index fbc074be..00000000 --- a/Classes/PhpWord/Style/Image.php +++ /dev/null @@ -1,175 +0,0 @@ -_width = null; - $this->_height = null; - $this->_align = null; - $this->_marginTop = null; - $this->_marginLeft = null; - $this->setWrappingStyle(self::WRAPPING_STYLE_INLINE); - } - - public function setStyleValue($key, $value) - { - $this->$key = $value; - } - - public function getWidth() - { - return $this->_width; - } - - public function setWidth($pValue = null) - { - $this->_width = $pValue; - } - - public function getHeight() - { - return $this->_height; - } - - public function setHeight($pValue = null) - { - $this->_height = $pValue; - } - - public function getAlign() - { - return $this->_align; - } - - public function setAlign($pValue = null) - { - $this->_align = $pValue; - } - - /** - * Get Margin Top - * - * @return int - */ - public function getMarginTop() - { - return $this->_marginTop; - } - - /** - * Set Margin Top - * - * @param int $pValue - * @return $this - */ - public function setMarginTop($pValue = null) - { - $this->_marginTop = $pValue; - return $this; - } - - /** - * Get Margin Left - * - * @return int - */ - public function getMarginLeft() - { - return $this->_marginLeft; - } - - /** - * Set Margin Left - * - * @param int $pValue - * @return $this - */ - public function setMarginLeft($pValue = null) - { - $this->_marginLeft = $pValue; - return $this; - } - - /** - * @param string $wrappingStyle - * @throws InvalidArgumentException - * @return $this - */ - public function setWrappingStyle($wrappingStyle) - { - switch ($wrappingStyle) { - case self::WRAPPING_STYLE_BEHIND: - case self::WRAPPING_STYLE_INFRONT: - case self::WRAPPING_STYLE_INLINE: - case self::WRAPPING_STYLE_SQUARE: - case self::WRAPPING_STYLE_TIGHT: - $this->wrappingStyle = $wrappingStyle; - break; - default: - throw new InvalidArgumentException('Wrapping style does not exists'); - break; - } - return $this; - } - - /** - * @return string - */ - public function getWrappingStyle() - { - return $this->wrappingStyle; - } -} diff --git a/Classes/PhpWord/Style/ListItem.php b/Classes/PhpWord/Style/ListItem.php deleted file mode 100644 index 458e08e8..00000000 --- a/Classes/PhpWord/Style/ListItem.php +++ /dev/null @@ -1,80 +0,0 @@ -_listType = self::TYPE_BULLET_FILLED; - } - - /** - * Set style value - * - * @param string $key - * @param string $value - */ - public function setStyleValue($key, $value) - { - $this->$key = $value; - } - - /** - * Set List Type - * - * @param int $pValue - */ - public function setListType($pValue = self::TYPE_BULLET_FILLED) - { - $this->_listType = $pValue; - } - - /** - * Get List Type - */ - public function getListType() - { - return $this->_listType; - } -} diff --git a/Classes/PhpWord/Style/Paragraph.php b/Classes/PhpWord/Style/Paragraph.php deleted file mode 100644 index 87827448..00000000 --- a/Classes/PhpWord/Style/Paragraph.php +++ /dev/null @@ -1,508 +0,0 @@ - $value) { - if ($key === 'line-height') { - null; - } elseif (substr($key, 0, 1) !== '_') { - $key = '_' . $key; - } - $this->setStyleValue($key, $value); - } - - return $this; - } - - /** - * Set Style value - * - * @param string $key - * @param mixed $value - */ - public function setStyleValue($key, $value) - { - if ($key == '_indent' || $key == '_hanging') { - $value = $value * 720; - } elseif ($key == '_spacing') { - $value += 240; // because line height of 1 matches 240 twips - } elseif ($key === 'line-height') { - $this->setLineHeight($value); - return; - } - $this->$key = $value; - $method = 'set' . substr($key, 1); - if (method_exists($this, $method)) { - $this->$method($value); - } - } - - /** - * Get Paragraph Alignment - * - * @return string - */ - public function getAlign() - { - return $this->_align; - } - - /** - * Set Paragraph Alignment - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setAlign($pValue = null) - { - if (strtolower($pValue) == 'justify') { - // justify becames both - $pValue = 'both'; - } - $this->_align = $pValue; - return $this; - } - - /** - * Get Space before Paragraph - * - * @return string - */ - public function getSpaceBefore() - { - return $this->_spaceBefore; - } - - /** - * Set Space before Paragraph - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setSpaceBefore($pValue = null) - { - $this->_spaceBefore = $pValue; - return $this; - } - - /** - * Get Space after Paragraph - * - * @return string - */ - public function getSpaceAfter() - { - return $this->_spaceAfter; - } - - /** - * Set Space after Paragraph - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setSpaceAfter($pValue = null) - { - $this->_spaceAfter = $pValue; - return $this; - } - - /** - * Get Spacing between breaks - * - * @return int - */ - public function getSpacing() - { - return $this->_spacing; - } - - /** - * Set Spacing between breaks - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setSpacing($pValue = null) - { - $this->_spacing = $pValue; - return $this; - } - - /** - * Get indentation - * - * @return int - */ - public function getIndent() - { - return $this->_indent; - } - - /** - * Set indentation - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setIndent($pValue = null) - { - $this->_indent = $pValue; - return $this; - } - - /** - * Get hanging - * - * @return int - */ - public function getHanging() - { - return $this->_hanging; - } - - /** - * Set hanging - * - * @param int $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setHanging($pValue = null) - { - $this->_hanging = $pValue; - return $this; - } - - /** - * Get tabs - * - * @return PhpOffice\PhpWord\Style\Tabs - */ - public function getTabs() - { - return $this->_tabs; - } - - /* - * Set tabs - * - * @param array $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setTabs($pValue = null) - { - if (is_array($pValue)) { - $this->_tabs = new Tabs($pValue); - } - return $this; - } - - /** - * Get parent style ID - * - * @return string - */ - public function getBasedOn() - { - return $this->_basedOn; - } - - /** - * Set parent style ID - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setBasedOn($pValue = 'Normal') - { - $this->_basedOn = $pValue; - return $this; - } - - /** - * Get style for next paragraph - * - * @return string - */ - public function getNext() - { - return $this->_next; - } - - /** - * Set style for next paragraph - * - * @param string $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setNext($pValue = null) - { - $this->_next = $pValue; - return $this; - } - - /** - * Get allow first/last line to display on a separate page setting - * - * @return bool - */ - public function getWidowControl() - { - return $this->_widowControl; - } - - /** - * Set keep paragraph with next paragraph setting - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setWidowControl($pValue = true) - { - if (!is_bool($pValue)) { - $pValue = true; - } - $this->_widowControl = $pValue; - return $this; - } - - /** - * Get keep paragraph with next paragraph setting - * - * @return bool - */ - public function getKeepNext() - { - return $this->_keepNext; - } - - /** - * Set keep paragraph with next paragraph setting - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setKeepNext($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_keepNext = $pValue; - return $this; - } - - /** - * Get keep all lines on one page setting - * - * @return bool - */ - public function getKeepLines() - { - return $this->_keepLines; - } - - /** - * Set keep all lines on one page setting - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setKeepLines($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_keepLines = $pValue; - return $this; - } - - /** - * Get start paragraph on next page setting - * - * @return bool - */ - public function getPageBreakBefore() - { - return $this->_pageBreakBefore; - } - - /** - * Set start paragraph on next page setting - * - * @param bool $pValue - * @return PhpOffice\PhpWord\Style\Paragraph - */ - public function setPageBreakBefore($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_pageBreakBefore = $pValue; - return $this; - } - - /** - * Set the line height - * - * @param int|float|string $lineHeight - * @return $this - * @throws InvalidStyleException - */ - public function setLineHeight($lineHeight) - { - if (is_string($lineHeight)) { - $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); - } - - if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) { - throw new InvalidStyleException('Line height must be a valid number'); - } - - $this->lineHeight = $lineHeight; - $this->setSpacing($lineHeight * self::LINE_HEIGHT); - return $this; - } - - /** - * @return int|float - */ - public function getLineHeight() - { - return $this->lineHeight; - } -} diff --git a/Classes/PhpWord/Style/Row.php b/Classes/PhpWord/Style/Row.php deleted file mode 100644 index 5431dd20..00000000 --- a/Classes/PhpWord/Style/Row.php +++ /dev/null @@ -1,88 +0,0 @@ -$key = $value; - } - - public function setTblHeader($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_tblHeader = $pValue; - return $this; - } - - public function getTblHeader() - { - return $this->_tblHeader; - } - - public function setCantSplit($pValue = false) - { - if (!is_bool($pValue)) { - $pValue = false; - } - $this->_cantSplit = $pValue; - return $this; - } - - public function getCantSplit() - { - return $this->_cantSplit; - } -} diff --git a/Classes/PhpWord/Style/TOC.php b/Classes/PhpWord/Style/TOC.php deleted file mode 100644 index b7da1059..00000000 --- a/Classes/PhpWord/Style/TOC.php +++ /dev/null @@ -1,139 +0,0 @@ -_tabPos = 9062; - $this->_tabLeader = self::TABLEADER_DOT; - $this->_indent = 200; - } - - /** - * Get Tab Position - * - * @return int - */ - public function getTabPos() - { - return $this->_tabPos; - } - - /** - * Set Tab Position - * - * @param int $pValue - */ - public function setTabPos($pValue) - { - $this->_tabPos = $pValue; - } - - /** - * Get Tab Leader - * - * @return string - */ - public function getTabLeader() - { - return $this->_tabLeader; - } - - /** - * Set Tab Leader - * - * @param string $pValue - */ - public function setTabLeader($pValue = self::TABLEADER_DOT) - { - $this->_tabLeader = $pValue; - } - - /** - * Get Indent - * - * @return int - */ - public function getIndent() - { - return $this->_indent; - } - - /** - * Set Indent - * - * @param string $pValue - */ - public function setIndent($pValue) - { - $this->_indent = $pValue; - } - - /** - * Set style value - * - * @param string $key - * @param string $value - */ - public function setStyleValue($key, $value) - { - $this->$key = $value; - } -} diff --git a/Classes/PhpWord/Style/Tab.php b/Classes/PhpWord/Style/Tab.php deleted file mode 100644 index b9d949e9..00000000 --- a/Classes/PhpWord/Style/Tab.php +++ /dev/null @@ -1,146 +0,0 @@ -_val = (self::isStopType($val)) ? $val : 'clear'; - - // Default to 0 if the position is non-numeric - $this->_position = (is_numeric($position)) ? intval($position) : 0; - - // Default to NULL if no tab leader - $this->_leader = (self::isLeaderType($leader)) ? $leader : null; - } - - /** - * Creates the XML DOM for the instance of Tab. - * - * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter - */ - public function toXml(XMLWriter &$xmlWriter = null) - { - if (isset($xmlWriter)) { - $xmlWriter->startElement("w:tab"); - $xmlWriter->writeAttribute("w:val", $this->_val); - if (!is_null($this->_leader)) { - $xmlWriter->writeAttribute("w:leader", $this->_leader); - } - $xmlWriter->writeAttribute("w:pos", $this->_position); - $xmlWriter->endElement(); - } - } - - /** - * Test if attribute is a valid stop type. - * - * @param string $attribute - * @return bool True if it is; false otherwise. - */ - private static function isStopType($attribute) - { - return in_array($attribute, self::$_possibleStopTypes); - } - - /** - * Test if attribute is a valid leader type. - * - * @param string $attribute - * @return bool True if it is; false otherwise. - */ - private static function isLeaderType($attribute) - { - return in_array($attribute, self::$_possibleLeaders); - } -} diff --git a/Classes/PhpWord/Style/Table.php b/Classes/PhpWord/Style/Table.php deleted file mode 100644 index 4de56605..00000000 --- a/Classes/PhpWord/Style/Table.php +++ /dev/null @@ -1,94 +0,0 @@ -_cellMarginTop = null; - $this->_cellMarginLeft = null; - $this->_cellMarginRight = null; - $this->_cellMarginBottom = null; - } - - public function setStyleValue($key, $value) - { - $this->$key = $value; - } - - public function setCellMarginTop($pValue = null) - { - $this->_cellMarginTop = $pValue; - } - - public function getCellMarginTop() - { - return $this->_cellMarginTop; - } - - public function setCellMarginLeft($pValue = null) - { - $this->_cellMarginLeft = $pValue; - } - - public function getCellMarginLeft() - { - return $this->_cellMarginLeft; - } - - public function setCellMarginRight($pValue = null) - { - $this->_cellMarginRight = $pValue; - } - - public function getCellMarginRight() - { - return $this->_cellMarginRight; - } - - public function setCellMarginBottom($pValue = null) - { - $this->_cellMarginBottom = $pValue; - } - - public function getCellMarginBottom() - { - return $this->_cellMarginBottom; - } - - public function getCellMargin() - { - return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); - } -} diff --git a/Classes/PhpWord/Style/TableFull.php b/Classes/PhpWord/Style/TableFull.php deleted file mode 100644 index 5ca7561b..00000000 --- a/Classes/PhpWord/Style/TableFull.php +++ /dev/null @@ -1,443 +0,0 @@ -_firstRow = clone $this; - - unset($this->_firstRow->_firstRow); - unset($this->_firstRow->_cellMarginBottom); - unset($this->_firstRow->_cellMarginTop); - unset($this->_firstRow->_cellMarginLeft); - unset($this->_firstRow->_cellMarginRight); - unset($this->_firstRow->_borderInsideVColor); - unset($this->_firstRow->_borderInsideVSize); - unset($this->_firstRow->_borderInsideHColor); - unset($this->_firstRow->_borderInsideHSize); - foreach ($styleFirstRow as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - - $this->_firstRow->setStyleValue($key, $value); - } - } - - if (!is_null($styleTable) && is_array($styleTable)) { - foreach ($styleTable as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - $this->setStyleValue($key, $value); - } - } - } - - /** - * @param string $key - * @param mixed $value - */ - public function setStyleValue($key, $value) - { - if ($key == '_borderSize') { - $this->setBorderSize($value); - } elseif ($key == '_borderColor') { - $this->setBorderColor($value); - } elseif ($key == '_cellMargin') { - $this->setCellMargin($value); - } else { - $this->$key = $value; - } - } - - /** - * Get First Row Style - * - * @return PhpOffice\PhpWord\Style\TableFull - */ - public function getFirstRow() - { - return $this->_firstRow; - } - - /** - * Get Last Row Style - * - * @return PhpOffice\PhpWord\Style\TableFull - */ - public function getLastRow() - { - return $this->_lastRow; - } - - public function getBgColor() - { - return $this->_bgColor; - } - - public function setBgColor($pValue = null) - { - $this->_bgColor = $pValue; - } - - /** - * Set TLRBVH Border Size - * - * @param int $pValue Border size in eighths of a point (1/8 point) - */ - public function setBorderSize($pValue = null) - { - $this->_borderTopSize = $pValue; - $this->_borderLeftSize = $pValue; - $this->_borderRightSize = $pValue; - $this->_borderBottomSize = $pValue; - $this->_borderInsideHSize = $pValue; - $this->_borderInsideVSize = $pValue; - } - - /** - * Get TLRBVH Border Size - * - * @return array - */ - public function getBorderSize() - { - $t = $this->getBorderTopSize(); - $l = $this->getBorderLeftSize(); - $r = $this->getBorderRightSize(); - $b = $this->getBorderBottomSize(); - $h = $this->getBorderInsideHSize(); - $v = $this->getBorderInsideVSize(); - - return array($t, $l, $r, $b, $h, $v); - } - - /** - * Set TLRBVH Border Color - */ - public function setBorderColor($pValue = null) - { - $this->_borderTopColor = $pValue; - $this->_borderLeftColor = $pValue; - $this->_borderRightColor = $pValue; - $this->_borderBottomColor = $pValue; - $this->_borderInsideHColor = $pValue; - $this->_borderInsideVColor = $pValue; - } - - /** - * Get TLRB Border Color - * - * @return array - */ - public function getBorderColor() - { - $t = $this->getBorderTopColor(); - $l = $this->getBorderLeftColor(); - $r = $this->getBorderRightColor(); - $b = $this->getBorderBottomColor(); - $h = $this->getBorderInsideHColor(); - $v = $this->getBorderInsideVColor(); - - return array($t, $l, $r, $b, $h, $v); - } - - public function setBorderTopSize($pValue = null) - { - $this->_borderTopSize = $pValue; - } - - public function getBorderTopSize() - { - return $this->_borderTopSize; - } - - public function setBorderTopColor($pValue = null) - { - $this->_borderTopColor = $pValue; - } - - public function getBorderTopColor() - { - return $this->_borderTopColor; - } - - public function setBorderLeftSize($pValue = null) - { - $this->_borderLeftSize = $pValue; - } - - public function getBorderLeftSize() - { - return $this->_borderLeftSize; - } - - public function setBorderLeftColor($pValue = null) - { - $this->_borderLeftColor = $pValue; - } - - public function getBorderLeftColor() - { - return $this->_borderLeftColor; - } - - public function setBorderRightSize($pValue = null) - { - $this->_borderRightSize = $pValue; - } - - public function getBorderRightSize() - { - return $this->_borderRightSize; - } - - public function setBorderRightColor($pValue = null) - { - $this->_borderRightColor = $pValue; - } - - public function getBorderRightColor() - { - return $this->_borderRightColor; - } - - public function setBorderBottomSize($pValue = null) - { - $this->_borderBottomSize = $pValue; - } - - public function getBorderBottomSize() - { - return $this->_borderBottomSize; - } - - public function setBorderBottomColor($pValue = null) - { - $this->_borderBottomColor = $pValue; - } - - public function getBorderBottomColor() - { - return $this->_borderBottomColor; - } - - public function setBorderInsideHColor($pValue = null) - { - $this->_borderInsideHColor = $pValue; - } - - public function getBorderInsideHColor() - { - return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null; - } - - public function setBorderInsideVColor($pValue = null) - { - $this->_borderInsideVColor = $pValue; - } - - public function getBorderInsideVColor() - { - return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null; - } - - public function setBorderInsideHSize($pValue = null) - { - $this->_borderInsideHSize = $pValue; - } - - public function getBorderInsideHSize() - { - return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null; - } - - public function setBorderInsideVSize($pValue = null) - { - $this->_borderInsideVSize = $pValue; - } - - public function getBorderInsideVSize() - { - return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null; - } - - public function setCellMarginTop($pValue = null) - { - $this->_cellMarginTop = $pValue; - } - - public function getCellMarginTop() - { - return $this->_cellMarginTop; - } - - public function setCellMarginLeft($pValue = null) - { - $this->_cellMarginLeft = $pValue; - } - - public function getCellMarginLeft() - { - return $this->_cellMarginLeft; - } - - public function setCellMarginRight($pValue = null) - { - $this->_cellMarginRight = $pValue; - } - - public function getCellMarginRight() - { - return $this->_cellMarginRight; - } - - public function setCellMarginBottom($pValue = null) - { - $this->_cellMarginBottom = $pValue; - } - - public function getCellMarginBottom() - { - return $this->_cellMarginBottom; - } - - /** - * Set TLRB cell margin - * - * @param int $pValue Margin in twips - */ - public function setCellMargin($pValue = null) - { - $this->_cellMarginTop = $pValue; - $this->_cellMarginLeft = $pValue; - $this->_cellMarginRight = $pValue; - $this->_cellMarginBottom = $pValue; - } - - public function getCellMargin() - { - return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Style/Tabs.php b/Classes/PhpWord/Style/Tabs.php deleted file mode 100644 index 45fdb568..00000000 --- a/Classes/PhpWord/Style/Tabs.php +++ /dev/null @@ -1,63 +0,0 @@ -_tabs = $tabs; - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter - */ - public function toXml(XMLWriter &$xmlWriter = null) - { - if (isset($xmlWriter)) { - $xmlWriter->startElement("w:tabs"); - foreach ($this->_tabs as &$tab) { - $tab->toXml($xmlWriter); - } - $xmlWriter->endElement(); - } - } -} diff --git a/Classes/PhpWord/TOC.php b/Classes/PhpWord/TOC.php deleted file mode 100644 index 932e54be..00000000 --- a/Classes/PhpWord/TOC.php +++ /dev/null @@ -1,155 +0,0 @@ - $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - self::$_styleTOC->setStyleValue($key, $value); - } - } - - if (!is_null($styleFont)) { - if (is_array($styleFont)) { - self::$_styleFont = new Font(); - - foreach ($styleFont as $key => $value) { - if (substr($key, 0, 1) != '_') { - $key = '_' . $key; - } - self::$_styleFont->setStyleValue($key, $value); - } - } else { - self::$_styleFont = $styleFont; - } - } - } - - /** - * Add a Title - * - * @return array - */ - public static function addTitle($text, $depth = 0) - { - $anchor = '_Toc' . ++self::$_anchor; - $bookmarkId = self::$_bookmarkId++; - - $title = array(); - $title['text'] = $text; - $title['depth'] = $depth; - $title['anchor'] = $anchor; - $title['bookmarkId'] = $bookmarkId; - - self::$_titles[] = $title; - - return array($anchor, $bookmarkId); - } - - /** - * Get all titles - * - * @return array - */ - public static function getTitles() - { - return self::$_titles; - } - - /** - * Get TOC Style - * - * @return PhpOffice\PhpWord\Style\TOC - */ - public static function getStyleTOC() - { - return self::$_styleTOC; - } - - /** - * Get Font Style - * - * @return PhpOffice\PhpWord\Style\Font - */ - public static function getStyleFont() - { - return self::$_styleFont; - } -} diff --git a/Classes/PhpWord/Template.php b/Classes/PhpWord/Template.php deleted file mode 100644 index f934257e..00000000 --- a/Classes/PhpWord/Template.php +++ /dev/null @@ -1,292 +0,0 @@ -_tempFileName = tempnam(sys_get_temp_dir(), ''); - if ($this->_tempFileName === false) { - throw new Exception('Could not create temporary file with unique name in the default temporary directory.'); - } - - // Copy the source File to the temp File - if (!copy($strFilename, $this->_tempFileName)) { - throw new Exception("Could not copy the template from {$strFilename} to {$this->_tempFileName}."); - } - - $this->_objZip = new ZipArchive(); - $this->_objZip->open($this->_tempFileName); - - $this->_documentXML = $this->_objZip->getFromName('word/document.xml'); - } - - /** - * Applies XSL style sheet to template's parts - * - * @param DOMDocument $xslDOMDocument - * @param array $xslOptions - * @param string $xslOptionsURI - * @throws Exception - */ - public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '') - { - $processor = new XSLTProcessor(); - - $processor->importStylesheet($xslDOMDocument); - - if ($processor->setParameter($xslOptionsURI, $xslOptions) === false) { - throw new Exception('Could not set values for the given XSL style sheet parameters.'); - } - - $xmlDOMDocument = new DOMDocument(); - if ($xmlDOMDocument->loadXML($this->_documentXML) === false) { - throw new Exception('Could not load XML from the given template.'); - } - - $xmlTransformed = $processor->transformToXml($xmlDOMDocument); - if ($xmlTransformed === false) { - throw new Exception('Could not transform the given XML document.'); - } - - $this->_documentXML = $xmlTransformed; - } - - /** - * Set a Template value - * - * @param mixed $search - * @param mixed $replace - * @param integer $limit - */ - public function setValue($search, $replace, $limit = -1) - { - $pattern = '|\$\{([^\}]+)\}|U'; - preg_match_all($pattern, $this->_documentXML, $matches); - foreach ($matches[0] as $value) { - $valueCleaned = preg_replace('/<[^>]+>/', '', $value); - $valueCleaned = preg_replace('/<\/[^>]+>/', '', $valueCleaned); - $this->_documentXML = str_replace($value, $valueCleaned, $this->_documentXML); - } - - if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { - $search = '${' . $search . '}'; - } - - if (!is_array($replace)) { - if (!String::IsUTF8($replace)) { - $replace = utf8_encode($replace); - } - $replace = htmlspecialchars($replace); - } else { - foreach ($replace as $key => $value) { - $replace[$key] = htmlspecialchars($value); - } - } - - $regExpDelim = '/'; - $escapedSearch = preg_quote($search, $regExpDelim); - $this->_documentXML = preg_replace("{$regExpDelim}{$escapedSearch}{$regExpDelim}u", $replace, $this->_documentXML, $limit); - } - - /** - * Returns array of all variables in template - */ - public function getVariables() - { - preg_match_all('/\$\{(.*?)}/i', $this->_documentXML, $matches); - return $matches[1]; - } - - /** - * Find the start position of the nearest table row before $offset - * - * @param int $offset - * @return int - * @throws Exception - */ - private function _findRowStart($offset) - { - $rowStart = strrpos($this->_documentXML, "_documentXML) - $offset) * -1)); - if (!$rowStart) { - $rowStart = strrpos($this->_documentXML, "", ((strlen($this->_documentXML) - $offset) * -1)); - } - if (!$rowStart) { - throw new Exception("Can not find the start position of the row to clone."); - } - return $rowStart; - } - - /** - * Find the end position of the nearest table row after $offset - * - * @param int $offset - * @return int - */ - private function _findRowEnd($offset) - { - $rowEnd = strpos($this->_documentXML, "", $offset) + 7; - return $rowEnd; - } - - /** - * Get a slice of a string - * - * @param int $startPosition - * @param int $endPosition - * @return string - */ - private function _getSlice($startPosition, $endPosition = 0) - { - if (!$endPosition) { - $endPosition = strlen($this->_documentXML); - } - return substr($this->_documentXML, $startPosition, ($endPosition - $startPosition)); - } - - /** - * Clone a table row in a template document - * - * @param string $search - * @param int $numberOfClones - * @throws Exception - */ - public function cloneRow($search, $numberOfClones) - { - if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { - $search = '${' . $search . '}'; - } - - $tagPos = strpos($this->_documentXML, $search); - if (!$tagPos) { - throw new Exception("Can not clone row, template variable not found or variable contains markup."); - } - - $rowStart = $this->_findRowStart($tagPos); - $rowEnd = $this->_findRowEnd($tagPos); - $xmlRow = $this->_getSlice($rowStart, $rowEnd); - - // Check if there's a cell spanning multiple rows. - if (preg_match('##', $xmlRow)) { - $extraRowStart = $rowEnd; - $extraRowEnd = $rowEnd; - while (true) { - $extraRowStart = $this->_findRowStart($extraRowEnd + 1); - $extraRowEnd = $this->_findRowEnd($extraRowEnd + 1); - - // If extraRowEnd is lower then 7, there was no next row found. - if ($extraRowEnd < 7) { - break; - } - - // If tmpXmlRow doesn't contain continue, this row is no longer part of the spanned row. - $tmpXmlRow = $this->_getSlice($extraRowStart, $extraRowEnd); - if (!preg_match('##', $tmpXmlRow) && !preg_match('##', $tmpXmlRow)) { - break; - } - // This row was a spanned row, update $rowEnd and search for the next row. - $rowEnd = $extraRowEnd; - } - $xmlRow = $this->_getSlice($rowStart, $rowEnd); - } - - $result = $this->_getSlice(0, $rowStart); - for ($i = 1; $i <= $numberOfClones; $i++) { - $result .= preg_replace('/\$\{(.*?)\}/', '\${\\1#' . $i . '}', $xmlRow); - } - $result .= $this->_getSlice($rowEnd); - - $this->_documentXML = $result; - } - - /** - * Save Template - * - * @return string - * @throws Exception - */ - public function save() - { - $this->_objZip->addFromString('word/document.xml', $this->_documentXML); - - // Close zip file - if ($this->_objZip->close() === false) { - throw new Exception('Could not close zip file.'); - } - - return $this->_tempFileName; - } - - /** - * Save Template As... - * - * @param string $strFilename - */ - public function saveAs($strFilename) - { - $tempFilename = $this->save(); - - if (file_exists($strFilename)) { - unlink($strFilename); - } - - rename($tempFilename, $strFilename); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Writer/IWriter.php b/Classes/PhpWord/Writer/IWriter.php deleted file mode 100644 index 98c15704..00000000 --- a/Classes/PhpWord/Writer/IWriter.php +++ /dev/null @@ -1,39 +0,0 @@ -setPhpWord($phpWord); - - // Set up disk caching location - $this->_diskCachingDirectory = './'; - - // Initialise writer parts - $this->_writerParts['content'] = new Content(); - $this->_writerParts['manifest'] = new Manifest(); - $this->_writerParts['meta'] = new Meta(); - $this->_writerParts['mimetype'] = new Mimetype(); - $this->_writerParts['styles'] = new Styles(); - - - // Assign parent IWriter - foreach ($this->_writerParts as $writer) { - $writer->setParentWriter($this); - } - - // Set HashTable variables - $this->_drawingHashTable = new HashTable(); - } - - /** - * Save PhpWord to file - * - * @param string $pFileName - * @throws \Exception - */ - public function save($pFilename = null) - { - if (!is_null($this->_document)) { - // 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 - - // 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 mimetype to ZIP file - //@todo Not in ZIPARCHIVE::CM_STORE mode - $objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->writeMimetype($this->_document)); - - // Add content.xml to ZIP file - $objZip->addFromString('content.xml', $this->getWriterPart('content')->writeContent($this->_document)); - - // Add meta.xml to ZIP file - $objZip->addFromString('meta.xml', $this->getWriterPart('meta')->writeMeta($this->_document)); - - // Add styles.xml to ZIP file - $objZip->addFromString('styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document)); - - // Add META-INF/manifest.xml - $objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('manifest')->writeManifest($this->_document)); - - // Add media. Has not used yet. Legacy from PHPExcel. - // @codeCoverageIgnoreStart - for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) { - if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_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('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); - } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_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('Pictures/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents); - } - } - // @codeCoverageIgnoreEnd - - // 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("PhpWord object unassigned."); - } - } - - /** - * @return PhpOffice\PhpWord - * @throws \Exception - */ - public function getPhpWord() - { - if (!is_null($this->_document)) { - return $this->_document; - } else { - throw new \Exception("No PhpWord assigned."); - } - } - - /** - * @param PhpOffice\PhpWord $phpWord - * @return PhpOffice\PhpWord\Writer\ODText - */ - public function setPhpWord(PhpWord $phpWord = null) - { - $this->_document = $phpWord; - return $this; - } - - /** - * Get PHPWord_Worksheet_BaseDrawing HashTable - * - * @return PhpOffice\PhpWord\HashTable - */ - public function getDrawingHashTable() - { - return $this->_drawingHashTable; - } - - /** - * @param string $pPartName Writer part name - * @return PhpOffice\PhpWord\Writer\ODText\WriterPart - */ - public function getWriterPart($pPartName = '') - { - if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { - return $this->_writerParts[strtolower($pPartName)]; - } else { - return null; - } - } - - /** - * 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 - * @return PhpOffice\PhpWord\Writer\ODText - */ - 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"); - } - } - - return $this; - } - - /** - * @return string - */ - public function getDiskCachingDirectory() - { - return $this->_diskCachingDirectory; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Writer/ODText/Content.php b/Classes/PhpWord/Writer/ODText/Content.php deleted file mode 100644 index d4f4d2eb..00000000 --- a/Classes/PhpWord/Writer/ODText/Content.php +++ /dev/null @@ -1,412 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8'); - - // office:document-content - $xmlWriter->startElement('office:document-content'); - $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); - $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); - $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); - $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); - $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); - $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); - $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); - $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); - $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); - $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); - $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); - $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); - $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); - $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); - $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); - $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); - $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); - $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); - $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); - $xmlWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms'); - $xmlWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); - $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); - $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); - $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); - $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); - $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); - $xmlWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0'); - $xmlWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0'); - $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); - $xmlWriter->writeAttribute('office:version', '1.2'); - - // We firstly search all fonts used - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - if ($countSections > 0) { - $pSection = 0; - $numPStyles = 0; - $numFStyles = 0; - - foreach ($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $fStyle = $element->getFontStyle(); - $pStyle = $element->getParagraphStyle(); - - if ($fStyle instanceof Font) { - $numFStyles++; - - $arrStyle = array( - 'color' => $fStyle->getColor(), - 'name' => $fStyle->getName() - ); - $phpWord->addFontStyle('T' . $numFStyles, $arrStyle); - $element->setFontStyle('T' . $numFStyles); - } elseif ($pStyle instanceof Paragraph) { - $numPStyles++; - - $phpWord->addParagraphStyle('P' . $numPStyles, array()); - $element->setParagraphStyle('P' . $numPStyles); - } - } - } - } - } - - // office:font-face-decls - $xmlWriter->startElement('office:font-face-decls'); - $arrFonts = array(); - - $styles = Style::getStyles(); - $numFonts = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - $numFonts++; - $name = $style->getName(); - if (!in_array($name, $arrFonts)) { - $arrFonts[] = $name; - - // style:font-face - $xmlWriter->startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', $name); - $xmlWriter->writeAttribute('svg:font-family', $name); - $xmlWriter->endElement(); - } - } - } - if (!in_array(PhpWord::DEFAULT_FONT_NAME, $arrFonts)) { - $xmlWriter->startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->endElement(); - } - } - $xmlWriter->endElement(); - - $xmlWriter->startElement('office:automatic-styles'); - $styles = Style::getStyles(); - $numPStyles = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - if (preg_match('#^T[0-9]+$#', $styleName) != 0 - || preg_match('#^P[0-9]+$#', $styleName) != 0 - ) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', $styleName); - $xmlWriter->writeAttribute('style:family', 'text'); - // style:text-properties - $xmlWriter->startElement('style:text-properties'); - $xmlWriter->writeAttribute('fo:color', '#' . $style->getColor()); - $xmlWriter->writeAttribute('style:font-name', $style->getName()); - $xmlWriter->writeAttribute('style:font-name-complex', $style->getName()); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - if ($style instanceof Paragraph) { - $numPStyles++; - // style:style - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', $styleName); - $xmlWriter->writeAttribute('style:family', 'paragraph'); - $xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); - $xmlWriter->writeAttribute('style:master-page-name', 'Standard'); - // style:paragraph-properties - $xmlWriter->startElement('style:paragraph-properties'); - $xmlWriter->writeAttribute('style:page-number', 'auto'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - } - - if ($numPStyles == 0) { - // style:style - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', 'P1'); - $xmlWriter->writeAttribute('style:family', 'paragraph'); - $xmlWriter->writeAttribute('style:parent-style-name', 'Standard'); - $xmlWriter->writeAttribute('style:master-page-name', 'Standard'); - // style:paragraph-properties - $xmlWriter->startElement('style:paragraph-properties'); - $xmlWriter->writeAttribute('style:page-number', 'auto'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - $xmlWriter->endElement(); - - // office:body - $xmlWriter->startElement('office:body'); - // office:text - $xmlWriter->startElement('office:text'); - // text:sequence-decls - $xmlWriter->startElement('text:sequence-decls'); - // text:sequence-decl - $xmlWriter->startElement('text:sequence-decl'); - $xmlWriter->writeAttribute('text:display-outline-level', 0); - $xmlWriter->writeAttribute('text:name', 'Illustration'); - $xmlWriter->endElement(); - // text:sequence-decl - $xmlWriter->startElement('text:sequence-decl'); - $xmlWriter->writeAttribute('text:display-outline-level', 0); - $xmlWriter->writeAttribute('text:name', 'Table'); - $xmlWriter->endElement(); - // text:sequence-decl - $xmlWriter->startElement('text:sequence-decl'); - $xmlWriter->writeAttribute('text:display-outline-level', 0); - $xmlWriter->writeAttribute('text:name', 'Text'); - $xmlWriter->endElement(); - // text:sequence-decl - $xmlWriter->startElement('text:sequence-decl'); - $xmlWriter->writeAttribute('text:display-outline-level', 0); - $xmlWriter->writeAttribute('text:name', 'Drawing'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if ($countSections > 0) { - foreach ($_sections as $section) { - $pSection++; - - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter); - } elseif ($element instanceof Link) { - $this->writeUnsupportedElement($xmlWriter, 'Link'); - } elseif ($element instanceof Title) { - $this->writeUnsupportedElement($xmlWriter, 'Title'); - } elseif ($element instanceof PageBreak) { - $this->writeUnsupportedElement($xmlWriter, 'Page Break'); - } elseif ($element instanceof Table) { - $this->writeUnsupportedElement($xmlWriter, 'Table'); - } elseif ($element instanceof ListItem) { - $this->writeUnsupportedElement($xmlWriter, 'List Item'); - } elseif ($element instanceof Image || - $element instanceof MemoryImage) { - $this->writeUnsupportedElement($xmlWriter, 'Image'); - } elseif ($element instanceof Object) { - $this->writeUnsupportedElement($xmlWriter, 'Object'); - } elseif ($element instanceof TOC) { - $this->writeUnsupportedElement($xmlWriter, 'TOC'); - } else { - $this->writeUnsupportedElement($xmlWriter, 'Element'); - } - } - - if ($pSection == $countSections) { - $this->_writeEndSection($xmlWriter, $section); - } else { - $this->_writeSection($xmlWriter, $section); - } - } - } - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - /** - * Write text - * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\Text $text - * @param bool $withoutP - */ - protected function _writeText(XMLWriter $xmlWriter = null, Text $text, $withoutP = false) - { - $styleFont = $text->getFontStyle(); - $styleParagraph = $text->getParagraphStyle(); - - // @todo Commented for TextRun. Should really checkout this value - // $SfIsObject = ($styleFont instanceof Font) ? true : false; - $SfIsObject = false; - - if ($SfIsObject) { - // Don't never be the case, because I browse all sections for cleaning all styles not declared - die('PhpWord : $SfIsObject wouldn\'t be an object'); - } else { - if (!$withoutP) { - $xmlWriter->startElement('text:p'); // text:p - } - if (empty($styleFont)) { - if (empty($styleParagraph)) { - $xmlWriter->writeAttribute('text:style-name', 'P1'); - } else { - $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); - } - $xmlWriter->writeRaw($text->getText()); - } else { - if (empty($styleParagraph)) { - $xmlWriter->writeAttribute('text:style-name', 'Standard'); - } else { - $xmlWriter->writeAttribute('text:style-name', $text->getParagraphStyle()); - } - // text:span - $xmlWriter->startElement('text:span'); - $xmlWriter->writeAttribute('text:style-name', $styleFont); - $xmlWriter->writeRaw($text->getText()); - $xmlWriter->endElement(); - } - if (!$withoutP) { - $xmlWriter->endElement(); // text:p - } - } - } - - /** - * Write TextRun section - * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\TextRun $textrun - * @todo Enable all other section types - */ - protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) - { - $elements = $textrun->getElements(); - $xmlWriter->startElement('text:p'); - if (count($elements) > 0) { - foreach ($elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element, true); - } - } - } - $xmlWriter->endElement(); - } - - /** - * Write TextBreak - */ - protected function _writeTextBreak(XMLWriter $xmlWriter = null) - { - $xmlWriter->startElement('text:p'); - $xmlWriter->writeAttribute('text:style-name', 'Standard'); - $xmlWriter->endElement(); - } - - // @codeCoverageIgnoreStart - private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null) - { - } - - private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null) - { - } - // @codeCoverageIgnoreEnd - - /** - * Write unsupported element - * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param string $element - */ - private function writeUnsupportedElement($xmlWriter, $element) - { - $xmlWriter->startElement('text:p'); - $xmlWriter->writeRaw($element); - $xmlWriter->endElement(); - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Writer/ODText/Manifest.php b/Classes/PhpWord/Writer/ODText/Manifest.php deleted file mode 100644 index 1169249d..00000000 --- a/Classes/PhpWord/Writer/ODText/Manifest.php +++ /dev/null @@ -1,132 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8'); - - // manifest:manifest - $xmlWriter->startElement('manifest:manifest'); - $xmlWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'); - $xmlWriter->writeAttribute('manifest:version', '1.2'); - - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text'); - $xmlWriter->writeAttribute('manifest:version', '1.2'); - $xmlWriter->writeAttribute('manifest:full-path', '/'); - $xmlWriter->endElement(); - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); - $xmlWriter->writeAttribute('manifest:full-path', 'content.xml'); - $xmlWriter->endElement(); - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); - $xmlWriter->writeAttribute('manifest:full-path', 'meta.xml'); - $xmlWriter->endElement(); - // manifest:file-entry - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', 'text/xml'); - $xmlWriter->writeAttribute('manifest:full-path', 'styles.xml'); - $xmlWriter->endElement(); - - // Not used yet. Legacy from PHPExcel - // @codeCoverageIgnoreStart - for ($i = 0; $i < $this->getParentWriter()->getDrawingHashTable()->count(); ++$i) { - if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_Drawing) { - $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension()); - $mimeType = $this->_getImageMimeType($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath()); - - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', $mimeType); - $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); - $xmlWriter->endElement(); - } elseif ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPWord_Shape_MemoryDrawing) { - $extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType()); - $extension = explode('/', $extension); - $extension = $extension[1]; - - $mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType(); - - $xmlWriter->startElement('manifest:file-entry'); - $xmlWriter->writeAttribute('manifest:media-type', $mimeType); - $xmlWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename())); - $xmlWriter->endElement(); - } - } - // @codeCoverageIgnoreEnd - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - - /** - * Get image mime type - * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception - */ - private function _getImageMimeType($pFile = '') - { - if (File::file_exists($pFile)) { - $image = getimagesize($pFile); - return image_type_to_mime_type($image[2]); - } else { - throw new Exception("File $pFile does not exist"); - } - } -} diff --git a/Classes/PhpWord/Writer/ODText/Meta.php b/Classes/PhpWord/Writer/ODText/Meta.php deleted file mode 100644 index 135f2ff7..00000000 --- a/Classes/PhpWord/Writer/ODText/Meta.php +++ /dev/null @@ -1,96 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8'); - - // office:document-meta - $xmlWriter->startElement('office:document-meta'); - $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); - $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); - $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); - $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); - $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); - $xmlWriter->writeAttribute('office:version', '1.2'); - - // office:meta - $xmlWriter->startElement('office:meta'); - - // dc:creator - $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getLastModifiedBy()); - // dc:date - $xmlWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getModified())); - // dc:description - $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); - // dc:subject - $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); - // dc:title - $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); - // meta:creation-date - $xmlWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $phpWord->getDocumentProperties()->getCreated())); - // meta:initial-creator - $xmlWriter->writeElement('meta:initial-creator', $phpWord->getDocumentProperties()->getCreator()); - // meta:keyword - $xmlWriter->writeElement('meta:keyword', $phpWord->getDocumentProperties()->getKeywords()); - - // @todo : Where these properties are written ? - // $phpWord->getDocumentProperties()->getCategory() - // $phpWord->getDocumentProperties()->getCompany() - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/ODText/Mimetype.php b/Classes/PhpWord/Writer/ODText/Mimetype.php deleted file mode 100644 index 570f1855..00000000 --- a/Classes/PhpWord/Writer/ODText/Mimetype.php +++ /dev/null @@ -1,46 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8'); - - // Styles:Styles - $xmlWriter->startElement('office:document-styles'); - $xmlWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); - $xmlWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); - $xmlWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); - $xmlWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); - $xmlWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); - $xmlWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); - $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); - $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $xmlWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); - $xmlWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); - $xmlWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); - $xmlWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); - $xmlWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); - $xmlWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); - $xmlWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); - $xmlWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); - $xmlWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); - $xmlWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); - $xmlWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); - $xmlWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); - $xmlWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); - $xmlWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); - $xmlWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); - $xmlWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); - $xmlWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); - $xmlWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); - $xmlWriter->writeAttribute('office:version', '1.2'); - - - // office:font-face-decls - $xmlWriter->startElement('office:font-face-decls'); - $arrFonts = array(); - $styles = Style::getStyles(); - $numFonts = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - $numFonts++; - $name = $style->getName(); - if (!in_array($name, $arrFonts)) { - $arrFonts[] = $name; - - // style:font-face - $xmlWriter->startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', $name); - $xmlWriter->writeAttribute('svg:font-family', $name); - $xmlWriter->endElement(); - } - } - } - } - if (!in_array(PhpWord::DEFAULT_FONT_NAME, $arrFonts)) { - $xmlWriter->startElement('style:font-face'); - $xmlWriter->writeAttribute('style:name', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->writeAttribute('svg:font-family', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - - // office:styles - $xmlWriter->startElement('office:styles'); - - // style:default-style - $xmlWriter->startElement('style:default-style'); - $xmlWriter->writeAttribute('style:family', 'paragraph'); - - // style:paragraph-properties - $xmlWriter->startElement('style:paragraph-properties'); - $xmlWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit'); - $xmlWriter->writeAttribute('style:text-autospace', 'ideograph-alpha'); - $xmlWriter->writeAttribute('style:punctuation-wrap', 'hanging'); - $xmlWriter->writeAttribute('style:line-break', 'strict'); - $xmlWriter->writeAttribute('style:tab-stop-distance', '1.249cm'); - $xmlWriter->writeAttribute('style:writing-mode', 'page'); - $xmlWriter->endElement(); - - // style:text-properties - $xmlWriter->startElement('style:text-properties'); - $xmlWriter->writeAttribute('style:use-window-font-color', 'true'); - $xmlWriter->writeAttribute('style:font-name', PhpWord::DEFAULT_FONT_NAME); - $xmlWriter->writeAttribute('fo:font-size', PhpWord::DEFAULT_FONT_SIZE . 'pt'); - $xmlWriter->writeAttribute('fo:language', 'fr'); - $xmlWriter->writeAttribute('fo:country', 'FR'); - $xmlWriter->writeAttribute('style:letter-kerning', 'true'); - $xmlWriter->writeAttribute('style:font-name-asian', PhpWord::DEFAULT_FONT_NAME . '2'); - $xmlWriter->writeAttribute('style:font-size-asian', PhpWord::DEFAULT_FONT_SIZE . 'pt'); - $xmlWriter->writeAttribute('style:language-asian', 'zh'); - $xmlWriter->writeAttribute('style:country-asian', 'CN'); - $xmlWriter->writeAttribute('style:font-name-complex', PhpWord::DEFAULT_FONT_NAME . '2'); - $xmlWriter->writeAttribute('style:font-size-complex', PhpWord::DEFAULT_FONT_SIZE . 'pt'); - $xmlWriter->writeAttribute('style:language-complex', 'hi'); - $xmlWriter->writeAttribute('style:country-complex', 'IN'); - $xmlWriter->writeAttribute('fo:hyphenate', 'false'); - $xmlWriter->writeAttribute('fo:hyphenation-remain-char-count', '2'); - $xmlWriter->writeAttribute('fo:hyphenation-push-char-count', '2'); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // Write Style Definitions - $styles = Style::getStyles(); - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - if (preg_match('#^T[0-9]+$#', $styleName) == 0 - && preg_match('#^P[0-9]+$#', $styleName) == 0 - ) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - // style:style - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', $styleName); - $xmlWriter->writeAttribute('style:family', 'text'); - - // style:text-properties - $xmlWriter->startElement('style:text-properties'); - $xmlWriter->writeAttribute('fo:font-size', ($style->getSize()) . 'pt'); - $xmlWriter->writeAttribute('style:font-size-asian', ($style->getSize()) . 'pt'); - $xmlWriter->writeAttribute('style:font-size-complex', ($style->getSize()) . 'pt'); - if ($style->getItalic()) { - $xmlWriter->writeAttribute('fo:font-style', 'italic'); - $xmlWriter->writeAttribute('style:font-style-asian', 'italic'); - $xmlWriter->writeAttribute('style:font-style-complex', 'italic'); - } - if ($style->getBold()) { - $xmlWriter->writeAttribute('fo:font-weight', 'bold'); - $xmlWriter->writeAttribute('style:font-weight-asian', 'bold'); - } - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } elseif ($style instanceof Paragraph) { - // PhpOffice\PhpWord\Style\Paragraph - // style:style - $xmlWriter->startElement('style:style'); - $xmlWriter->writeAttribute('style:name', $styleName); - $xmlWriter->writeAttribute('style:family', 'paragraph'); - - //style:paragraph-properties - $xmlWriter->startElement('style:paragraph-properties'); - $xmlWriter->writeAttribute('fo:margin-top', ((is_null($style->getSpaceBefore())) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)) . 'cm'); - $xmlWriter->writeAttribute('fo:margin-bottom', ((is_null($style->getSpaceAfter())) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)) . 'cm'); - $xmlWriter->writeAttribute('fo:text-align', $style->getAlign()); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - } elseif ($style instanceof TableFull) { - // PhpOffice\PhpWord\Style\TableFull - } - } - } - } - $xmlWriter->endElement(); - - // office:automatic-styles - $xmlWriter->startElement('office:automatic-styles'); - // style:page-layout - $xmlWriter->startElement('style:page-layout'); - $xmlWriter->writeAttribute('style:name', 'Mpm1'); - // style:page-layout-properties - $xmlWriter->startElement('style:page-layout-properties'); - $xmlWriter->writeAttribute('fo:page-width', "21.001cm"); - $xmlWriter->writeAttribute('fo:page-height', '29.7cm'); - $xmlWriter->writeAttribute('style:num-format', '1'); - $xmlWriter->writeAttribute('style:print-orientation', 'portrait'); - $xmlWriter->writeAttribute('fo:margin-top', '2.501cm'); - $xmlWriter->writeAttribute('fo:margin-bottom', '2cm'); - $xmlWriter->writeAttribute('fo:margin-left', '2.501cm'); - $xmlWriter->writeAttribute('fo:margin-right', '2.501cm'); - $xmlWriter->writeAttribute('style:writing-mode', 'lr-tb'); - $xmlWriter->writeAttribute('style:layout-grid-color', '#c0c0c0'); - $xmlWriter->writeAttribute('style:layout-grid-lines', '25199'); - $xmlWriter->writeAttribute('style:layout-grid-base-height', '0.423cm'); - $xmlWriter->writeAttribute('style:layout-grid-ruby-height', '0cm'); - $xmlWriter->writeAttribute('style:layout-grid-mode', 'none'); - $xmlWriter->writeAttribute('style:layout-grid-ruby-below', 'false'); - $xmlWriter->writeAttribute('style:layout-grid-print', 'false'); - $xmlWriter->writeAttribute('style:layout-grid-display', 'false'); - $xmlWriter->writeAttribute('style:layout-grid-base-width', '0.37cm'); - $xmlWriter->writeAttribute('style:layout-grid-snap-to', 'true'); - $xmlWriter->writeAttribute('style:footnote-max-height', '0cm'); - //style:footnote-sep - $xmlWriter->startElement('style:footnote-sep'); - $xmlWriter->writeAttribute('style:width', '0.018cm'); - $xmlWriter->writeAttribute('style:line-style', 'solid'); - $xmlWriter->writeAttribute('style:adjustment', 'left'); - $xmlWriter->writeAttribute('style:rel-width', '25%'); - $xmlWriter->writeAttribute('style:color', '#000000'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - // style:header-style - $xmlWriter->startElement('style:header-style'); - $xmlWriter->endElement(); - // style:footer-style - $xmlWriter->startElement('style:footer-style'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - // office:master-styles - $xmlWriter->startElement('office:master-styles'); - // style:master-page - $xmlWriter->startElement('style:master-page'); - $xmlWriter->writeAttribute('style:name', 'Standard'); - $xmlWriter->writeAttribute('style:page-layout-name', 'Mpm1'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/ODText/WriterPart.php b/Classes/PhpWord/Writer/ODText/WriterPart.php deleted file mode 100644 index 06e4a404..00000000 --- a/Classes/PhpWord/Writer/ODText/WriterPart.php +++ /dev/null @@ -1,66 +0,0 @@ -_parentWriter = $pWriter; - } - - /** - * Get parent IWriter object - * - * @return PhpOffice\PhpWord\Writer\IWriter - * @throws Exception - */ - public function getParentWriter() - { - if (!is_null($this->_parentWriter)) { - return $this->_parentWriter; - } else { - throw new Exception("No parent IWriter assigned."); - } - } -} diff --git a/Classes/PhpWord/Writer/RTF.php b/Classes/PhpWord/Writer/RTF.php deleted file mode 100644 index c4dabe96..00000000 --- a/Classes/PhpWord/Writer/RTF.php +++ /dev/null @@ -1,482 +0,0 @@ -setPhpWord($phpWord); - - // Set HashTable variables - $this->_drawingHashTable = new HashTable(); - } - - /** - * Save PhpWord to file - * - * @param string $pFileName - * @throws \Exception - */ - public function save($pFilename = null) - { - if (!is_null($this->_document)) { - // 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; - } - } - - $hFile = fopen($pFilename, 'w') or die("can't open file"); - fwrite($hFile, $this->getData()); - fclose($hFile); - - // 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("PhpWord object unassigned."); - } - } - - /** - * @return PhpOffice\PhpWord - * @throws \Exception - */ - public function getPhpWord() - { - if (!is_null($this->_document)) { - return $this->_document; - } else { - throw new \Exception("No PhpWord assigned."); - } - } - - /** - * @param PhpOffice\PhpWord $phpWord - * @throws \Exception - * @return PhpOffice\PhpWord\Writer\RTF - */ - public function setPhpWord(PhpWord $phpWord = null) - { - $this->_document = $phpWord; - return $this; - } - - /** - * Get PHPWord_Worksheet_BaseDrawing HashTable - * - * @return PhpOffice\PhpWord\HashTable - */ - public function getDrawingHashTable() - { - return $this->_drawingHashTable; - } - - private function getData() - { - // PhpWord object : $this->_document - $this->_fontTable = $this->getDataFont(); - $this->_colorTable = $this->getDataColor(); - - $sRTFContent = '{\rtf1'; - // Set the default character set - $sRTFContent .= '\ansi\ansicpg1252'; - // Set the default font (the first one) - $sRTFContent .= '\deff0'; - // Set the default tab size (720 twips) - $sRTFContent .= '\deftab720'; - $sRTFContent .= PHP_EOL; - // Set the font tbl group - $sRTFContent .= '{\fonttbl'; - foreach ($this->_fontTable as $idx => $font) { - $sRTFContent .= '{\f' . $idx . '\fnil\fcharset0 ' . $font . ';}'; - } - $sRTFContent .= '}' . PHP_EOL; - // Set the color tbl group - $sRTFContent .= '{\colortbl '; - foreach ($this->_colorTable as $idx => $color) { - $arrColor = Drawing::htmlToRGB($color); - $sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; - } - $sRTFContent .= ';}' . PHP_EOL; - // Set the generator - $sRTFContent .= '{\*\generator PhpWord;}' . PHP_EOL; - // Set the view mode of the document - $sRTFContent .= '\viewkind4'; - // Set the numberof bytes that follows a unicode character - $sRTFContent .= '\uc1'; - // Resets to default paragraph properties. - $sRTFContent .= '\pard'; - // No widow/orphan control - $sRTFContent .= '\nowidctlpar'; - // Applies a language to a text run (1036 : French (France)) - $sRTFContent .= '\lang1036'; - // Point size (in half-points) above which to kern character pairs - $sRTFContent .= '\kerning1'; - // Set the font size in half-points - $sRTFContent .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); - $sRTFContent .= PHP_EOL; - // Body - $sRTFContent .= $this->getDataContent(); - - - $sRTFContent .= '}'; - - return $sRTFContent; - } - - private function getDataFont() - { - $phpWord = $this->_document; - - $arrFonts = array(); - // Default font : PhpWord::DEFAULT_FONT_NAME - $arrFonts[] = PhpWord::DEFAULT_FONT_NAME; - // PhpWord object : $this->_document - - // Browse styles - $styles = Style::getStyles(); - $numPStyles = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - // PhpOffice\PhpWord\Style\Font - if ($style instanceof Font) { - if (in_array($style->getName(), $arrFonts) == false) { - $arrFonts[] = $style->getName(); - } - } - } - } - - // Search all fonts used - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - if ($countSections > 0) { - $pSection = 0; - - foreach ($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $fStyle = $element->getFontStyle(); - - if ($fStyle instanceof Font) { - if (in_array($fStyle->getName(), $arrFonts) == false) { - $arrFonts[] = $fStyle->getName(); - } - } - } - } - } - } - - return $arrFonts; - } - - private function getDataColor() - { - $phpWord = $this->_document; - - $arrColors = array(); - // PhpWord object : $this->_document - - // Browse styles - $styles = Style::getStyles(); - $numPStyles = 0; - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - // Font - if ($style instanceof Font) { - $color = $style->getColor(); - $fgcolor = $style->getFgColor(); - if (in_array($color, $arrColors) == false && $color != PhpWord::DEFAULT_FONT_COLOR && !empty($color)) { - $arrColors[] = $color; - } - if (in_array($fgcolor, $arrColors) == false && $fgcolor != PhpWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) { - $arrColors[] = $fgcolor; - } - } - } - } - - // Search all fonts used - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - if ($countSections > 0) { - $pSection = 0; - - foreach ($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $fStyle = $element->getFontStyle(); - - if ($fStyle instanceof Font) { - if (in_array($fStyle->getColor(), $arrColors) == false) { - $arrColors[] = $fStyle->getColor(); - } - if (in_array($fStyle->getFgColor(), $arrColors) == false) { - $arrColors[] = $fStyle->getFgColor(); - } - } - } - } - } - } - - return $arrColors; - } - - private function getDataContent() - { - $phpWord = $this->_document; - $sRTFBody = ''; - - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if ($countSections > 0) { - foreach ($_sections as $section) { - $pSection++; - $_elements = $section->getElements(); - foreach ($_elements as $element) { - if ($element instanceof Text) { - $sRTFBody .= $this->getDataContentText($element); - } elseif ($element instanceof TextBreak) { - $sRTFBody .= $this->getDataContentTextBreak(); - } elseif ($element instanceof TextRun) { - $sRTFBody .= $this->getDataContentTextRun($element); - } elseif ($element instanceof Link) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Link'); - } elseif ($element instanceof Title) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Title'); - } elseif ($element instanceof PageBreak) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Page Break'); - } elseif ($element instanceof Table) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Table'); - } elseif ($element instanceof ListItem) { - $sRTFBody .= $this->getDataContentUnsupportedElement('List Item'); - } elseif ($element instanceof Image || - $element instanceof MemoryImage) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Image'); - } elseif ($element instanceof Object) { - $sRTFBody .= $this->getDataContentUnsupportedElement('Object'); - } elseif ($element instanceof TOC) { - $sRTFBody .= $this->getDataContentUnsupportedElement('TOC'); - } else { - $sRTFBody .= $this->getDataContentUnsupportedElement('Other'); - } - } - } - } - return $sRTFBody; - } - - private function getDataContentText(Text $text, $withoutP = false) - { - $sRTFText = ''; - - $styleFont = $text->getFontStyle(); - $SfIsObject = ($styleFont instanceof Font) ? true : false; - if (!$SfIsObject) { - $styleFont = Style::getStyle($styleFont); - } - - $styleParagraph = $text->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - if (!$SpIsObject) { - $styleParagraph = Style::getStyle($styleParagraph); - } - - if ($styleParagraph && !$withoutP) { - if ($this->_lastParagraphStyle != $text->getParagraphStyle()) { - $sRTFText .= '\pard\nowidctlpar'; - if ($styleParagraph->getSpaceAfter() != null) { - $sRTFText .= '\sa' . $styleParagraph->getSpaceAfter(); - } - if ($styleParagraph->getAlign() != null) { - if ($styleParagraph->getAlign() == 'center') { - $sRTFText .= '\qc'; - } - } - $this->_lastParagraphStyle = $text->getParagraphStyle(); - } else { - $this->_lastParagraphStyle = ''; - } - } else { - $this->_lastParagraphStyle = ''; - } - - if ($styleFont instanceof Font) { - if ($styleFont->getColor() != null) { - $idxColor = array_search($styleFont->getColor(), $this->_colorTable); - if ($idxColor !== false) { - $sRTFText .= '\cf' . ($idxColor + 1); - } - } else { - $sRTFText .= '\cf0'; - } - if ($styleFont->getName() != null) { - $idxFont = array_search($styleFont->getName(), $this->_fontTable); - if ($idxFont !== false) { - $sRTFText .= '\f' . $idxFont; - } - } else { - $sRTFText .= '\f0'; - } - if ($styleFont->getBold()) { - $sRTFText .= '\b'; - } - if ($styleFont->getBold()) { - $sRTFText .= '\i'; - } - if ($styleFont->getSize()) { - $sRTFText .= '\fs' . ($styleFont->getSize() * 2); - } - } - if ($this->_lastParagraphStyle != '' || $styleFont) { - $sRTFText .= ' '; - } - $sRTFText .= $text->getText(); - - if ($styleFont instanceof Font) { - $sRTFText .= '\cf0'; - $sRTFText .= '\f0'; - - if ($styleFont->getBold()) { - $sRTFText .= '\b0'; - } - if ($styleFont->getItalic()) { - $sRTFText .= '\i0'; - } - if ($styleFont->getSize()) { - $sRTFText .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); - } - } - - if (!$withoutP) { - $sRTFText .= '\par' . PHP_EOL; - } - return $sRTFText; - } - - private function getDataContentTextRun(TextRun $textrun) - { - $sRTFText = ''; - $elements = $textrun->getElements(); - if (count($elements) > 0) { - $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; - foreach ($elements as $element) { - if ($element instanceof Text) { - $sRTFText .= '{'; - $sRTFText .= $this->getDataContentText($element, true); - $sRTFText .= '}' . PHP_EOL; - } - } - $sRTFText .= '\par' . PHP_EOL; - } - return $sRTFText; - } - - private function getDataContentTextBreak() - { - $this->_lastParagraphStyle = ''; - - return '\par' . PHP_EOL; - } - - /** - * Write unsupported element - * - * @param string $element - */ - private function getDataContentUnsupportedElement($element) - { - $sRTFText = ''; - $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; - $sRTFText .= "{$element}"; - $sRTFText .= '\par' . PHP_EOL; - - return $sRTFText; - } -} \ No newline at end of file diff --git a/Classes/PhpWord/Writer/Word2007.php b/Classes/PhpWord/Writer/Word2007.php deleted file mode 100644 index 7e356d97..00000000 --- a/Classes/PhpWord/Writer/Word2007.php +++ /dev/null @@ -1,301 +0,0 @@ -_document = $phpWord; - - $this->_diskCachingDirectory = './'; - - $this->_writerParts['contenttypes'] = new ContentTypes(); - $this->_writerParts['rels'] = new Rels(); - $this->_writerParts['docprops'] = new DocProps(); - $this->_writerParts['documentrels'] = new DocumentRels(); - $this->_writerParts['document'] = new Document(); - $this->_writerParts['styles'] = new Styles(); - $this->_writerParts['header'] = new Header(); - $this->_writerParts['footer'] = new Footer(); - $this->_writerParts['footnotes'] = new Footnotes(); - $this->_writerParts['footnotesrels'] = new FootnotesRels(); - - foreach ($this->_writerParts as $writer) { - $writer->setParentWriter($this); - } - } - - public function save($pFilename = null) - { - if (!is_null($this->_document)) { - - // 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 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."); - } - } - - - $sectionElements = array(); - $_secElements = Media::getSectionMediaElements(); - foreach ($_secElements as $element) { // loop through section media elements - if ($element['type'] != 'hyperlink') { - $this->_addFileToPackage($objZip, $element); - } - $sectionElements[] = $element; - } - - $_hdrElements = Media::getHeaderMediaElements(); - foreach ($_hdrElements as $_headerFile => $_hdrMedia) { // loop through headers - if (count($_hdrMedia) > 0) { - $objZip->addFromString('word/_rels/' . $_headerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_hdrMedia)); - foreach ($_hdrMedia as $element) { // loop through header media elements - $this->_addFileToPackage($objZip, $element); - } - } - } - - $_ftrElements = Media::getFooterMediaElements(); - foreach ($_ftrElements as $_footerFile => $_ftrMedia) { // loop through footers - if (count($_ftrMedia) > 0) { - $objZip->addFromString('word/_rels/' . $_footerFile . '.xml.rels', $this->getWriterPart('documentrels')->writeHeaderFooterRels($_ftrMedia)); - foreach ($_ftrMedia as $element) { // loop through footers media elements - $this->_addFileToPackage($objZip, $element); - } - } - } - - $footnoteLinks = array(); - $_footnoteElements = Footnote::getFootnoteLinkElements(); - // loop through footnote link elements - foreach ($_footnoteElements as $element) { - $footnoteLinks[] = $element; - } - - $_cHdrs = 0; - $_cFtrs = 0; - $rID = Media::countSectionMediaElements() + 6; - $_sections = $this->_document->getSections(); - - $footers = array(); - foreach ($_sections as $section) { - $_headers = $section->getHeaders(); - foreach ($_headers as $index => &$_header) { - $_cHdrs++; - $_header->setRelationId(++$rID); - $_headerFile = 'header' . $_cHdrs . '.xml'; - $sectionElements[] = array('target' => $_headerFile, 'type' => 'header', 'rID' => $rID); - $objZip->addFromString('word/' . $_headerFile, $this->getWriterPart('header')->writeHeader($_header)); - } - - $_footer = $section->getFooter(); - $footers[++$_cFtrs] = $_footer; - if (!is_null($_footer)) { - $_footer->setRelationId(++$rID); - $_footerCount = $_footer->getFooterCount(); - $_footerFile = 'footer' . $_footerCount . '.xml'; - $sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID); - $objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer)); - } - } - - if (Footnote::countFootnoteElements() > 0) { - $_allFootnotesCollection = Footnote::getFootnoteElements(); - $_footnoteFile = 'footnotes.xml'; - $sectionElements[] = array('target'=>$_footnoteFile, 'type'=>'footnotes', 'rID'=>++$rID); - $objZip->addFromString('word/'.$_footnoteFile, $this->getWriterPart('footnotes')->writeFootnotes($_allFootnotesCollection)); - if (count($footnoteLinks) > 0) { - $objZip->addFromString('word/_rels/footnotes.xml.rels', $this->getWriterPart('footnotesrels')->writeFootnotesRels($footnoteLinks)); - } - } - - // build docx file - // Write dynamic files - $objZip->addFromString( - '[Content_Types].xml', - $this->getWriterPart('contenttypes')->writeContentTypes( - $this->_imageTypes, - $this->_objectTypes, - $_cHdrs, - $footers - ) - ); - $objZip->addFromString('_rels/.rels', $this->getWriterPart('rels')->writeRelationships($this->_document)); - $objZip->addFromString('docProps/app.xml', $this->getWriterPart('docprops')->writeDocPropsApp($this->_document)); - $objZip->addFromString('docProps/core.xml', $this->getWriterPart('docprops')->writeDocPropsCore($this->_document)); - $objZip->addFromString('word/document.xml', $this->getWriterPart('document')->writeDocument($this->_document)); - $objZip->addFromString('word/_rels/document.xml.rels', $this->getWriterPart('documentrels')->writeDocumentRels($sectionElements)); - $objZip->addFromString('word/styles.xml', $this->getWriterPart('styles')->writeStyles($this->_document)); - - // Write static files - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/numbering.xml', 'word/numbering.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/settings.xml', 'word/settings.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/theme1.xml', 'word/theme/theme1.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/webSettings.xml', 'word/webSettings.xml'); - $objZip->addFile(PHPWORD_BASE_PATH . 'PhpWord/_staticDocParts/fontTable.xml', 'word/fontTable.xml'); - - - // 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("PhpWord object unassigned."); - } - } - - /** - * @param string $src - */ - private function checkContentTypes($src) - { - $extension = null; - if (stripos(strrev($src), strrev('.php')) === 0) { - $extension = 'php'; - } else { - $imageType = exif_imagetype($src); - if ($imageType === IMAGETYPE_JPEG) { - $extension = 'jpg'; - } elseif ($imageType === IMAGETYPE_GIF) { - $extension = 'gif'; - } elseif ($imageType === IMAGETYPE_PNG) { - $extension = 'png'; - } elseif ($imageType === IMAGETYPE_BMP) { - $extension = 'bmp'; - } elseif ($imageType === IMAGETYPE_TIFF_II || $imageType === IMAGETYPE_TIFF_MM) { - $extension = 'tif'; - } - } - - if (isset($extension)) { - $imageData = getimagesize($src); - $imageType = image_type_to_mime_type($imageData[2]); - $imageExtension = str_replace('.', '', image_type_to_extension($imageData[2])); - if ($imageExtension === 'jpeg') { - $imageExtension = 'jpg'; - } - if (!in_array($imageType, $this->_imageTypes)) { - $this->_imageTypes[$imageExtension] = $imageType; - } - } else { - if (!in_array($extension, $this->_objectTypes)) { - $this->_objectTypes[] = $extension; - } - } - } - - public function getWriterPart($pPartName = '') - { - if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { - return $this->_writerParts[strtolower($pPartName)]; - } else { - return null; - } - } - - public function getUseDiskCaching() - { - return $this->_useDiskCaching; - } - - 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"); - } - } - - return $this; - } - - private function _addFileToPackage($objZip, $element) - { - if (isset($element['isMemImage']) && $element['isMemImage']) { - $image = call_user_func($element['createfunction'], $element['source']); - ob_start(); - call_user_func($element['imagefunction'], $image); - $imageContents = ob_get_contents(); - ob_end_clean(); - $objZip->addFromString('word/' . $element['target'], $imageContents); - imagedestroy($image); - - $this->checkContentTypes($element['source']); - } else { - $objZip->addFile($element['source'], 'word/' . $element['target']); - $this->checkContentTypes($element['source']); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Base.php b/Classes/PhpWord/Writer/Word2007/Base.php deleted file mode 100644 index 902e8e49..00000000 --- a/Classes/PhpWord/Writer/Word2007/Base.php +++ /dev/null @@ -1,1003 +0,0 @@ -getFontStyle(); - - $SfIsObject = ($styleFont instanceof Font) ? true : false; - - if (!$withoutP) { - $xmlWriter->startElement('w:p'); - - $styleParagraph = $text->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - $strText = htmlspecialchars($text->getText()); - $strText = String::ControlCharacterPHP2OOXML($strText); - - $xmlWriter->startElement('w:r'); - - if ($SfIsObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } elseif (!$SfIsObject && !is_null($styleFont)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:t'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text - $xmlWriter->writeRaw($strText); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); // w:r - - if (!$withoutP) { - $xmlWriter->endElement(); // w:p - } - } - - protected function _writeTextRun(XMLWriter $xmlWriter = null, TextRun $textrun) - { - $elements = $textrun->getElements(); - $styleParagraph = $textrun->getParagraphStyle(); - - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - $xmlWriter->startElement('w:p'); - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - if (count($elements) > 0) { - foreach ($elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element, true); - } elseif ($element instanceof Link) { - $this->_writeLink($xmlWriter, $element, true); - } elseif ($element instanceof Image) { - $this->_writeImage($xmlWriter, $element, true); - } elseif ($element instanceof Footnote) { - $this->_writeFootnoteReference($xmlWriter, $element, true); - } elseif ($element instanceof TextBreak) { - $xmlWriter->writeElement('w:br'); - } - } - } - - $xmlWriter->endElement(); - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Style\Paragraph $style - * @param bool $withoutPPR - * @return void - */ - protected function _writeParagraphStyle( - XMLWriter $xmlWriter = null, - Paragraph $style, - $withoutPPR = false - ) { - - $align = $style->getAlign(); - $spacing = $style->getSpacing(); - $spaceBefore = $style->getSpaceBefore(); - $spaceAfter = $style->getSpaceAfter(); - $indent = $style->getIndent(); - $hanging = $style->getHanging(); - $tabs = $style->getTabs(); - $widowControl = $style->getWidowControl(); - $keepNext = $style->getKeepNext(); - $keepLines = $style->getKeepLines(); - $pageBreakBefore = $style->getPageBreakBefore(); - - if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || - !is_null($spaceAfter) || !is_null($indent) || !is_null($hanging) || - !is_null($tabs) || !is_null($widowControl) || !is_null($keepNext) || - !is_null($keepLines) || !is_null($pageBreakBefore)) { - if (!$withoutPPR) { - $xmlWriter->startElement('w:pPr'); - } - - // Alignment - if (!is_null($align)) { - $xmlWriter->startElement('w:jc'); - $xmlWriter->writeAttribute('w:val', $align); - $xmlWriter->endElement(); - } - - // Indentation - if (!is_null($indent) || !is_null($hanging)) { - $xmlWriter->startElement('w:ind'); - $xmlWriter->writeAttribute('w:firstLine', 0); - if (!is_null($indent)) { - $xmlWriter->writeAttribute('w:left', $indent); - } - if (!is_null($hanging)) { - $xmlWriter->writeAttribute('w:hanging', $hanging); - } - $xmlWriter->endElement(); - } - - // Spacing - if (!is_null($spaceBefore) || !is_null($spaceAfter) || - !is_null($spacing)) { - $xmlWriter->startElement('w:spacing'); - if (!is_null($spaceBefore)) { - $xmlWriter->writeAttribute('w:before', $spaceBefore); - } - if (!is_null($spaceAfter)) { - $xmlWriter->writeAttribute('w:after', $spaceAfter); - } - if (!is_null($spacing)) { - $xmlWriter->writeAttribute('w:line', $spacing); - $xmlWriter->writeAttribute('w:lineRule', 'auto'); - } - $xmlWriter->endElement(); - } - - // Pagination - if (!$widowControl) { - $xmlWriter->startElement('w:widowControl'); - $xmlWriter->writeAttribute('w:val', '0'); - $xmlWriter->endElement(); - } - if ($keepNext) { - $xmlWriter->startElement('w:keepNext'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - if ($keepLines) { - $xmlWriter->startElement('w:keepLines'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - if ($pageBreakBefore) { - $xmlWriter->startElement('w:pageBreakBefore'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - - // Tabs - if (!is_null($tabs)) { - $tabs->toXml($xmlWriter); - } - - if (!$withoutPPR) { - $xmlWriter->endElement(); // w:pPr - } - } - } - - protected function _writeLink(XMLWriter $xmlWriter = null, Link $link, $withoutP = false) - { - $rID = $link->getRelationId(); - $linkName = $link->getLinkName(); - if (is_null($linkName)) { - $linkName = $link->getLinkSrc(); - } - - $styleFont = $link->getFontStyle(); - $SfIsObject = ($styleFont instanceof Font) ? true : false; - - if (!$withoutP) { - $xmlWriter->startElement('w:p'); - - $styleParagraph = $link->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - $xmlWriter->startElement('w:hyperlink'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rID); - $xmlWriter->writeAttribute('w:history', '1'); - - $xmlWriter->startElement('w:r'); - if ($SfIsObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } elseif (!$SfIsObject && !is_null($styleFont)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:t'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); // needed because of drawing spaces before and after text - $xmlWriter->writeRaw($linkName); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - if (!$withoutP) { - $xmlWriter->endElement(); // w:p - } - } - - protected function _writePreserveText(XMLWriter $xmlWriter = null, PreserveText $textrun) - { - $styleFont = $textrun->getFontStyle(); - $styleParagraph = $textrun->getParagraphStyle(); - - $SfIsObject = ($styleFont instanceof Font) ? true : false; - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - $arrText = $textrun->getText(); - if (!is_array($arrText)) { - $arrText = array($arrText); - } - - $xmlWriter->startElement('w:p'); - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - foreach ($arrText as $text) { - - if (substr($text, 0, 1) == '{') { - $text = substr($text, 1, -1); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - - if ($SfIsObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } elseif (!$SfIsObject && !is_null($styleFont)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:instrText'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw($text); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'separate'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'end'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } else { - $text = htmlspecialchars($text); - $text = String::ControlCharacterPHP2OOXML($text); - - $xmlWriter->startElement('w:r'); - - if ($SfIsObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } elseif (!$SfIsObject && !is_null($styleFont)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:t'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw($text); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - $xmlWriter->endElement(); // p - } - - protected function _writeTextStyle(XMLWriter $xmlWriter = null, Font $style) - { - $font = $style->getName(); - $bold = $style->getBold(); - $italic = $style->getItalic(); - $color = $style->getColor(); - $size = $style->getSize(); - $fgColor = $style->getFgColor(); - $strikethrough = $style->getStrikethrough(); - $underline = $style->getUnderline(); - $superscript = $style->getSuperScript(); - $subscript = $style->getSubScript(); - $hint = $style->getHint(); - - $xmlWriter->startElement('w:rPr'); - - // Font - if ($font != PhpWord::DEFAULT_FONT_NAME) { - $xmlWriter->startElement('w:rFonts'); - $xmlWriter->writeAttribute('w:ascii', $font); - $xmlWriter->writeAttribute('w:hAnsi', $font); - $xmlWriter->writeAttribute('w:eastAsia', $font); - $xmlWriter->writeAttribute('w:cs', $font); - //Font Content Type - if ($hint != PhpWord::DEFAULT_FONT_CONTENT_TYPE) { - $xmlWriter->writeAttribute('w:hint', $hint); - } - $xmlWriter->endElement(); - } - - - // Color - if ($color != PhpWord::DEFAULT_FONT_COLOR) { - $xmlWriter->startElement('w:color'); - $xmlWriter->writeAttribute('w:val', $color); - $xmlWriter->endElement(); - } - - // Size - if ($size != PhpWord::DEFAULT_FONT_SIZE) { - $xmlWriter->startElement('w:sz'); - $xmlWriter->writeAttribute('w:val', $size * 2); - $xmlWriter->endElement(); - $xmlWriter->startElement('w:szCs'); - $xmlWriter->writeAttribute('w:val', $size * 2); - $xmlWriter->endElement(); - } - - // Bold - if ($bold) { - $xmlWriter->writeElement('w:b', null); - } - - // Italic - if ($italic) { - $xmlWriter->writeElement('w:i', null); - $xmlWriter->writeElement('w:iCs', null); - } - - // Underline - if (!is_null($underline) && $underline != 'none') { - $xmlWriter->startElement('w:u'); - $xmlWriter->writeAttribute('w:val', $underline); - $xmlWriter->endElement(); - } - - // Strikethrough - if ($strikethrough) { - $xmlWriter->writeElement('w:strike', null); - } - - // Foreground-Color - if (!is_null($fgColor)) { - $xmlWriter->startElement('w:highlight'); - $xmlWriter->writeAttribute('w:val', $fgColor); - $xmlWriter->endElement(); - } - - // Superscript/subscript - if ($superscript || $subscript) { - $xmlWriter->startElement('w:vertAlign'); - $xmlWriter->writeAttribute('w:val', $superscript ? 'superscript' : 'subscript'); - $xmlWriter->endElement(); - } - - $xmlWriter->endElement(); - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\TextBreak $element - */ - protected function _writeTextBreak($xmlWriter, $element = null) - { - $hasStyle = false; - if (!is_null($element)) { - $fontStyle = $element->getFontStyle(); - $sfIsObject = ($fontStyle instanceof Font) ? true : false; - $paragraphStyle = $element->getParagraphStyle(); - $spIsObject = ($paragraphStyle instanceof Paragraph) ? true : false; - $hasStyle = !is_null($fontStyle) || !is_null($paragraphStyle); - } - if ($hasStyle) { - // Paragraph style - $xmlWriter->startElement('w:p'); - if ($spIsObject) { - $this->_writeParagraphStyle($xmlWriter, $paragraphStyle); - } elseif (!$spIsObject && !is_null($paragraphStyle)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $paragraphStyle); - $xmlWriter->endElement(); // w:pStyle - $xmlWriter->endElement(); // w:pPr - } - // Font style - if (!is_null($fontStyle)) { - $xmlWriter->startElement('w:pPr'); - if ($sfIsObject) { - $this->_writeTextStyle($xmlWriter, $fontStyle); - } elseif (!$sfIsObject && !is_null($fontStyle)) { - $xmlWriter->startElement('w:rPr'); - $xmlWriter->startElement('w:rStyle'); - $xmlWriter->writeAttribute('w:val', $fontStyle); - $xmlWriter->endElement(); // w:rStyle - $xmlWriter->endElement(); // w:rPr - } - $xmlWriter->endElement(); // w:pPr - } - $xmlWriter->endElement(); // w:p - } else { - // Null element. No paragraph nor font style - $xmlWriter->writeElement('w:p', null); - } - } - - protected function _writeTable(XMLWriter $xmlWriter = null, Table $table) - { - $_rows = $table->getRows(); - $_cRows = count($_rows); - - if ($_cRows > 0) { - $xmlWriter->startElement('w:tbl'); - $tblStyle = $table->getStyle(); - $tblWidth = $table->getWidth(); - if ($tblStyle instanceof PhpOffice\PhpWord\Style\Table) { - $this->_writeTableStyle($xmlWriter, $tblStyle); - } else { - if (!empty($tblStyle)) { - $xmlWriter->startElement('w:tblPr'); - $xmlWriter->startElement('w:tblStyle'); - $xmlWriter->writeAttribute('w:val', $tblStyle); - $xmlWriter->endElement(); - if (!is_null($tblWidth)) { - $xmlWriter->startElement('w:tblW'); - $xmlWriter->writeAttribute('w:w', $tblWidth); - $xmlWriter->writeAttribute('w:type', 'pct'); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - } - - for ($i = 0; $i < $_cRows; $i++) { - $row = $_rows[$i]; - $height = $row->getHeight(); - $rowStyle = $row->getStyle(); - $tblHeader = $rowStyle->getTblHeader(); - $cantSplit = $rowStyle->getCantSplit(); - - $xmlWriter->startElement('w:tr'); - - if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) { - $xmlWriter->startElement('w:trPr'); - if (!is_null($height)) { - $xmlWriter->startElement('w:trHeight'); - $xmlWriter->writeAttribute('w:val', $height); - $xmlWriter->endElement(); - } - if ($tblHeader) { - $xmlWriter->startElement('w:tblHeader'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - if ($cantSplit) { - $xmlWriter->startElement('w:cantSplit'); - $xmlWriter->writeAttribute('w:val', '1'); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - - foreach ($row->getCells() as $cell) { - $xmlWriter->startElement('w:tc'); - - $cellStyle = $cell->getStyle(); - $width = $cell->getWidth(); - - $xmlWriter->startElement('w:tcPr'); - $xmlWriter->startElement('w:tcW'); - $xmlWriter->writeAttribute('w:w', $width); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - - if ($cellStyle instanceof Cell) { - $this->_writeCellStyle($xmlWriter, $cellStyle); - } - - $xmlWriter->endElement(); - - $_elements = $cell->getElements(); - if (count($_elements) > 0) { - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof Link) { - $this->_writeLink($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter, $element); - } elseif ($element instanceof ListItem) { - $this->_writeListItem($xmlWriter, $element); - } elseif ($element instanceof Image || - $element instanceof MemoryImage - ) { - $this->_writeImage($xmlWriter, $element); - } elseif ($element instanceof Object) { - $this->_writeObject($xmlWriter, $element); - } elseif ($element instanceof PreserveText) { - $this->_writePreserveText($xmlWriter, $element); - } - } - } else { - $this->_writeTextBreak($xmlWriter); - } - - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - } - - protected function _writeTableStyle( - XMLWriter $xmlWriter = null, - PhpOffice\PhpWord\Style\Table $style = null - ) { - $margins = $style->getCellMargin(); - $mTop = (!is_null($margins[0])) ? true : false; - $mLeft = (!is_null($margins[1])) ? true : false; - $mRight = (!is_null($margins[2])) ? true : false; - $mBottom = (!is_null($margins[3])) ? true : false; - - if ($mTop || $mLeft || $mRight || $mBottom) { - $xmlWriter->startElement('w:tblPr'); - $xmlWriter->startElement('w:tblCellMar'); - - if ($mTop) { - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:w', $margins[0]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - - if ($mLeft) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:w', $margins[1]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - - if ($mRight) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:w', $margins[2]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - - if ($mBottom) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:w', $margins[3]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - protected function _writeCellStyle(XMLWriter $xmlWriter = null, Cell $style = null) - { - $bgColor = $style->getBgColor(); - $valign = $style->getVAlign(); - $textDir = $style->getTextDirection(); - $brdSz = $style->getBorderSize(); - $brdCol = $style->getBorderColor(); - - $bTop = (!is_null($brdSz[0])) ? true : false; - $bLeft = (!is_null($brdSz[1])) ? true : false; - $bRight = (!is_null($brdSz[2])) ? true : false; - $bBottom = (!is_null($brdSz[3])) ? true : false; - $borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false; - - $styles = (!is_null($bgColor) || !is_null($valign) || !is_null($textDir) || $borders) ? true : false; - - if ($styles) { - if (!is_null($textDir)) { - $xmlWriter->startElement('w:textDirection'); - $xmlWriter->writeAttribute('w:val', $textDir); - $xmlWriter->endElement(); - } - - if (!is_null($bgColor)) { - $xmlWriter->startElement('w:shd'); - $xmlWriter->writeAttribute('w:val', 'clear'); - $xmlWriter->writeAttribute('w:color', 'auto'); - $xmlWriter->writeAttribute('w:fill', $bgColor); - $xmlWriter->endElement(); - } - - if (!is_null($valign)) { - $xmlWriter->startElement('w:vAlign'); - $xmlWriter->writeAttribute('w:val', $valign); - $xmlWriter->endElement(); - } - - if ($borders) { - $_defaultColor = $style->getDefaultBorderColor(); - - $xmlWriter->startElement('w:tcBorders'); - if ($bTop) { - if (is_null($brdCol[0])) { - $brdCol[0] = $_defaultColor; - } - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[0]); - $xmlWriter->writeAttribute('w:color', $brdCol[0]); - $xmlWriter->endElement(); - } - - if ($bLeft) { - if (is_null($brdCol[1])) { - $brdCol[1] = $_defaultColor; - } - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[1]); - $xmlWriter->writeAttribute('w:color', $brdCol[1]); - $xmlWriter->endElement(); - } - - if ($bRight) { - if (is_null($brdCol[2])) { - $brdCol[2] = $_defaultColor; - } - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[2]); - $xmlWriter->writeAttribute('w:color', $brdCol[2]); - $xmlWriter->endElement(); - } - - if ($bBottom) { - if (is_null($brdCol[3])) { - $brdCol[3] = $_defaultColor; - } - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[3]); - $xmlWriter->writeAttribute('w:color', $brdCol[3]); - $xmlWriter->endElement(); - } - - $xmlWriter->endElement(); - } - } - $gridSpan = $style->getGridSpan(); - if (!is_null($gridSpan)) { - $xmlWriter->startElement('w:gridSpan'); - $xmlWriter->writeAttribute('w:val', $gridSpan); - $xmlWriter->endElement(); - } - - $vMerge = $style->getVMerge(); - if (!is_null($vMerge)) { - $xmlWriter->startElement('w:vMerge'); - $xmlWriter->writeAttribute('w:val', $vMerge); - $xmlWriter->endElement(); - } - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param PhpOffice\PhpWord\Section\Image|PhpOffice\PhpWord\Section\MemoryImage $image - */ - protected function _writeImage(XMLWriter $xmlWriter = null, $image, $withoutP = false) - { - $rId = $image->getRelationId(); - - $style = $image->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $align = $style->getAlign(); - $marginTop = $style->getMarginTop(); - $marginLeft = $style->getMarginLeft(); - $wrappingStyle = $style->getWrappingStyle(); - - if (!$withoutP) { - $xmlWriter->startElement('w:p'); - - if (!is_null($align)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:jc'); - $xmlWriter->writeAttribute('w:val', $align); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - } - - $xmlWriter->startElement('w:r'); - - $xmlWriter->startElement('w:pict'); - - $xmlWriter->startElement('v:shape'); - $xmlWriter->writeAttribute('type', '#_x0000_t75'); - - $imgStyle = ''; - if (null !== $width) { - $imgStyle .= 'width:' . $width . 'px;'; - } - if (null !== $height) { - $imgStyle .= 'height:' . $height . 'px;'; - } - if (null !== $marginTop) { - $imgStyle .= 'margin-top:' . $marginTop . 'in;'; - } - if (null !== $marginLeft) { - $imgStyle .= 'margin-left:' . $marginLeft . 'in;'; - } - - switch ($wrappingStyle) { - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_BEHIND: - $imgStyle .= 'position:absolute;z-index:-251658752;'; - break; - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_SQUARE: - $imgStyle .= 'position:absolute;z-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; - break; - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_TIGHT: - $imgStyle .= 'position:absolute;z-index:251659264;mso-wrap-edited:f;mso-position-horizontal:absolute;mso-position-vertical:absolute'; - break; - case PhpOffice\PhpWord\Style\Image::WRAPPING_STYLE_INFRONT: - $imgStyle .= 'position:absolute;zz-index:251659264;mso-position-horizontal:absolute;mso-position-vertical:absolute;'; - break; - } - - $xmlWriter->writeAttribute('style', $imgStyle); - - $xmlWriter->startElement('v:imagedata'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $xmlWriter->writeAttribute('o:title', ''); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - if (!$withoutP) { - $xmlWriter->endElement(); // w:p - } - } - - protected function _writeWatermark(XMLWriter $xmlWriter = null, $image) - { - $rId = $image->getRelationId(); - - $style = $image->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $marginLeft = $style->getMarginLeft(); - $marginTop = $style->getMarginTop(); - - $xmlWriter->startElement('w:p'); - - $xmlWriter->startElement('w:r'); - - $xmlWriter->startElement('w:pict'); - - $xmlWriter->startElement('v:shape'); - $xmlWriter->writeAttribute('type', '#_x0000_t75'); - - $strStyle = 'position:absolute;'; - $strStyle .= ' width:' . $width . 'px;'; - $strStyle .= ' height:' . $height . 'px;'; - if (!is_null($marginTop)) { - $strStyle .= ' margin-top:' . $marginTop . 'px;'; - } - if (!is_null($marginLeft)) { - $strStyle .= ' margin-left:' . $marginLeft . 'px;'; - } - - $xmlWriter->writeAttribute('style', $strStyle); - - $xmlWriter->startElement('v:imagedata'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $xmlWriter->writeAttribute('o:title', ''); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - } - - protected function _writeTitle(XMLWriter $xmlWriter = null, Title $title) - { - $text = htmlspecialchars($title->getText()); - $text = String::ControlCharacterPHP2OOXML($text); - $anchor = $title->getAnchor(); - $bookmarkId = $title->getBookmarkId(); - $style = $title->getStyle(); - - $xmlWriter->startElement('w:p'); - - if (!empty($style)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $style); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'end'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:bookmarkStart'); - $xmlWriter->writeAttribute('w:id', $bookmarkId); - $xmlWriter->writeAttribute('w:name', $anchor); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:t'); - $xmlWriter->writeRaw($text); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:bookmarkEnd'); - $xmlWriter->writeAttribute('w:id', $bookmarkId); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - } - - protected function _writeFootnote(XMLWriter $xmlWriter = null, Footnote $footnote) - { - $xmlWriter->startElement('w:footnote'); - $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId()); - - $styleParagraph = $footnote->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - $xmlWriter->startElement('w:p'); - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $elements = $footnote->getElements(); - if (count($elements) > 0) { - foreach ($elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element, true); - } elseif ($element instanceof Link) { - $this->_writeLink($xmlWriter, $element, true); - } - } - } - - $xmlWriter->endElement(); // w:p - $xmlWriter->endElement(); // w:footnote - } - - protected function _writeFootnoteReference(XMLWriter $xmlWriter = null, Footnote $footnote, $withoutP = false) - { - if (!$withoutP) { - $xmlWriter->startElement('w:p'); - } - - $xmlWriter->startElement('w:r'); - - $xmlWriter->startElement('w:footnoteReference'); - $xmlWriter->writeAttribute('w:id', $footnote->getReferenceId()); - $xmlWriter->endElement(); // w:footnoteReference - - $xmlWriter->endElement(); // w:r - - if (!$withoutP) { - $xmlWriter->endElement(); // w:p - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/ContentTypes.php b/Classes/PhpWord/Writer/Word2007/ContentTypes.php deleted file mode 100644 index 2d84070d..00000000 --- a/Classes/PhpWord/Writer/Word2007/ContentTypes.php +++ /dev/null @@ -1,228 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Types - $xmlWriter->startElement('Types'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); - - // Rels - $this->_writeDefaultContentType( - $xmlWriter, - 'rels', - 'application/vnd.openxmlformats-package.relationships+xml' - ); - - // XML - $this->_writeDefaultContentType( - $xmlWriter, - 'xml', - 'application/xml' - ); - - // Add media content-types - foreach ($_imageTypes as $key => $value) { - $this->_writeDefaultContentType($xmlWriter, $key, $value); - } - - // Add embedding content-types - if (count($_objectTypes) > 0) { - $this->_writeDefaultContentType( - $xmlWriter, - 'bin', - 'application/vnd.openxmlformats-officedocument.oleObject' - ); - } - - // DocProps - $this->_writeOverrideContentType( - $xmlWriter, - '/docProps/app.xml', - 'application/vnd.openxmlformats-officedocument.extended-properties+xml' - ); - - $this->_writeOverrideContentType( - $xmlWriter, - '/docProps/core.xml', - 'application/vnd.openxmlformats-package.core-properties+xml' - ); - - // Document - $this->_writeOverrideContentType( - $xmlWriter, - '/word/document.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml' - ); - - // Styles - $this->_writeOverrideContentType( - $xmlWriter, - '/word/styles.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml' - ); - - // Numbering - $this->_writeOverrideContentType( - $xmlWriter, - '/word/numbering.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml' - ); - - // Settings - $this->_writeOverrideContentType( - $xmlWriter, - '/word/settings.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml' - ); - - // Theme1 - $this->_writeOverrideContentType( - $xmlWriter, - '/word/theme/theme1.xml', - 'application/vnd.openxmlformats-officedocument.theme+xml' - ); - - // WebSettings - $this->_writeOverrideContentType( - $xmlWriter, - '/word/webSettings.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml' - ); - - // Font Table - $this->_writeOverrideContentType( - $xmlWriter, - '/word/fontTable.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml' - ); - - // Footnotes - $this->_writeOverrideContentType( - $xmlWriter, - '/word/footnotes.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml' - ); - - for ($i = 1; $i <= $_cHdrs; $i++) { - $this->_writeOverrideContentType( - $xmlWriter, - '/word/header' . $i . '.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml' - ); - } - - for ($i = 1; $i <= count($footers); $i++) { - if (!is_null($footers[$i])) { - $this->_writeOverrideContentType( - $xmlWriter, - '/word/footer' . $i . '.xml', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml' - ); - } - } - - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - /** - * Get image mime type - * - * @param string $pFile Filename - * @return string Mime Type - * @throws Exception - */ - private function _getImageMimeType($pFile = '') - { - if (File::file_exists($pFile)) { - $image = getimagesize($pFile); - return image_type_to_mime_type($image[2]); - } else { - throw new Exception("File $pFile does not exist"); - } - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception - */ - private function _writeDefaultContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') - { - if ($pPartname != '' && $pContentType != '') { - // Write content type - $xmlWriter->startElement('Default'); - $xmlWriter->writeAttribute('Extension', $pPartname); - $xmlWriter->writeAttribute('ContentType', $pContentType); - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } - - /** - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param string $pPartname Part name - * @param string $pContentType Content type - * @throws Exception - */ - private function _writeOverrideContentType(XMLWriter $xmlWriter = null, $pPartname = '', $pContentType = '') - { - if ($pPartname != '' && $pContentType != '') { - // Write content type - $xmlWriter->startElement('Override'); - $xmlWriter->writeAttribute('PartName', $pPartname); - $xmlWriter->writeAttribute('ContentType', $pContentType); - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/DocProps.php b/Classes/PhpWord/Writer/Word2007/DocProps.php deleted file mode 100644 index edf397ee..00000000 --- a/Classes/PhpWord/Writer/Word2007/DocProps.php +++ /dev/null @@ -1,186 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Properties - $xmlWriter->startElement('Properties'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); - $xmlWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); - - // Application - $xmlWriter->writeElement('Application', 'Microsoft Office Word'); - - // ScaleCrop - $xmlWriter->writeElement('ScaleCrop', 'false'); - - // HeadingPairs - $xmlWriter->startElement('HeadingPairs'); - - // Vector - $xmlWriter->startElement('vt:vector'); - $xmlWriter->writeAttribute('size', '4'); - $xmlWriter->writeAttribute('baseType', 'variant'); - - // Variant - $xmlWriter->startElement('vt:variant'); - $xmlWriter->writeElement('vt:lpstr', 'Theme'); - $xmlWriter->endElement(); - - // Variant - $xmlWriter->startElement('vt:variant'); - $xmlWriter->writeElement('vt:i4', '1'); - $xmlWriter->endElement(); - - // Variant - $xmlWriter->startElement('vt:variant'); - $xmlWriter->writeElement('vt:lpstr', 'Slide Titles'); - $xmlWriter->endElement(); - - // Variant - $xmlWriter->startElement('vt:variant'); - $xmlWriter->writeElement('vt:i4', '1'); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // TitlesOfParts - $xmlWriter->startElement('TitlesOfParts'); - - // Vector - $xmlWriter->startElement('vt:vector'); - $xmlWriter->writeAttribute('size', '1'); - $xmlWriter->writeAttribute('baseType', 'lpstr'); - - $xmlWriter->writeElement('vt:lpstr', 'Office Theme'); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - // Company - $xmlWriter->writeElement('Company', $phpWord->getDocumentProperties()->getCompany()); - - // LinksUpToDate - $xmlWriter->writeElement('LinksUpToDate', 'false'); - - // SharedDoc - $xmlWriter->writeElement('SharedDoc', 'false'); - - // HyperlinksChanged - $xmlWriter->writeElement('HyperlinksChanged', 'false'); - - // AppVersion - $xmlWriter->writeElement('AppVersion', '12.0000'); - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - - public function writeDocPropsCore(PhpWord $phpWord = null) - { - // Create XML writer - $xmlWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // cp:coreProperties - $xmlWriter->startElement('cp:coreProperties'); - $xmlWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); - $xmlWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); - $xmlWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); - $xmlWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); - $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - - // dc:creator - $xmlWriter->writeElement('dc:creator', $phpWord->getDocumentProperties()->getCreator()); - - // cp:lastModifiedBy - $xmlWriter->writeElement('cp:lastModifiedBy', $phpWord->getDocumentProperties()->getLastModifiedBy()); - - // dcterms:created - $xmlWriter->startElement('dcterms:created'); - $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getCreated())); - $xmlWriter->endElement(); - - // dcterms:modified - $xmlWriter->startElement('dcterms:modified'); - $xmlWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); - $xmlWriter->writeRaw(date(DATE_W3C, $phpWord->getDocumentProperties()->getModified())); - $xmlWriter->endElement(); - - // dc:title - $xmlWriter->writeElement('dc:title', $phpWord->getDocumentProperties()->getTitle()); - - // dc:description - $xmlWriter->writeElement('dc:description', $phpWord->getDocumentProperties()->getDescription()); - - // dc:subject - $xmlWriter->writeElement('dc:subject', $phpWord->getDocumentProperties()->getSubject()); - - // cp:keywords - $xmlWriter->writeElement('cp:keywords', $phpWord->getDocumentProperties()->getKeywords()); - - // cp:category - $xmlWriter->writeElement('cp:category', $phpWord->getDocumentProperties()->getCategory()); - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Document.php b/Classes/PhpWord/Writer/Word2007/Document.php deleted file mode 100644 index f4cd15ea..00000000 --- a/Classes/PhpWord/Writer/Word2007/Document.php +++ /dev/null @@ -1,506 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // w:document - $xmlWriter->startElement('w:document'); - - $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - - $xmlWriter->startElement('w:body'); - - $_sections = $phpWord->getSections(); - $countSections = count($_sections); - $pSection = 0; - - if ($countSections > 0) { - foreach ($_sections as $section) { - $pSection++; - - $_elements = $section->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof Link) { - $this->_writeLink($xmlWriter, $element); - } elseif ($element instanceof Title) { - $this->_writeTitle($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter, $element); - } elseif ($element instanceof PageBreak) { - $this->_writePageBreak($xmlWriter); - } elseif ($element instanceof Table) { - $this->_writeTable($xmlWriter, $element); - } elseif ($element instanceof ListItem) { - $this->_writeListItem($xmlWriter, $element); - } elseif ($element instanceof Image || - $element instanceof MemoryImage - ) { - $this->_writeImage($xmlWriter, $element); - } elseif ($element instanceof Object) { - $this->_writeObject($xmlWriter, $element); - } elseif ($element instanceof TOC) { - $this->_writeTOC($xmlWriter); - } elseif ($element instanceof Footnote) { - $this->_writeFootnoteReference($xmlWriter, $element); - } - } - - if ($pSection == $countSections) { - $this->_writeEndSection($xmlWriter, $section); - } else { - $this->_writeSection($xmlWriter, $section); - } - } - } - - $xmlWriter->endElement(); // End w:body - $xmlWriter->endElement(); // End w:document - - // Return - return $xmlWriter->getData(); - } - - private function _writeSection(XMLWriter $xmlWriter = null, Section $section) - { - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:pPr'); - $this->_writeEndSection($xmlWriter, $section, 3); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section) - { - $settings = $section->getSettings(); - $_headers = $section->getHeaders(); - $_footer = $section->getFooter(); - $pgSzW = $settings->getPageSizeW(); - $pgSzH = $settings->getPageSizeH(); - $orientation = $settings->getOrientation(); - - $marginTop = $settings->getMarginTop(); - $marginLeft = $settings->getMarginLeft(); - $marginRight = $settings->getMarginRight(); - $marginBottom = $settings->getMarginBottom(); - - $headerHeight = $settings->getHeaderHeight(); - $footerHeight = $settings->getFooterHeight(); - - $borders = $settings->getBorderSize(); - - $colsNum = $settings->getColsNum(); - $colsSpace = $settings->getColsSpace(); - $breakType = $settings->getBreakType(); - - $xmlWriter->startElement('w:sectPr'); - - foreach ($_headers as &$_header) { - $rId = $_header->getRelationId(); - $xmlWriter->startElement('w:headerReference'); - $xmlWriter->writeAttribute('w:type', $_header->getType()); - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $xmlWriter->endElement(); - } - - if ($section->hasDifferentFirstPage()) { - $xmlWriter->startElement('w:titlePg'); - $xmlWriter->endElement(); - } - - if (!is_null($breakType)) { - $xmlWriter->startElement('w:type'); - $xmlWriter->writeAttribute('w:val', $breakType); - $xmlWriter->endElement(); - } - - if (!is_null($_footer)) { - $rId = $_footer->getRelationId(); - $xmlWriter->startElement('w:footerReference'); - $xmlWriter->writeAttribute('w:type', 'default'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rId); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:pgSz'); - $xmlWriter->writeAttribute('w:w', $pgSzW); - $xmlWriter->writeAttribute('w:h', $pgSzH); - - if (!is_null($orientation) && strtolower($orientation) != 'portrait') { - $xmlWriter->writeAttribute('w:orient', $orientation); - } - - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:pgMar'); - $xmlWriter->writeAttribute('w:top', $marginTop); - $xmlWriter->writeAttribute('w:right', $marginRight); - $xmlWriter->writeAttribute('w:bottom', $marginBottom); - $xmlWriter->writeAttribute('w:left', $marginLeft); - $xmlWriter->writeAttribute('w:header', $headerHeight); - $xmlWriter->writeAttribute('w:footer', $footerHeight); - $xmlWriter->writeAttribute('w:gutter', '0'); - $xmlWriter->endElement(); - - - if (!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) { - $borderColor = $settings->getBorderColor(); - - $xmlWriter->startElement('w:pgBorders'); - $xmlWriter->writeAttribute('w:offsetFrom', 'page'); - - if (!is_null($borders[0])) { - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $borders[0]); - $xmlWriter->writeAttribute('w:space', '24'); - $xmlWriter->writeAttribute('w:color', $borderColor[0]); - $xmlWriter->endElement(); - } - - if (!is_null($borders[1])) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $borders[1]); - $xmlWriter->writeAttribute('w:space', '24'); - $xmlWriter->writeAttribute('w:color', $borderColor[1]); - $xmlWriter->endElement(); - } - - if (!is_null($borders[2])) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $borders[2]); - $xmlWriter->writeAttribute('w:space', '24'); - $xmlWriter->writeAttribute('w:color', $borderColor[2]); - $xmlWriter->endElement(); - } - - if (!is_null($borders[3])) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $borders[3]); - $xmlWriter->writeAttribute('w:space', '24'); - $xmlWriter->writeAttribute('w:color', $borderColor[3]); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - - // Page numbering - if (null !== $settings->getPageNumberingStart()) { - $xmlWriter->startElement('w:pgNumType'); - $xmlWriter->writeAttribute('w:start', $section->getSettings()->getPageNumberingStart()); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:cols'); - $xmlWriter->writeAttribute('w:num', $colsNum); - $xmlWriter->writeAttribute('w:space', $colsSpace); - $xmlWriter->endElement(); - - - $xmlWriter->endElement(); - } - - private function _writePageBreak(XMLWriter $xmlWriter = null) - { - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:br'); - $xmlWriter->writeAttribute('w:type', 'page'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - public function _writeListItem(XMLWriter $xmlWriter = null, ListItem $listItem) - { - $textObject = $listItem->getTextObject(); - $text = $textObject->getText(); - $styleParagraph = $textObject->getParagraphStyle(); - $SpIsObject = ($styleParagraph instanceof Paragraph) ? true : false; - - $depth = $listItem->getDepth(); - $listType = $listItem->getStyle()->getListType(); - - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:pPr'); - - if ($SpIsObject) { - $this->_writeParagraphStyle($xmlWriter, $styleParagraph, true); - } elseif (!$SpIsObject && !is_null($styleParagraph)) { - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleParagraph); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:numPr'); - - $xmlWriter->startElement('w:ilvl'); - $xmlWriter->writeAttribute('w:val', $depth); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:numId'); - $xmlWriter->writeAttribute('w:val', $listType); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $this->_writeText($xmlWriter, $textObject, true); - - $xmlWriter->endElement(); - } - - protected function _writeObject(XMLWriter $xmlWriter = null, Object $object) - { - $rIdObject = $object->getRelationId(); - $rIdImage = $object->getImageRelationId(); - $shapeId = md5($rIdObject . '_' . $rIdImage); - - $objectId = $object->getObjectId(); - - $style = $object->getStyle(); - $width = $style->getWidth(); - $height = $style->getHeight(); - $align = $style->getAlign(); - - - $xmlWriter->startElement('w:p'); - - if (!is_null($align)) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:jc'); - $xmlWriter->writeAttribute('w:val', $align); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:r'); - - $xmlWriter->startElement('w:object'); - $xmlWriter->writeAttribute('w:dxaOrig', '249'); - $xmlWriter->writeAttribute('w:dyaOrig', '160'); - - $xmlWriter->startElement('v:shape'); - $xmlWriter->writeAttribute('id', $shapeId); - $xmlWriter->writeAttribute('type', '#_x0000_t75'); - $xmlWriter->writeAttribute('style', 'width:104px;height:67px'); - $xmlWriter->writeAttribute('o:ole', ''); - - $xmlWriter->startElement('v:imagedata'); - $xmlWriter->writeAttribute('r:id', 'rId' . $rIdImage); - $xmlWriter->writeAttribute('o:title', ''); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->startElement('o:OLEObject'); - $xmlWriter->writeAttribute('Type', 'Embed'); - $xmlWriter->writeAttribute('ProgID', 'Package'); - $xmlWriter->writeAttribute('ShapeID', $shapeId); - $xmlWriter->writeAttribute('DrawAspect', 'Icon'); - $xmlWriter->writeAttribute('ObjectID', '_' . $objectId); - $xmlWriter->writeAttribute('r:id', 'rId' . $rIdObject); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); // w:r - - $xmlWriter->endElement(); // w:p - } - - private function _writeTOC(XMLWriter $xmlWriter = null) - { - $titles = TOC::getTitles(); - $styleFont = TOC::getStyleFont(); - - $styleTOC = TOC::getStyleTOC(); - $fIndent = $styleTOC->getIndent(); - $tabLeader = $styleTOC->getTabLeader(); - $tabPos = $styleTOC->getTabPos(); - - $isObject = ($styleFont instanceof Font) ? true : false; - - for ($i = 0; $i < count($titles); $i++) { - $title = $titles[$i]; - $indent = ($title['depth'] - 1) * $fIndent; - - $xmlWriter->startElement('w:p'); - - $xmlWriter->startElement('w:pPr'); - - if ($isObject && !is_null($styleFont->getParagraphStyle())) { - $this->_writeParagraphStyle($xmlWriter, $styleFont->getParagraphStyle()); - } - - if ($indent > 0) { - $xmlWriter->startElement('w:ind'); - $xmlWriter->writeAttribute('w:left', $indent); - $xmlWriter->endElement(); - } - - if (!empty($styleFont) && !$isObject) { - $xmlWriter->startElement('w:pPr'); - $xmlWriter->startElement('w:pStyle'); - $xmlWriter->writeAttribute('w:val', $styleFont); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:tabs'); - $xmlWriter->startElement('w:tab'); - $xmlWriter->writeAttribute('w:val', 'right'); - if (!empty($tabLeader)) { - $xmlWriter->writeAttribute('w:leader', $tabLeader); - } - $xmlWriter->writeAttribute('w:pos', $tabPos); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); // w:pPr - - - if ($i == 0) { - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:instrText'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw('TOC \o "1-9" \h \z \u'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'separate'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:hyperlink'); - $xmlWriter->writeAttribute('w:anchor', $title['anchor']); - $xmlWriter->writeAttribute('w:history', '1'); - - $xmlWriter->startElement('w:r'); - - if ($isObject) { - $this->_writeTextStyle($xmlWriter, $styleFont); - } - - $xmlWriter->startElement('w:t'); - $xmlWriter->writeRaw($title['text']); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->writeElement('w:tab', null); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'begin'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:instrText'); - $xmlWriter->writeAttribute('xml:space', 'preserve'); - $xmlWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \h'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'end'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); // w:hyperlink - - $xmlWriter->endElement(); // w:p - } - - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:fldChar'); - $xmlWriter->writeAttribute('w:fldCharType', 'end'); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/DocumentRels.php b/Classes/PhpWord/Writer/Word2007/DocumentRels.php deleted file mode 100644 index 176dd055..00000000 --- a/Classes/PhpWord/Writer/Word2007/DocumentRels.php +++ /dev/null @@ -1,182 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Relationships - $xmlWriter->startElement('Relationships'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - // Relationship word/document.xml - $this->_writeRelationship( - $xmlWriter, - 1, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', - 'styles.xml' - ); - - // Relationship word/numbering.xml - $this->_writeRelationship( - $xmlWriter, - 2, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering', - 'numbering.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $xmlWriter, - 3, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings', - 'settings.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $xmlWriter, - 4, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', - 'theme/theme1.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $xmlWriter, - 5, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings', - 'webSettings.xml' - ); - - // Relationship word/settings.xml - $this->_writeRelationship( - $xmlWriter, - 6, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable', - 'fontTable.xml' - ); - - // Relationships to Images / Embeddings / Headers / Footers - foreach ($_relsCollection as $relation) { - $relationType = $relation['type']; - $relationName = $relation['target']; - $relationId = $relation['rID']; - $targetMode = ($relationType == 'hyperlink') ? 'External' : ''; - - $this->_writeRelationship( - $xmlWriter, - $relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, - $relationName, - $targetMode - ); - } - - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - public function writeHeaderFooterRels($_relsCollection) - { - // Create XML writer - $xmlWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Relationships - $xmlWriter->startElement('Relationships'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - // Relationships to Images / Embeddings / Headers / Footers - foreach ($_relsCollection as $relation) { - $relationType = $relation['type']; - $relationName = $relation['target']; - $relationId = $relation['rID']; - - $this->_writeRelationship( - $xmlWriter, - $relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, - $relationName - ); - } - - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') - { - if ($pType != '' && $pTarget != '') { - if (strpos($pId, 'rId') === false) { - $pId = 'rId' . $pId; - } - - // Write relationship - $xmlWriter->startElement('Relationship'); - $xmlWriter->writeAttribute('Id', $pId); - $xmlWriter->writeAttribute('Type', $pType); - $xmlWriter->writeAttribute('Target', $pTarget); - - if ($pTargetMode != '') { - $xmlWriter->writeAttribute('TargetMode', $pTargetMode); - } - - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Footer.php b/Classes/PhpWord/Writer/Word2007/Footer.php deleted file mode 100644 index f3ef2a1f..00000000 --- a/Classes/PhpWord/Writer/Word2007/Footer.php +++ /dev/null @@ -1,90 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - $xmlWriter->startElement('w:ftr'); - $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - - $_elements = $footer->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter, $element); - } elseif ($element instanceof Table) { - $this->_writeTable($xmlWriter, $element); - } elseif ($element instanceof Image || - $element instanceof MemoryImage - ) { - $this->_writeImage($xmlWriter, $element); - } elseif ($element instanceof PreserveText) { - $this->_writePreserveText($xmlWriter, $element); - } - } - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Footnotes.php b/Classes/PhpWord/Writer/Word2007/Footnotes.php deleted file mode 100644 index d467859f..00000000 --- a/Classes/PhpWord/Writer/Word2007/Footnotes.php +++ /dev/null @@ -1,87 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - $xmlWriter->startElement('w:footnotes'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - - // write separator and continuation separator - $xmlWriter->startElement('w:footnote'); - $xmlWriter->writeAttribute('w:id', 0); - $xmlWriter->writeAttribute('w:type', 'separator'); - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:separator'); - $xmlWriter->endElement(); // w:separator - $xmlWriter->endElement(); // w:r - $xmlWriter->endElement(); // w:p - $xmlWriter->endElement(); // w:footnote - - $xmlWriter->startElement('w:footnote'); - $xmlWriter->writeAttribute('w:id', 1); - $xmlWriter->writeAttribute('w:type', 'continuationSeparator'); - $xmlWriter->startElement('w:p'); - $xmlWriter->startElement('w:r'); - $xmlWriter->startElement('w:continuationSeparator'); - $xmlWriter->endElement(); // w:continuationSeparator - $xmlWriter->endElement(); // w:r - $xmlWriter->endElement(); // w:p - $xmlWriter->endElement(); // w:footnote - - - foreach ($allFootnotesCollection as $footnote) { - if ($footnote instanceof Footnote) { - $this->_writeFootnote($xmlWriter, $footnote); - } - } - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/FootnotesRels.php b/Classes/PhpWord/Writer/Word2007/FootnotesRels.php deleted file mode 100644 index b1819876..00000000 --- a/Classes/PhpWord/Writer/Word2007/FootnotesRels.php +++ /dev/null @@ -1,89 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Relationships - $xmlWriter->startElement('Relationships'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - // Relationships to Links - foreach ($_relsCollection as $relation) { - $relationType = $relation['type']; - $relationName = $relation['target']; - $relationId = $relation['rID']; - $targetMode = ($relationType == 'hyperlink') ? 'External' : ''; - - $this->_writeRelationship($xmlWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName, $targetMode); - } - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } - - private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') - { - if ($pType != '' && $pTarget != '') { - if (strpos($pId, 'rId') === false) { - $pId = 'rId' . $pId; - } - - // Write relationship - $xmlWriter->startElement('Relationship'); - $xmlWriter->writeAttribute('Id', $pId); - $xmlWriter->writeAttribute('Type', $pType); - $xmlWriter->writeAttribute('Target', $pTarget); - - if ($pTargetMode != '') { - $xmlWriter->writeAttribute('TargetMode', $pTargetMode); - } - - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Header.php b/Classes/PhpWord/Writer/Word2007/Header.php deleted file mode 100644 index aef2c38a..00000000 --- a/Classes/PhpWord/Writer/Word2007/Header.php +++ /dev/null @@ -1,94 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - $xmlWriter->startElement('w:hdr'); - $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); - $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); - $xmlWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); - $xmlWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); - $xmlWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); - - - $_elements = $header->getElements(); - - foreach ($_elements as $element) { - if ($element instanceof Text) { - $this->_writeText($xmlWriter, $element); - } elseif ($element instanceof TextRun) { - $this->_writeTextRun($xmlWriter, $element); - } elseif ($element instanceof TextBreak) { - $this->_writeTextBreak($xmlWriter, $element); - } elseif ($element instanceof Table) { - $this->_writeTable($xmlWriter, $element); - } elseif ($element instanceof Image || - $element instanceof MemoryImage - ) { - if (!$element->getIsWatermark()) { - $this->_writeImage($xmlWriter, $element); - } else { - $this->_writeWatermark($xmlWriter, $element); - } - } elseif ($element instanceof PreserveText) { - $this->_writePreserveText($xmlWriter, $element); - } - } - - $xmlWriter->endElement(); - - // Return - return $xmlWriter->getData(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Rels.php b/Classes/PhpWord/Writer/Word2007/Rels.php deleted file mode 100644 index 615fd13e..00000000 --- a/Classes/PhpWord/Writer/Word2007/Rels.php +++ /dev/null @@ -1,115 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - // Relationships - $xmlWriter->startElement('Relationships'); - $xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - - $relationId = 1; - - // Relationship word/document.xml - $this->_writeRelationship( - $xmlWriter, - $relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', - 'word/document.xml' - ); - - // Relationship docProps/core.xml - $this->_writeRelationship( - $xmlWriter, - ++$relationId, - 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', - 'docProps/core.xml' - ); - - // Relationship docProps/app.xml - $this->_writeRelationship( - $xmlWriter, - ++$relationId, - 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', - 'docProps/app.xml' - ); - - $xmlWriter->endElement(); - - return $xmlWriter->getData(); - } - - /** - * Write Override content type - * - * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @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(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') - { - if ($pType != '' && $pTarget != '') { - if (strpos($pId, 'rId') === false) { - $pId = 'rId' . $pId; - } - - // Write relationship - $xmlWriter->startElement('Relationship'); - $xmlWriter->writeAttribute('Id', $pId); - $xmlWriter->writeAttribute('Type', $pType); - $xmlWriter->writeAttribute('Target', $pTarget); - - if ($pTargetMode != '') { - $xmlWriter->writeAttribute('TargetMode', $pTargetMode); - } - - $xmlWriter->endElement(); - } else { - throw new Exception("Invalid parameters passed."); - } - } -} diff --git a/Classes/PhpWord/Writer/Word2007/Styles.php b/Classes/PhpWord/Writer/Word2007/Styles.php deleted file mode 100644 index 7918851c..00000000 --- a/Classes/PhpWord/Writer/Word2007/Styles.php +++ /dev/null @@ -1,399 +0,0 @@ -getParentWriter()->getUseDiskCaching()) { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $xmlWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); - } - - $this->_document = $phpWord; - - // XML header - $xmlWriter->startDocument('1.0', 'UTF-8', 'yes'); - - $xmlWriter->startElement('w:styles'); - - $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); - $xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); - - // Write DocDefaults - $this->_writeDocDefaults($xmlWriter); - - - // Write Style Definitions - $styles = Style::getStyles(); - - // Write normal paragraph style - $normalStyle = null; - if (array_key_exists('Normal', $styles)) { - $normalStyle = $styles['Normal']; - } - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', 'paragraph'); - $xmlWriter->writeAttribute('w:default', '1'); - $xmlWriter->writeAttribute('w:styleId', 'Normal'); - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', 'Normal'); - $xmlWriter->endElement(); - if (!is_null($normalStyle)) { - $this->_writeParagraphStyle($xmlWriter, $normalStyle); - } - $xmlWriter->endElement(); - - // Write other styles - if (count($styles) > 0) { - foreach ($styles as $styleName => $style) { - if ($styleName == 'Normal') { - continue; - } - if ($style instanceof Font) { - - $paragraphStyle = $style->getParagraphStyle(); - $styleType = $style->getStyleType(); - - $type = ($styleType == 'title') ? 'paragraph' : 'character'; - - if (!is_null($paragraphStyle)) { - $type = 'paragraph'; - } - - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', $type); - - if ($styleType == 'title') { - $arrStyle = explode('_', $styleName); - $styleId = 'Heading' . $arrStyle[1]; - $styleName = 'heading ' . $arrStyle[1]; - $styleLink = 'Heading' . $arrStyle[1] . 'Char'; - $xmlWriter->writeAttribute('w:styleId', $styleId); - - $xmlWriter->startElement('w:link'); - $xmlWriter->writeAttribute('w:val', $styleLink); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $styleName); - $xmlWriter->endElement(); - - if (!is_null($paragraphStyle)) { - // Point parent style to Normal - $xmlWriter->startElement('w:basedOn'); - $xmlWriter->writeAttribute('w:val', 'Normal'); - $xmlWriter->endElement(); - $this->_writeParagraphStyle($xmlWriter, $paragraphStyle); - } - - $this->_writeTextStyle($xmlWriter, $style); - - $xmlWriter->endElement(); - - } elseif ($style instanceof Paragraph) { - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', 'paragraph'); - $xmlWriter->writeAttribute('w:customStyle', '1'); - $xmlWriter->writeAttribute('w:styleId', $styleName); - - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $styleName); - $xmlWriter->endElement(); - - // Parent style - $basedOn = $style->getBasedOn(); - if (!is_null($basedOn)) { - $xmlWriter->startElement('w:basedOn'); - $xmlWriter->writeAttribute('w:val', $basedOn); - $xmlWriter->endElement(); - } - - // Next paragraph style - $next = $style->getNext(); - if (!is_null($next)) { - $xmlWriter->startElement('w:next'); - $xmlWriter->writeAttribute('w:val', $next); - $xmlWriter->endElement(); - } - - $this->_writeParagraphStyle($xmlWriter, $style); - $xmlWriter->endElement(); - - } elseif ($style instanceof TableFull) { - $xmlWriter->startElement('w:style'); - $xmlWriter->writeAttribute('w:type', 'table'); - $xmlWriter->writeAttribute('w:customStyle', '1'); - $xmlWriter->writeAttribute('w:styleId', $styleName); - - $xmlWriter->startElement('w:name'); - $xmlWriter->writeAttribute('w:val', $styleName); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:uiPriority'); - $xmlWriter->writeAttribute('w:val', '99'); - $xmlWriter->endElement(); - - $this->_writeFullTableStyle($xmlWriter, $style); - - $xmlWriter->endElement(); - } - } - } - - $xmlWriter->endElement(); // w:styles - - // Return - return $xmlWriter->getData(); - } - - private function _writeFullTableStyle(XMLWriter $xmlWriter = null, TableFull $style) - { - - $brdSz = $style->getBorderSize(); - $brdCol = $style->getBorderColor(); - $bgColor = $style->getBgColor(); - $cellMargin = $style->getCellMargin(); - - $bTop = (!is_null($brdSz[0])) ? true : false; - $bLeft = (!is_null($brdSz[1])) ? true : false; - $bRight = (!is_null($brdSz[2])) ? true : false; - $bBottom = (!is_null($brdSz[3])) ? true : false; - $bInsH = (!is_null($brdSz[4])) ? true : false; - $bInsV = (!is_null($brdSz[5])) ? true : false; - $borders = ($bTop || $bLeft || $bRight || $bBottom || $bInsH || $bInsV) ? true : false; - - $mTop = (!is_null($cellMargin[0])) ? true : false; - $mLeft = (!is_null($cellMargin[1])) ? true : false; - $mRight = (!is_null($cellMargin[2])) ? true : false; - $mBottom = (!is_null($cellMargin[3])) ? true : false; - $margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false; - - $xmlWriter->startElement('w:tblPr'); - - if ($margins) { - $xmlWriter->startElement('w:tblCellMar'); - if ($mTop) { - echo $margins[0]; - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:w', $cellMargin[0]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - if ($mLeft) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:w', $cellMargin[1]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - if ($mRight) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:w', $cellMargin[2]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - if ($mBottom) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:w', $cellMargin[3]); - $xmlWriter->writeAttribute('w:type', 'dxa'); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - - if ($borders) { - $xmlWriter->startElement('w:tblBorders'); - if ($bTop) { - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[0]); - $xmlWriter->writeAttribute('w:color', $brdCol[0]); - $xmlWriter->endElement(); - } - if ($bLeft) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[1]); - $xmlWriter->writeAttribute('w:color', $brdCol[1]); - $xmlWriter->endElement(); - } - if ($bRight) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[2]); - $xmlWriter->writeAttribute('w:color', $brdCol[2]); - $xmlWriter->endElement(); - } - if ($bBottom) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[3]); - $xmlWriter->writeAttribute('w:color', $brdCol[3]); - $xmlWriter->endElement(); - } - if ($bInsH) { - $xmlWriter->startElement('w:insideH'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[4]); - $xmlWriter->writeAttribute('w:color', $brdCol[4]); - $xmlWriter->endElement(); - } - if ($bInsV) { - $xmlWriter->startElement('w:insideV'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[5]); - $xmlWriter->writeAttribute('w:color', $brdCol[5]); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - } - - $xmlWriter->endElement(); - - if (!is_null($bgColor)) { - $xmlWriter->startElement('w:tcPr'); - $xmlWriter->startElement('w:shd'); - $xmlWriter->writeAttribute('w:val', 'clear'); - $xmlWriter->writeAttribute('w:color', 'auto'); - $xmlWriter->writeAttribute('w:fill', $bgColor); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } - - - // First Row - $firstRow = $style->getFirstRow(); - if (!is_null($firstRow)) { - $this->_writeRowStyle($xmlWriter, 'firstRow', $firstRow); - } - } - - private function _writeRowStyle(XMLWriter $xmlWriter = null, $type, TableFull $style) - { - $brdSz = $style->getBorderSize(); - $brdCol = $style->getBorderColor(); - $bgColor = $style->getBgColor(); - - $bTop = (!is_null($brdSz[0])) ? true : false; - $bLeft = (!is_null($brdSz[1])) ? true : false; - $bRight = (!is_null($brdSz[2])) ? true : false; - $bBottom = (!is_null($brdSz[3])) ? true : false; - $borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false; - - $xmlWriter->startElement('w:tblStylePr'); - $xmlWriter->writeAttribute('w:type', $type); - - $xmlWriter->startElement('w:tcPr'); - if (!is_null($bgColor)) { - $xmlWriter->startElement('w:shd'); - $xmlWriter->writeAttribute('w:val', 'clear'); - $xmlWriter->writeAttribute('w:color', 'auto'); - $xmlWriter->writeAttribute('w:fill', $bgColor); - $xmlWriter->endElement(); - } - - $xmlWriter->startElement('w:tcBorders'); - if ($bTop) { - $xmlWriter->startElement('w:top'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[0]); - $xmlWriter->writeAttribute('w:color', $brdCol[0]); - $xmlWriter->endElement(); - } - if ($bLeft) { - $xmlWriter->startElement('w:left'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[1]); - $xmlWriter->writeAttribute('w:color', $brdCol[1]); - $xmlWriter->endElement(); - } - if ($bRight) { - $xmlWriter->startElement('w:right'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[2]); - $xmlWriter->writeAttribute('w:color', $brdCol[2]); - $xmlWriter->endElement(); - } - if ($bBottom) { - $xmlWriter->startElement('w:bottom'); - $xmlWriter->writeAttribute('w:val', 'single'); - $xmlWriter->writeAttribute('w:sz', $brdSz[3]); - $xmlWriter->writeAttribute('w:color', $brdCol[3]); - $xmlWriter->endElement(); - } - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - } - - - private function _writeDocDefaults(XMLWriter $xmlWriter = null) - { - $fontName = $this->_document->getDefaultFontName(); - $fontSize = $this->_document->getDefaultFontSize(); - - $xmlWriter->startElement('w:docDefaults'); - $xmlWriter->startElement('w:rPrDefault'); - $xmlWriter->startElement('w:rPr'); - - $xmlWriter->startElement('w:rFonts'); - $xmlWriter->writeAttribute('w:ascii', $fontName); - $xmlWriter->writeAttribute('w:hAnsi', $fontName); - $xmlWriter->writeAttribute('w:eastAsia', $fontName); - $xmlWriter->writeAttribute('w:cs', $fontName); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:sz'); - $xmlWriter->writeAttribute('w:val', $fontSize * 2); - $xmlWriter->endElement(); - - $xmlWriter->startElement('w:szCs'); - $xmlWriter->writeAttribute('w:val', $fontSize * 2); - $xmlWriter->endElement(); - - $xmlWriter->endElement(); - $xmlWriter->endElement(); - $xmlWriter->endElement(); - } -} diff --git a/Classes/PhpWord/Writer/Word2007/WriterPart.php b/Classes/PhpWord/Writer/Word2007/WriterPart.php deleted file mode 100644 index bb8fefc3..00000000 --- a/Classes/PhpWord/Writer/Word2007/WriterPart.php +++ /dev/null @@ -1,49 +0,0 @@ -_parentWriter = $pWriter; - } - - public function getParentWriter() - { - if (!is_null($this->_parentWriter)) { - return $this->_parentWriter; - } else { - throw new Exception("No parent IWriter assigned."); - } - } -} diff --git a/Classes/PhpWord/_staticDocParts/_doc.png b/Classes/PhpWord/_staticDocParts/_doc.png deleted file mode 100644 index 3128a803..00000000 Binary files a/Classes/PhpWord/_staticDocParts/_doc.png and /dev/null differ diff --git a/Classes/PhpWord/_staticDocParts/_ppt.png b/Classes/PhpWord/_staticDocParts/_ppt.png deleted file mode 100644 index 3e925f50..00000000 Binary files a/Classes/PhpWord/_staticDocParts/_ppt.png and /dev/null differ diff --git a/Classes/PhpWord/_staticDocParts/_xls.png b/Classes/PhpWord/_staticDocParts/_xls.png deleted file mode 100644 index a7d7697f..00000000 Binary files a/Classes/PhpWord/_staticDocParts/_xls.png and /dev/null differ diff --git a/Classes/PhpWord/_staticDocParts/fontTable.xml b/Classes/PhpWord/_staticDocParts/fontTable.xml deleted file mode 100644 index a2e183c4..00000000 --- a/Classes/PhpWord/_staticDocParts/fontTable.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/Classes/PhpWord/_staticDocParts/numbering.xml b/Classes/PhpWord/_staticDocParts/numbering.xml deleted file mode 100644 index ac229f40..00000000 --- a/Classes/PhpWord/_staticDocParts/numbering.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/Classes/PhpWord/_staticDocParts/settings.xml b/Classes/PhpWord/_staticDocParts/settings.xml deleted file mode 100644 index 5eb22891..00000000 --- a/Classes/PhpWord/_staticDocParts/settings.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Classes/PhpWord/_staticDocParts/theme1.xml b/Classes/PhpWord/_staticDocParts/theme1.xml deleted file mode 100644 index 4fab507b..00000000 --- a/Classes/PhpWord/_staticDocParts/theme1.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/Classes/PhpWord/_staticDocParts/webSettings.xml b/Classes/PhpWord/_staticDocParts/webSettings.xml deleted file mode 100644 index 72d28307..00000000 --- a/Classes/PhpWord/_staticDocParts/webSettings.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/src/Exceptions/Exception.php b/src/Exceptions/Exception.php old mode 100644 new mode 100755