PhpOffice\PhpPresentation\Shape\RichText::createParagraph PHP Method

createParagraph() public method

Create paragraph
public createParagraph ( ) : Paragraph
return PhpOffice\PhpPresentation\Shape\RichText\Paragraph
    public function createParagraph()
    {
        $numParagraphs = count($this->richTextParagraphs);
        if ($numParagraphs > 0) {
            $alignment = clone $this->getActiveParagraph()->getAlignment();
            $font = clone $this->getActiveParagraph()->getFont();
            $bulletStyle = clone $this->getActiveParagraph()->getBulletStyle();
        }
        $this->richTextParagraphs[] = new Paragraph();
        $this->activeParagraph = count($this->richTextParagraphs) - 1;
        if (isset($alignment)) {
            $this->getActiveParagraph()->setAlignment($alignment);
        }
        if (isset($font)) {
            $this->getActiveParagraph()->setFont($font);
        }
        if (isset($bulletStyle)) {
            $this->getActiveParagraph()->setBulletStyle($bulletStyle);
        }
        return $this->getActiveParagraph();
    }

Usage Example

Ejemplo n.º 1
0
 public function testActiveParagraph()
 {
     $object = new RichText();
     $this->assertEquals(0, $object->getActiveParagraphIndex());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->createParagraph());
     $this->assertCount(2, $object->getParagraphs());
     $value = rand(0, 1);
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->setActiveParagraph($value));
     $this->assertEquals($value, $object->getActiveParagraphIndex());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->getActiveParagraph());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->getParagraph());
     $value = rand(0, 1);
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->getParagraph($value));
 }
All Usage Examples Of PhpOffice\PhpPresentation\Shape\RichText::createParagraph