Ejemplo n.º 1
2
 public function writeDocument(PHPWord $pPHPWord = null)
 {
     // Create XML writer
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // w:document
     $objWriter->startElement('w:document');
     $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
     $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
     $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
     $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
     $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
     $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
     $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
     $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
     $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
     $objWriter->startElement('w:body');
     $_sections = $pPHPWord->getSections();
     $countSections = count($_sections);
     $pSection = 0;
     if ($countSections > 0) {
         foreach ($_sections as $section) {
             $pSection++;
             $_elements = $section->getElements();
             foreach ($_elements as $element) {
                 if ($element instanceof PHPWord_Section_Text) {
                     $this->_writeText($objWriter, $element);
                 } elseif ($element instanceof PHPWord_Section_TextRun) {
                     $this->_writeTextRun($objWriter, $element);
                 } elseif ($element instanceof PHPWord_Section_Link) {
                     $this->_writeLink($objWriter, $element);
                 } elseif ($element instanceof PHPWord_Section_Title) {
                     $this->_writeTitle($objWriter, $element);
                 } elseif ($element instanceof PHPWord_Section_TextBreak) {
                     $this->_writeTextBreak($objWriter);
                 } elseif ($element instanceof PHPWord_Section_PageBreak) {
                     $this->_writePageBreak($objWriter);
                 } elseif ($element instanceof PHPWord_Section_Table) {
                     $this->_writeTable($objWriter, $element);
                 } elseif ($element instanceof PHPWord_Section_ListItem) {
                     $this->_writeListItem($objWriter, $element);
                 } elseif ($element instanceof PHPWord_Section_Image || $element instanceof PHPWord_Section_MemoryImage) {
                     $this->_writeImage($objWriter, $element);
                 } elseif ($element instanceof PHPWord_Section_Object) {
                     $this->_writeObject($objWriter, $element);
                 } elseif ($element instanceof PHPWord_TOC) {
                     $this->_writeTOC($objWriter);
                 }
             }
             if ($pSection == $countSections) {
                 $this->_writeEndSection($objWriter, $section);
             } else {
                 $this->_writeSection($objWriter, $section);
             }
         }
     }
     $objWriter->endElement();
     // End w:body
     $objWriter->endElement();
     // End w:document
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 2
0
 public function writeRelationships(PHPWord $pPHPWord = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     $relationId = 1;
     // Relationship word/document.xml
     $this->_writeRelationship($objWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', 'word/document.xml');
     // Relationship docProps/core.xml
     $this->_writeRelationship($objWriter, ++$relationId, 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', 'docProps/core.xml');
     // Relationship docProps/app.xml
     $this->_writeRelationship($objWriter, ++$relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', 'docProps/app.xml');
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 3
0
 public function writeHeaderFooterRels($_relsCollection)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     // Relationships to Images / Embeddings / Headers / Footers
     foreach ($_relsCollection as $relation) {
         $relationType = $relation['type'];
         $relationName = $relation['target'];
         $relationId = $relation['rID'];
         $this->_writeRelationship($objWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName);
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 4
0
 public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $_cFtrs)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Types
     $objWriter->startElement('Types');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
     // Rels
     $this->_writeDefaultContentType($objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml');
     // XML
     $this->_writeDefaultContentType($objWriter, 'xml', 'application/xml');
     // Add media content-types
     foreach ($_imageTypes as $key => $value) {
         $this->_writeDefaultContentType($objWriter, $key, $value);
     }
     // Add embedding content-types
     if (count($_objectTypes) > 0) {
         $this->_writeDefaultContentType($objWriter, 'bin', 'application/vnd.openxmlformats-officedocument.oleObject');
     }
     // DocProps
     $this->_writeOverrideContentType($objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml');
     $this->_writeOverrideContentType($objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml');
     // Document
     $this->_writeOverrideContentType($objWriter, '/word/document.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml');
     // Styles
     $this->_writeOverrideContentType($objWriter, '/word/styles.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml');
     // Numbering
     $this->_writeOverrideContentType($objWriter, '/word/numbering.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml');
     // Settings
     $this->_writeOverrideContentType($objWriter, '/word/settings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml');
     // Theme1
     $this->_writeOverrideContentType($objWriter, '/word/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml');
     // WebSettings
     $this->_writeOverrideContentType($objWriter, '/word/webSettings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml');
     // Font Table
     $this->_writeOverrideContentType($objWriter, '/word/fontTable.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml');
     for ($i = 1; $i <= $_cHdrs; $i++) {
         $this->_writeOverrideContentType($objWriter, '/word/header' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml');
     }
     for ($i = 1; $i <= $_cFtrs; $i++) {
         $this->_writeOverrideContentType($objWriter, '/word/footer' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml');
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 5
0
 public function writeFootnotes($allFootnotesCollection)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     $objWriter->startElement('w:footnotes');
     $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
     $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
     // write separator and continuation separator
     $objWriter->startElement('w:footnote');
     $objWriter->writeAttribute('w:id', 0);
     $objWriter->writeAttribute('w:type', 'separator');
     $objWriter->startElement('w:p');
     $objWriter->startElement('w:r');
     $objWriter->startElement('w:separator');
     $objWriter->endElement();
     // w:separator
     $objWriter->endElement();
     // w:r
     $objWriter->endElement();
     // w:p
     $objWriter->endElement();
     // w:footnote
     $objWriter->startElement('w:footnote');
     $objWriter->writeAttribute('w:id', 1);
     $objWriter->writeAttribute('w:type', 'continuationSeparator');
     $objWriter->startElement('w:p');
     $objWriter->startElement('w:r');
     $objWriter->startElement('w:continuationSeparator');
     $objWriter->endElement();
     // w:continuationSeparator
     $objWriter->endElement();
     // w:r
     $objWriter->endElement();
     // w:p
     $objWriter->endElement();
     // w:footnote
     foreach ($allFootnotesCollection as $footnote) {
         if ($footnote instanceof PHPWord_Section_Footnote) {
             $this->_writeFootnote($objWriter, $footnote);
         }
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 6
0
 /**
  * Write Meta file to XML format
  *
  * @param 	PHPWord $pPHPWord
  * @return 	string 						XML Output
  * @throws 	Exception
  */
 public function writeMeta(PHPWord $pPHPWord = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8');
     // office:document-meta
     $objWriter->startElement('office:document-meta');
     $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
     $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
     $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
     $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
     $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
     $objWriter->writeAttribute('office:version', '1.2');
     // office:meta
     $objWriter->startElement('office:meta');
     // dc:creator
     $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy());
     // dc:date
     $objWriter->writeElement('dc:date', gmdate('Y-m-d\\TH:i:s.000', $pPHPWord->getProperties()->getModified()));
     // dc:description
     $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
     // dc:subject
     $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
     // dc:title
     $objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
     // meta:creation-date
     $objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\\TH:i:s.000', $pPHPWord->getProperties()->getCreated()));
     // meta:initial-creator
     $objWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator());
     // meta:keyword
     $objWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords());
     // @todo : Where these properties are written ?
     // $pPHPWord->getProperties()->getCategory()
     // $pPHPWord->getProperties()->getCompany()
     $objWriter->endElement();
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 7
0
 public function writeHeader(PHPWord_Section_Header $header)
 {
     // Create XML writer
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     $objWriter->startElement('w:hdr');
     $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
     $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
     $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
     $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
     $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
     $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
     $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
     $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
     $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
     $_elements = $header->getElements();
     foreach ($_elements as $element) {
         if ($element instanceof PHPWord_Section_Text) {
             $this->_writeText($objWriter, $element);
         } elseif ($element instanceof PHPWord_Section_TextRun) {
             $this->_writeTextRun($objWriter, $element);
         } elseif ($element instanceof PHPWord_Section_TextBreak) {
             $this->_writeTextBreak($objWriter);
         } elseif ($element instanceof PHPWord_Section_Table) {
             $this->_writeTable($objWriter, $element);
         } elseif ($element instanceof PHPWord_Section_Image || $element instanceof PHPWord_Section_MemoryImage) {
             if (!$element->getIsWatermark()) {
                 $this->_writeImage($objWriter, $element);
             } else {
                 $this->_writeWatermark($objWriter, $element);
             }
         } elseif ($element instanceof PHPWord_Section_Footer_PreserveText) {
             $this->_writePreserveText($objWriter, $element);
         }
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 8
0
 /**
  *
  * @param PHPWord $PHPWord
  * @return string
  */
 public function writeDocument(PHPWord $PHPWord = null)
 {
     $numbering = $PHPWord->getNumbering();
     // Create XML writer
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // START w:numbering
     $objWriter->startElement('w:numbering');
     $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
     $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
     $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
     $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
     $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
     $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
     $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
     $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
     $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
     // Write all of the abstractNum elements
     foreach ($numbering as $key => $value) {
         $value->toXml($objWriter);
     }
     // Write all of the num elements
     foreach ($numbering as $key => $value) {
         $objWriter->startElement('w:num');
         $objWriter->writeAttribute("w:numId", $key + 1);
         $objWriter->startElement('w:abstractNumId');
         $objWriter->writeAttribute("w:val", $key + 1);
         $objWriter->endElement();
         $objWriter->endElement();
     }
     // END w:numbering
     $objWriter->endElement();
     return $objWriter->getData();
 }
Ejemplo n.º 9
0
 /**
  * Write Manifest file to XML format
  *
  * @param 	PHPWord $pPHPWord
  * @return 	string 						XML Output
  * @throws 	Exception
  */
 public function writeManifest(PHPWord $pPHPWord = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8');
     // manifest:manifest
     $objWriter->startElement('manifest:manifest');
     $objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0');
     $objWriter->writeAttribute('manifest:version', '1.2');
     // manifest:file-entry
     $objWriter->startElement('manifest:file-entry');
     $objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.text');
     $objWriter->writeAttribute('manifest:version', '1.2');
     $objWriter->writeAttribute('manifest:full-path', '/');
     $objWriter->endElement();
     // manifest:file-entry
     $objWriter->startElement('manifest:file-entry');
     $objWriter->writeAttribute('manifest:media-type', 'text/xml');
     $objWriter->writeAttribute('manifest:full-path', 'content.xml');
     $objWriter->endElement();
     // manifest:file-entry
     $objWriter->startElement('manifest:file-entry');
     $objWriter->writeAttribute('manifest:media-type', 'text/xml');
     $objWriter->writeAttribute('manifest:full-path', 'meta.xml');
     $objWriter->endElement();
     // manifest:file-entry
     $objWriter->startElement('manifest:file-entry');
     $objWriter->writeAttribute('manifest:media-type', 'text/xml');
     $objWriter->writeAttribute('manifest:full-path', 'styles.xml');
     $objWriter->endElement();
     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());
             $objWriter->startElement('manifest:file-entry');
             $objWriter->writeAttribute('manifest:media-type', $mimeType);
             $objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()));
             $objWriter->endElement();
         } else {
             if ($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();
                 $objWriter->startElement('manifest:file-entry');
                 $objWriter->writeAttribute('manifest:media-type', $mimeType);
                 $objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()));
                 $objWriter->endElement();
             }
         }
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 10
0
 public function writeStyles(PHPWord $pPHPWord = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     $this->_document = $pPHPWord;
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     $objWriter->startElement('w:styles');
     $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
     $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
     // Write DocDefaults
     $this->_writeDocDefaults($objWriter);
     // Write Style Definitions
     $styles = PHPWord_Style::getStyles();
     if (count($styles) > 0) {
         foreach ($styles as $styleName => $style) {
             if ($style instanceof PHPWord_Style_Font) {
                 $paragraphStyle = $style->getParagraphStyle();
                 $styleType = $style->getStyleType();
                 $type = $styleType == 'title' ? 'paragraph' : 'character';
                 if (!is_null($paragraphStyle)) {
                     $type = 'paragraph';
                 }
                 $objWriter->startElement('w:style');
                 $objWriter->writeAttribute('w:type', $type);
                 if ($styleType == 'title') {
                     $arrStyle = explode('_', $styleName);
                     $styleId = 'Heading' . $arrStyle[1];
                     $styleName = 'heading ' . $arrStyle[1];
                     $styleLink = 'Heading' . $arrStyle[1] . 'Char';
                     $objWriter->writeAttribute('w:styleId', $styleId);
                     $objWriter->startElement('w:link');
                     $objWriter->writeAttribute('w:val', $styleLink);
                     $objWriter->endElement();
                 }
                 $objWriter->startElement('w:name');
                 $objWriter->writeAttribute('w:val', $styleName);
                 $objWriter->endElement();
                 if (!is_null($paragraphStyle)) {
                     $this->_writeParagraphStyle($objWriter, $paragraphStyle);
                 }
                 $this->_writeTextStyle($objWriter, $style);
                 $objWriter->endElement();
             } elseif ($style instanceof PHPWord_Style_Paragraph) {
                 $objWriter->startElement('w:style');
                 $objWriter->writeAttribute('w:type', 'paragraph');
                 $objWriter->writeAttribute('w:customStyle', '1');
                 $objWriter->writeAttribute('w:styleId', $styleName);
                 $objWriter->startElement('w:name');
                 $objWriter->writeAttribute('w:val', $styleName);
                 $objWriter->endElement();
                 $this->_writeParagraphStyle($objWriter, $style);
                 $objWriter->endElement();
             } elseif ($style instanceof PHPWord_Style_TableFull) {
                 $objWriter->startElement('w:style');
                 $objWriter->writeAttribute('w:type', 'table');
                 $objWriter->writeAttribute('w:customStyle', '1');
                 $objWriter->writeAttribute('w:styleId', $styleName);
                 $objWriter->startElement('w:name');
                 $objWriter->writeAttribute('w:val', $styleName);
                 $objWriter->endElement();
                 $objWriter->startElement('w:uiPriority');
                 $objWriter->writeAttribute('w:val', '99');
                 $objWriter->endElement();
                 $this->_writeFullTableStyle($objWriter, $style);
                 $objWriter->endElement();
             }
         }
     }
     $objWriter->endElement();
     // w:styles
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 11
0
 /**
  * Write Styles file to XML format
  *
  * @param 	PHPWord $pPHPWord
  * @return 	string 						XML Output
  * @throws 	Exception
  */
 public function writeStyles(PHPWord $pPHPWord = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8');
     // Styles:Styles
     $objWriter->startElement('office:document-styles');
     $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
     $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
     $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
     $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
     $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
     $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
     $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
     $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
     $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
     $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
     $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
     $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
     $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
     $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
     $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
     $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
     $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
     $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
     $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
     $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
     $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
     $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
     $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
     $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
     $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
     $objWriter->writeAttribute('office:version', '1.2');
     // office:font-face-decls
     $objWriter->startElement('office:font-face-decls');
     $arrFonts = array();
     $styles = PHPWord_Style::getStyles();
     $numFonts = 0;
     if (count($styles) > 0) {
         foreach ($styles as $styleName => $style) {
             // PHPWord_Style_Font
             if ($style instanceof PHPWord_Style_Font) {
                 $numFonts++;
                 $name = $style->getName();
                 if (!in_array($name, $arrFonts)) {
                     $arrFonts[] = $name;
                     // style:font-face
                     $objWriter->startElement('style:font-face');
                     $objWriter->writeAttribute('style:name', $name);
                     $objWriter->writeAttribute('svg:font-family', $name);
                     $objWriter->endElement();
                 }
             }
         }
     }
     if (!in_array('Arial', $arrFonts)) {
         $objWriter->startElement('style:font-face');
         $objWriter->writeAttribute('style:name', 'Arial');
         $objWriter->writeAttribute('svg:font-family', 'Arial');
         $objWriter->endElement();
     }
     $objWriter->endElement();
     // office:styles
     $objWriter->startElement('office:styles');
     // style:default-style
     $objWriter->startElement('style:default-style');
     $objWriter->writeAttribute('style:family', 'paragraph');
     // style:paragraph-properties
     $objWriter->startElement('style:paragraph-properties');
     $objWriter->writeAttribute('fo:hyphenation-ladder-count', 'no-limit');
     $objWriter->writeAttribute('style:text-autospace', 'ideograph-alpha');
     $objWriter->writeAttribute('style:punctuation-wrap', 'hanging');
     $objWriter->writeAttribute('style:line-break', 'strict');
     $objWriter->writeAttribute('style:tab-stop-distance', '1.249cm');
     $objWriter->writeAttribute('style:writing-mode', 'page');
     $objWriter->endElement();
     // style:text-properties
     $objWriter->startElement('style:text-properties');
     $objWriter->writeAttribute('style:use-window-font-color', 'true');
     $objWriter->writeAttribute('style:font-name', 'Arial');
     $objWriter->writeAttribute('fo:font-size', '10pt');
     $objWriter->writeAttribute('fo:language', 'fr');
     $objWriter->writeAttribute('fo:country', 'FR');
     $objWriter->writeAttribute('style:letter-kerning', 'true');
     $objWriter->writeAttribute('style:font-name-asian', 'Arial2');
     $objWriter->writeAttribute('style:font-size-asian', '10pt');
     $objWriter->writeAttribute('style:language-asian', 'zh');
     $objWriter->writeAttribute('style:country-asian', 'CN');
     $objWriter->writeAttribute('style:font-name-complex', 'Arial2');
     $objWriter->writeAttribute('style:font-size-complex', '10pt');
     $objWriter->writeAttribute('style:language-complex', 'hi');
     $objWriter->writeAttribute('style:country-complex', 'IN');
     $objWriter->writeAttribute('fo:hyphenate', 'false');
     $objWriter->writeAttribute('fo:hyphenation-remain-char-count', '2');
     $objWriter->writeAttribute('fo:hyphenation-push-char-count', '2');
     $objWriter->endElement();
     $objWriter->endElement();
     // Write Style Definitions
     $styles = PHPWord_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) {
                 // PHPWord_Style_Font
                 if ($style instanceof PHPWord_Style_Font) {
                     // style:style
                     $objWriter->startElement('style:style');
                     $objWriter->writeAttribute('style:name', $styleName);
                     $objWriter->writeAttribute('style:family', 'text');
                     // style:text-properties
                     $objWriter->startElement('style:text-properties');
                     $objWriter->writeAttribute('fo:font-size', $style->getSize() / 2 . 'pt');
                     $objWriter->writeAttribute('style:font-size-asian', $style->getSize() / 2 . 'pt');
                     $objWriter->writeAttribute('style:font-size-complex', $style->getSize() / 2 . 'pt');
                     if ($style->getItalic()) {
                         $objWriter->writeAttribute('fo:font-style', 'italic');
                         $objWriter->writeAttribute('style:font-style-asian', 'italic');
                         $objWriter->writeAttribute('style:font-style-complex', 'italic');
                     }
                     if ($style->getBold()) {
                         $objWriter->writeAttribute('fo:font-weight', 'bold');
                         $objWriter->writeAttribute('style:font-weight-asian', 'bold');
                     }
                     $objWriter->endElement();
                     $objWriter->endElement();
                 } elseif ($style instanceof PHPWord_Style_Paragraph) {
                     // style:style
                     $objWriter->startElement('style:style');
                     $objWriter->writeAttribute('style:name', $styleName);
                     $objWriter->writeAttribute('style:family', 'paragraph');
                     //style:paragraph-properties
                     $objWriter->startElement('style:paragraph-properties');
                     $objWriter->writeAttribute('fo:margin-top', (is_null($style->getSpaceBefore()) ? '0' : round(17.6 / $style->getSpaceBefore(), 2)) . 'cm');
                     $objWriter->writeAttribute('fo:margin-bottom', (is_null($style->getSpaceAfter()) ? '0' : round(17.6 / $style->getSpaceAfter(), 2)) . 'cm');
                     $objWriter->writeAttribute('fo:text-align', $style->getAlign());
                     $objWriter->endElement();
                     $objWriter->endElement();
                 } elseif ($style instanceof PHPWord_Style_TableFull) {
                 }
             }
         }
     }
     $objWriter->endElement();
     // office:automatic-styles
     $objWriter->startElement('office:automatic-styles');
     // style:page-layout
     $objWriter->startElement('style:page-layout');
     $objWriter->writeAttribute('style:name', 'Mpm1');
     // style:page-layout-properties
     $objWriter->startElement('style:page-layout-properties');
     $objWriter->writeAttribute('fo:page-width', "21.001cm");
     $objWriter->writeAttribute('fo:page-height', '29.7cm');
     $objWriter->writeAttribute('style:num-format', '1');
     $objWriter->writeAttribute('style:print-orientation', 'portrait');
     $objWriter->writeAttribute('fo:margin-top', '2.501cm');
     $objWriter->writeAttribute('fo:margin-bottom', '2cm');
     $objWriter->writeAttribute('fo:margin-left', '2.501cm');
     $objWriter->writeAttribute('fo:margin-right', '2.501cm');
     $objWriter->writeAttribute('style:writing-mode', 'lr-tb');
     $objWriter->writeAttribute('style:layout-grid-color', '#c0c0c0');
     $objWriter->writeAttribute('style:layout-grid-lines', '25199');
     $objWriter->writeAttribute('style:layout-grid-base-height', '0.423cm');
     $objWriter->writeAttribute('style:layout-grid-ruby-height', '0cm');
     $objWriter->writeAttribute('style:layout-grid-mode', 'none');
     $objWriter->writeAttribute('style:layout-grid-ruby-below', 'false');
     $objWriter->writeAttribute('style:layout-grid-print', 'false');
     $objWriter->writeAttribute('style:layout-grid-display', 'false');
     $objWriter->writeAttribute('style:layout-grid-base-width', '0.37cm');
     $objWriter->writeAttribute('style:layout-grid-snap-to', 'true');
     $objWriter->writeAttribute('style:footnote-max-height', '0cm');
     //style:footnote-sep
     $objWriter->startElement('style:footnote-sep');
     $objWriter->writeAttribute('style:width', '0.018cm');
     $objWriter->writeAttribute('style:line-style', 'solid');
     $objWriter->writeAttribute('style:adjustment', 'left');
     $objWriter->writeAttribute('style:rel-width', '25%');
     $objWriter->writeAttribute('style:color', '#000000');
     $objWriter->endElement();
     $objWriter->endElement();
     // style:header-style
     $objWriter->startElement('style:header-style');
     $objWriter->endElement();
     // style:footer-style
     $objWriter->startElement('style:footer-style');
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     // office:master-styles
     $objWriter->startElement('office:master-styles');
     // style:master-page
     $objWriter->startElement('style:master-page');
     $objWriter->writeAttribute('style:name', 'Standard');
     $objWriter->writeAttribute('style:page-layout-name', 'Mpm1');
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 12
0
 public function writeDocPropsCore(PHPWord $pPHPWord = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // cp:coreProperties
     $objWriter->startElement('cp:coreProperties');
     $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
     $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
     $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
     $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     // dc:creator
     $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getCreator());
     // cp:lastModifiedBy
     $objWriter->writeElement('cp:lastModifiedBy', $pPHPWord->getProperties()->getLastModifiedBy());
     // dcterms:created
     $objWriter->startElement('dcterms:created');
     $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
     $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getCreated()));
     $objWriter->endElement();
     // dcterms:modified
     $objWriter->startElement('dcterms:modified');
     $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
     $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getModified()));
     $objWriter->endElement();
     // dc:title
     $objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
     // dc:description
     $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
     // dc:subject
     $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
     // cp:keywords
     $objWriter->writeElement('cp:keywords', $pPHPWord->getProperties()->getKeywords());
     // cp:category
     $objWriter->writeElement('cp:category', $pPHPWord->getProperties()->getCategory());
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Ejemplo n.º 13
0
 /**
  * Write content file to XML format
  *
  * @param    PHPWord $pPHPWord
  * @return    string                        XML Output
  * @throws    Exception
  */
 public function writeContent(PHPWord $pPHPWord = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8');
     // office:document-content
     $objWriter->startElement('office:document-content');
     $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
     $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
     $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
     $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
     $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
     $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
     $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
     $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
     $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
     $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
     $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
     $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
     $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
     $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
     $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
     $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
     $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
     $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
     $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
     $objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
     $objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
     $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
     $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
     $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
     $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
     $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
     $objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
     $objWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0');
     $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
     $objWriter->writeAttribute('office:version', '1.2');
     // We firstly search all fonts used
     $_sections = $pPHPWord->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 PHPWord_Section_Text) {
                     $fStyle = $element->getFontStyle();
                     $pStyle = $element->getParagraphStyle();
                     if ($fStyle instanceof PHPWord_Style_Font) {
                         $numFStyles++;
                         $arrStyle = array('color' => $fStyle->getColor(), 'name' => $fStyle->getName());
                         $pPHPWord->addFontStyle('T' . $numFStyles, $arrStyle);
                         $element->setFontStyle('T' . $numFStyles);
                     } elseif ($pStyle instanceof PHPWord_Style_Paragraph) {
                         $numPStyles++;
                         $pPHPWord->addParagraphStyle('P' . $numPStyles, array());
                         $element->setParagraph('P' . $numPStyles);
                     }
                 }
             }
         }
     }
     // office:font-face-decls
     $objWriter->startElement('office:font-face-decls');
     $arrFonts = array();
     $styles = PHPWord_Style::getStyles();
     $numFonts = 0;
     if (count($styles) > 0) {
         foreach ($styles as $styleName => $style) {
             // PHPWord_Style_Font
             if ($style instanceof PHPWord_Style_Font) {
                 $numFonts++;
                 $name = $style->getName();
                 if (!in_array($name, $arrFonts)) {
                     $arrFonts[] = $name;
                     // style:font-face
                     $objWriter->startElement('style:font-face');
                     $objWriter->writeAttribute('style:name', $name);
                     $objWriter->writeAttribute('svg:font-family', $name);
                     $objWriter->endElement();
                 }
             }
         }
         if (!in_array('Times New Roman', $arrFonts)) {
             $objWriter->startElement('style:font-face');
             $objWriter->writeAttribute('style:name', 'Times New Roman');
             $objWriter->writeAttribute('svg:font-family', 'Times New Roman');
             $objWriter->endElement();
         }
     }
     $objWriter->endElement();
     $objWriter->startElement('office:automatic-styles');
     $styles = PHPWord_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) {
                 // PHPWord_Style_Font
                 if ($style instanceof PHPWord_Style_Font) {
                     $objWriter->startElement('style:style');
                     $objWriter->writeAttribute('style:name', $styleName);
                     $objWriter->writeAttribute('style:family', 'text');
                     // style:text-properties
                     $objWriter->startElement('style:text-properties');
                     $objWriter->writeAttribute('fo:color', '#' . $style->getColor());
                     $objWriter->writeAttribute('style:font-name', $style->getName());
                     $objWriter->writeAttribute('style:font-name-complex', $style->getName());
                     $objWriter->endElement();
                     $objWriter->endElement();
                 }
                 if ($style instanceof PHPWord_Style_Paragraph) {
                     $numPStyles++;
                     // style:style
                     $objWriter->startElement('style:style');
                     $objWriter->writeAttribute('style:name', $styleName);
                     $objWriter->writeAttribute('style:family', 'paragraph');
                     $objWriter->writeAttribute('style:parent-style-name', 'Standard');
                     $objWriter->writeAttribute('style:master-page-name', 'Standard');
                     // style:paragraph-properties
                     $objWriter->startElement('style:paragraph-properties');
                     $objWriter->writeAttribute('style:page-number', 'auto');
                     $objWriter->endElement();
                     $objWriter->endElement();
                 }
             }
         }
         if ($numPStyles == 0) {
             // style:style
             $objWriter->startElement('style:style');
             $objWriter->writeAttribute('style:name', 'P1');
             $objWriter->writeAttribute('style:family', 'paragraph');
             $objWriter->writeAttribute('style:parent-style-name', 'Standard');
             $objWriter->writeAttribute('style:master-page-name', 'Standard');
             // style:paragraph-properties
             $objWriter->startElement('style:paragraph-properties');
             $objWriter->writeAttribute('style:page-number', 'auto');
             $objWriter->endElement();
             $objWriter->endElement();
         }
     }
     $objWriter->endElement();
     // office:body
     $objWriter->startElement('office:body');
     // office:text
     $objWriter->startElement('office:text');
     // text:sequence-decls
     $objWriter->startElement('text:sequence-decls');
     // text:sequence-decl
     $objWriter->startElement('text:sequence-decl');
     $objWriter->writeAttribute('text:display-outline-level', 0);
     $objWriter->writeAttribute('text:name', 'Illustration');
     $objWriter->endElement();
     // text:sequence-decl
     $objWriter->startElement('text:sequence-decl');
     $objWriter->writeAttribute('text:display-outline-level', 0);
     $objWriter->writeAttribute('text:name', 'Table');
     $objWriter->endElement();
     // text:sequence-decl
     $objWriter->startElement('text:sequence-decl');
     $objWriter->writeAttribute('text:display-outline-level', 0);
     $objWriter->writeAttribute('text:name', 'Text');
     $objWriter->endElement();
     // text:sequence-decl
     $objWriter->startElement('text:sequence-decl');
     $objWriter->writeAttribute('text:display-outline-level', 0);
     $objWriter->writeAttribute('text:name', 'Drawing');
     $objWriter->endElement();
     $objWriter->endElement();
     $_sections = $pPHPWord->getSections();
     $countSections = count($_sections);
     $pSection = 0;
     if ($countSections > 0) {
         foreach ($_sections as $section) {
             $pSection++;
             $_elements = $section->getElements();
             foreach ($_elements as $element) {
                 if ($element instanceof PHPWord_Section_Text) {
                     $this->_writeText($objWriter, $element);
                 } elseif ($element instanceof PHPWord_Section_TextBreak) {
                     $this->_writeTextBreak($objWriter);
                 } else {
                     print_r($element);
                     echo '<br />';
                 }
             }
             if ($pSection == $countSections) {
                 $this->_writeEndSection($objWriter, $section);
             } else {
                 $this->_writeSection($objWriter, $section);
             }
         }
     }
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }