示例#1
0
 /**
  * Get paragraph style
  */
 public function testParagraph()
 {
     $oText = new Text(htmlspecialchars('text', ENT_COMPAT, 'UTF-8'), 'fontStyle', 'paragraphStyle');
     $this->assertEquals('paragraphStyle', $oText->getParagraphStyle());
     $oText->setParagraphStyle(array('alignment' => Jc::CENTER, 'spaceAfter' => 100));
     $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
 }
示例#2
0
 /**
  * Get paragraph style
  */
 public function testParagraph()
 {
     $oText = new Text('text', 'fontStyle', 'paragraphStyle');
     $this->assertEquals($oText->getParagraphStyle(), 'paragraphStyle');
     $oText->setParagraphStyle(array('align' => 'center', 'spaceAfter' => 100));
     $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oText->getParagraphStyle());
 }
示例#3
0
 /**
  * Get style of individual element
  *
  * @param \PhpOffice\PhpWord\Element\Text $element
  * @param int $paragraphStyleCount
  * @param int $fontStyleCount
  */
 private function getElementStyle(&$element, &$paragraphStyleCount, &$fontStyleCount)
 {
     $fontStyle = $element->getFontStyle();
     $paragraphStyle = $element->getParagraphStyle();
     $phpWord = $this->getParentWriter()->getPhpWord();
     // Font
     if ($fontStyle instanceof Font) {
         $fontStyleCount++;
         $style = $phpWord->addFontStyle("T{$fontStyleCount}", $fontStyle);
         $style->setAuto();
         $element->setFontStyle("T{$fontStyleCount}");
         // Paragraph
     } elseif ($paragraphStyle instanceof Paragraph) {
         $paragraphStyleCount++;
         $style = $phpWord->addParagraphStyle("P{$paragraphStyleCount}", array());
         $style->setAuto();
         $element->setParagraphStyle("P{$paragraphStyleCount}");
     }
 }