Example #1
0
 /**
  * Construct with named font style
  */
 public function testConstructWithStyleName()
 {
     $object = new TOC('Font Style');
     // $tocStyle = $object->getStyleTOC();
     $this->assertEquals('Font Style', $object->getStyleFont());
 }
Example #2
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
 }