diff --git a/docs/changes/1.0.0.md b/docs/changes/1.0.0.md index cf6f68849..e1b1473b0 100644 --- a/docs/changes/1.0.0.md +++ b/docs/changes/1.0.0.md @@ -30,6 +30,11 @@ - ODPresentation Writer - PowerPoint2007 Reader - PowerPoint2007 Writer +- Support for RTL in Alignment & Font Format (Latin/East Asian/Complex Script) - @amirakbari GH-629 & @Progi1986 GH-657 + - ODPresentation Reader + - ODPresentation Writer + - PowerPoint2007 Reader + - PowerPoint2007 Writer ## Project Management - Migrated from Travis CI to Github Actions - @Progi1984 GH-635 diff --git a/docs/credits.md b/docs/credits.md index 222b31a0e..7a5c36329 100644 --- a/docs/credits.md +++ b/docs/credits.md @@ -32,6 +32,7 @@ Library of Congress : ### OpenDocument - [Oasis OpenDocument Standard Version 1.2](http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html) +- [Schema Central Open Document 1.1](http://www.datypic.com/sc/odf/ss.html) ### PowerPoint 97 diff --git a/docs/usage/styles.md b/docs/usage/styles.md index 1deba1d90..ba2147985 100644 --- a/docs/usage/styles.md +++ b/docs/usage/styles.md @@ -25,12 +25,14 @@ Properties: Use this style to define border of a shape as example below. -.. code-block:: php +``` php +getBorder() ->setLineStyle(Border::LINE_SINGLE) ->setLineWidth(4) ->getColor()->setARGB('FFC00000'); +``` Properties: @@ -71,6 +73,25 @@ Properties: - `marginLeft` - `marginRight` +### RTL / LTR + +You can define if the alignment is RTL or LTR. + +``` php +setIsRTL(true); +// Set alignment to LTR +$alignment->setIsRTL(false); +// Is the alignment RTL? +echo $alignment->isRTL(); +``` + ## Font - `name` @@ -82,6 +103,26 @@ Properties: - `strikethrough` - `color` +### Format + +Some formats are available : + +* `Font::FORMAT_LATIN` +* `Font::FORMAT_EAST_ASIAN` +* `Font::FORMAT_COMPLEX_SCRIPT` + +``` php +setFormat(Font::FORMAT_EAST_ASIAN); +// Get format of font +echo $font->getFormat(); +``` ## Bullet - `bulletType` diff --git a/samples/Sample_01_Simple.php b/samples/Sample_01_Simple.php index e7ebd0b9a..1ecb00302 100644 --- a/samples/Sample_01_Simple.php +++ b/samples/Sample_01_Simple.php @@ -5,6 +5,7 @@ use PhpOffice\PhpPresentation\PhpPresentation; use PhpOffice\PhpPresentation\Style\Alignment; use PhpOffice\PhpPresentation\Style\Color; +use PhpOffice\PhpPresentation\Style\Font; // Create new PHPPresentation object echo date('H:i:s') . ' Create new PHPPresentation object' . EOL; @@ -44,13 +45,32 @@ ->setHeight(300) ->setWidth(600) ->setOffsetX(170) - ->setOffsetY(180); -$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER); + ->setOffsetY(100); +$shape->getActiveParagraph()->getAlignment() + ->setHorizontal(Alignment::HORIZONTAL_CENTER); $textRun = $shape->createTextRun('Thank you for using PHPPresentation!'); $textRun->getFont()->setBold(true) ->setSize(60) ->setColor(new Color('FFE06B20')); +// Create a shape (text) +echo date('H:i:s') . ' Create a shape (rich text)' . EOL; +$shape = $currentSlide->createRichTextShape() + ->setHeight(300) + ->setWidth(600) + ->setOffsetX(170) + ->setOffsetY(550); +$shape->getActiveParagraph()->getAlignment() + ->setHorizontal(Alignment::HORIZONTAL_RIGHT) + ->setIsRTL(true); +$textRun = $shape->createTextRun('تست فونت فارسی'); +$textRun->getFont() + ->setBold(true) + ->setSize(60) + ->setColor(new Color('FFE06B20')) + ->setFormat(Font::FORMAT_COMPLEX_SCRIPT) + ->setName('B Nazanin'); + // Save file echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers); if (!CLI) { diff --git a/src/PhpPresentation/Reader/ODPresentation.php b/src/PhpPresentation/Reader/ODPresentation.php index 8d18d029c..a7fd1fde6 100644 --- a/src/PhpPresentation/Reader/ODPresentation.php +++ b/src/PhpPresentation/Reader/ODPresentation.php @@ -300,14 +300,66 @@ protected function loadStyle(DOMElement $nodeStyle) if ($nodeTextProperties->hasAttribute('fo:color')) { $oFont->getColor()->setRGB(substr($nodeTextProperties->getAttribute('fo:color'), -6)); } + // Font Latin if ($nodeTextProperties->hasAttribute('fo:font-family')) { - $oFont->setName($nodeTextProperties->getAttribute('fo:font-family')); + $oFont + ->setName($nodeTextProperties->getAttribute('fo:font-family')) + ->setFormat(Font::FORMAT_LATIN); } if ($nodeTextProperties->hasAttribute('fo:font-weight') && 'bold' == $nodeTextProperties->getAttribute('fo:font-weight')) { - $oFont->setBold(true); + $oFont + ->setBold(true) + ->setFormat(Font::FORMAT_LATIN); } if ($nodeTextProperties->hasAttribute('fo:font-size')) { - $oFont->setSize((int) substr($nodeTextProperties->getAttribute('fo:font-size'), 0, -2)); + $oFont + ->setSize((int) substr($nodeTextProperties->getAttribute('fo:font-size'), 0, -2)) + ->setFormat(Font::FORMAT_LATIN); + } + // Font East Asian + if ($nodeTextProperties->hasAttribute('style:font-family-asian')) { + $oFont + ->setName($nodeTextProperties->getAttribute('style:font-family-asian')) + ->setFormat(Font::FORMAT_EAST_ASIAN); + } + if ($nodeTextProperties->hasAttribute('style:font-weight-asian') && 'bold' == $nodeTextProperties->getAttribute('style:font-weight-asian')) { + $oFont + ->setBold(true) + ->setFormat(Font::FORMAT_EAST_ASIAN); + } + if ($nodeTextProperties->hasAttribute('style:font-size-asian')) { + $oFont + ->setSize((int) substr($nodeTextProperties->getAttribute('style:font-size-asian'), 0, -2)) + ->setFormat(Font::FORMAT_EAST_ASIAN); + } + // Font Complex Script + if ($nodeTextProperties->hasAttribute('style:font-family-complex')) { + $oFont + ->setName($nodeTextProperties->getAttribute('style:font-family-complex')) + ->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + } + if ($nodeTextProperties->hasAttribute('style:font-weight-complex') && 'bold' == $nodeTextProperties->getAttribute('style:font-weight-complex')) { + $oFont + ->setBold(true) + ->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + } + if ($nodeTextProperties->hasAttribute('style:font-size-complex')) { + $oFont + ->setSize((int) substr($nodeTextProperties->getAttribute('style:font-size-complex'), 0, -2)) + ->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + } + if ($nodeTextProperties->hasAttribute('style:script-type')) { + switch ($nodeTextProperties->getAttribute('style:script-type')) { + case 'latin': + $oFont->setFormat(Font::FORMAT_LATIN); + break; + case 'asian': + $oFont->setFormat(Font::FORMAT_EAST_ASIAN); + break; + case 'complex': + $oFont->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + break; + } } } @@ -317,6 +369,24 @@ protected function loadStyle(DOMElement $nodeStyle) if ($nodeParagraphProps->hasAttribute('fo:text-align')) { $oAlignment->setHorizontal($nodeParagraphProps->getAttribute('fo:text-align')); } + if ($nodeParagraphProps->hasAttribute('style:writing-mode')) { + switch ($nodeParagraphProps->getAttribute('style:writing-mode')) { + case 'lr-tb': + case 'tb-lr': + case 'lr': + $oAlignment->setIsRTL(false); + break; + case 'rl-tb': + case 'tb-rl': + case 'rl': + $oAlignment->setIsRTL(false); + break; + case 'tb': + case 'page': + default: + break; + } + } } if ('text:list-style' == $nodeStyle->nodeName) { diff --git a/src/PhpPresentation/Reader/PowerPoint2007.php b/src/PhpPresentation/Reader/PowerPoint2007.php index 4ab57d8d6..558ece186 100644 --- a/src/PhpPresentation/Reader/PowerPoint2007.php +++ b/src/PhpPresentation/Reader/PowerPoint2007.php @@ -42,6 +42,7 @@ use PhpOffice\PhpPresentation\Style\Bullet; use PhpOffice\PhpPresentation\Style\Color; use PhpOffice\PhpPresentation\Style\Fill; +use PhpOffice\PhpPresentation\Style\Font; use PhpOffice\PhpPresentation\Style\SchemeColor; use PhpOffice\PhpPresentation\Style\TextStyle; use ZipArchive; @@ -1093,6 +1094,9 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh if ($oSubElement->hasAttribute('lvl')) { $oParagraph->getAlignment()->setLevel((int) $oSubElement->getAttribute('lvl')); } + if ($oSubElement->hasAttribute('rtl')) { + $oParagraph->getAlignment()->setIsRTL((bool) $oSubElement->getAttribute('rtl')); + } $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE); @@ -1179,6 +1183,27 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh $oText->getHyperlink()->setUrl($this->arrayRels[$this->fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target']); } } + // Font + $oElementFontFormat = null; + $oElementFontFormatLatin = $document->getElement('a:latin', $oElementrPr); + if (is_object($oElementFontFormatLatin)) { + $oText->getFont()->setFormat(Font::FORMAT_LATIN); + $oElementFontFormat = $oElementFontFormatLatin; + } + $oElementFontFormatEastAsian = $document->getElement('a:ea', $oElementrPr); + if (is_object($oElementFontFormatEastAsian)) { + $oText->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); + $oElementFontFormat = $oElementFontFormatEastAsian; + } + $oElementFontFormatComplexScript = $document->getElement('a:cs', $oElementrPr); + if (is_object($oElementFontFormatComplexScript)) { + $oText->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + $oElementFontFormat = $oElementFontFormatComplexScript; + } + if (is_object($oElementFontFormat) && $oElementFontFormat->hasAttribute('typeface')) { + $oText->getFont()->setName($oElementFontFormat->getAttribute('typeface')); + } + //} else { // $oText = $oParagraph->createText(); diff --git a/src/PhpPresentation/Style/Alignment.php b/src/PhpPresentation/Style/Alignment.php index 55058ebbd..cf0c92202 100644 --- a/src/PhpPresentation/Style/Alignment.php +++ b/src/PhpPresentation/Style/Alignment.php @@ -118,6 +118,13 @@ class Alignment implements ComparableInterface */ private $marginBottom = 0; + /** + * RTL Direction Support + * + * @var bool + */ + private $isRTL = false; + /** * Hash index. * @@ -319,6 +326,26 @@ public function setTextDirection(string $pValue = self::TEXT_DIRECTION_HORIZONTA return $this; } + /** + * @return bool + */ + public function isRTL(): bool + { + return $this->isRTL; + } + + /** + * @param bool $value + * + * @return self + */ + public function setIsRTL(bool $value = false): self + { + $this->isRTL = $value; + + return $this; + } + /** * Get hash code. * @@ -333,6 +360,7 @@ public function getHashCode(): string . $this->indent . $this->marginLeft . $this->marginRight + . ($this->isRTL ? '1' : '0') . __CLASS__ ); } diff --git a/src/PhpPresentation/Style/Font.php b/src/PhpPresentation/Style/Font.php index 8113052e7..87b841c22 100644 --- a/src/PhpPresentation/Style/Font.php +++ b/src/PhpPresentation/Style/Font.php @@ -45,61 +45,65 @@ class Font implements ComparableInterface public const UNDERLINE_WAVYHEAVY = 'wavyHeavy'; public const UNDERLINE_WORDS = 'words'; + public const FORMAT_LATIN = 'latin'; + public const FORMAT_EAST_ASIAN = 'ea'; + public const FORMAT_COMPLEX_SCRIPT = 'cs'; + /** * Name. * * @var string */ - private $name; + private $name = 'Calibri'; /** * Font Size. * * @var int */ - private $size; + private $size = 10; /** * Bold. * * @var bool */ - private $bold; + private $bold = false; /** * Italic. * * @var bool */ - private $italic; + private $italic = false; /** * Superscript. * * @var bool */ - private $superScript; + private $superScript = false; /** * Subscript. * * @var bool */ - private $subScript; + private $subScript = false; /** * Underline. * * @var string */ - private $underline; + private $underline = self::UNDERLINE_NONE; /** * Strikethrough. * * @var bool */ - private $strikethrough; + private $strikethrough = false; /** * Foreground color. @@ -111,9 +115,16 @@ class Font implements ComparableInterface /** * Character Spacing. * - * @var int + * @var float + */ + private $characterSpacing = 0; + + /** + * Format + * + * @var string */ - private $characterSpacing; + private $format = self::FORMAT_LATIN; /** * Hash index. @@ -122,42 +133,29 @@ class Font implements ComparableInterface */ private $hashIndex; - /** - * Create a new \PhpOffice\PhpPresentation\Style\Font. - */ public function __construct() { - // Initialise values - $this->name = 'Calibri'; - $this->size = 10; - $this->characterSpacing = 0; - $this->bold = false; - $this->italic = false; - $this->superScript = false; - $this->subScript = false; - $this->underline = self::UNDERLINE_NONE; - $this->strikethrough = false; $this->color = new Color(Color::COLOR_BLACK); } /** - * Get Name. + * Get Name * * @return string */ - public function getName() + public function getName(): string { return $this->name; } /** - * Set Name. + * Set Name * * @param string $pValue * - * @return \PhpOffice\PhpPresentation\Style\Font + * @return self */ - public function setName($pValue = 'Calibri') + public function setName(string $pValue = 'Calibri'): self { if ('' == $pValue) { $pValue = 'Calibri'; @@ -172,7 +170,7 @@ public function setName($pValue = 'Calibri') * * @return float */ - public function getCharacterSpacing() + public function getCharacterSpacing(): float { return $this->characterSpacing; } @@ -181,15 +179,12 @@ public function getCharacterSpacing() * Set Character Spacing * Value in pt. * - * @param float|int $pValue + * @param float $pValue * - * @return \PhpOffice\PhpPresentation\Style\Font + * @return self */ - public function setCharacterSpacing($pValue = 0) + public function setCharacterSpacing(float $pValue = 0): self { - if ('' == $pValue) { - $pValue = 0; - } $this->characterSpacing = $pValue * 100; return $this; @@ -218,7 +213,7 @@ public function setSize(int $pValue = 10): self * * @return bool */ - public function isBold() + public function isBold(): bool { return $this->bold; } @@ -238,7 +233,7 @@ public function setBold(bool $pValue = false): self * * @return bool */ - public function isItalic() + public function isItalic(): bool { return $this->italic; } @@ -258,7 +253,7 @@ public function setItalic(bool $pValue = false): self * * @return bool */ - public function isSuperScript() + public function isSuperScript(): bool { return $this->superScript; } @@ -300,7 +295,7 @@ public function setSubScript(bool $pValue = false): self * * @return string */ - public function getUnderline() + public function getUnderline(): string { return $this->underline; } @@ -308,11 +303,11 @@ public function getUnderline() /** * Set Underline. * - * @param string $pValue \PhpOffice\PhpPresentation\Style\Font underline type + * @param string $pValue Underline type * - * @return \PhpOffice\PhpPresentation\Style\Font + * @return self */ - public function setUnderline($pValue = self::UNDERLINE_NONE) + public function setUnderline(string $pValue = self::UNDERLINE_NONE): self { if ('' == $pValue) { $pValue = self::UNDERLINE_NONE; @@ -327,7 +322,7 @@ public function setUnderline($pValue = self::UNDERLINE_NONE) * * @return bool */ - public function isStrikethrough() + public function isStrikethrough(): bool { return $this->strikethrough; } @@ -352,8 +347,6 @@ public function getColor(): Color /** * Set Color. - * - * @throws \Exception */ public function setColor(Color $pValue): self { @@ -362,6 +355,36 @@ public function setColor(Color $pValue): self return $this; } + /** + * Get format + * + * @return string + */ + public function getFormat(): string + { + return $this->format; + } + + /** + * Set format + * + * @param string $value + * + * @return self + */ + public function setFormat(string $value = self::FORMAT_LATIN): self + { + if (in_array($value, [ + self::FORMAT_COMPLEX_SCRIPT, + self::FORMAT_EAST_ASIAN, + self::FORMAT_LATIN, + ])) { + $this->format = $value; + } + + return $this; + } + /** * Get hash code. * @@ -369,7 +392,19 @@ public function setColor(Color $pValue): self */ public function getHashCode(): string { - return md5($this->name . $this->size . ($this->bold ? 't' : 'f') . ($this->italic ? 't' : 'f') . ($this->superScript ? 't' : 'f') . ($this->subScript ? 't' : 'f') . $this->underline . ($this->strikethrough ? 't' : 'f') . $this->color->getHashCode() . __CLASS__); + return md5( + $this->name + . $this->size + . ($this->bold ? 't' : 'f') + . ($this->italic ? 't' : 'f') + . ($this->superScript ? 't' : 'f') + . ($this->subScript ? 't' : 'f') + . $this->underline + . ($this->strikethrough ? 't' : 'f') + . $this->format + . $this->color->getHashCode() + . __CLASS__ + ); } /** diff --git a/src/PhpPresentation/Writer/ODPresentation/Content.php b/src/PhpPresentation/Writer/ODPresentation/Content.php index 31e7141bd..38e6e1a76 100644 --- a/src/PhpPresentation/Writer/ODPresentation/Content.php +++ b/src/PhpPresentation/Writer/ODPresentation/Content.php @@ -26,6 +26,7 @@ use PhpOffice\PhpPresentation\Style\Alignment; use PhpOffice\PhpPresentation\Style\Border; use PhpOffice\PhpPresentation\Style\Fill; +use PhpOffice\PhpPresentation\Style\Font; use PhpOffice\PhpPresentation\Style\Shadow; class Content extends AbstractDecoratorWriter @@ -219,6 +220,10 @@ public function writeContent(): string $objWriter->writeAttribute('fo:text-align', 'left'); break; } + $objWriter->writeAttribute( + 'style:writing-mode', + $item->getAlignment()->isRTL() ? 'rl-tb' : 'lr-tb' + ); $objWriter->endElement(); $objWriter->endElement(); } @@ -230,19 +235,37 @@ public function writeContent(): string $objWriter->startElement('style:style'); $objWriter->writeAttribute('style:name', 'T_' . $key); $objWriter->writeAttribute('style:family', 'text'); - // style:text-properties + + // style:style > style:text-properties $objWriter->startElement('style:text-properties'); $objWriter->writeAttribute('fo:color', '#' . $item->getFont()->getColor()->getRGB()); - $objWriter->writeAttribute('fo:font-family', $item->getFont()->getName()); - $objWriter->writeAttribute('fo:font-size', $item->getFont()->getSize() . 'pt'); - // @todo : fo:font-style - if ($item->getFont()->isBold()) { - $objWriter->writeAttribute('fo:font-weight', 'bold'); + switch ($item->getFont()->getFormat()) { + case Font::FORMAT_LATIN: + $objWriter->writeAttribute('fo:font-family', $item->getFont()->getName()); + $objWriter->writeAttribute('fo:font-size', $item->getFont()->getSize() . 'pt'); + $objWriter->writeAttributeIf($item->getFont()->isBold(), 'fo:font-weight', 'bold'); + $objWriter->writeAttribute('fo:language', ($item->getLanguage() ? $item->getLanguage() : 'en')); + $objWriter->writeAttribute('style:script-type', 'latin'); + break; + case Font::FORMAT_EAST_ASIAN: + $objWriter->writeAttribute('style:font-family-asian', $item->getFont()->getName()); + $objWriter->writeAttribute('style:font-size-asian', $item->getFont()->getSize() . 'pt'); + $objWriter->writeAttributeIf($item->getFont()->isBold(), 'style:font-weight-asian', 'bold'); + $objWriter->writeAttribute('style:language-asian', ($item->getLanguage() ? $item->getLanguage() : 'en')); + $objWriter->writeAttribute('style:script-type', 'asian'); + break; + case Font::FORMAT_COMPLEX_SCRIPT: + $objWriter->writeAttribute('style:font-family-complex', $item->getFont()->getName()); + $objWriter->writeAttribute('style:font-size-complex', $item->getFont()->getSize() . 'pt'); + $objWriter->writeAttributeIf($item->getFont()->isBold(), 'style:font-weight-complex', 'bold'); + $objWriter->writeAttribute('style:language-complex', ($item->getLanguage() ? $item->getLanguage() : 'en')); + $objWriter->writeAttribute('style:script-type', 'complex'); + break; } - $objWriter->writeAttribute('fo:language', ($item->getLanguage() ? $item->getLanguage() : 'en')); - // @todo : style:text-underline-style + // > style:style > style:text-properties $objWriter->endElement(); + // > style:style $objWriter->endElement(); } } diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php index 493c7395f..e8838d909 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php @@ -519,6 +519,7 @@ protected function writeParagraphs(XMLWriter $objWriter, array $paragraphs, bool if (!$bIsPlaceholder) { $objWriter->startElement('a:pPr'); $objWriter->writeAttribute('algn', $paragraph->getAlignment()->getHorizontal()); + $objWriter->writeAttribute('rtl', $paragraph->getAlignment()->isRTL() ? '1' : '0'); $objWriter->writeAttribute('fontAlgn', $paragraph->getAlignment()->getVertical()); $objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginLeft())); $objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginRight())); @@ -596,8 +597,11 @@ protected function writeParagraphs(XMLWriter $objWriter, array $paragraphs, bool $this->writeColor($objWriter, $element->getFont()->getColor()); $objWriter->endElement(); - // Font - a:latin - $objWriter->startElement('a:latin'); + // Font + // - a:latin + // - a:ea + // - a:cs + $objWriter->startElement('a:' . $element->getFont()->getFormat()); $objWriter->writeAttribute('typeface', $element->getFont()->getName()); $objWriter->endElement(); diff --git a/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php b/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php index 674e635c6..f3b844689 100644 --- a/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php +++ b/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php @@ -24,6 +24,7 @@ use PhpOffice\PhpPresentation\Shape\RichText; use PhpOffice\PhpPresentation\Style\Alignment; use PhpOffice\PhpPresentation\Style\Bullet; +use PhpOffice\PhpPresentation\Style\Font; use PHPUnit\Framework\TestCase; /** @@ -124,6 +125,7 @@ public function testLoadFile01(): void $this->assertEquals(10, $oShape->getOffsetX()); $this->assertEquals(400, $oShape->getOffsetY()); $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal()); + $this->assertFalse($oShape->getActiveParagraph()->getAlignment()->isRTL()); $arrayParagraphs = $oShape->getParagraphs(); $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; @@ -136,6 +138,8 @@ public function testLoadFile01(): void $this->assertTrue($oRichText->getFont()->isBold()); $this->assertEquals(28, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 1 : Shape 2 : Paragraph 2 $oRichText = $arrayRichText[1]; $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText); @@ -146,6 +150,8 @@ public function testLoadFile01(): void $this->assertTrue($oRichText->getFont()->isBold()); $this->assertEquals(60, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 2 $oSlide2 = $oPhpPresentation->getSlide(1); @@ -175,6 +181,7 @@ public function testLoadFile01(): void $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); // Slide 2 : Shape 2 : Paragraph 1 @@ -197,6 +204,7 @@ public function testLoadFile01(): void // Slide 2 : Shape 3 : Paragraph 1 $oParagraph = $arrayParagraphs[0]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); @@ -207,9 +215,12 @@ public function testLoadFile01(): void $this->assertEquals('A class library', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 2 : Shape 3 : Paragraph 2 $oParagraph = $arrayParagraphs[1]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); @@ -220,9 +231,12 @@ public function testLoadFile01(): void $this->assertEquals('Written in PHP', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 2 : Shape 3 : Paragraph 3 $oParagraph = $arrayParagraphs[2]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); @@ -233,9 +247,12 @@ public function testLoadFile01(): void $this->assertEquals('Representing a presentation', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 2 : Shape 3 : Paragraph 4 $oParagraph = $arrayParagraphs[3]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); @@ -246,6 +263,8 @@ public function testLoadFile01(): void $this->assertEquals('Supports writing to different file formats', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 $oSlide2 = $oPhpPresentation->getSlide(2); @@ -272,6 +291,7 @@ public function testLoadFile01(): void $this->assertEquals(10, $oShape->getOffsetX()); $this->assertEquals(50, $oShape->getOffsetY()); $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal()); + $this->assertFalse($oShape->getActiveParagraph()->getAlignment()->isRTL()); $arrayParagraphs = $oShape->getParagraphs(); $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; @@ -284,6 +304,8 @@ public function testLoadFile01(): void $this->assertTrue($oRichText->getFont()->isBold()); $this->assertEquals(48, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 2 /** @var RichText $oShape */ $oShape = $arrayShape[2]; @@ -297,6 +319,7 @@ public function testLoadFile01(): void // Slide 3 : Shape 3 : Paragraph 1 $oParagraph = $arrayParagraphs[0]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(0, $oParagraph->getAlignment()->getLevel()); @@ -308,9 +331,12 @@ public function testLoadFile01(): void $this->assertEquals('Generate slide decks', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 2 $oParagraph = $arrayParagraphs[1]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); @@ -322,9 +348,12 @@ public function testLoadFile01(): void $this->assertEquals('Represent business data', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 3 $oParagraph = $arrayParagraphs[2]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); @@ -336,9 +365,12 @@ public function testLoadFile01(): void $this->assertEquals('Show a family slide show', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 4 $oParagraph = $arrayParagraphs[3]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); @@ -350,9 +382,12 @@ public function testLoadFile01(): void $this->assertEquals('...', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 5 $oParagraph = $arrayParagraphs[4]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(0, $oParagraph->getAlignment()->getLevel()); @@ -364,9 +399,12 @@ public function testLoadFile01(): void $this->assertEquals('Export these to different formats', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 6 $oParagraph = $arrayParagraphs[5]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); @@ -378,9 +416,12 @@ public function testLoadFile01(): void $this->assertEquals('PHPPresentation 2007', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 7 $oParagraph = $arrayParagraphs[6]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); @@ -392,9 +433,12 @@ public function testLoadFile01(): void $this->assertEquals('Serialized', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 8 $oParagraph = $arrayParagraphs[7]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft()); // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); @@ -406,6 +450,8 @@ public function testLoadFile01(): void $this->assertEquals('... (more to come) ...', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 4 $oSlide3 = $oPhpPresentation->getSlide(3); @@ -432,6 +478,7 @@ public function testLoadFile01(): void $this->assertEquals(10, $oShape->getOffsetX()); $this->assertEquals(50, $oShape->getOffsetY()); $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal()); + $this->assertFalse($oShape->getActiveParagraph()->getAlignment()->isRTL()); $arrayParagraphs = $oShape->getParagraphs(); $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; @@ -443,7 +490,9 @@ public function testLoadFile01(): void $this->assertEquals('Need more info?', $oRichText->getText()); $this->assertTrue($oRichText->getFont()->isBold()); $this->assertEquals(48, $oRichText->getFont()->getSize()); - $this->assertEquals('FF000000', $oShape->getActiveParagraph()->getFont()->getColor()->getARGB()); + $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 4 : Shape 3 /** @var RichText $oShape */ $oShape = $arrayShape[2]; @@ -453,6 +502,7 @@ public function testLoadFile01(): void $this->assertEquals(10, $oShape->getOffsetX()); $this->assertEquals(130, $oShape->getOffsetY()); $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal()); + $this->assertFalse($oShape->getActiveParagraph()->getAlignment()->isRTL()); $arrayParagraphs = $oShape->getParagraphs(); $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; @@ -464,7 +514,9 @@ public function testLoadFile01(): void $this->assertEquals('Check the project site on GitHub:', $oRichText->getText()); $this->assertFalse($oRichText->getFont()->isBold()); $this->assertEquals(36, $oRichText->getFont()->getSize()); - $this->assertEquals('FF000000', $oShape->getActiveParagraph()->getFont()->getColor()->getARGB()); + $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 4 : Shape 3 : Paragraph 2 $oRichText = $arrayRichText[1]; $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText); @@ -475,7 +527,9 @@ public function testLoadFile01(): void $this->assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getText()); $this->assertFalse($oRichText->getFont()->isBold()); $this->assertEquals(32, $oRichText->getFont()->getSize()); - $this->assertEquals('FF000000', $oShape->getActiveParagraph()->getFont()->getColor()->getARGB()); + $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); $this->assertTrue($oRichText->hasHyperlink()); $this->assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getHyperlink()->getUrl()); //$this->assertEquals('PHPPresentation', $oRichText->getHyperlink()->getTooltip()); diff --git a/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php b/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php index b0eb48e6d..98fb65ac4 100644 --- a/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php +++ b/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php @@ -25,6 +25,7 @@ use PhpOffice\PhpPresentation\Shape\RichText; use PhpOffice\PhpPresentation\Style\Alignment; use PhpOffice\PhpPresentation\Style\Bullet; +use PhpOffice\PhpPresentation\Style\Font; use PHPUnit\Framework\TestCase; /** @@ -128,6 +129,7 @@ public function testLoadFile01(): void $this->assertEquals(10, $oShape->getOffsetX()); $this->assertEquals(400, $oShape->getOffsetY()); $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal()); + $this->assertFalse($oShape->getActiveParagraph()->getAlignment()->isRTL()); $arrayParagraphs = $oShape->getParagraphs(); $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; @@ -140,6 +142,8 @@ public function testLoadFile01(): void $this->assertTrue($oRichText->getFont()->isBold()); $this->assertEquals(28, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 1 : Shape 2 : Paragraph 2 $oRichText = $arrayRichText[1]; $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText); @@ -150,6 +154,8 @@ public function testLoadFile01(): void $this->assertTrue($oRichText->getFont()->isBold()); $this->assertEquals(60, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 2 $oSlide2 = $oPhpPresentation->getSlide(1); @@ -179,6 +185,7 @@ public function testLoadFile01(): void $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); // Slide 2 : Shape 2 : Paragraph 1 @@ -188,6 +195,8 @@ public function testLoadFile01(): void $this->assertTrue($oRichText->getFont()->isBold()); $this->assertEquals(48, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 2 : Shape 3 /** @var RichText $oShape */ $oShape = $arrayShape[2]; @@ -204,6 +213,7 @@ public function testLoadFile01(): void $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -211,12 +221,15 @@ public function testLoadFile01(): void $this->assertEquals('A class library', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 2 : Shape 3 : Paragraph 2 $oParagraph = $arrayParagraphs[1]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -224,12 +237,15 @@ public function testLoadFile01(): void $this->assertEquals('Written in PHP', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 2 : Shape 3 : Paragraph 3 $oParagraph = $arrayParagraphs[2]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -237,12 +253,15 @@ public function testLoadFile01(): void $this->assertEquals('Representing a presentation', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 2 : Shape 3 : Paragraph 4 $oParagraph = $arrayParagraphs[3]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft()); $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -250,6 +269,8 @@ public function testLoadFile01(): void $this->assertEquals('Supports writing to different file formats', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 $oSlide2 = $oPhpPresentation->getSlide(2); @@ -276,6 +297,7 @@ public function testLoadFile01(): void $this->assertEquals(10, $oShape->getOffsetX()); $this->assertEquals(50, $oShape->getOffsetY()); $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal()); + $this->assertFalse($oShape->getActiveParagraph()->getAlignment()->isRTL()); $arrayParagraphs = $oShape->getParagraphs(); $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; @@ -288,6 +310,8 @@ public function testLoadFile01(): void $this->assertTrue($oRichText->getFont()->isBold()); $this->assertEquals(48, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 2 /** @var RichText $oShape */ $oShape = $arrayShape[2]; @@ -305,6 +329,7 @@ public function testLoadFile01(): void $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(0, $oParagraph->getAlignment()->getLevel()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -312,6 +337,8 @@ public function testLoadFile01(): void $this->assertEquals('Generate slide decks', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 2 $oParagraph = $arrayParagraphs[1]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); @@ -319,6 +346,7 @@ public function testLoadFile01(): void $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -326,6 +354,8 @@ public function testLoadFile01(): void $this->assertEquals('Represent business data', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 3 $oParagraph = $arrayParagraphs[2]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); @@ -333,6 +363,7 @@ public function testLoadFile01(): void $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -340,6 +371,8 @@ public function testLoadFile01(): void $this->assertEquals('Show a family slide show', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 4 $oParagraph = $arrayParagraphs[3]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); @@ -347,6 +380,7 @@ public function testLoadFile01(): void $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -354,6 +388,8 @@ public function testLoadFile01(): void $this->assertEquals('...', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 5 $oParagraph = $arrayParagraphs[4]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); @@ -361,6 +397,7 @@ public function testLoadFile01(): void $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(0, $oParagraph->getAlignment()->getLevel()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -368,6 +405,8 @@ public function testLoadFile01(): void $this->assertEquals('Export these to different formats', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 6 $oParagraph = $arrayParagraphs[5]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); @@ -375,6 +414,7 @@ public function testLoadFile01(): void $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -382,6 +422,8 @@ public function testLoadFile01(): void $this->assertEquals('PHPPresentation 2007', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 7 $oParagraph = $arrayParagraphs[6]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); @@ -389,6 +431,7 @@ public function testLoadFile01(): void $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -396,6 +439,8 @@ public function testLoadFile01(): void $this->assertEquals('Serialized', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 3 : Shape 3 : Paragraph 8 $oParagraph = $arrayParagraphs[7]; $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal()); @@ -403,6 +448,7 @@ public function testLoadFile01(): void $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent()); $this->assertEquals(1, $oParagraph->getAlignment()->getLevel()); $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType()); + $this->assertFalse($oParagraph->getAlignment()->isRTL()); $arrayRichText = $oParagraph->getRichTextElements(); $this->assertCount(1, $arrayRichText); $oRichText = $arrayRichText[0]; @@ -410,6 +456,8 @@ public function testLoadFile01(): void $this->assertEquals('... (more to come) ...', $oRichText->getText()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 4 $oSlide3 = $oPhpPresentation->getSlide(3); @@ -436,6 +484,7 @@ public function testLoadFile01(): void $this->assertEquals(10, $oShape->getOffsetX()); $this->assertEquals(50, $oShape->getOffsetY()); $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal()); + $this->assertFalse($oShape->getActiveParagraph()->getAlignment()->isRTL()); $arrayParagraphs = $oShape->getParagraphs(); $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; @@ -448,6 +497,8 @@ public function testLoadFile01(): void $this->assertTrue($oRichText->getFont()->isBold()); $this->assertEquals(48, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oShape->getActiveParagraph()->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 4 : Shape 3 /** @var RichText $oShape */ $oShape = $arrayShape[2]; @@ -457,6 +508,7 @@ public function testLoadFile01(): void $this->assertEquals(10, $oShape->getOffsetX()); $this->assertEquals(130, $oShape->getOffsetY()); $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal()); + $this->assertFalse($oShape->getActiveParagraph()->getAlignment()->isRTL()); $arrayParagraphs = $oShape->getParagraphs(); $this->assertCount(1, $arrayParagraphs); $oParagraph = $arrayParagraphs[0]; @@ -469,6 +521,8 @@ public function testLoadFile01(): void $this->assertFalse($oRichText->getFont()->isBold()); $this->assertEquals(36, $oRichText->getFont()->getSize()); $this->assertEquals('FF000000', $oShape->getActiveParagraph()->getFont()->getColor()->getARGB()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); // Slide 4 : Shape 3 : Paragraph 2 $oRichText = $arrayRichText[1]; $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText); @@ -483,6 +537,8 @@ public function testLoadFile01(): void $this->assertTrue($oRichText->hasHyperlink()); $this->assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getHyperlink()->getUrl()); $this->assertEquals('PHPPresentation', $oRichText->getHyperlink()->getTooltip()); + $this->assertEquals('Calibri', $oRichText->getFont()->getName()); + $this->assertEquals(Font::FORMAT_LATIN, $oRichText->getFont()->getFormat()); } public function testMarkAsFinal(): void diff --git a/tests/PhpPresentation/Tests/Style/AlignmentTest.php b/tests/PhpPresentation/Tests/Style/AlignmentTest.php index 523fe9fe2..e10d550da 100644 --- a/tests/PhpPresentation/Tests/Style/AlignmentTest.php +++ b/tests/PhpPresentation/Tests/Style/AlignmentTest.php @@ -51,9 +51,9 @@ public function testConstruct(): void public function testSetGetHorizontal(): void { $object = new Alignment(); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setHorizontal('')); + $this->assertInstanceOf(Alignment::class, $object->setHorizontal('')); $this->assertEquals(Alignment::HORIZONTAL_LEFT, $object->getHorizontal()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setHorizontal(Alignment::HORIZONTAL_GENERAL)); + $this->assertInstanceOf(Alignment::class, $object->setHorizontal(Alignment::HORIZONTAL_GENERAL)); $this->assertEquals(Alignment::HORIZONTAL_GENERAL, $object->getHorizontal()); } @@ -63,11 +63,11 @@ public function testSetGetHorizontal(): void public function testTextDirection(): void { $object = new Alignment(); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setTextDirection('')); + $this->assertInstanceOf(Alignment::class, $object->setTextDirection('')); $this->assertEquals(Alignment::TEXT_DIRECTION_HORIZONTAL, $object->getTextDirection()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setTextDirection(Alignment::TEXT_DIRECTION_VERTICAL_90)); + $this->assertInstanceOf(Alignment::class, $object->setTextDirection(Alignment::TEXT_DIRECTION_VERTICAL_90)); $this->assertEquals(Alignment::TEXT_DIRECTION_VERTICAL_90, $object->getTextDirection()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setTextDirection()); + $this->assertInstanceOf(Alignment::class, $object->setTextDirection()); $this->assertEquals(Alignment::TEXT_DIRECTION_HORIZONTAL, $object->getTextDirection()); } @@ -77,9 +77,9 @@ public function testTextDirection(): void public function testSetGetVertical(): void { $object = new Alignment(); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setVertical('')); + $this->assertInstanceOf(Alignment::class, $object->setVertical('')); $this->assertEquals(Alignment::VERTICAL_BASE, $object->getVertical()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setVertical(Alignment::VERTICAL_AUTO)); + $this->assertInstanceOf(Alignment::class, $object->setVertical(Alignment::VERTICAL_AUTO)); $this->assertEquals(Alignment::VERTICAL_AUTO, $object->getVertical()); } @@ -102,7 +102,7 @@ public function testSetGetLevel(): void { $object = new Alignment(); $value = mt_rand(1, 8); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setLevel($value)); + $this->assertInstanceOf(Alignment::class, $object->setLevel($value)); $this->assertEquals($value, $object->getLevel()); } @@ -115,18 +115,18 @@ public function testSetGetIndent(): void // != Alignment::HORIZONTAL_GENERAL $object->setHorizontal(Alignment::HORIZONTAL_CENTER); $value = mt_rand(1, 100); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setIndent($value)); + $this->assertInstanceOf(Alignment::class, $object->setIndent($value)); $this->assertEquals(0, $object->getIndent()); $value = mt_rand(-100, 0); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setIndent($value)); + $this->assertInstanceOf(Alignment::class, $object->setIndent($value)); $this->assertEquals($value, $object->getIndent()); $object->setHorizontal(Alignment::HORIZONTAL_GENERAL); $value = mt_rand(1, 100); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setIndent($value)); + $this->assertInstanceOf(Alignment::class, $object->setIndent($value)); $this->assertEquals($value, $object->getIndent()); $value = mt_rand(-100, 0); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setIndent($value)); + $this->assertInstanceOf(Alignment::class, $object->setIndent($value)); $this->assertEquals($value, $object->getIndent()); } @@ -137,9 +137,9 @@ public function testSetGetMarginBottom(): void { $object = new Alignment(); $value = mt_rand(0, 100); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginBottom($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginBottom($value)); $this->assertEquals($value, $object->getMarginBottom()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginBottom()); + $this->assertInstanceOf(Alignment::class, $object->setMarginBottom()); $this->assertEquals(0, $object->getMarginBottom()); } @@ -152,18 +152,18 @@ public function testSetGetMarginLeft(): void // != Alignment::HORIZONTAL_GENERAL $object->setHorizontal(Alignment::HORIZONTAL_CENTER); $value = mt_rand(1, 100); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginLeft($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginLeft($value)); $this->assertEquals(0, $object->getMarginLeft()); $value = mt_rand(-100, 0); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginLeft($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginLeft($value)); $this->assertEquals($value, $object->getMarginLeft()); $object->setHorizontal(Alignment::HORIZONTAL_GENERAL); $value = mt_rand(1, 100); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginLeft($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginLeft($value)); $this->assertEquals($value, $object->getMarginLeft()); $value = mt_rand(-100, 0); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginLeft($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginLeft($value)); $this->assertEquals($value, $object->getMarginLeft()); } @@ -176,18 +176,18 @@ public function testSetGetMarginRight(): void // != Alignment::HORIZONTAL_GENERAL $object->setHorizontal(Alignment::HORIZONTAL_CENTER); $value = mt_rand(1, 100); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginRight($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginRight($value)); $this->assertEquals(0, $object->getMarginRight()); $value = mt_rand(-100, 0); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginRight($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginRight($value)); $this->assertEquals($value, $object->getMarginRight()); $object->setHorizontal(Alignment::HORIZONTAL_GENERAL); $value = mt_rand(1, 100); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginRight($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginRight($value)); $this->assertEquals($value, $object->getMarginRight()); $value = mt_rand(-100, 0); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginRight($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginRight($value)); $this->assertEquals($value, $object->getMarginRight()); } @@ -198,12 +198,24 @@ public function testSetGetMarginTop(): void { $object = new Alignment(); $value = mt_rand(1, 100); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginTop($value)); + $this->assertInstanceOf(Alignment::class, $object->setMarginTop($value)); $this->assertEquals($value, $object->getMarginTop()); - $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->setMarginTop()); + $this->assertInstanceOf(Alignment::class, $object->setMarginTop()); $this->assertEquals(0, $object->getMarginTop()); } + public function testRTL(): void + { + $object = new Alignment(); + $this->assertFalse($object->isRTL()); + $this->assertInstanceOf(Alignment::class, $object->setIsRTL(true)); + $this->assertTrue($object->isRTL()); + $this->assertInstanceOf(Alignment::class, $object->setIsRTL(false)); + $this->assertFalse($object->isRTL()); + $this->assertInstanceOf(Alignment::class, $object->setIsRTL()); + $this->assertFalse($object->isRTL()); + } + /** * Test get/set hash index. */ diff --git a/tests/PhpPresentation/Tests/Style/FontTest.php b/tests/PhpPresentation/Tests/Style/FontTest.php index 05c4df64a..0952f5459 100644 --- a/tests/PhpPresentation/Tests/Style/FontTest.php +++ b/tests/PhpPresentation/Tests/Style/FontTest.php @@ -51,7 +51,7 @@ public function testConstruct(): void /** * Test get/set Character Spacing. */ - public function testSetGetCharacterSpacing(): void + public function testCharacterSpacing(): void { $object = new Font(); $this->assertEquals(0, $object->getCharacterSpacing()); @@ -66,7 +66,7 @@ public function testSetGetCharacterSpacing(): void /** * Test get/set color. */ - public function testSetGetColor(): void + public function testColor(): void { $object = new Font(); $this->assertEquals(Color::COLOR_BLACK, $object->getColor()->getARGB()); @@ -78,7 +78,24 @@ public function testSetGetColor(): void /** * Test get/set name. */ - public function testSetGetName(): void + public function testFormat(): void + { + $object = new Font(); + $this->assertEquals(Font::FORMAT_LATIN, $object->getFormat()); + $this->assertInstanceOf(Font::class, $object->setFormat()); + $this->assertEquals(Font::FORMAT_LATIN, $object->getFormat()); + $this->assertInstanceOf(Font::class, $object->setFormat('UnAuthorized')); + $this->assertEquals(Font::FORMAT_LATIN, $object->getFormat()); + $this->assertInstanceOf(Font::class, $object->setFormat(Font::FORMAT_EAST_ASIAN)); + $this->assertEquals(Font::FORMAT_EAST_ASIAN, $object->getFormat()); + $this->assertInstanceOf(Font::class, $object->setFormat(Font::FORMAT_COMPLEX_SCRIPT)); + $this->assertEquals(Font::FORMAT_COMPLEX_SCRIPT, $object->getFormat()); + } + + /** + * Test get/set name. + */ + public function testName(): void { $object = new Font(); $this->assertInstanceOf(Font::class, $object->setName()); @@ -92,7 +109,7 @@ public function testSetGetName(): void /** * Test get/set size. */ - public function testSetGetSize(): void + public function testSize(): void { $object = new Font(); $this->assertInstanceOf(Font::class, $object->setSize()); @@ -105,7 +122,7 @@ public function testSetGetSize(): void /** * Test get/set underline. */ - public function testSetGetUnderline(): void + public function testUnderline(): void { $object = new Font(); $this->assertInstanceOf(Font::class, $object->setUnderline()); @@ -215,7 +232,7 @@ public function testSetIsSuperScript(): void /** * Test get/set hash index. */ - public function testSetGetHashIndex(): void + public function testHashIndex(): void { $object = new Font(); $value = mt_rand(1, 100); diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php index 4c87f7d99..198b16f5c 100644 --- a/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php +++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php @@ -15,6 +15,7 @@ use PhpOffice\PhpPresentation\Style\Bullet; use PhpOffice\PhpPresentation\Style\Color; use PhpOffice\PhpPresentation\Style\Fill; +use PhpOffice\PhpPresentation\Style\Font; use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase; /** @@ -306,21 +307,78 @@ public function testRichTextAutoShrink(): void public function testRichTextRunLanguage(): void { $oRichText = $this->oPresentation->getActiveSlide()->createRichTextShape(); - $oRun = $oRichText->createTextRun('MyText'); + $oRun = $oRichText->createTextRun('Run1'); + $oRun->getFont()->setFormat(Font::FORMAT_LATIN); - $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $oRun->getHashCode() . '\']/style:text-properties'; + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:language-asian'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:language-complex'); $this->assertZipXmlAttributeExists('content.xml', $element, 'fo:language'); $this->assertZipXmlAttributeEquals('content.xml', $element, 'fo:language', 'en'); $this->assertIsSchemaOpenDocumentValid('1.2'); + $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:language'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:language-complex'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:language-asian'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:language-asian', 'en'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:language'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:language-asian'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:language-complex'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:language-complex', 'en'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + $oRun->setLanguage('de'); + $oRun->getFont()->setFormat(Font::FORMAT_LATIN); $this->resetPresentationFile(); + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:language-asian'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:language-complex'); $this->assertZipXmlAttributeExists('content.xml', $element, 'fo:language'); $this->assertZipXmlAttributeEquals('content.xml', $element, 'fo:language', 'de'); $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:language'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:language-complex'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:language-asian'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:language-asian', 'de'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:language'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:language-asian'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:language-complex'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:language-complex', 'de'); + $this->assertIsSchemaOpenDocumentValid('1.2'); } public function testRichTextBorder(): void @@ -485,18 +543,218 @@ public function testStyleAlignment(): void $this->assertIsSchemaOpenDocumentValid('1.2'); } - public function testStyleFont(): void + public function testStyleAlignmentRTL(): void + { + $oSlide = $this->oPresentation->getActiveSlide(); + $oRichText1 = $oSlide->createRichTextShape(); + $oRichText1->getActiveParagraph()->getAlignment()->setIsRTL(true); + $oRichText1->createTextRun('Run1'); + $oRichText2 = $oSlide->createRichTextShape(); + $oRichText2->getActiveParagraph()->getAlignment()->setIsRTL(false); + $oRichText2->createTextRun('Run2'); + + $p1HashCode = $oRichText1->getActiveParagraph()->getHashCode(); + $p2HashCode = $oRichText2->getActiveParagraph()->getHashCode(); + + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'P_' . $p1HashCode . '\']/style:paragraph-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:writing-mode', 'rl-tb'); + + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'P_' . $p2HashCode . '\']/style:paragraph-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:writing-mode', 'lr-tb'); + + $this->assertIsSchemaOpenDocumentValid('1.2'); + } + + public function testStyleFontBold(): void { $oRichText = $this->oPresentation->getActiveSlide()->createRichTextShape(); $oRun = $oRichText->createTextRun('Run1'); $oRun->getFont()->setBold(true); + $oRun->getFont()->setFormat(Font::FORMAT_LATIN); $expectedHashCode = $oRun->getHashCode(); - $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-asian'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-complex'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'fo:font-weight'); $this->assertZipXmlAttributeEquals('content.xml', $element, 'fo:font-weight', 'bold'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:font-weight'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-complex'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:font-weight-asian'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:font-weight-asian', 'bold'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:font-weight'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-asian'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:font-weight-complex'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:font-weight-complex', 'bold'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setBold(false); + $oRun->getFont()->setFormat(Font::FORMAT_LATIN); + $this->resetPresentationFile(); + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:font-weight'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-asian'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-complex'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:font-weight'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-asian'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-complex'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:font-weight'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-asian'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-weight-complex'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + } + + public function testStyleFontFormat(): void + { + $oRichText = $this->oPresentation->getActiveSlide()->createRichTextShape(); + $oRun = $oRichText->createTextRun('Run1'); + $oRun->getFont()->setFormat(Font::FORMAT_LATIN); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:script-type'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:script-type', 'latin'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:script-type'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:script-type', 'asian'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:script-type'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:script-type', 'complex'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + } + + public function testStyleFontName(): void + { + $oRichText = $this->oPresentation->getActiveSlide()->createRichTextShape(); + $oRun = $oRichText->createTextRun('Run1'); + $oRun->getFont()->setName('Calibri'); + $oRun->getFont()->setFormat(Font::FORMAT_LATIN); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-family-asian'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-family-complex'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'fo:font-family'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'fo:font-family', 'Calibri'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:font-family'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-family-complex'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:font-family-asian'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:font-family-asian', 'Calibri'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:font-family'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-family-asian'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:font-family-complex'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:font-family-complex', 'Calibri'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + } + + public function testStyleFontSize(): void + { + $oRichText = $this->oPresentation->getActiveSlide()->createRichTextShape(); + $oRun = $oRichText->createTextRun('Run1'); + $oRun->getFont()->setSize(12); + $oRun->getFont()->setFormat(Font::FORMAT_LATIN); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-size-asian'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-size-complex'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'fo:font-size'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'fo:font-size', '12pt'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:font-size'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-size-complex'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:font-size-asian'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:font-size-asian', '12pt'); + $this->assertIsSchemaOpenDocumentValid('1.2'); + + $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + $this->resetPresentationFile(); + + $expectedHashCode = $oRun->getHashCode(); + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'T_' . $expectedHashCode . '\']/style:text-properties'; + $this->assertZipXmlElementExists('content.xml', $element); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'fo:font-size'); + $this->assertZipXmlAttributeNotExists('content.xml', $element, 'style:font-size-asian'); + $this->assertZipXmlAttributeExists('content.xml', $element, 'style:font-size-complex'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'style:font-size-complex', '12pt'); $this->assertIsSchemaOpenDocumentValid('1.2'); } diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php index afee0906c..c19e16c6c 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php @@ -14,17 +14,34 @@ use PhpOffice\PhpPresentation\Style\Bullet; use PhpOffice\PhpPresentation\Style\Color; use PhpOffice\PhpPresentation\Style\Fill; +use PhpOffice\PhpPresentation\Style\Font; use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase; -/** - * Test class for PowerPoint2007. - * - * @coversDefaultClass \PowerPoint2007 - */ -class PptSlideTest extends PhpPresentationTestCase +class PptSlidesTest extends PhpPresentationTestCase { protected $writerName = 'PowerPoint2007'; + public function testAlignmentRTL(): void + { + $oSlide = $this->oPresentation->getActiveSlide(); + $oRichText = $oSlide->createRichTextShape(); + $oRichText->createTextRun('AAA'); + $oRichText->getActiveParagraph()->getAlignment()->setIsRTL(false); + + $expectedElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr'; + $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $expectedElement); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $expectedElement, 'rtl', '0'); + $this->assertIsSchemaECMA376Valid(); + + $oRichText->getActiveParagraph()->getAlignment()->setIsRTL(true); + $this->resetPresentationFile(); + + $expectedElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:pPr'; + $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $expectedElement); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $expectedElement, 'rtl', '1'); + $this->assertIsSchemaECMA376Valid(); + } + /** * @see https://github.com/PHPOffice/PHPPresentation/issues/42 */ @@ -597,6 +614,45 @@ public function testRichTextLineSpacing(): void $this->assertIsSchemaECMA376Valid(); } + public function testRichTextRunFontFormat(): void + { + $latinElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:latin'; + $eastAsianElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:ea'; + $complexScriptElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:cs'; + + $oSlide = $this->oPresentation->getActiveSlide(); + $oRichText = $oSlide->createRichTextShape(); + $oRun = $oRichText->createTextRun('MyText'); + $oRun->getFont()->setFormat(Font::FORMAT_LATIN); + + $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $latinElement); + $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'typeface'); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'typeface', 'Calibri'); + $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement); + $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement); + $this->assertIsSchemaECMA376Valid(); + + $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); + $this->resetPresentationFile(); + + $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement); + $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $eastAsianElement); + $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'typeface'); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'typeface', 'Calibri'); + $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement); + $this->assertIsSchemaECMA376Valid(); + + $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); + $this->resetPresentationFile(); + + $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement); + $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement); + $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $complexScriptElement); + $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'typeface'); + $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'typeface', 'Calibri'); + $this->assertIsSchemaECMA376Valid(); + } + public function testRichTextRunLanguage(): void { $oSlide = $this->oPresentation->getActiveSlide();