Create break
public createBreak ( ) : |
||
Résultat |
/** * Test text methods */ public function testText() { $object = new Paragraph(); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $object->addText(new TextElement())); $this->assertcount(1, $object->getRichTextElements()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->createText()); $this->assertcount(2, $object->getRichTextElements()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $object->createText('AAA')); $this->assertcount(3, $object->getRichTextElements()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $object->createBreak()); $this->assertcount(4, $object->getRichTextElements()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun()); $this->assertcount(5, $object->getRichTextElements()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $object->createTextRun('BBB')); $this->assertcount(6, $object->getRichTextElements()); $this->assertEquals('AAA' . "\r\n" . 'BBB', $object->getPlainText()); $this->assertEquals('AAA' . "\r\n" . 'BBB', (string) $object); }
/** * Read Paragraph Item * @param RichText $oShape * @param \DOMElement $oNodeParent */ protected function readParagraphItem(Paragraph $oParagraph, \DOMElement $oNodeParent) { if ($this->oXMLReader->elementExists('text:line-break', $oNodeParent)) { $oParagraph->createBreak(); } else { $oTextRun = $oParagraph->createTextRun(); if ($oNodeParent->hasAttribute('text:style-name')) { $keyStyle = $oNodeParent->getAttribute('text:style-name'); if (isset($this->arrayStyles[$keyStyle])) { $oTextRun->setFont($this->arrayStyles[$keyStyle]['font']); } } if ($oTextRunLink = $this->oXMLReader->getElement('text:a', $oNodeParent)) { $oTextRun->setText($oTextRunLink->nodeValue); if ($oTextRunLink->hasAttribute('xlink:href')) { $oTextRun->getHyperlink()->setUrl($oTextRunLink->getAttribute('xlink:href')); } } else { $oTextRun->setText($oNodeParent->nodeValue); } } }