/**
  * Add title with predefined style
  *
  * @coversNothing
  */
 public function testAddTitleWithStyle()
 {
     Style::addTitleStyle(1, array('size' => 14));
     $section = new Section(0);
     $section->setPhpWord(new PhpWord());
     $section->addTitle('Test', 1);
     $elementCollection = $section->getElements();
     $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Title', $elementCollection[0]);
 }
Ejemplo n.º 2
0
 /**
  * Add and get paragraph, font, link, title, and table styles
  *
  * @covers ::addParagraphStyle
  * @covers ::addFontStyle
  * @covers ::addLinkStyle
  * @covers ::addTitleStyle
  * @covers ::addTableStyle
  * @covers ::setDefaultParagraphStyle
  * @covers ::countStyles
  * @covers ::getStyle
  * @covers ::resetStyles
  * @covers ::getStyles
  * @test
  */
 public function testStyles()
 {
     $paragraph = array('alignment' => Jc::CENTER);
     $font = array('italic' => true, '_bold' => true);
     $table = array('bgColor' => 'CCCCCC');
     $styles = array('Paragraph' => 'Paragraph', 'Font' => 'Font', 'Link' => 'Font', 'Table' => 'Table', 'Heading_1' => 'Font', 'Normal' => 'Paragraph');
     Style::addParagraphStyle('Paragraph', $paragraph);
     Style::addFontStyle('Font', $font);
     Style::addLinkStyle('Link', $font);
     // @todo Style::addNumberingStyle
     Style::addTitleStyle(1, $font);
     Style::addTableStyle('Table', $table);
     Style::setDefaultParagraphStyle($paragraph);
     $this->assertCount(count($styles), Style::getStyles());
     foreach ($styles as $name => $style) {
         $this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$style}", Style::getStyle($name));
     }
     $this->assertNull(Style::getStyle('Unknown'));
     Style::resetStyles();
     $this->assertCount(0, Style::getStyles());
 }
Ejemplo n.º 3
0
 /**
  * Adds a heading style definition to styles.xml
  *
  * @param int $depth
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  * @return \PhpOffice\PhpWord\Style\Font
  */
 public function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
 {
     return Style::addTitleStyle($depth, $fontStyle, $paragraphStyle);
 }
Ejemplo n.º 4
0
 /**
  * Adds a heading style definition to styles.xml
  *
  * @param int $titleCount
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  */
 public function addTitleStyle($titleCount, $fontStyle, $paragraphStyle = null)
 {
     Style::addTitleStyle($titleCount, $fontStyle, $paragraphStyle);
 }