Example #1
0
 /**
  * Write list item element.
  *
  * @return void
  */
 public function write()
 {
     $xmlWriter = $this->getXmlWriter();
     $element = $this->getElement();
     if (!$element instanceof \PhpOffice\PhpWord\Element\ListItem) {
         return;
     }
     $textObject = $element->getTextObject();
     $styleWriter = new ParagraphStyleWriter($xmlWriter, $textObject->getParagraphStyle());
     $styleWriter->setWithoutPPR(true);
     $styleWriter->setIsInline(true);
     $xmlWriter->startElement('w:p');
     $xmlWriter->startElement('w:pPr');
     $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
     $elementWriter = new Text($xmlWriter, $textObject, true);
     $elementWriter->write();
     $xmlWriter->endElement();
     // w:p
 }
Example #2
0
 /**
  * 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
 }
Example #3
0
 /**
  * Write text break element
  */
 public function write()
 {
     if (!$this->withoutP) {
         $hasStyle = false;
         $fontStyle = null;
         $paragraphStyle = null;
         if (!is_null($this->element)) {
             $fontStyle = $this->element->getFontStyle();
             $paragraphStyle = $this->element->getParagraphStyle();
             $hasStyle = !is_null($fontStyle) || !is_null($paragraphStyle);
         }
         if ($hasStyle) {
             $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle);
             $styleWriter->setIsInline(true);
             $this->xmlWriter->startElement('w:p');
             $styleWriter->write();
             if (!is_null($fontStyle)) {
                 $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle);
                 $styleWriter->setIsInline(true);
                 $this->xmlWriter->startElement('w:pPr');
                 $styleWriter->write();
                 $this->xmlWriter->endElement();
                 // w:pPr
             }
             $this->xmlWriter->endElement();
             // w:p
         } else {
             $this->xmlWriter->writeElement('w:p');
         }
     } else {
         $this->xmlWriter->writeElement('w:br');
     }
 }
Example #4
0
 /**
  * Write link element
  */
 public function write()
 {
     $rId = $this->element->getRelationId() + ($this->element->isInSection() ? 6 : 0);
     $fontStyle = $this->element->getFontStyle();
     $paragraphStyle = $this->element->getParagraphStyle();
     if (!$this->withoutP) {
         $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle);
         $styleWriter->setIsInline(true);
         $this->xmlWriter->startElement('w:p');
         $styleWriter->write();
     }
     $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle);
     $styleWriter->setIsInline(true);
     $this->xmlWriter->startElement('w:hyperlink');
     $this->xmlWriter->writeAttribute('r:id', 'rId' . $rId);
     $this->xmlWriter->writeAttribute('w:history', '1');
     $this->xmlWriter->startElement('w:r');
     $styleWriter->write();
     $this->xmlWriter->startElement('w:t');
     $this->xmlWriter->writeAttribute('xml:space', 'preserve');
     $this->xmlWriter->writeRaw($this->element->getText());
     $this->xmlWriter->endElement();
     // w:t
     $this->xmlWriter->endElement();
     // w:r
     $this->xmlWriter->endElement();
     // w:hyperlink
     if (!$this->withoutP) {
         $this->xmlWriter->endElement();
         // w:p
     }
 }
Example #5
0
 /**
  * Write list item element
  */
 public function write()
 {
     $textObject = $this->element->getTextObject();
     $depth = $this->element->getDepth();
     $numId = $this->element->getStyle()->getNumId();
     $paragraphStyle = $textObject->getParagraphStyle();
     $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle);
     $styleWriter->setWithoutPPR(true);
     $styleWriter->setIsInline(true);
     $this->xmlWriter->startElement('w:p');
     $this->xmlWriter->startElement('w:pPr');
     $styleWriter->write();
     $this->xmlWriter->startElement('w:numPr');
     $this->xmlWriter->startElement('w:ilvl');
     $this->xmlWriter->writeAttribute('w:val', $depth);
     $this->xmlWriter->endElement();
     // w:ilvl
     $this->xmlWriter->startElement('w:numId');
     $this->xmlWriter->writeAttribute('w:val', $numId);
     $this->xmlWriter->endElement();
     // w:numId
     $this->xmlWriter->endElement();
     // w:numPr
     $this->xmlWriter->endElement();
     // w:pPr
     $elementWriter = new ElementWriter($this->xmlWriter, $this->parentWriter, $textObject, true);
     $elementWriter->write();
     $this->xmlWriter->endElement();
     // w:p
 }
Example #6
0
 /**
  * Write text element
  */
 public function write()
 {
     $fontStyle = $this->element->getFontStyle();
     $paragraphStyle = $this->element->getParagraphStyle();
     $text = htmlspecialchars($this->element->getText());
     $text = String::controlCharacterPHP2OOXML($text);
     if (!$this->withoutP) {
         $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle);
         $styleWriter->setIsInline(true);
         $this->xmlWriter->startElement('w:p');
         $styleWriter->write();
     }
     $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle);
     $styleWriter->setIsInline(true);
     $this->xmlWriter->startElement('w:r');
     $styleWriter->write();
     $this->xmlWriter->startElement('w:t');
     $this->xmlWriter->writeAttribute('xml:space', 'preserve');
     $this->xmlWriter->writeRaw($text);
     $this->xmlWriter->endElement();
     $this->xmlWriter->endElement();
     // w:r
     if (!$this->withoutP) {
         $this->xmlWriter->endElement();
         // w:p
     }
 }
Example #7
0
 /**
  * Write preserve text element
  */
 public function write()
 {
     $fontStyle = $this->element->getFontStyle();
     $paragraphStyle = $this->element->getParagraphStyle();
     $texts = $this->element->getText();
     if (!is_array($texts)) {
         $texts = array($texts);
     }
     $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle);
     $styleWriter->setIsInline(true);
     $this->xmlWriter->startElement('w:p');
     $styleWriter->write();
     foreach ($texts as $text) {
         if (substr($text, 0, 1) == '{') {
             $text = substr($text, 1, -1);
             $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle);
             $styleWriter->setIsInline(true);
             $this->xmlWriter->startElement('w:r');
             $this->xmlWriter->startElement('w:fldChar');
             $this->xmlWriter->writeAttribute('w:fldCharType', 'begin');
             $this->xmlWriter->endElement();
             $this->xmlWriter->endElement();
             $this->xmlWriter->startElement('w:r');
             $styleWriter->write();
             $this->xmlWriter->startElement('w:instrText');
             $this->xmlWriter->writeAttribute('xml:space', 'preserve');
             $this->xmlWriter->writeRaw($text);
             $this->xmlWriter->endElement();
             $this->xmlWriter->endElement();
             $this->xmlWriter->startElement('w:r');
             $this->xmlWriter->startElement('w:fldChar');
             $this->xmlWriter->writeAttribute('w:fldCharType', 'separate');
             $this->xmlWriter->endElement();
             $this->xmlWriter->endElement();
             $this->xmlWriter->startElement('w:r');
             $this->xmlWriter->startElement('w:fldChar');
             $this->xmlWriter->writeAttribute('w:fldCharType', 'end');
             $this->xmlWriter->endElement();
             $this->xmlWriter->endElement();
         } else {
             $text = htmlspecialchars($text);
             $text = String::controlCharacterPHP2OOXML($text);
             $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle);
             $styleWriter->setIsInline(true);
             $this->xmlWriter->startElement('w:r');
             $styleWriter->write();
             $this->xmlWriter->startElement('w:t');
             $this->xmlWriter->writeAttribute('xml:space', 'preserve');
             $this->xmlWriter->writeRaw($text);
             $this->xmlWriter->endElement();
             $this->xmlWriter->endElement();
         }
     }
     $this->xmlWriter->endElement();
     // p
 }
Example #8
0
 /**
  * Write textrun element
  */
 public function write()
 {
     $paragraphStyle = $this->element->getParagraphStyle();
     $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle);
     $styleWriter->setIsInline(true);
     $this->xmlWriter->startElement('w:p');
     $styleWriter->write();
     $this->parentWriter->writeContainerElements($this->xmlWriter, $this->element);
     $this->xmlWriter->endElement();
     // w:p
 }
Example #9
0
 /**
  * Write default font and other default styles
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param array $styles
  */
 private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $styles)
 {
     $fontName = $phpWord->getDefaultFontName();
     $fontSize = $phpWord->getDefaultFontSize();
     // Default font
     $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();
     // w:rFonts
     $xmlWriter->startElement('w:sz');
     $xmlWriter->writeAttribute('w:val', $fontSize * 2);
     $xmlWriter->endElement();
     // w:sz
     $xmlWriter->startElement('w:szCs');
     $xmlWriter->writeAttribute('w:val', $fontSize * 2);
     $xmlWriter->endElement();
     // w:szCs
     $xmlWriter->endElement();
     // w:rPr
     $xmlWriter->endElement();
     // w:rPrDefault
     $xmlWriter->endElement();
     // w:docDefaults
     // Normal style
     $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();
     // w:name
     if (array_key_exists('Normal', $styles)) {
         $styleWriter = new ParagraphStyleWriter($xmlWriter, $styles['Normal']);
         $styleWriter->write();
     }
     $xmlWriter->endElement();
     // w:style
     // FootnoteReference style
     if (!array_key_exists('FootnoteReference', $styles)) {
         $xmlWriter->startElement('w:style');
         $xmlWriter->writeAttribute('w:type', 'character');
         $xmlWriter->writeAttribute('w:styleId', 'FootnoteReference');
         $xmlWriter->startElement('w:name');
         $xmlWriter->writeAttribute('w:val', 'Footnote Reference');
         $xmlWriter->endElement();
         // w:name
         $xmlWriter->writeElement('w:semiHidden');
         $xmlWriter->writeElement('w:unhideWhenUsed');
         $xmlWriter->startElement('w:rPr');
         $xmlWriter->startElement('w:vertAlign');
         $xmlWriter->writeAttribute('w:val', 'superscript');
         $xmlWriter->endElement();
         // w:vertAlign
         $xmlWriter->endElement();
         // w:rPr
         $xmlWriter->endElement();
         // w:style
     }
 }
Example #10
0
 /**
  * Write ending
  */
 protected function writeParagraphStyle()
 {
     $xmlWriter = $this->getXmlWriter();
     /** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
     $element = $this->getElement();
     $paragraphStyle = $element->getParagraphStyle();
     $styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle);
     $styleWriter->setIsInline(true);
     $styleWriter->write();
 }
Example #11
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
     $this->writeContainerElements($xmlWriter, $element);
     $xmlWriter->endElement();
     // w:p
     $xmlWriter->endElement();
     // $this->elementNode
 }
Example #12
0
 /**
  * Write style
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param \PhpOffice\PhpWord\Element\TOC $element
  * @param int $indent
  */
 private function writeStyle(XMLWriter $xmlWriter, TOCElement $element, $indent)
 {
     $tocStyle = $element->getStyleTOC();
     $fontStyle = $element->getStyleFont();
     $isObject = $fontStyle instanceof Font ? true : false;
     $xmlWriter->startElement('w:pPr');
     // Paragraph
     if ($isObject && !is_null($fontStyle->getParagraph())) {
         $styleWriter = new ParagraphStyleWriter($xmlWriter, $fontStyle->getParagraph());
         $styleWriter->write();
     }
     // Font
     if (!empty($fontStyle) && !$isObject) {
         $xmlWriter->startElement('w:rPr');
         $xmlWriter->startElement('w:rStyle');
         $xmlWriter->writeAttribute('w:val', $fontStyle);
         $xmlWriter->endElement();
         $xmlWriter->endElement();
         // w:rPr
     }
     // Tab
     $xmlWriter->startElement('w:tabs');
     $styleWriter = new TabStyleWriter($xmlWriter, $tocStyle);
     $styleWriter->write();
     $xmlWriter->endElement();
     // Indent
     if ($indent > 0) {
         $xmlWriter->startElement('w:ind');
         $xmlWriter->writeAttribute('w:left', $indent);
         $xmlWriter->endElement();
     }
     $xmlWriter->endElement();
     // w:pPr
 }
Example #13
0
 /**
  * Write paragraph style
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param string $styleName
  * @param \PhpOffice\PhpWord\Style\Paragraph $style
  */
 private function writeParagraphStyle(XMLWriter $xmlWriter, $styleName, ParagraphStyle $style)
 {
     $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();
     $xmlWriter->writeElementIf(!is_null($basedOn), 'w:basedOn', 'w:val', $basedOn);
     // Next paragraph style
     $next = $style->getNext();
     $xmlWriter->writeElementIf(!is_null($next), 'w:next', 'w:val', $next);
     // w:pPr
     $styleWriter = new ParagraphStyleWriter($xmlWriter, $style);
     $styleWriter->write();
     $xmlWriter->endElement();
 }
Example #14
0
 /**
  * Write element
  */
 public function write()
 {
     $name = htmlspecialchars($this->element->getName());
     $name = String::controlCharacterPHP2OOXML($name);
     $text = htmlspecialchars($this->element->getText());
     $text = String::controlCharacterPHP2OOXML($text);
     $fontStyle = $this->element->getFontStyle();
     $paragraphStyle = $this->element->getParagraphStyle();
     if (!$this->withoutP) {
         $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $paragraphStyle);
         $styleWriter->setIsInline(true);
         $this->xmlWriter->startElement('w:p');
         $styleWriter->write();
     }
     $this->xmlWriter->startElement('w:r');
     $this->xmlWriter->startElement('w:fldChar');
     $this->xmlWriter->writeAttribute('w:fldCharType', 'begin');
     $this->xmlWriter->startElement('w:ffData');
     $this->xmlWriter->startElement('w:name');
     $this->xmlWriter->writeAttribute('w:val', $name);
     $this->xmlWriter->endElement();
     //w:name
     $this->xmlWriter->writeAttribute('w:enabled', '');
     $this->xmlWriter->startElement('w:calcOnExit');
     $this->xmlWriter->writeAttribute('w:val', '0');
     $this->xmlWriter->endElement();
     //w:calcOnExit
     $this->xmlWriter->startElement('w:checkBox');
     $this->xmlWriter->writeAttribute('w:sizeAuto', '');
     $this->xmlWriter->startElement('w:default');
     $this->xmlWriter->writeAttribute('w:val', 0);
     $this->xmlWriter->endElement();
     //w:default
     $this->xmlWriter->endElement();
     //w:checkBox
     $this->xmlWriter->endElement();
     // w:ffData
     $this->xmlWriter->endElement();
     // w:fldChar
     $this->xmlWriter->endElement();
     // w:r
     $this->xmlWriter->startElement('w:r');
     $this->xmlWriter->startElement('w:instrText');
     $this->xmlWriter->writeAttribute('xml:space', 'preserve');
     $this->xmlWriter->writeRaw(' FORMCHECKBOX ');
     $this->xmlWriter->endElement();
     // w:instrText
     $this->xmlWriter->endElement();
     // w:r
     $this->xmlWriter->startElement('w:r');
     $this->xmlWriter->startElement('w:fldChar');
     $this->xmlWriter->writeAttribute('w:fldCharType', 'seperate');
     $this->xmlWriter->endElement();
     // w:fldChar
     $this->xmlWriter->endElement();
     // w:r
     $this->xmlWriter->startElement('w:r');
     $this->xmlWriter->startElement('w:fldChar');
     $this->xmlWriter->writeAttribute('w:fldCharType', 'end');
     $this->xmlWriter->endElement();
     // w:fldChar
     $this->xmlWriter->endElement();
     // w:r
     $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle);
     $styleWriter->setIsInline(true);
     $this->xmlWriter->startElement('w:r');
     $styleWriter->write();
     $this->xmlWriter->startElement('w:t');
     $this->xmlWriter->writeAttribute('xml:space', 'preserve');
     $this->xmlWriter->writeRaw($text);
     $this->xmlWriter->endElement();
     // w:t
     $this->xmlWriter->endElement();
     // w:r
     if (!$this->withoutP) {
         $this->xmlWriter->endElement();
         // w:p
     }
 }
Example #15
0
 /**
  * Write element
  */
 public function write()
 {
     $titles = $this->element->getTitles();
     $fontStyle = $this->element->getStyleFont();
     $tocStyle = $this->element->getStyleTOC();
     $fIndent = $tocStyle->getIndent();
     $tabLeader = $tocStyle->getTabLeader();
     $tabPos = $tocStyle->getTabPos();
     $maxDepth = $this->element->getMaxDepth();
     $minDepth = $this->element->getMinDepth();
     $isObject = $fontStyle instanceof Font ? true : false;
     for ($i = 0; $i < count($titles); $i++) {
         $title = $titles[$i];
         $indent = ($title['depth'] - 1) * $fIndent;
         $this->xmlWriter->startElement('w:p');
         $this->xmlWriter->startElement('w:pPr');
         if ($isObject && !is_null($fontStyle->getParagraphStyle())) {
             $styleWriter = new ParagraphStyleWriter($this->xmlWriter, $fontStyle->getParagraphStyle());
             $styleWriter->write();
         }
         if ($indent > 0) {
             $this->xmlWriter->startElement('w:ind');
             $this->xmlWriter->writeAttribute('w:left', $indent);
             $this->xmlWriter->endElement();
         }
         if (!empty($fontStyle) && !$isObject) {
             $this->xmlWriter->startElement('w:pPr');
             $this->xmlWriter->startElement('w:pStyle');
             $this->xmlWriter->writeAttribute('w:val', $fontStyle);
             $this->xmlWriter->endElement();
             $this->xmlWriter->endElement();
         }
         $this->xmlWriter->startElement('w:tabs');
         $this->xmlWriter->startElement('w:tab');
         $this->xmlWriter->writeAttribute('w:val', 'right');
         if (!empty($tabLeader)) {
             $this->xmlWriter->writeAttribute('w:leader', $tabLeader);
         }
         $this->xmlWriter->writeAttribute('w:pos', $tabPos);
         $this->xmlWriter->endElement();
         $this->xmlWriter->endElement();
         $this->xmlWriter->endElement();
         // w:pPr
         if ($i == 0) {
             $this->xmlWriter->startElement('w:r');
             $this->xmlWriter->startElement('w:fldChar');
             $this->xmlWriter->writeAttribute('w:fldCharType', 'begin');
             $this->xmlWriter->endElement();
             $this->xmlWriter->endElement();
             $this->xmlWriter->startElement('w:r');
             $this->xmlWriter->startElement('w:instrText');
             $this->xmlWriter->writeAttribute('xml:space', 'preserve');
             $this->xmlWriter->writeRaw('TOC \\o "' . $minDepth . '-' . $maxDepth . '" \\h \\z \\u');
             $this->xmlWriter->endElement();
             $this->xmlWriter->endElement();
             $this->xmlWriter->startElement('w:r');
             $this->xmlWriter->startElement('w:fldChar');
             $this->xmlWriter->writeAttribute('w:fldCharType', 'separate');
             $this->xmlWriter->endElement();
             $this->xmlWriter->endElement();
         }
         $this->xmlWriter->startElement('w:hyperlink');
         $this->xmlWriter->writeAttribute('w:anchor', $title['anchor']);
         $this->xmlWriter->writeAttribute('w:history', '1');
         $this->xmlWriter->startElement('w:r');
         if ($isObject) {
             $styleWriter = new FontStyleWriter($this->xmlWriter, $fontStyle);
             $styleWriter->write();
         }
         $this->xmlWriter->startElement('w:t');
         $this->xmlWriter->writeRaw($title['text']);
         $this->xmlWriter->endElement();
         $this->xmlWriter->endElement();
         $this->xmlWriter->startElement('w:r');
         $this->xmlWriter->writeElement('w:tab', null);
         $this->xmlWriter->endElement();
         $this->xmlWriter->startElement('w:r');
         $this->xmlWriter->startElement('w:fldChar');
         $this->xmlWriter->writeAttribute('w:fldCharType', 'begin');
         $this->xmlWriter->endElement();
         $this->xmlWriter->endElement();
         $this->xmlWriter->startElement('w:r');
         $this->xmlWriter->startElement('w:instrText');
         $this->xmlWriter->writeAttribute('xml:space', 'preserve');
         $this->xmlWriter->writeRaw('PAGEREF ' . $title['anchor'] . ' \\h');
         $this->xmlWriter->endElement();
         $this->xmlWriter->endElement();
         $this->xmlWriter->startElement('w:r');
         $this->xmlWriter->startElement('w:fldChar');
         $this->xmlWriter->writeAttribute('w:fldCharType', 'end');
         $this->xmlWriter->endElement();
         $this->xmlWriter->endElement();
         $this->xmlWriter->endElement();
         // w:hyperlink
         $this->xmlWriter->endElement();
         // w:p
     }
     $this->xmlWriter->startElement('w:p');
     $this->xmlWriter->startElement('w:r');
     $this->xmlWriter->startElement('w:fldChar');
     $this->xmlWriter->writeAttribute('w:fldCharType', 'end');
     $this->xmlWriter->endElement();
     $this->xmlWriter->endElement();
     $this->xmlWriter->endElement();
 }