예제 #1
0
 /**
  * Write alignment.
  *
  * @return void
  */
 public function writeAlignment()
 {
     $style = $this->getStyle();
     if (!$style instanceof FrameStyle) {
         return;
     }
     $xmlWriter = $this->getXmlWriter();
     $xmlWriter->startElement('w:pPr');
     if ('' !== $style->getAlignment()) {
         $paragraphAlignment = new ParagraphAlignment($style->getAlignment());
         $xmlWriter->startElement($paragraphAlignment->getName());
         foreach ($paragraphAlignment->getAttributes() as $attributeName => $attributeValue) {
             $xmlWriter->writeAttribute($attributeName, $attributeValue);
         }
         $xmlWriter->endElement();
     }
     $xmlWriter->endElement();
 }
예제 #2
0
 /**
  * Write full style.
  *
  * @return void
  */
 private function writeStyle()
 {
     $style = $this->getStyle();
     if (!$style instanceof ParagraphStyle) {
         return;
     }
     $xmlWriter = $this->getXmlWriter();
     $styles = $style->getStyleValues();
     if (!$this->withoutPPR) {
         $xmlWriter->startElement('w:pPr');
     }
     // Style name
     if ($this->isInline === true) {
         $xmlWriter->writeElementIf($styles['name'] !== null, 'w:pStyle', 'w:val', $styles['name']);
     }
     // Pagination
     $xmlWriter->writeElementIf($styles['pagination']['widowControl'] === false, 'w:widowControl', 'w:val', '0');
     $xmlWriter->writeElementIf($styles['pagination']['keepNext'] === true, 'w:keepNext', 'w:val', '1');
     $xmlWriter->writeElementIf($styles['pagination']['keepLines'] === true, 'w:keepLines', 'w:val', '1');
     $xmlWriter->writeElementIf($styles['pagination']['pageBreak'] === true, 'w:pageBreakBefore', 'w:val', '1');
     // Paragraph alignment
     if ('' !== $styles['alignment']) {
         $paragraphAlignment = new ParagraphAlignment($styles['alignment']);
         $xmlWriter->startElement($paragraphAlignment->getName());
         foreach ($paragraphAlignment->getAttributes() as $attributeName => $attributeValue) {
             $xmlWriter->writeAttribute($attributeName, $attributeValue);
         }
         $xmlWriter->endElement();
     }
     // Child style: alignment, indentation, spacing, and shading
     $this->writeChildStyle($xmlWriter, 'Indentation', $styles['indentation']);
     $this->writeChildStyle($xmlWriter, 'Spacing', $styles['spacing']);
     $this->writeChildStyle($xmlWriter, 'Shading', $styles['shading']);
     // Tabs
     $this->writeTabs($xmlWriter, $styles['tabs']);
     // Numbering
     $this->writeNumbering($xmlWriter, $styles['numbering']);
     // Border
     if ($style->hasBorder()) {
         $xmlWriter->startElement('w:pBdr');
         $styleWriter = new MarginBorder($xmlWriter);
         $styleWriter->setSizes($style->getBorderSize());
         $styleWriter->setColors($style->getBorderColor());
         $styleWriter->write();
         $xmlWriter->endElement();
     }
     if (!$this->withoutPPR) {
         $xmlWriter->endElement();
         // w:pPr
     }
 }