/**
  * Write list item element
  */
 public function write()
 {
     $xmlWriter = $this->getXmlWriter();
     $element = $this->getElement();
     if (!$element instanceof \PhpOffice\PhpWord\Element\ListItemRun) {
         return;
     }
     $xmlWriter->startElement('w:p');
     $xmlWriter->startElement('w:pPr');
     $paragraphStyle = $element->getParagraphStyle();
     $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle);
     $styleWriter->setIsInline(true);
     $styleWriter->write();
     $xmlWriter->startElement('w:numPr');
     $xmlWriter->startElement('w:ilvl');
     $xmlWriter->writeAttribute('w:val', $element->getDepth());
     $xmlWriter->endElement();
     // w:ilvl
     $xmlWriter->startElement('w:numId');
     $xmlWriter->writeAttribute('w:val', $element->getStyle()->getNumId());
     $xmlWriter->endElement();
     // w:numId
     $xmlWriter->endElement();
     // w:numPr
     $xmlWriter->endElement();
     // w:pPr
     $containerWriter = new Container($xmlWriter, $element);
     $containerWriter->write();
     $xmlWriter->endElement();
     // w:p
 }
Exemple #2
0
 /**
  * Write part
  *
  * @return string
  */
 public function write()
 {
     $xmlWriter = $this->getXmlWriter();
     $drawingSchema = 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing';
     $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
     $xmlWriter->startElement($this->rootElement);
     $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', $drawingSchema);
     $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');
     $containerWriter = new Container($xmlWriter, $this->element);
     $containerWriter->write();
     $xmlWriter->endElement();
     // $this->rootElement
     return $xmlWriter->getData();
 }
Exemple #3
0
 /**
  * Write element
  */
 public function write()
 {
     $xmlWriter = $this->getXmlWriter();
     $element = $this->getElement();
     if (!$element instanceof \PhpOffice\PhpWord\Element\TextBox) {
         return;
     }
     $style = $element->getStyle();
     $styleWriter = new TextBoxStyleWriter($xmlWriter, $style);
     if (!$this->withoutP) {
         $xmlWriter->startElement('w:p');
         $styleWriter->writeAlignment();
     }
     $xmlWriter->startElement('w:r');
     $xmlWriter->startElement('w:pict');
     $xmlWriter->startElement('v:shape');
     $xmlWriter->writeAttribute('type', '#_x0000_t0202');
     $styleWriter->write();
     $xmlWriter->startElement('v:textbox');
     $styleWriter->writeInnerMargin();
     // TextBox content, serving as a container
     $xmlWriter->startElement('w:txbxContent');
     $containerWriter = new Container($xmlWriter, $element);
     $containerWriter->write();
     $xmlWriter->endElement();
     // w:txbxContent
     $xmlWriter->endElement();
     // v: textbox
     $styleWriter->writeW10Wrap();
     $xmlWriter->endElement();
     // v:shape
     $xmlWriter->endElement();
     // w:pict
     $xmlWriter->endElement();
     // w:r
     if (!$this->withoutP) {
         $xmlWriter->endElement();
         // w:p
     }
 }
 /**
  * Write part
  *
  * @return string
  */
 public function write()
 {
     $phpWord = $this->getParentWriter()->getPhpWord();
     $xmlWriter = $this->getXmlWriter();
     $sections = $phpWord->getSections();
     $sectionCount = count($sections);
     $currentSection = 0;
     $drawingSchema = 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing';
     $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
     $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', $drawingSchema);
     $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');
     if ($sectionCount > 0) {
         foreach ($sections as $section) {
             $currentSection++;
             $containerWriter = new Container($xmlWriter, $section);
             $containerWriter->write();
             if ($currentSection == $sectionCount) {
                 $this->writeSectionSettings($xmlWriter, $section);
             } else {
                 $this->writeSection($xmlWriter, $section);
             }
         }
     }
     $xmlWriter->endElement();
     // w:body
     $xmlWriter->endElement();
     // w:document
     return $xmlWriter->getData();
 }
Exemple #5
0
 /**
  * Write cell.
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param \PhpOffice\PhpWord\Element\Cell $cell
  * @return void
  */
 private function writeCell(XMLWriter $xmlWriter, CellElement $cell)
 {
     $xmlWriter->startElement('w:tc');
     // Write style
     $cellStyle = $cell->getStyle();
     if ($cellStyle instanceof CellStyle) {
         $styleWriter = new CellStyleWriter($xmlWriter, $cellStyle);
         $styleWriter->setWidth($cell->getWidth());
         $styleWriter->write();
     }
     // Write content
     $containerWriter = new Container($xmlWriter, $cell);
     $containerWriter->write();
     $xmlWriter->endElement();
     // w:tc
 }
Exemple #6
0
 /**
  * Write note item
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param \PhpOffice\PhpWord\Element\Footnote|\PhpOffice\PhpWord\Element\Endnote $element
  */
 protected function writeNote(XMLWriter $xmlWriter, $element)
 {
     $xmlWriter->startElement($this->elementNode);
     $xmlWriter->writeAttribute('w:id', $element->getRelationId());
     $xmlWriter->startElement('w:p');
     // Paragraph style
     $styleWriter = new ParagraphStyleWriter($xmlWriter, $element->getParagraphStyle());
     $styleWriter->setIsInline(true);
     $styleWriter->write();
     // Reference symbol
     $xmlWriter->startElement('w:r');
     $xmlWriter->startElement('w:rPr');
     $xmlWriter->startElement('w:rStyle');
     $xmlWriter->writeAttribute('w:val', $this->refStyle);
     $xmlWriter->endElement();
     // w:rStyle
     $xmlWriter->endElement();
     // w:rPr
     $xmlWriter->writeElement($this->refNode);
     $xmlWriter->endElement();
     // w:r
     // Empty space after refence symbol
     $xmlWriter->startElement('w:r');
     $xmlWriter->startElement('w:t');
     $xmlWriter->writeAttribute('xml:space', 'preserve');
     $xmlWriter->writeRaw(' ');
     $xmlWriter->endElement();
     // w:t
     $xmlWriter->endElement();
     // w:r
     $containerWriter = new Container($xmlWriter, $element);
     $containerWriter->write();
     $xmlWriter->endElement();
     // w:p
     $xmlWriter->endElement();
     // $this->elementNode
 }