Example #1
0
 protected function _writeParagraphStyle(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Style_Paragraph $style, $withoutPPR = false)
 {
     $flag = false;
     $align = $style->getAlign();
     $spaceBefore = $style->getSpaceBefore();
     $spaceAfter = $style->getSpaceAfter();
     $spacing = $style->getSpacing();
     $indentLeft = $style->getIndentLeft();
     $indentRight = $style->getIndentRight();
     $indentFirstLine = $style->getIndentFirstLine();
     $indentFirstLineChars = $style->getIndentFirstLineChars();
     if (!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter)) {
         if (!$withoutPPR) {
             $objWriter->startElement('w:pPr');
             $flag = true;
         }
         if (!is_null($align)) {
             $objWriter->startElement('w:jc');
             $objWriter->writeAttribute('w:val', $align);
             $objWriter->endElement();
         }
         if (!is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($spacing)) {
             $objWriter->startElement('w:spacing');
             if (!is_null($spaceBefore)) {
                 $objWriter->writeAttribute('w:before', $spaceBefore);
             }
             if (!is_null($spaceAfter)) {
                 $objWriter->writeAttribute('w:after', $spaceAfter);
             }
             if (!is_null($spacing)) {
                 $objWriter->writeAttribute('w:line', $spacing);
                 $objWriter->writeAttribute('w:lineRule', 'auto');
             }
             $objWriter->endElement();
         }
     }
     if (!is_null($indentLeft) || !is_null($indentRight) || !is_null($indentFirstLine) || !is_null($indentFirstLineChars)) {
         $objWriter->startElement('w:ind');
         if (!is_null($indentLeft)) {
             $objWriter->writeAttribute('w:left', $indentLeft);
         }
         if (!is_null($indentRight)) {
             $objWriter->writeAttribute('w:right', $indentRight);
         }
         if (!is_null($indentFirstLine)) {
             $objWriter->writeAttribute('w:firstLine', $indentFirstLine);
         }
         if (!is_null($indentFirstLineChars)) {
             $objWriter->writeAttribute('w:firstLineChars', $indentFirstLineChars);
             $objWriter->writeAttribute('w:firstLine', '420');
         }
         $objWriter->endElement();
     }
     if (!$withoutPPR && $flag) {
         $objWriter->endElement();
         // w:pPr
     }
 }