コード例 #1
0
ファイル: Content.php プロジェクト: Senasum/PHPWord
 /**
  * Get automatic styles.
  *
  * @param \PhpOffice\PhpWord\PhpWord $phpWord
  * @return void
  */
 private function getAutoStyles(PhpWord $phpWord)
 {
     $sections = $phpWord->getSections();
     $paragraphStyleCount = 0;
     $fontStyleCount = 0;
     foreach ($sections as $section) {
         $style = $section->getStyle();
         $style->setStyleName("Section{$section->getSectionId()}");
         $this->autoStyles['Section'][] = $style;
         $this->getContainerStyle($section, $paragraphStyleCount, $fontStyleCount);
     }
 }
コード例 #2
0
ファイル: PhpWordTest.php プロジェクト: HaiLeader/quizz
 /**
  * Test create/get section
  */
 public function testCreateGetSections()
 {
     $phpWord = new PhpWord();
     $phpWord->addSection();
     $this->assertCount(1, $phpWord->getSections());
 }
コード例 #3
0
ファイル: Content.php プロジェクト: kaantunc/MYK-BOR
 /**
  * Set automatic styles
  */
 private function getAutomaticStyles(PhpWord $phpWord)
 {
     $sections = $phpWord->getSections();
     $sectionCount = count($sections);
     if ($sectionCount > 0) {
         $paragraphStyleCount = 0;
         $fontStyleCount = 0;
         foreach ($sections as $section) {
             $elements = $section->getElements();
             foreach ($elements as $element) {
                 if ($element instanceof Text) {
                     $fontStyle = $element->getFontStyle();
                     $paragraphStyle = $element->getParagraphStyle();
                     // Font
                     if ($fontStyle instanceof Font) {
                         $fontStyleCount++;
                         $arrStyle = array('color' => $fontStyle->getColor(), 'name' => $fontStyle->getName());
                         $phpWord->addFontStyle('T' . $fontStyleCount, $arrStyle);
                         $element->setFontStyle('T' . $fontStyleCount);
                         // Paragraph
                     } elseif ($paragraphStyle instanceof Paragraph) {
                         $paragraphStyleCount++;
                         $phpWord->addParagraphStyle('P' . $paragraphStyleCount, array());
                         $element->setParagraphStyle('P' . $paragraphStyleCount);
                     }
                 }
             }
         }
     }
 }
コード例 #4
-1
ファイル: PhpWordTest.php プロジェクト: kaantunc/MYK-BOR
 /**
  * Test create/get section
  */
 public function testCreateGetSections()
 {
     $phpWord = new PhpWord();
     $this->assertEquals(new Section(1), $phpWord->addSection());
     $phpWord->addSection();
     $this->assertEquals(2, count($phpWord->getSections()));
 }