getActiveSlide() public method

Get active slide
public getActiveSlide ( ) : Slide
return Slide
Example #1
0
 public function testTypeBar()
 {
     $seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oBar = new Bar();
     $oSeries = new Series('Downloads', $seriesData);
     $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
     $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE));
     $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKGREEN));
     $oSeries->getDataPointFill(3)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKRED));
     $oSeries->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKYELLOW));
     $oBar->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oBar);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml'));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt/c:spPr';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:tx/c:v';
     $this->assertEquals($oSeries->getTitle(), $oXMLDoc->getElement($element, 'ppt/charts/' . $oShape->getIndexedFilename())->nodeValue);
 }
 public function testCommentsAuthors()
 {
     $oAuthor = new Comment\Author();
     $oComment = new Comment();
     $oComment->setAuthor($oAuthor);
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getActiveSlide()->addShape($oComment);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($pres->elementExists('/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"]', 'ppt/_rels/presentation.xml.rels'));
 }
Example #3
0
 public function testVisibility()
 {
     $expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePage0\']/style:drawing-page-properties';
     $pres = TestHelperDOCX::getDocument($this->oPresentation, 'ODPresentation');
     $this->assertTrue($pres->elementExists($expectedElement, 'content.xml'));
     $this->assertFalse($pres->attributeElementExists($expectedElement, 'presentation:visibility', 'content.xml'));
     $oSlide = $this->oPresentation->getActiveSlide();
     $oSlide->setIsVisible(false);
     $pres = TestHelperDOCX::getDocument($this->oPresentation, 'ODPresentation');
     $this->assertTrue($pres->elementExists($expectedElement, 'content.xml'));
     $this->assertTrue($pres->attributeElementExists($expectedElement, 'presentation:visibility', 'content.xml'));
     $this->assertEquals('hidden', $pres->getElementAttribute($expectedElement, 'presentation:visibility', 'content.xml'));
 }
Example #4
0
 public function testGroup()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oGroup = $oSlide->createGroup();
     $oDrawing = new Drawing();
     $this->assertInternalType('array', $oDrawing->allDrawings($oPhpPresentation));
     $this->assertEmpty($oDrawing->allDrawings($oPhpPresentation));
     $oGroup->createDrawingShape();
     $oGroup->createDrawingShape();
     $oGroup->createDrawingShape();
     $this->assertInternalType('array', $oDrawing->allDrawings($oPhpPresentation));
     $this->assertCount(3, $oDrawing->allDrawings($oPhpPresentation));
 }
Example #5
0
 public function testMemoryDrawing()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = new MemoryDrawing();
     $gdImage = @imagecreatetruecolor(140, 20);
     $textColor = imagecolorallocate($gdImage, 255, 255, 255);
     imagestring($gdImage, 1, 5, 5, 'Created with PhpPresentation', $textColor);
     $oShape->setImageResource($gdImage)->setRenderingFunction(MemoryDrawing::RENDERING_JPEG)->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT);
     $oSlide->addShape($oShape);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
     $element = '/manifest:manifest/manifest:file-entry[5]';
     $this->assertTrue($pres->elementExists($element, 'META-INF/manifest.xml'));
     $this->assertEquals('Pictures/' . $oShape->getIndexedFilename(), $pres->getElementAttribute($element, 'manifest:full-path', 'META-INF/manifest.xml'));
 }
 /**
  * Test save
  */
 public function testSave()
 {
     $filename = tempnam(sys_get_temp_dir(), 'PhpPresentation');
     $imageFile = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/images/PhpPresentationLogo.png';
     $oPhpPresentation = new PhpPresentation();
     $slide = $oPhpPresentation->getActiveSlide();
     $slide->createRichTextShape();
     $slide->createLineShape(10, 10, 10, 10);
     $slide->createChartShape()->getPlotArea()->setType(new \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D());
     $slide->createDrawingShape()->setName('Drawing')->setPath($imageFile);
     $slide->createTableShape()->createRow();
     $object = new ODPresentation($oPhpPresentation);
     $object->save($filename);
     $this->assertTrue(file_exists($filename));
     unlink($filename);
 }
Example #7
0
 public function testTypeArea()
 {
     $seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oArea = new Area();
     $oSeries = new Series('Downloads', $seriesData);
     $oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
     $oArea->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oArea);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml'));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
 }
Example #8
0
 public function testStrokeDash()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oRichText1 = $oSlide->createRichTextShape();
     $oRichText1->getBorder()->setColor(new Color('FF4672A8'))->setLineStyle(Border::LINE_SINGLE);
     $arrayDashStyle = array(Border::DASH_DASH, Border::DASH_DASHDOT, Border::DASH_DOT, Border::DASH_LARGEDASH, Border::DASH_LARGEDASHDOT, Border::DASH_LARGEDASHDOTDOT, Border::DASH_SYSDASH, Border::DASH_SYSDASHDOT, Border::DASH_SYSDASHDOTDOT, Border::DASH_SYSDOT);
     foreach ($arrayDashStyle as $style) {
         $oRichText1->getBorder()->setDashStyle($style);
         $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
         $element = '/office:document-styles/office:styles/draw:stroke-dash[@draw:name=\'strokeDash_' . $style . '\']';
         $this->assertTrue($pres->elementExists($element, 'styles.xml'));
         $this->assertEquals('rect', $pres->getElementAttribute($element, 'draw:style', 'styles.xml'));
         $this->assertTrue($pres->attributeElementExists($element, 'draw:distance', 'styles.xml'));
         switch ($style) {
             case Border::DASH_DOT:
             case Border::DASH_SYSDOT:
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots1', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots1-length', 'styles.xml'));
                 break;
             case Border::DASH_DASH:
             case Border::DASH_LARGEDASH:
             case Border::DASH_SYSDASH:
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots2', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots2-length', 'styles.xml'));
                 break;
             case Border::DASH_DASHDOT:
             case Border::DASH_LARGEDASHDOT:
             case Border::DASH_LARGEDASHDOTDOT:
             case Border::DASH_SYSDASHDOT:
             case Border::DASH_SYSDASHDOTDOT:
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots1', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots1-length', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots2', 'styles.xml'));
                 $this->assertTrue($pres->attributeElementExists($element, 'draw:dots2-length', 'styles.xml'));
                 break;
         }
     }
 }
 /**
  * Read Shape RichText
  *
  * @param \DOMElement $oNodeFrame
  */
 protected function loadShapeRichText(\DOMElement $oNodeFrame)
 {
     // Core
     $oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
     $oShape->setParagraphs(array());
     $oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:width'), 0, -2))) : '');
     $oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:height'), 0, -2))) : '');
     $oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:x'), 0, -2))) : '');
     $oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:y'), 0, -2))) : '');
     foreach ($this->oXMLReader->getElements('draw:text-box/*', $oNodeFrame) as $oNodeParagraph) {
         $this->levelParagraph = 0;
         if ($oNodeParagraph->nodeName == 'text:p') {
             $this->readParagraph($oShape, $oNodeParagraph);
         }
         if ($oNodeParagraph->nodeName == 'text:list') {
             $this->readList($oShape, $oNodeParagraph);
         }
     }
     if (count($oShape->getParagraphs()) > 0) {
         $oShape->setActiveParagraph(0);
     }
 }
Example #10
0
 public function testChartArea()
 {
     $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
     $oSeries->getFill()->setStartColor(new Color('FF93A9CE'));
     $oArea = new Area();
     $oArea->addSeries($oSeries);
     $phpPresentation = new PhpPresentation();
     $oSlide = $phpPresentation->getActiveSlide();
     $oChart = $oSlide->createChartShape();
     $oChart->getPlotArea()->setType($oArea);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $element = '/office:document-content/office:body/office:chart/chart:chart';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
     $element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
     $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\']/style:graphic-properties';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertFalse($pres->attributeElementExists($element, 'draw:fill', 'Object 1/content.xml'));
     $this->assertTrue($pres->attributeElementExists($element, 'draw:fill-color', 'Object 1/content.xml'));
     $this->assertEquals('#93A9CE', $pres->getElementAttribute($element, 'draw:fill-color', 'Object 1/content.xml'));
 }
Example #11
0
 public function testChartBarHorizontal()
 {
     $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
     $oSeries->setShowSeriesName(true);
     $oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4672A8'));
     $oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFAB4744'));
     $oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8AA64F'));
     $oBar = new Bar();
     $oBar->setBarDirection(Bar::DIRECTION_HORIZONTAL);
     $oBar->addSeries($oSeries);
     $phpPresentation = new PhpPresentation();
     $oSlide = $phpPresentation->getActiveSlide();
     $oChart = $oSlide->createChartShape();
     $oChart->getPlotArea()->setType($oBar);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $element = '/office:document-content/office:body/office:chart/chart:chart';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('chart:bar', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
     $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePlotArea\']/style:chart-properties';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $this->assertEquals('true', $pres->getElementAttribute($element, 'chart:vertical', 'Object 1/content.xml'));
     $this->assertFalse($pres->attributeElementExists($element, 'chart:three-dimensional', 'Object 1/content.xml'));
     $this->assertFalse($pres->attributeElementExists($element, 'chart:right-angled-axes', 'Object 1/content.xml'));
 }
<?php

include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\IOFactory;
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 03 Title')->setSubject('Sample 03 Subject')->setDescription('Sample 03 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();
// Create a shape (drawing)
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')->setDescription('PHPPresentation logo')->setPath('./resources/phppowerpoint_logo.gif')->setHeight(36)->setOffsetX(10)->setOffsetY(10);
$shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
// 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(180);
$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'));
// Save serialized file
$basename = basename(__FILE__, '.php');
echo date('H:i:s') . ' Write to serialized format' . EOL;
$objWriter = IOFactory::createWriter($objPHPPresentation, 'Serialized');
Example #13
0
 protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $baseFile)
 {
     // Core
     $oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
     $oShape->setParagraphs(array());
     // Variables
     $fileRels = 'ppt/slides/_rels/' . $baseFile . '.rels';
     $oElement = $document->getElement('p:spPr/a:xfrm', $node);
     if ($oElement && $oElement->hasAttribute('rot')) {
         $oShape->setRotation(CommonDrawing::angleToDegrees($oElement->getAttribute('rot')));
     }
     $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node);
     if ($oElement) {
         if ($oElement->hasAttribute('x')) {
             $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x')));
         }
         if ($oElement->hasAttribute('y')) {
             $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y')));
         }
     }
     $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node);
     if ($oElement) {
         if ($oElement->hasAttribute('cx')) {
             $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx')));
         }
         if ($oElement->hasAttribute('cy')) {
             $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy')));
         }
     }
     $arrayElements = $document->getElements('p:txBody/a:p', $node);
     foreach ($arrayElements as $oElement) {
         // Core
         $oParagraph = $oShape->createParagraph();
         $oParagraph->setRichTextElements(array());
         $oSubElement = $document->getElement('a:pPr', $oElement);
         if ($oSubElement) {
             if ($oSubElement->hasAttribute('algn')) {
                 $oParagraph->getAlignment()->setHorizontal($oSubElement->getAttribute('algn'));
             }
             if ($oSubElement->hasAttribute('fontAlgn')) {
                 $oParagraph->getAlignment()->setVertical($oSubElement->getAttribute('fontAlgn'));
             }
             if ($oSubElement->hasAttribute('marL')) {
                 $oParagraph->getAlignment()->setMarginLeft(CommonDrawing::emuToPixels($oSubElement->getAttribute('marL')));
             }
             if ($oSubElement->hasAttribute('marR')) {
                 $oParagraph->getAlignment()->setMarginRight(CommonDrawing::emuToPixels($oSubElement->getAttribute('marR')));
             }
             if ($oSubElement->hasAttribute('indent')) {
                 $oParagraph->getAlignment()->setIndent(CommonDrawing::emuToPixels($oSubElement->getAttribute('indent')));
             }
             if ($oSubElement->hasAttribute('lvl')) {
                 $oParagraph->getAlignment()->setLevel($oSubElement->getAttribute('lvl'));
             }
             $oElementBuFont = $document->getElement('a:buFont', $oSubElement);
             $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE);
             if ($oElementBuFont) {
                 if ($oElementBuFont->hasAttribute('typeface')) {
                     $oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface'));
                 }
             }
             $oElementBuChar = $document->getElement('a:buChar', $oSubElement);
             if ($oElementBuChar) {
                 $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
                 if ($oElementBuChar->hasAttribute('char')) {
                     $oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char'));
                 }
             }
             /*$oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement);
               if ($oElementBuAutoNum) {
                   $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC);
                   if ($oElementBuAutoNum->hasAttribute('type')) {
                       $oParagraph->getBulletStyle()->setBulletNumericStyle($oElementBuAutoNum->getAttribute('type'));
                   }
                   if ($oElementBuAutoNum->hasAttribute('startAt') && $oElementBuAutoNum->getAttribute('startAt') != 1) {
                       $oParagraph->getBulletStyle()->setBulletNumericStartAt($oElementBuAutoNum->getAttribute('startAt'));
                   }
               }*/
         }
         $arraySubElements = $document->getElements('(a:r|a:br)', $oElement);
         foreach ($arraySubElements as $oSubElement) {
             if ($oSubElement->tagName == 'a:br') {
                 $oParagraph->createBreak();
             }
             if ($oSubElement->tagName == 'a:r') {
                 $oElementrPr = $document->getElement('a:rPr', $oSubElement);
                 if (is_object($oElementrPr)) {
                     $oText = $oParagraph->createTextRun();
                     if ($oElementrPr->hasAttribute('b')) {
                         $oText->getFont()->setBold($oElementrPr->getAttribute('b') == 'true' ? true : false);
                     }
                     if ($oElementrPr->hasAttribute('i')) {
                         $oText->getFont()->setItalic($oElementrPr->getAttribute('i') == 'true' ? true : false);
                     }
                     if ($oElementrPr->hasAttribute('strike')) {
                         $oText->getFont()->setStrikethrough($oElementrPr->getAttribute('strike') == 'noStrike' ? false : true);
                     }
                     if ($oElementrPr->hasAttribute('sz')) {
                         $oText->getFont()->setSize((int) ($oElementrPr->getAttribute('sz') / 100));
                     }
                     if ($oElementrPr->hasAttribute('u')) {
                         $oText->getFont()->setUnderline($oElementrPr->getAttribute('u'));
                     }
                     // Color
                     $oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr);
                     if (is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) {
                         $oColor = new Color();
                         $oColor->setRGB($oElementSrgbClr->getAttribute('val'));
                         $oText->getFont()->setColor($oColor);
                     }
                     // Hyperlink
                     $oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr);
                     if (is_object($oElementHlinkClick)) {
                         if ($oElementHlinkClick->hasAttribute('tooltip')) {
                             $oText->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip'));
                         }
                         if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')])) {
                             $oText->getHyperlink()->setUrl($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]);
                         }
                     }
                     //} else {
                     // $oText = $oParagraph->createText();
                 }
                 $oSubSubElement = $document->getElement('a:t', $oSubElement);
                 $oText->setText($oSubSubElement->nodeValue);
             }
         }
     }
     if (count($oShape->getParagraphs()) > 0) {
         $oShape->setActiveParagraph(0);
     }
 }
Example #14
0
 /**
  * The OfficeArtSpgrContainer record specifies a container for groups of shapes.
  * @param string $stream
  * @param integer $pos
  * @param boolean $bInGroup
  * @link : https://msdn.microsoft.com/en-us/library/dd910416(v=office.12).aspx
  */
 private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = false)
 {
     $arrayReturn = array('length' => 0);
     $data = $this->loadRecordHeader($stream, $pos);
     if ($data['recVer'] == 0xf && $data['recInstance'] == 0x0 && $data['recType'] == 0xf003) {
         $arrayReturn['length'] += 8;
         do {
             $rhFileBlock = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']);
             if (!($rhFileBlock['recVer'] == 0xf && $rhFileBlock['recInstance'] == 0x0 && ($rhFileBlock['recType'] == 0xf003 || $rhFileBlock['recType'] == 0xf004))) {
                 throw new \Exception('PowerPoint97 Reader : readRecordOfficeArtSpgrContainer.');
             }
             switch ($rhFileBlock['recType']) {
                 case 0xf003:
                     // Core
                     $this->oCurrentGroup = $this->oPhpPresentation->getActiveSlide()->createGroup();
                     $this->bFirstShapeGroup = false;
                     // OfficeArtSpgrContainer
                     $fileBlock = $this->readRecordOfficeArtSpgrContainer($stream, $pos + $arrayReturn['length'], true);
                     $arrayReturn['length'] += $fileBlock['length'];
                     $data['recLen'] -= $fileBlock['length'];
                     break;
                 case 0xf004:
                     // Core
                     if (!$bInGroup) {
                         $this->oCurrentGroup = null;
                     }
                     // OfficeArtSpContainer
                     $fileBlock = $this->readRecordOfficeArtSpContainer($stream, $pos + $arrayReturn['length']);
                     $arrayReturn['length'] += $fileBlock['length'];
                     $data['recLen'] -= $fileBlock['length'];
                     // Core
                     //@todo
                     if (!is_null($fileBlock['shape'])) {
                         if ($bInGroup) {
                             $this->oCurrentGroup->addShape($fileBlock['shape']);
                         } else {
                             $this->oPhpPresentation->getActiveSlide()->addShape($fileBlock['shape']);
                         }
                     }
                     break;
             }
         } while ($data['recLen'] > 0);
     }
     return $arrayReturn;
 }
Example #15
0
 public function testMemoryDrawing()
 {
     $gdImage = imagecreatetruecolor(140, 20);
     $textColor = imagecolorallocate($gdImage, 255, 255, 255);
     imagestring($gdImage, 1, 5, 5, 'Created with PHPPresentation', $textColor);
     $oShape = new Drawing\Gd();
     $oShape->setImageResource($gdImage);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oSlide->addShape($oShape);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('ppt/media/' . $oShape->getIndexedFilename()));
 }
Example #16
0
 public function testTransition()
 {
     $value = rand(1000, 5000);
     $oTransition = new Transition();
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $element = '/p:sld/p:transition';
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertFalse($pres->elementExists($element, 'ppt/slides/slide1.xml'));
     $oTransition->setTimeTrigger(true, $value);
     $oSlide->setTransition($oTransition);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($pres->elementExists($element, 'ppt/slides/slide1.xml'));
     $this->assertTrue($pres->attributeElementExists($element, 'advTm', 'ppt/slides/slide1.xml'));
     $this->assertEquals($value, $pres->getElementAttribute($element, 'advTm', 'ppt/slides/slide1.xml'));
     $this->assertContains('0', $pres->getElementAttribute($element, 'advClick', 'ppt/slides/slide1.xml'));
     $oTransition->setSpeed(Transition::SPEED_FAST);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertContains('fast', $pres->getElementAttribute($element, 'spd', 'ppt/slides/slide1.xml'));
     $oTransition->setSpeed(Transition::SPEED_MEDIUM);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertContains('med', $pres->getElementAttribute($element, 'spd', 'ppt/slides/slide1.xml'));
     $oTransition->setSpeed(Transition::SPEED_SLOW);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertContains('slow', $pres->getElementAttribute($element, 'spd', 'ppt/slides/slide1.xml'));
     $rcTransition = new \ReflectionClass('PhpOffice\\PhpPresentation\\Slide\\Transition');
     $arrayConstants = $rcTransition->getConstants();
     foreach ($arrayConstants as $key => $value) {
         if (strpos($key, 'TRANSITION_') !== 0) {
             continue;
         }
         $oTransition->setTransitionType($rcTransition->getConstant($key));
         $oSlide->setTransition($oTransition);
         $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
         switch ($key) {
             case 'TRANSITION_BLINDS_HORIZONTAL':
                 $this->assertTrue($pres->elementExists($element . '/p:blinds[@dir=\'horz\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_BLINDS_VERTICAL':
                 $this->assertTrue($pres->elementExists($element . '/p:blinds[@dir=\'vert\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_CHECKER_HORIZONTAL':
                 $this->assertTrue($pres->elementExists($element . '/p:checker[@dir=\'horz\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_CHECKER_VERTICAL':
                 $this->assertTrue($pres->elementExists($element . '/p:checker[@dir=\'vert\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_CIRCLE_HORIZONTAL':
                 $this->assertTrue($pres->elementExists($element . '/p:circle[@dir=\'horz\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_CIRCLE_VERTICAL':
                 $this->assertTrue($pres->elementExists($element . '/p:circle[@dir=\'vert\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COMB_HORIZONTAL':
                 $this->assertTrue($pres->elementExists($element . '/p:comb[@dir=\'horz\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COMB_VERTICAL':
                 $this->assertTrue($pres->elementExists($element . '/p:comb[@dir=\'vert\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COVER_DOWN':
                 $this->assertTrue($pres->elementExists($element . '/p:cover[@dir=\'d\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COVER_LEFT':
                 $this->assertTrue($pres->elementExists($element . '/p:cover[@dir=\'l\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COVER_LEFT_DOWN':
                 $this->assertTrue($pres->elementExists($element . '/p:cover[@dir=\'ld\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COVER_LEFT_UP':
                 $this->assertTrue($pres->elementExists($element . '/p:cover[@dir=\'lu\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COVER_RIGHT':
                 $this->assertTrue($pres->elementExists($element . '/p:cover[@dir=\'r\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COVER_RIGHT_DOWN':
                 $this->assertTrue($pres->elementExists($element . '/p:cover[@dir=\'rd\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COVER_RIGHT_UP':
                 $this->assertTrue($pres->elementExists($element . '/p:cover[@dir=\'ru\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_COVER_UP':
                 $this->assertTrue($pres->elementExists($element . '/p:cover[@dir=\'u\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_CUT':
                 $this->assertTrue($pres->elementExists($element . '/p:cut', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_DIAMOND':
                 $this->assertTrue($pres->elementExists($element . '/p:diamond', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_DISSOLVE':
                 $this->assertTrue($pres->elementExists($element . '/p:dissolve', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_FADE':
                 $this->assertTrue($pres->elementExists($element . '/p:fade', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_NEWSFLASH':
                 $this->assertTrue($pres->elementExists($element . '/p:newsflash', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_PLUS':
                 $this->assertTrue($pres->elementExists($element . '/p:plus', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_PULL_DOWN':
                 $this->assertTrue($pres->elementExists($element . '/p:pull[@dir=\'d\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_PULL_LEFT':
                 $this->assertTrue($pres->elementExists($element . '/p:pull[@dir=\'l\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_PULL_RIGHT':
                 $this->assertTrue($pres->elementExists($element . '/p:pull[@dir=\'r\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_PULL_UP':
                 $this->assertTrue($pres->elementExists($element . '/p:pull[@dir=\'u\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_PUSH_DOWN':
                 $this->assertTrue($pres->elementExists($element . '/p:push[@dir=\'d\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_PUSH_LEFT':
                 $this->assertTrue($pres->elementExists($element . '/p:push[@dir=\'l\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_PUSH_RIGHT':
                 $this->assertTrue($pres->elementExists($element . '/p:push[@dir=\'r\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_PUSH_UP':
                 $this->assertTrue($pres->elementExists($element . '/p:push[@dir=\'u\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_RANDOM':
                 $this->assertTrue($pres->elementExists($element . '/p:random', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_RANDOMBAR_HORIZONTAL':
                 $this->assertTrue($pres->elementExists($element . '/p:randomBar[@dir=\'horz\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_RANDOMBAR_VERTICAL':
                 $this->assertTrue($pres->elementExists($element . '/p:randomBar[@dir=\'vert\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_SPLIT_IN_HORIZONTAL':
                 $this->assertTrue($pres->elementExists($element . '/p:split[@dir=\'in\'][@orient=\'horz\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_SPLIT_OUT_HORIZONTAL':
                 $this->assertTrue($pres->elementExists($element . '/p:split[@dir=\'out\'][@orient=\'horz\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_SPLIT_IN_VERTICAL':
                 $this->assertTrue($pres->elementExists($element . '/p:split[@dir=\'in\'][@orient=\'vert\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_SPLIT_OUT_VERTICAL':
                 $this->assertTrue($pres->elementExists($element . '/p:split[@dir=\'out\'][@orient=\'vert\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_STRIPS_LEFT_DOWN':
                 $this->assertTrue($pres->elementExists($element . '/p:strips[@dir=\'ld\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_STRIPS_LEFT_UP':
                 $this->assertTrue($pres->elementExists($element . '/p:strips[@dir=\'lu\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_STRIPS_RIGHT_DOWN':
                 $this->assertTrue($pres->elementExists($element . '/p:strips[@dir=\'rd\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_STRIPS_RIGHT_UP':
                 $this->assertTrue($pres->elementExists($element . '/p:strips[@dir=\'ru\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_WEDGE':
                 $this->assertTrue($pres->elementExists($element . '/p:wedge', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_WIPE_DOWN':
                 $this->assertTrue($pres->elementExists($element . '/p:wipe[@dir=\'d\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_WIPE_LEFT':
                 $this->assertTrue($pres->elementExists($element . '/p:wipe[@dir=\'l\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_WIPE_RIGHT':
                 $this->assertTrue($pres->elementExists($element . '/p:wipe[@dir=\'r\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_WIPE_UP':
                 $this->assertTrue($pres->elementExists($element . '/p:wipe[@dir=\'u\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_ZOOM_IN':
                 $this->assertTrue($pres->elementExists($element . '/p:zoom[@dir=\'in\']', 'ppt/slides/slide1.xml'));
                 break;
             case 'TRANSITION_ZOOM_OUT':
                 $this->assertTrue($pres->elementExists($element . '/p:zoom[@dir=\'out\']', 'ppt/slides/slide1.xml'));
                 break;
         }
     }
     $oTransition->setManualTrigger(true);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertContains('1', $pres->getElementAttribute($element, 'advClick', 'ppt/slides/slide1.xml'));
 }
Example #17
0
 public function testTypeLineGridlines()
 {
     $arrayTests = array(array('methodAxis' => 'getAxisX', 'methodGrid' => 'setMajorGridlines', 'expectedElement' => '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:majorGridlines/c:spPr/a:ln', 'expectedElementColor' => '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:majorGridlines/c:spPr/a:ln/a:solidFill/a:srgbClr'), array('methodAxis' => 'getAxisX', 'methodGrid' => 'setMinorGridlines', 'expectedElement' => '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:minorGridlines/c:spPr/a:ln', 'expectedElementColor' => '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:minorGridlines/c:spPr/a:ln/a:solidFill/a:srgbClr'), array('methodAxis' => 'getAxisY', 'methodGrid' => 'setMajorGridlines', 'expectedElement' => '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:majorGridlines/c:spPr/a:ln', 'expectedElementColor' => '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:majorGridlines/c:spPr/a:ln/a:solidFill/a:srgbClr'), array('methodAxis' => 'getAxisY', 'methodGrid' => 'setMinorGridlines', 'expectedElement' => '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:minorGridlines/c:spPr/a:ln', 'expectedElementColor' => '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:minorGridlines/c:spPr/a:ln/a:solidFill/a:srgbClr'));
     $expectedColor = new Color(Color::COLOR_BLUE);
     foreach ($arrayTests as $arrayTest) {
         $expectedSizePts = rand(1, 100);
         $expectedSizeEmu = round(Drawing::pointsToPixels(Drawing::pixelsToEmu($expectedSizePts)));
         $oPresentation = new PhpPresentation();
         $oSlide = $oPresentation->getActiveSlide();
         $oShape = $oSlide->createChartShape();
         $oLine = new Line();
         $oLine->addSeries(new Series('Downloads', array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2)));
         $oShape->getPlotArea()->setType($oLine);
         $oGridlines = new Gridlines();
         $oGridlines->getOutline()->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor($expectedColor);
         $oGridlines->getOutline()->setWidth($expectedSizePts);
         $oShape->getPlotArea()->{$arrayTest['methodAxis']}()->{$arrayTest['methodGrid']}($oGridlines);
         $oXMLDoc = TestHelperDOCX::getDocument($oPresentation, 'PowerPoint2007');
         $this->assertTrue($oXMLDoc->fileExists('ppt/charts/' . $oShape->getIndexedFilename()));
         $this->assertTrue($oXMLDoc->elementExists($arrayTest['expectedElement'], 'ppt/charts/' . $oShape->getIndexedFilename()));
         $this->assertTrue($oXMLDoc->attributeElementExists($arrayTest['expectedElement'], 'w', 'ppt/charts/' . $oShape->getIndexedFilename()));
         $this->assertEquals($expectedSizeEmu, $oXMLDoc->getElementAttribute($arrayTest['expectedElement'], 'w', 'ppt/charts/' . $oShape->getIndexedFilename()));
         $this->assertTrue($oXMLDoc->elementExists($arrayTest['expectedElementColor'], 'ppt/charts/' . $oShape->getIndexedFilename()));
         $this->assertTrue($oXMLDoc->attributeElementExists($arrayTest['expectedElementColor'], 'val', 'ppt/charts/' . $oShape->getIndexedFilename()));
         $this->assertEquals($expectedColor->getRGB(), $oXMLDoc->getElementAttribute($arrayTest['expectedElementColor'], 'val', 'ppt/charts/' . $oShape->getIndexedFilename()));
         unset($oPresentation);
         TestHelperDOCX::clear();
     }
 }
Example #18
0
 public function testLegend()
 {
     $oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
     $oSeries->setShowSeriesName(true);
     $oLine = new Line();
     $oLine->addSeries($oSeries);
     $phpPresentation = new PhpPresentation();
     $oSlide = $phpPresentation->getActiveSlide();
     $oChart = $oSlide->createChartShape();
     $oChart->getPlotArea()->setType($oLine);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $element = '/office:document-content/office:body/office:chart/chart:chart/chart:legend';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row/table:table-cell';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
     $element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row/table:table-cell[@office:value-type=\'string\']';
     $this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
 }
 public function testTypeScatterSeriesOutline()
 {
     $expectedWidth = rand(1, 100);
     $expectedWidthCm = number_format(CommonDrawing::pointsToCentimeters($expectedWidth), 3, '.', '') . 'cm';
     $expectedElement = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\'][@style:family=\'chart\']/style:graphic-properties';
     $oColor = new Color(Color::COLOR_YELLOW);
     $oOutline = new Outline();
     // Define the color
     $oOutline->getFill()->setFillType(Fill::FILL_SOLID);
     $oOutline->getFill()->setStartColor($oColor);
     // Define the width (in points)
     $oOutline->setWidth($expectedWidth);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oScatter = new Scatter();
     $oSeries = new Series('Downloads', array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2));
     $oScatter->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oScatter);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
     $this->assertTrue($oXMLDoc->fileExists('Object 1/content.xml'));
     $this->assertTrue($oXMLDoc->elementExists($expectedElement, 'Object 1/content.xml'));
     $this->assertTrue($oXMLDoc->attributeElementExists($expectedElement, 'svg:stroke-width', 'Object 1/content.xml'));
     $this->assertEquals('0.079cm', $oXMLDoc->getElementAttribute($expectedElement, 'svg:stroke-width', 'Object 1/content.xml'));
     $this->assertTrue($oXMLDoc->attributeElementExists($expectedElement, 'svg:stroke-color', 'Object 1/content.xml'));
     $this->assertEquals('#4a7ebb', $oXMLDoc->getElementAttribute($expectedElement, 'svg:stroke-color', 'Object 1/content.xml'));
     $oSeries->setOutline($oOutline);
     $oScatter->setSeries(array($oSeries));
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
     $this->assertTrue($oXMLDoc->fileExists('Object 1/content.xml'));
     $this->assertTrue($oXMLDoc->elementExists($expectedElement, 'Object 1/content.xml'));
     $this->assertTrue($oXMLDoc->attributeElementExists($expectedElement, 'svg:stroke-width', 'Object 1/content.xml'));
     $this->assertEquals($expectedWidthCm, $oXMLDoc->getElementAttribute($expectedElement, 'svg:stroke-width', 'Object 1/content.xml'));
     $this->assertTrue($oXMLDoc->attributeElementExists($expectedElement, 'svg:stroke-color', 'Object 1/content.xml'));
     $this->assertEquals('#' . $oColor->getRGB(), $oXMLDoc->getElementAttribute($expectedElement, 'svg:stroke-color', 'Object 1/content.xml'));
 }
Example #20
0
 public function testTypeScatterSuperScript()
 {
     $seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oShape = $oSlide->createChartShape();
     $oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
     $oScatter = new Scatter();
     $oSeries = new Series('Downloads', $seriesData);
     $oSeries->getFont()->setSuperScript(true);
     $oScatter->addSeries($oSeries);
     $oShape->getPlotArea()->setType($oScatter);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $element = '/c:chartSpace/c:chart/c:plotArea/c:scatterChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr';
     $this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
     $this->assertEquals('30000', $oXMLDoc->getElementAttribute($element, 'baseline', 'ppt/charts/' . $oShape->getIndexedFilename()));
 }
 /**
  * Extract data from slide
  * @param string $sPart
  * @param string $baseFile
  */
 protected function loadSlide($sPart, $baseFile)
 {
     $xmlReader = new XMLReader();
     if ($xmlReader->getDomFromString($sPart)) {
         // Core
         $oSlide = $this->oPhpPresentation->createSlide();
         $this->oPhpPresentation->setActiveSlideIndex($this->oPhpPresentation->getSlideCount() - 1);
         $oSlide->setRelsIndex('ppt/slides/_rels/' . $baseFile . '.rels');
         // Background
         $oElement = $xmlReader->getElement('/p:sld/p:cSld/p:bg/p:bgPr');
         if ($oElement) {
             $oElementColor = $xmlReader->getElement('a:solidFill/a:srgbClr', $oElement);
             if ($oElementColor) {
                 // Color
                 $oColor = new Color();
                 $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
                 // Background
                 $oBackground = new \PhpOffice\PhpPresentation\Slide\Background\Color();
                 $oBackground->setColor($oColor);
                 // Slide Background
                 $oSlide = $this->oPhpPresentation->getActiveSlide();
                 $oSlide->setBackground($oBackground);
             }
             $oElementImage = $xmlReader->getElement('a:blipFill/a:blip', $oElement);
             if ($oElementImage) {
                 $relImg = $this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'][$oElementImage->getAttribute('r:embed')];
                 if (is_array($relImg)) {
                     // File
                     $pathImage = 'ppt/slides/' . $relImg['Target'];
                     $pathImage = explode('/', $pathImage);
                     foreach ($pathImage as $key => $partPath) {
                         if ($partPath == '..') {
                             unset($pathImage[$key - 1]);
                             unset($pathImage[$key]);
                         }
                     }
                     $pathImage = implode('/', $pathImage);
                     $contentImg = $this->oZip->getFromName($pathImage);
                     $tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg');
                     file_put_contents($tmpBkgImg, $contentImg);
                     // Background
                     $oBackground = new Image();
                     $oBackground->setPath($tmpBkgImg);
                     // Slide Background
                     $oSlide = $this->oPhpPresentation->getActiveSlide();
                     $oSlide->setBackground($oBackground);
                 }
             }
         }
         // Shapes
         foreach ($xmlReader->getElements('/p:sld/p:cSld/p:spTree/*') as $oNode) {
             switch ($oNode->tagName) {
                 case 'p:pic':
                     $this->loadShapeDrawing($xmlReader, $oNode, $oSlide);
                     break;
                 case 'p:sp':
                     $this->loadShapeRichText($xmlReader, $oNode, $oSlide);
                     break;
                 default:
                     //var_export($oNode->tagName);
             }
         }
         // Layout
         $oSlide = $this->oPhpPresentation->getActiveSlide();
         foreach ($this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'] as $valueRel) {
             if ($valueRel['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout') {
                 $layoutBasename = basename($valueRel['Target']);
                 if (array_key_exists($layoutBasename, $this->arraySlideLayouts)) {
                     $oSlide->setSlideLayout($this->arraySlideLayouts[$layoutBasename]);
                 }
                 break;
             }
         }
     }
 }
Example #22
0
 public function testSaveOverwriting()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oImage = $oSlide->createDrawingShape();
     $oImage->setPath(PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png');
     $object = new Serialized($oPhpPresentation);
     $file = tempnam(sys_get_temp_dir(), 'PhpPresentation_Serialized');
     file_put_contents($file, rand(1, 100));
     $this->assertFileExists($file, $object->save($file));
 }
<?php

include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\Slide\Transition;
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 10 Title')->setSubject('Sample 10 Subject')->setDescription('Sample 10 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$slide0 = $objPHPPresentation->getActiveSlide();
// Create a shape (drawing)
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
$shapeDrawing = $slide0->createDrawingShape();
$shapeDrawing->setName('PHPPresentation logo')->setDescription('PHPPresentation logo')->setPath('./resources/phppowerpoint_logo.gif')->setHeight(36)->setOffsetX(10)->setOffsetY(10);
$shapeDrawing->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
$shapeDrawing->getHyperlink()->setUrl('https://github.com/PHPOffice/PHPPresentation/')->setTooltip('PHPPresentation');
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shapeRichText = $slide0->createRichTextShape()->setHeight(300)->setWidth(600)->setOffsetX(170)->setOffsetY(180);
$shapeRichText->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$textRun = $shapeRichText->createTextRun('Thank you for using PHPPresentation!');
$textRun->getFont()->setBold(true)->setSize(60)->setColor(new Color('FFE06B20'));
$oTransition = new Transition();
$oTransition->setManualTrigger(false);
$oTransition->setTimeTrigger(true, 4000);
Example #24
0
 public function testTransition()
 {
     $value = rand(1000, 5000);
     $oTransition = new Transition();
     $phpPresentation = new PhpPresentation();
     $oSlide = $phpPresentation->getActiveSlide();
     $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePage0\']/style:drawing-page-properties';
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $this->assertTrue($pres->elementExists($element, 'content.xml'));
     $this->assertFalse($pres->attributeElementExists($element, 'presentation:duration', 'content.xml'));
     $oTransition->setTimeTrigger(true, $value);
     $oSlide->setTransition($oTransition);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $this->assertTrue($pres->elementExists($element, 'content.xml'));
     $this->assertTrue($pres->attributeElementExists($element, 'presentation:duration', 'content.xml'));
     $this->assertStringStartsWith('PT', $pres->getElementAttribute($element, 'presentation:duration', 'content.xml'));
     $this->assertStringEndsWith('S', $pres->getElementAttribute($element, 'presentation:duration', 'content.xml'));
     $this->assertContains(number_format($value / 1000, 6, '.', ''), $pres->getElementAttribute($element, 'presentation:duration', 'content.xml'));
     $this->assertContains('automatic', $pres->getElementAttribute($element, 'presentation:transition-type', 'content.xml'));
     $oTransition->setSpeed(Transition::SPEED_FAST);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $this->assertContains('fast', $pres->getElementAttribute($element, 'presentation:transition-speed', 'content.xml'));
     $oTransition->setSpeed(Transition::SPEED_MEDIUM);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $this->assertContains('medium', $pres->getElementAttribute($element, 'presentation:transition-speed', 'content.xml'));
     $oTransition->setSpeed(Transition::SPEED_SLOW);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $this->assertContains('slow', $pres->getElementAttribute($element, 'presentation:transition-speed', 'content.xml'));
     $rcTransition = new \ReflectionClass('PhpOffice\\PhpPresentation\\Slide\\Transition');
     $arrayConstants = $rcTransition->getConstants();
     foreach ($arrayConstants as $key => $value) {
         if (strpos($key, 'TRANSITION_') !== 0) {
             continue;
         }
         $oTransition->setTransitionType($rcTransition->getConstant($key));
         $oSlide->setTransition($oTransition);
         $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
         switch ($key) {
             case 'TRANSITION_BLINDS_HORIZONTAL':
                 $this->assertContains('horizontal-stripes', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_BLINDS_VERTICAL':
                 $this->assertContains('vertical-stripes', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_CHECKER_HORIZONTAL':
                 $this->assertContains('horizontal-checkerboard', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_CHECKER_VERTICAL':
                 $this->assertContains('vertical-checkerboard', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_CIRCLE_HORIZONTAL':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_CIRCLE_VERTICAL':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COMB_HORIZONTAL':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COMB_VERTICAL':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COVER_DOWN':
                 $this->assertContains('uncover-to-bottom', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COVER_LEFT':
                 $this->assertContains('uncover-to-left', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COVER_LEFT_DOWN':
                 $this->assertContains('uncover-to-lowerleft', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COVER_LEFT_UP':
                 $this->assertContains('uncover-to-upperleft', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COVER_RIGHT':
                 $this->assertContains('uncover-to-right', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COVER_RIGHT_DOWN':
                 $this->assertContains('uncover-to-lowerright', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COVER_RIGHT_UP':
                 $this->assertContains('uncover-to-upperright', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_COVER_UP':
                 $this->assertContains('uncover-to-top', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_CUT':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_DIAMOND':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_DISSOLVE':
                 $this->assertContains('dissolve', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_FADE':
                 $this->assertContains('fade-from-center', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_NEWSFLASH':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_PLUS':
                 $this->assertContains('close', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_PULL_DOWN':
                 $this->assertContains('stretch-from-bottom', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_PULL_LEFT':
                 $this->assertContains('stretch-from-left', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_PULL_RIGHT':
                 $this->assertContains('stretch-from-right', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_PULL_UP':
                 $this->assertContains('stretch-from-top', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_PUSH_DOWN':
                 $this->assertContains('roll-from-bottom', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_PUSH_LEFT':
                 $this->assertContains('roll-from-left', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_PUSH_RIGHT':
                 $this->assertContains('roll-from-right', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_PUSH_UP':
                 $this->assertContains('roll-from-top', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_RANDOM':
                 $this->assertContains('random', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_RANDOMBAR_HORIZONTAL':
                 $this->assertContains('horizontal-lines', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_RANDOMBAR_VERTICAL':
                 $this->assertContains('vertical-lines', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_SPLIT_IN_HORIZONTAL':
                 $this->assertContains('close-horizontal', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_SPLIT_OUT_HORIZONTAL':
                 $this->assertContains('open-horizontal', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_SPLIT_IN_VERTICAL':
                 $this->assertContains('close-vertical', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_SPLIT_OUT_VERTICAL':
                 $this->assertContains('open-vertical', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_STRIPS_LEFT_DOWN':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_STRIPS_LEFT_UP':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_STRIPS_RIGHT_DOWN':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_STRIPS_RIGHT_UP':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_WEDGE':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_WIPE_DOWN':
                 $this->assertContains('fade-from-bottom', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_WIPE_LEFT':
                 $this->assertContains('fade-from-left', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_WIPE_RIGHT':
                 $this->assertContains('fade-from-right', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_WIPE_UP':
                 $this->assertContains('fade-from-top', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_ZOOM_IN':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
             case 'TRANSITION_ZOOM_OUT':
                 $this->assertContains('none', $pres->getElementAttribute($element, 'presentation:transition-style', 'content.xml'));
                 break;
         }
     }
     $oTransition->setManualTrigger(true);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $this->assertContains('manual', $pres->getElementAttribute($element, 'presentation:transition-type', 'content.xml'));
 }
Example #25
0
<?php

include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 01 Title')->setSubject('Sample 01 Subject')->setDescription('Sample 01 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$currentGroup = $objPHPPresentation->getActiveSlide()->createGroup();
// Create a shape (drawing)
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
$shape = $currentGroup->createDrawingShape();
$shape->setName('PHPPresentation logo')->setDescription('PHPPresentation logo')->setPath('./resources/phppowerpoint_logo.gif')->setHeight(36)->setOffsetX(10)->setOffsetY(10);
$shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentGroup->createRichTextShape()->setHeight(300)->setWidth(600)->setOffsetX(170)->setOffsetY(180);
$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'));
// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
 public function testSlideBackground()
 {
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oBkgImage = new Image();
     $oBkgImage->setPath(PHPPRESENTATION_TESTS_BASE_DIR . '/resources/images/PhpPresentationLogo.png');
     $oSlide->setBackground($oBkgImage);
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
     $element = '/manifest:manifest/manifest:file-entry[5]';
     $this->assertTrue($pres->elementExists($element, 'META-INF/manifest.xml'));
     $this->assertEquals('Pictures/' . str_replace(' ', '_', $oBkgImage->getIndexedFilename(0)), $pres->getElementAttribute($element, 'manifest:full-path', 'META-INF/manifest.xml'));
 }
<?php

include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Slide\Background\Color;
use PhpOffice\PhpPresentation\Style\Color as StyleColor;
use PhpOffice\PhpPresentation\Slide\Background\Image;
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$oSlide1 = $objPHPPresentation->getActiveSlide();
$oSlide1->addShape(clone $oShapeDrawing);
$oSlide1->addShape(clone $oShapeRichText);
// Slide > Background > Color
$oBkgColor = new Color();
$oBkgColor->setColor(new StyleColor(StyleColor::COLOR_DARKGREEN));
$oSlide1->setBackground($oBkgColor);
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$oSlide2 = $objPHPPresentation->createSlide();
$oSlide2->addShape(clone $oShapeDrawing);
$oSlide2->addShape(clone $oShapeRichText);
// Slide > Background > Image
/*
 * @link : http://publicdomainarchive.com/public-domain-images-cave-red-rocks-light-beam-cavern/
 */
$oBkgImage = new Image();
$oBkgImage->setPath('./resources/background.jpg');
$oSlide2->setBackground($oBkgImage);