| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- <?php
- /**
- * This file is part of PHPPresentation - A pure PHP library for reading and writing
- * presentations documents.
- *
- * PHPPresentation is free software distributed under the terms of the GNU Lesser
- * General Public License version 3 as published by the Free Software Foundation.
- *
- * For the full copyright and license information, please read the LICENSE
- * file that was distributed with this source code. For the full list of
- * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
- *
- * @copyright 2009-2015 PHPPresentation contributors
- * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
- * @link https://github.com/PHPOffice/PHPPresentation
- */
- namespace PhpOffice\PhpPresentation\Tests\Reader;
- use PhpOffice\PhpPresentation\Reader\ODPresentation;
- use PhpOffice\PhpPresentation\Style\Alignment;
- use PhpOffice\PhpPresentation\Style\Bullet;
- /**
- * Test class for ODPresentation reader
- *
- * @coversDefaultClass PhpOffice\PhpPresentation\Reader\ODPresentation
- */
- class ODPresentationTest extends \PHPUnit_Framework_TestCase
- {
- /**
- * Test can read
- */
- public function testCanRead()
- {
- $object = new ODPresentation();
-
- $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.ppt';
- $this->assertFalse($object->canRead($file));
-
- $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/serialized.phppt';
- $this->assertFalse($object->canRead($file));
-
- $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.pptx';
- $this->assertFalse($object->canRead($file));
-
- $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.odp';
- $this->assertTrue($object->canRead($file));
- }
-
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Could not open for reading! File does not exist.
- */
- public function testLoadFileNotExists()
- {
- $object = new ODPresentation();
- $object->load('');
- }
-
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid file format for PhpOffice\PhpPresentation\Reader\ODPresentation:
- */
- public function testLoadFileBadFormat()
- {
- $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.ppt';
- $object = new ODPresentation();
- $object->load($file);
- }
-
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Could not open for reading! File does not exist.
- */
- public function testFileSupportsNotExists()
- {
- $object = new ODPresentation();
- $object->fileSupportsUnserializePhpPresentation('');
- }
-
- public function testLoadFile01()
- {
- $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.odp';
- $object = new ODPresentation();
- $oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- // Document Properties
- $this->assertEquals('PHPOffice', $oPhpPresentation->getDocumentProperties()->getCreator());
- $this->assertEquals('PHPPresentation Team', $oPhpPresentation->getDocumentProperties()->getLastModifiedBy());
- $this->assertEquals('Sample 02 Title', $oPhpPresentation->getDocumentProperties()->getTitle());
- $this->assertEquals('Sample 02 Subject', $oPhpPresentation->getDocumentProperties()->getSubject());
- $this->assertEquals('Sample 02 Description', $oPhpPresentation->getDocumentProperties()->getDescription());
- $this->assertEquals('office 2007 openxml libreoffice odt php', $oPhpPresentation->getDocumentProperties()->getKeywords());
- //
- $this->assertCount(4, $oPhpPresentation->getAllSlides());
-
- // Slide 1
- $oSlide1 = $oPhpPresentation->getSlide(0);
- $arrayShape = $oSlide1->getShapeCollection();
- $this->assertCount(2, $arrayShape);
- // Slide 1 : Shape 1
- $oShape = $arrayShape[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\Gd', $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
- // Slide 1 : Shape 2
- $oShape = $arrayShape[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $oShape);
- $this->assertEquals(200, $oShape->getHeight());
- $this->assertEquals(600, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(400, $oShape->getOffsetY());
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal());
- $arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
- $oParagraph = $arrayParagraphs[0];
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(3, $arrayRichText);
- // Slide 1 : Shape 2 : Paragraph 1
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Introduction to', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(28, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 1 : Shape 2 : Paragraph 2
- $oRichText = $arrayRichText[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
- // Slide 1 : Shape 2 : Paragraph 3
- $oRichText = $arrayRichText[2];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('PHPPresentation', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(60, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
-
- // Slide 2
- $oSlide2 = $oPhpPresentation->getSlide(1);
- $arrayShape = $oSlide2->getShapeCollection();
- $this->assertCount(3, $arrayShape);
- // Slide 2 : Shape 1
- $oShape = $arrayShape[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\Gd', $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
- // Slide 2 : Shape 2
- $oShape = $arrayShape[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $oShape);
- $this->assertEquals(100, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(50, $oShape->getOffsetY());
- $arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
- $oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- // Slide 2 : Shape 2 : Paragraph 1
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('What is PHPPresentation?', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(48, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 2 : Shape 3
- $oShape = $arrayShape[2];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $oShape);
- $this->assertEquals(600, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(130, $oShape->getOffsetY());
- $arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(4, $arrayParagraphs);
- // Slide 2 : Shape 3 : Paragraph 1
- $oParagraph = $arrayParagraphs[0];
- $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());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('A class library', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // 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());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Written in PHP', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // 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());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Representing a presentation', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // 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());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Supports writing to different file formats', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
-
- // Slide 3
- $oSlide2 = $oPhpPresentation->getSlide(2);
- $arrayShape = $oSlide2->getShapeCollection();
- $this->assertCount(3, $arrayShape);
- // Slide 3 : Shape 1
- $oShape = $arrayShape[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\Gd', $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
- // Slide 3 : Shape 2
- $oShape = $arrayShape[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $oShape);
- $this->assertEquals(100, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(50, $oShape->getOffsetY());
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal());
- $arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
- $oParagraph = $arrayParagraphs[0];
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- // Slide 3 : Shape 2 : Paragraph 1
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('What\'s the point?', $oRichText->getText());
- $this->assertTrue($oRichText->getFont()->isBold());
- $this->assertEquals(48, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 3 : Shape 2
- $oShape = $arrayShape[2];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $oShape);
- $this->assertEquals(600, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(130, $oShape->getOffsetY());
- $arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(8, $arrayParagraphs);
- // Slide 3 : Shape 3 : Paragraph 1
- $oParagraph = $arrayParagraphs[0];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- // $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
- // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(0, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Generate slide decks', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 3 : Shape 3 : Paragraph 2
- $oParagraph = $arrayParagraphs[1];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Represent business data', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 3 : Shape 3 : Paragraph 3
- $oParagraph = $arrayParagraphs[2];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Show a family slide show', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 3 : Shape 3 : Paragraph 4
- $oParagraph = $arrayParagraphs[3];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('...', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 3 : Shape 3 : Paragraph 5
- $oParagraph = $arrayParagraphs[4];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- // $this->assertEquals(25, $oParagraph->getAlignment()->getMarginLeft());
- // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(0, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Export these to different formats', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 3 : Shape 3 : Paragraph 6
- $oParagraph = $arrayParagraphs[5];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('PHPPresentation 2007', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 3 : Shape 3 : Paragraph 7
- $oParagraph = $arrayParagraphs[6];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('Serialized', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
- // Slide 3 : Shape 3 : Paragraph 8
- $oParagraph = $arrayParagraphs[7];
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
- // $this->assertEquals(75, $oParagraph->getAlignment()->getMarginLeft());
- // $this->assertEquals(-25, $oParagraph->getAlignment()->getIndent());
- $this->assertEquals(1, $oParagraph->getAlignment()->getLevel());
- $this->assertEquals(Bullet::TYPE_BULLET, $oParagraph->getBulletStyle()->getBulletType());
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $this->assertEquals('... (more to come) ...', $oRichText->getText());
- $this->assertEquals(36, $oRichText->getFont()->getSize());
- $this->assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
-
- // Slide 4
- $oSlide3 = $oPhpPresentation->getSlide(3);
- $arrayShape = $oSlide3->getShapeCollection();
- $this->assertCount(3, $arrayShape);
- // Slide 4 : Shape 1
- $oShape = $arrayShape[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Drawing\\Gd', $oShape);
- $this->assertEquals('PHPPresentation logo', $oShape->getName());
- $this->assertEquals('PHPPresentation logo', $oShape->getDescription());
- $this->assertEquals(36, $oShape->getHeight());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(10, $oShape->getOffsetY());
- $this->assertTrue($oShape->getShadow()->isVisible());
- $this->assertEquals(45, $oShape->getShadow()->getDirection());
- $this->assertEquals(10, $oShape->getShadow()->getDistance());
- // Slide 4 : Shape 2
- $oShape = $arrayShape[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $oShape);
- $this->assertEquals(100, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(50, $oShape->getOffsetY());
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal());
- $arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
- $oParagraph = $arrayParagraphs[0];
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayRichText);
- // Slide 4 : Shape 2 : Paragraph 1
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $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());
- // Slide 4 : Shape 3
- $oShape = $arrayShape[2];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $oShape);
- $this->assertEquals(600, $oShape->getHeight());
- $this->assertEquals(930, $oShape->getWidth());
- $this->assertEquals(10, $oShape->getOffsetX());
- $this->assertEquals(130, $oShape->getOffsetY());
- $this->assertEquals(Alignment::HORIZONTAL_LEFT, $oShape->getActiveParagraph()->getAlignment()->getHorizontal());
- $arrayParagraphs = $oShape->getParagraphs();
- $this->assertCount(1, $arrayParagraphs);
- $oParagraph = $arrayParagraphs[0];
- $arrayRichText = $oParagraph->getRichTextElements();
- $this->assertCount(3, $arrayRichText);
- // Slide 4 : Shape 3 : Paragraph 1
- $oRichText = $arrayRichText[0];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $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());
- // Slide 4 : Shape 3 : Paragraph 2
- $oRichText = $arrayRichText[1];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\BreakElement', $oRichText);
- // Slide 4 : Shape 3 : Paragraph 3
- $oRichText = $arrayRichText[2];
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
- $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->assertTrue($oRichText->hasHyperlink());
- $this->assertEquals('https://github.com/PHPOffice/PHPPresentation/', $oRichText->getHyperlink()->getUrl());
- //$this->assertEquals('PHPPresentation', $oRichText->getHyperlink()->getTooltip());
- }
- public function testSlideName()
- {
- $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/ODP_Slide_Name.odp';
- $object = new ODPresentation();
- $oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertEquals('MaDiapo', $oPhpPresentation->getSlide(0)->getName());
- }
- public function testIssue00141()
- {
- $file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Issue_00141.odp';
- $object = new ODPresentation();
- $oPhpPresentation = $object->load($file);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
- $this->assertCount(3, $oPhpPresentation->getAllSlides());
- // Slide 1
- $oSlide = $oPhpPresentation->getSlide(1);
- $arrayShape = $oSlide->getShapeCollection();
- $this->assertCount(2, $arrayShape);
- // Slide 1 : Shape 1
- $oShape = reset($arrayShape);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText', $oShape);
- // Slide 1 : Shape 1 : Paragraph 1
- $oParagraph = $oShape->getParagraph();
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Paragraph', $oParagraph);
- // Slide 1 : Shape 1 : Paragraph 1 : RichText Elements
- $arrayElements = $oParagraph->getRichTextElements();
- $this->assertCount(1, $arrayElements);
- $oElement = reset($arrayElements);
- $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\TextElement', $oElement);
- $this->assertEquals('TEST IMAGE', $oElement->getText());
- }
- }
|