Пример #1
0
 /**
  * Test create new instance
  */
 public function testConstruct()
 {
     $object = new PhpPowerpoint();
     $slide = $object->getSlide();
     $this->assertEquals(new DocumentProperties(), $object->getProperties());
     $this->assertEquals(new DocumentLayout(), $object->getLayout());
     $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Slide', $object->getSlide());
     $this->assertEquals(1, count($object->getAllSlides()));
     $this->assertEquals(0, $object->getIndex($slide));
     $this->assertEquals(1, $object->getSlideCount());
     $this->assertEquals(0, $object->getActiveSlideIndex());
     $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Slide\\Iterator', $object->getSlideIterator());
 }
Пример #2
0
 /**
  * Write content file to XML format
  *
  * @param  PHPPowerPoint $pPHPPowerPoint
  * @return string        XML Output
  * @throws \Exception
  */
 public function writePart(PhpPowerpoint $pPHPPowerPoint)
 {
     // Create XML writer
     $objWriter = $this->getXMLWriter();
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8');
     // office:document-content
     $objWriter->startElement('office:document-content');
     $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
     $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
     $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
     $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
     $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
     $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
     $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
     $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
     $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
     $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
     $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
     $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
     $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
     $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
     $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
     $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
     $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
     $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
     $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
     $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
     $objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
     $objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
     $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $objWriter->writeAttribute('xmlns:smil', 'urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0');
     $objWriter->writeAttribute('xmlns:anim', 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0');
     $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
     $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
     $objWriter->writeAttribute('xmlns:rdfa', 'http://docs.oasis-open.org/opendocument/meta/rdfa#');
     $objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
     $objWriter->writeAttribute('office:version', '1.2');
     // office:automatic-styles
     $objWriter->startElement('office:automatic-styles');
     $this->shapeId = 0;
     $incSlide = 0;
     foreach ($pPHPPowerPoint->getAllSlides() as $pSlide) {
         // Slides
         $this->writeStyleSlide($objWriter, $pSlide, $incSlide);
         // Images
         $shapes = $pSlide->getShapeCollection();
         foreach ($shapes as $shape) {
             // Increment $this->shapeId
             ++$this->shapeId;
             // Check type
             if ($shape instanceof RichText) {
                 $this->writeTxtStyle($objWriter, $shape);
             }
             if ($shape instanceof AbstractDrawing) {
                 $this->writeDrawingStyle($objWriter, $shape);
             }
             if ($shape instanceof Line) {
                 $this->writeLineStyle($objWriter, $shape);
             }
             if ($shape instanceof Table) {
                 $this->writeTableStyle($objWriter, $shape);
             }
             if ($shape instanceof Group) {
                 $this->writeGroupStyle($objWriter, $shape);
             }
         }
         $incSlide++;
     }
     // Style : Bullet
     if (!empty($this->arrStyleBullet)) {
         foreach ($this->arrStyleBullet as $key => $item) {
             $oStyle = $item['oStyle'];
             $arrLevel = explode(';', $item['level']);
             // style:style
             $objWriter->startElement('text:list-style');
             $objWriter->writeAttribute('style:name', 'L_' . $key);
             foreach ($arrLevel as $level) {
                 if ($level != '') {
                     $oAlign = $item['oAlign_' . $level];
                     // text:list-level-style-bullet
                     $objWriter->startElement('text:list-level-style-bullet');
                     $objWriter->writeAttribute('text:level', $level + 1);
                     $objWriter->writeAttribute('text:bullet-char', $oStyle->getBulletChar());
                     // style:list-level-properties
                     $objWriter->startElement('style:list-level-properties');
                     if ($oAlign->getIndent() < 0) {
                         $objWriter->writeAttribute('text:space-before', CommonDrawing::pixelsToCentimeters($oAlign->getMarginLeft() - -1 * $oAlign->getIndent()) . 'cm');
                         $objWriter->writeAttribute('text:min-label-width', CommonDrawing::pixelsToCentimeters(-1 * $oAlign->getIndent()) . 'cm');
                     } else {
                         $objWriter->writeAttribute('text:space-before', CommonDrawing::pixelsToCentimeters($oAlign->getMarginLeft() - $oAlign->getIndent()) . 'cm');
                         $objWriter->writeAttribute('text:min-label-width', CommonDrawing::pixelsToCentimeters($oAlign->getIndent()) . 'cm');
                     }
                     $objWriter->endElement();
                     // style:text-properties
                     $objWriter->startElement('style:text-properties');
                     $objWriter->writeAttribute('fo:font-family', $oStyle->getBulletFont());
                     $objWriter->writeAttribute('style:font-family-generic', 'swiss');
                     $objWriter->writeAttribute('style:use-window-font-color', 'true');
                     $objWriter->writeAttribute('fo:font-size', '100');
                     $objWriter->endElement();
                     $objWriter->endElement();
                 }
             }
             $objWriter->endElement();
         }
     }
     // Style : Paragraph
     if (!empty($this->arrStyleParagraph)) {
         foreach ($this->arrStyleParagraph as $key => $item) {
             // style:style
             $objWriter->startElement('style:style');
             $objWriter->writeAttribute('style:name', 'P_' . $key);
             $objWriter->writeAttribute('style:family', 'paragraph');
             // style:paragraph-properties
             $objWriter->startElement('style:paragraph-properties');
             switch ($item->getAlignment()->getHorizontal()) {
                 case Alignment::HORIZONTAL_LEFT:
                     $objWriter->writeAttribute('fo:text-align', 'left');
                     break;
                 case Alignment::HORIZONTAL_RIGHT:
                     $objWriter->writeAttribute('fo:text-align', 'right');
                     break;
                 case Alignment::HORIZONTAL_CENTER:
                     $objWriter->writeAttribute('fo:text-align', 'center');
                     break;
                 case Alignment::HORIZONTAL_JUSTIFY:
                     $objWriter->writeAttribute('fo:text-align', 'justify');
                     break;
                 case Alignment::HORIZONTAL_DISTRIBUTED:
                     $objWriter->writeAttribute('fo:text-align', 'justify');
                     break;
                 default:
                     $objWriter->writeAttribute('fo:text-align', 'left');
                     break;
             }
             $objWriter->endElement();
             $objWriter->endElement();
         }
     }
     // Style : Text : Font
     if (!empty($this->arrStyleTextFont)) {
         foreach ($this->arrStyleTextFont as $key => $item) {
             // style:style
             $objWriter->startElement('style:style');
             $objWriter->writeAttribute('style:name', 'T_' . $key);
             $objWriter->writeAttribute('style:family', 'text');
             // style:text-properties
             $objWriter->startElement('style:text-properties');
             $objWriter->writeAttribute('fo:color', '#' . $item->getColor()->getRGB());
             $objWriter->writeAttribute('fo:font-family', $item->getName());
             $objWriter->writeAttribute('fo:font-size', $item->getSize() . 'pt');
             // @todo : fo:font-style
             if ($item->isBold()) {
                 $objWriter->writeAttribute('fo:font-weight', 'bold');
             }
             // @todo : style:text-underline-style
             $objWriter->endElement();
             $objWriter->endElement();
         }
     }
     $objWriter->endElement();
     //===============================================
     // Body
     //===============================================
     // office:body
     $objWriter->startElement('office:body');
     // office:presentation
     $objWriter->startElement('office:presentation');
     // Write slides
     $slideCount = $pPHPPowerPoint->getSlideCount();
     $this->shapeId = 0;
     for ($i = 0; $i < $slideCount; ++$i) {
         $pSlide = $pPHPPowerPoint->getSlide($i);
         $objWriter->startElement('draw:page');
         $objWriter->writeAttribute('draw:name', 'page' . $i);
         $objWriter->writeAttribute('draw:master-page-name', 'Standard');
         $objWriter->writeAttribute('draw:style-name', 'stylePage' . $i);
         // Images
         $shapes = $pSlide->getShapeCollection();
         foreach ($shapes as $shape) {
             // Increment $this->shapeId
             ++$this->shapeId;
             // Check type
             if ($shape instanceof RichText) {
                 $this->writeShapeTxt($objWriter, $shape);
             } elseif ($shape instanceof Table) {
                 $this->writeShapeTable($objWriter, $shape);
             } elseif ($shape instanceof Line) {
                 $this->writeShapeLine($objWriter, $shape);
             } elseif ($shape instanceof Chart) {
                 $this->writeShapeChart($objWriter, $shape);
             } elseif ($shape instanceof AbstractDrawing) {
                 $this->writeShapePic($objWriter, $shape);
             } elseif ($shape instanceof Group) {
                 $this->writeShapeGroup($objWriter, $shape);
             }
         }
         // Slide Note
         if ($pSlide->getNote() instanceof Note) {
             $this->writeSlideNote($objWriter, $pSlide->getNote());
         }
         $objWriter->endElement();
     }
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
Пример #3
0
 /**
  * Write content file to XML format
  *
  * @param  PHPPowerPoint $pPHPPowerPoint
  * @return string        XML Output
  * @throws \Exception
  */
 public function writePart(PhpPowerpoint $pPHPPowerPoint)
 {
     // Create XML writer
     $objWriter = $this->getXMLWriter();
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8');
     // office:document-content
     $objWriter->startElement('office:document-content');
     $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
     $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
     $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
     $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
     $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
     $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
     $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
     $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
     $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
     $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
     $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
     $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
     $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
     $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
     $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
     $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
     $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
     $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
     $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
     $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
     $objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
     $objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
     $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $objWriter->writeAttribute('xmlns:smil', 'urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0');
     $objWriter->writeAttribute('xmlns:anim', 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0');
     $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
     $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
     $objWriter->writeAttribute('xmlns:rdfa', 'http://docs.oasis-open.org/opendocument/meta/rdfa#');
     $objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
     $objWriter->writeAttribute('office:version', '1.2');
     //===============================================
     // Styles
     //===============================================
     $arrStyleBullet = array();
     $arrStyleParagraph = array();
     $arrStyleTextFont = array();
     // office:automatic-styles
     $objWriter->startElement('office:automatic-styles');
     $shapeId = 0;
     foreach ($pPHPPowerPoint->getAllSlides() as $pSlide) {
         // Images
         $shapes = $pSlide->getShapeCollection();
         foreach ($shapes as $shape) {
             // Increment $shapeId
             ++$shapeId;
             // Check type
             if ($shape instanceof RichText) {
                 // style:style
                 $objWriter->startElement('style:style');
                 $objWriter->writeAttribute('style:name', 'gr' . $shapeId);
                 $objWriter->writeAttribute('style:family', 'graphic');
                 $objWriter->writeAttribute('style:parent-style-name', 'standard');
                 // style:graphic-properties
                 $objWriter->startElement('style:graphic-properties');
                 if (is_bool($shape->hasAutoShrinkVertical())) {
                     $objWriter->writeAttribute('draw:auto-grow-height', var_export($shape->hasAutoShrinkVertical(), true));
                 }
                 if (is_bool($shape->hasAutoShrinkHorizontal())) {
                     $objWriter->writeAttribute('draw:auto-grow-width', var_export($shape->hasAutoShrinkHorizontal(), true));
                 }
                 switch ($shape->getFill()->getFillType()) {
                     case Fill::FILL_NONE:
                     default:
                         $objWriter->writeAttribute('draw:fill', 'none');
                         $objWriter->writeAttribute('draw:fill-color', '#' . $shape->getFill()->getStartColor()->getRGB());
                         break;
                 }
                 switch ($shape->getBorder()->getLineStyle()) {
                     case Border::LINE_NONE:
                     default:
                         $objWriter->writeAttribute('draw:stroke', 'none');
                         $objWriter->writeAttribute('svg:stroke-color', '#' . $shape->getBorder()->getColor()->getRGB());
                 }
                 $objWriter->writeAttribute('fo:wrap-option', 'wrap');
                 // > style:graphic-properties
                 $objWriter->endElement();
                 // > style:style
                 $objWriter->endElement();
                 $paragraphs = $shape->getParagraphs();
                 $paragraphId = 0;
                 foreach ($paragraphs as $paragraph) {
                     ++$paragraphId;
                     // Style des paragraphes
                     if (!isset($arrStyleParagraph[$paragraph->getHashCode()])) {
                         $arrStyleParagraph[$paragraph->getHashCode()] = $paragraph;
                     }
                     // Style des listes
                     if (!isset($arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()])) {
                         $arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['oStyle'] = $paragraph->getBulletStyle();
                         $arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['level'] = '';
                     }
                     if (strpos($arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['level'], ';' . $paragraph->getAlignment()->getLevel()) === false) {
                         $arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['level'] .= ';' . $paragraph->getAlignment()->getLevel();
                         $arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['oAlign_' . $paragraph->getAlignment()->getLevel()] = $paragraph->getAlignment();
                     }
                     $richtexts = $paragraph->getRichTextElements();
                     $richtextId = 0;
                     foreach ($richtexts as $richtext) {
                         ++$richtextId;
                         // Not a line break
                         if ($richtext instanceof Run) {
                             // Style des font text
                             if (!isset($arrStyleTextFont[$richtext->getFont()->getHashCode()])) {
                                 $arrStyleTextFont[$richtext->getFont()->getHashCode()] = $richtext->getFont();
                             }
                         }
                     }
                 }
             }
             if ($shape instanceof AbstractDrawing) {
                 if ($shape->getShadow()->isVisible()) {
                     // style:style
                     $objWriter->startElement('style:style');
                     $objWriter->writeAttribute('style:name', 'gr' . $shapeId);
                     $objWriter->writeAttribute('style:family', 'graphic');
                     $objWriter->writeAttribute('style:parent-style-name', 'standard');
                     // style:graphic-properties
                     $objWriter->startElement('style:graphic-properties');
                     $objWriter->writeAttribute('draw:stroke', 'none');
                     $objWriter->writeAttribute('draw:fill', 'none');
                     $objWriter->writeAttribute('draw:shadow', 'visible');
                     $objWriter->writeAttribute('draw:shadow-color', '#' . $shape->getShadow()->getColor()->getRGB());
                     if ($shape->getShadow()->getDirection() == 0 || $shape->getShadow()->getDirection() == 360) {
                         $objWriter->writeAttribute('draw:shadow-offset-x', SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                         $objWriter->writeAttribute('draw:shadow-offset-y', '0cm');
                     } elseif ($shape->getShadow()->getDirection() == 45) {
                         $objWriter->writeAttribute('draw:shadow-offset-x', SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                         $objWriter->writeAttribute('draw:shadow-offset-y', SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                     } elseif ($shape->getShadow()->getDirection() == 90) {
                         $objWriter->writeAttribute('draw:shadow-offset-x', '0cm');
                         $objWriter->writeAttribute('draw:shadow-offset-y', SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                     } elseif ($shape->getShadow()->getDirection() == 135) {
                         $objWriter->writeAttribute('draw:shadow-offset-x', '-' . SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                         $objWriter->writeAttribute('draw:shadow-offset-y', SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                     } elseif ($shape->getShadow()->getDirection() == 180) {
                         $objWriter->writeAttribute('draw:shadow-offset-x', '-' . SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                         $objWriter->writeAttribute('draw:shadow-offset-y', '0cm');
                     } elseif ($shape->getShadow()->getDirection() == 225) {
                         $objWriter->writeAttribute('draw:shadow-offset-x', '-' . SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                         $objWriter->writeAttribute('draw:shadow-offset-y', '-' . SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                     } elseif ($shape->getShadow()->getDirection() == 270) {
                         $objWriter->writeAttribute('draw:shadow-offset-x', '0cm');
                         $objWriter->writeAttribute('draw:shadow-offset-y', '-' . SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                     } elseif ($shape->getShadow()->getDirection() == 315) {
                         $objWriter->writeAttribute('draw:shadow-offset-x', SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                         $objWriter->writeAttribute('draw:shadow-offset-y', '-' . SharedDrawing::pixelsToCentimeters($shape->getShadow()->getDistance()) . 'cm');
                     }
                     $objWriter->writeAttribute('draw:shadow-opacity', 100 - $shape->getShadow()->getAlpha() . '%');
                     $objWriter->writeAttribute('style:mirror', 'none');
                     $objWriter->endElement();
                     $objWriter->endElement();
                 }
             }
             if ($shape instanceof Line) {
                 // style:style
                 $objWriter->startElement('style:style');
                 $objWriter->writeAttribute('style:name', 'gr' . $shapeId);
                 $objWriter->writeAttribute('style:family', 'graphic');
                 $objWriter->writeAttribute('style:parent-style-name', 'standard');
                 // style:graphic-properties
                 $objWriter->startElement('style:graphic-properties');
                 $objWriter->writeAttribute('draw:fill', 'none');
                 switch ($shape->getBorder()->getLineStyle()) {
                     case Border::LINE_NONE:
                         $objWriter->writeAttribute('draw:stroke', 'none');
                         break;
                     case Border::LINE_SINGLE:
                         $objWriter->writeAttribute('draw:stroke', 'solid');
                         break;
                     default:
                         $objWriter->writeAttribute('draw:stroke', 'none');
                         break;
                 }
                 $objWriter->writeAttribute('svg:stroke-color', '#' . $shape->getBorder()->getColor()->getRGB());
                 $objWriter->writeAttribute('svg:stroke-width', StringHelper::numberFormat(SharedDrawing::pixelsToCentimeters(SharedDrawing::pointsToPixels($shape->getBorder()->getLineWidth())), 3) . 'cm');
                 $objWriter->endElement();
                 $objWriter->endElement();
             }
             if ($shape instanceof Table) {
                 foreach ($shape->getRows() as $keyRow => $shapeRow) {
                     // style:style
                     $objWriter->startElement('style:style');
                     $objWriter->writeAttribute('style:name', 'gr' . $shapeId . 'r' . $keyRow);
                     $objWriter->writeAttribute('style:family', 'table-row');
                     // style:table-row-properties
                     $objWriter->startElement('style:table-row-properties');
                     $objWriter->writeAttribute('style:row-height', StringHelper::numberFormat(SharedDrawing::pixelsToCentimeters(SharedDrawing::pointsToPixels($shapeRow->getHeight())), 3) . 'cm');
                     $objWriter->endElement();
                     $objWriter->endElement();
                     foreach ($shapeRow->getCells() as $keyCell => $shapeCell) {
                         // style:style
                         $objWriter->startElement('style:style');
                         $objWriter->writeAttribute('style:name', 'gr' . $shapeId . 'r' . $keyRow . 'c' . $keyCell);
                         $objWriter->writeAttribute('style:family', 'table-cell');
                         // style:graphic-properties
                         $objWriter->startElement('style:graphic-properties');
                         if ($shapeCell->getFill()->getFillType() == Fill::FILL_SOLID) {
                             $objWriter->writeAttribute('draw:fill', 'solid');
                             $objWriter->writeAttribute('draw:fill-color', '#' . $shapeCell->getFill()->getStartColor()->getRGB());
                         }
                         if ($shapeCell->getFill()->getFillType() == Fill::FILL_GRADIENT_LINEAR) {
                             $objWriter->writeAttribute('draw:fill', 'gradient');
                             $objWriter->writeAttribute('draw:fill-gradient-name', 'gradient_' . $shapeCell->getFill()->getHashCode());
                         }
                         $objWriter->endElement();
                         // <style:graphic-properties
                         // style:paragraph-properties
                         $objWriter->startElement('style:paragraph-properties');
                         if ($shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getTop()->getHashCode() && $shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getLeft()->getHashCode() && $shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getRight()->getHashCode()) {
                             $lineStyle = 'none';
                             $lineWidth = StringHelper::numberFormat($shapeCell->getBorders()->getBottom()->getLineWidth() / 1.75, 2);
                             $lineColor = $shapeCell->getBorders()->getBottom()->getColor()->getRGB();
                             switch ($shapeCell->getBorders()->getBottom()->getLineStyle()) {
                                 case Border::LINE_SINGLE:
                                     $lineStyle = 'solid';
                             }
                             $objWriter->writeAttribute('fo:border', $lineWidth . 'pt ' . $lineStyle . ' #' . $lineColor);
                         } else {
                             $lineStyle = 'none';
                             $lineWidth = StringHelper::numberFormat($shapeCell->getBorders()->getBottom()->getLineWidth() / 1.75, 2);
                             $lineColor = $shapeCell->getBorders()->getBottom()->getColor()->getRGB();
                             switch ($shapeCell->getBorders()->getBottom()->getLineStyle()) {
                                 case Border::LINE_SINGLE:
                                     $lineStyle = 'solid';
                             }
                             $objWriter->writeAttribute('fo:border-bottom', $lineWidth . 'pt ' . $lineStyle . ' #' . $lineColor);
                             // TOP
                             $lineStyle = 'none';
                             $lineWidth = StringHelper::numberFormat($shapeCell->getBorders()->getTop()->getLineWidth() / 1.75, 2);
                             $lineColor = $shapeCell->getBorders()->getTop()->getColor()->getRGB();
                             switch ($shapeCell->getBorders()->getTop()->getLineStyle()) {
                                 case Border::LINE_SINGLE:
                                     $lineStyle = 'solid';
                             }
                             $objWriter->writeAttribute('fo:border-top', $lineWidth . 'pt ' . $lineStyle . ' #' . $lineColor);
                             // RIGHT
                             $lineStyle = 'none';
                             $lineWidth = StringHelper::numberFormat($shapeCell->getBorders()->getRight()->getLineWidth() / 1.75, 2);
                             $lineColor = $shapeCell->getBorders()->getRight()->getColor()->getRGB();
                             switch ($shapeCell->getBorders()->getRight()->getLineStyle()) {
                                 case Border::LINE_SINGLE:
                                     $lineStyle = 'solid';
                             }
                             $objWriter->writeAttribute('fo:border-right', $lineWidth . 'pt ' . $lineStyle . ' #' . $lineColor);
                             // LEFT
                             $lineStyle = 'none';
                             $lineWidth = StringHelper::numberFormat($shapeCell->getBorders()->getLeft()->getLineWidth() / 1.75, 2);
                             $lineColor = $shapeCell->getBorders()->getLeft()->getColor()->getRGB();
                             switch ($shapeCell->getBorders()->getLeft()->getLineStyle()) {
                                 case Border::LINE_SINGLE:
                                     $lineStyle = 'solid';
                             }
                             $objWriter->writeAttribute('fo:border-left', $lineWidth . 'pt ' . $lineStyle . ' #' . $lineColor);
                         }
                         $objWriter->endElement();
                         $objWriter->endElement();
                         foreach ($shapeCell->getParagraphs() as $shapeParagraph) {
                             foreach ($shapeParagraph->getRichTextElements() as $shapeRichText) {
                                 if ($shapeRichText instanceof Run) {
                                     // Style des font text
                                     if (!isset($arrStyleTextFont[$shapeRichText->getFont()->getHashCode()])) {
                                         $arrStyleTextFont[$shapeRichText->getFont()->getHashCode()] = $shapeRichText->getFont();
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Style : Bullet
     if (!empty($arrStyleBullet)) {
         foreach ($arrStyleBullet as $key => $item) {
             $oStyle = $item['oStyle'];
             $arrLevel = explode(';', $item['level']);
             // style:style
             $objWriter->startElement('text:list-style');
             $objWriter->writeAttribute('style:name', 'L_' . $key);
             foreach ($arrLevel as $level) {
                 if ($level != '') {
                     $oAlign = $item['oAlign_' . $level];
                     // text:list-level-style-bullet
                     $objWriter->startElement('text:list-level-style-bullet');
                     $objWriter->writeAttribute('text:level', $level + 1);
                     $objWriter->writeAttribute('text:bullet-char', $oStyle->getBulletChar());
                     // style:list-level-properties
                     $objWriter->startElement('style:list-level-properties');
                     if ($oAlign->getIndent() < 0) {
                         $objWriter->writeAttribute('text:space-before', SharedDrawing::pixelsToCentimeters($oAlign->getMarginLeft() - -1 * $oAlign->getIndent()) . 'cm');
                         $objWriter->writeAttribute('text:min-label-width', SharedDrawing::pixelsToCentimeters(-1 * $oAlign->getIndent()) . 'cm');
                     } else {
                         $objWriter->writeAttribute('text:space-before', SharedDrawing::pixelsToCentimeters($oAlign->getMarginLeft() - $oAlign->getIndent()) . 'cm');
                         $objWriter->writeAttribute('text:min-label-width', SharedDrawing::pixelsToCentimeters($oAlign->getIndent()) . 'cm');
                     }
                     $objWriter->endElement();
                     // style:text-properties
                     $objWriter->startElement('style:text-properties');
                     $objWriter->writeAttribute('fo:font-family', $oStyle->getBulletFont());
                     $objWriter->writeAttribute('style:font-family-generic', 'swiss');
                     $objWriter->writeAttribute('style:use-window-font-color', 'true');
                     $objWriter->writeAttribute('fo:font-size', '100');
                     $objWriter->endElement();
                     $objWriter->endElement();
                 }
             }
             $objWriter->endElement();
         }
     }
     // Style : Paragraph
     if (!empty($arrStyleParagraph)) {
         foreach ($arrStyleParagraph as $key => $item) {
             // style:style
             $objWriter->startElement('style:style');
             $objWriter->writeAttribute('style:name', 'P_' . $key);
             $objWriter->writeAttribute('style:family', 'paragraph');
             // style:paragraph-properties
             $objWriter->startElement('style:paragraph-properties');
             switch ($item->getAlignment()->getHorizontal()) {
                 case Alignment::HORIZONTAL_LEFT:
                     $objWriter->writeAttribute('fo:text-align', 'left');
                     break;
                 case Alignment::HORIZONTAL_RIGHT:
                     $objWriter->writeAttribute('fo:text-align', 'right');
                     break;
                 case Alignment::HORIZONTAL_CENTER:
                     $objWriter->writeAttribute('fo:text-align', 'center');
                     break;
                 case Alignment::HORIZONTAL_JUSTIFY:
                     $objWriter->writeAttribute('fo:text-align', 'justify');
                     break;
                 case Alignment::HORIZONTAL_DISTRIBUTED:
                     $objWriter->writeAttribute('fo:text-align', 'justify');
                     break;
                 default:
                     $objWriter->writeAttribute('fo:text-align', 'left');
                     break;
             }
             $objWriter->endElement();
             $objWriter->endElement();
         }
     }
     // Style : Text : Font
     if (!empty($arrStyleTextFont)) {
         foreach ($arrStyleTextFont as $key => $item) {
             // style:style
             $objWriter->startElement('style:style');
             $objWriter->writeAttribute('style:name', 'T_' . $key);
             $objWriter->writeAttribute('style:family', 'text');
             // style:text-properties
             $objWriter->startElement('style:text-properties');
             $objWriter->writeAttribute('fo:color', '#' . $item->getColor()->getRGB());
             $objWriter->writeAttribute('fo:font-family', $item->getName());
             $objWriter->writeAttribute('fo:font-size', $item->getSize() . 'pt');
             // @todo : fo:font-style
             if ($item->isBold()) {
                 $objWriter->writeAttribute('fo:font-weight', 'bold');
             }
             // @todo : style:text-underline-style
             $objWriter->endElement();
             $objWriter->endElement();
         }
     }
     $objWriter->endElement();
     //===============================================
     // Body
     //===============================================
     // office:body
     $objWriter->startElement('office:body');
     // office:presentation
     $objWriter->startElement('office:presentation');
     // Write slides
     $slideCount = $pPHPPowerPoint->getSlideCount();
     $shapeId = 0;
     for ($i = 0; $i < $slideCount; ++$i) {
         $pSlide = $pPHPPowerPoint->getSlide($i);
         $objWriter->startElement('draw:page');
         $objWriter->writeAttribute('draw:name', 'page' . $i);
         $objWriter->writeAttribute('draw:master-page-name', 'Standard');
         // Images
         $shapes = $pSlide->getShapeCollection();
         foreach ($shapes as $shape) {
             // Increment $shapeId
             ++$shapeId;
             // Check type
             if ($shape instanceof RichText) {
                 $this->writeShapeTxt($objWriter, $shape, $shapeId);
             } elseif ($shape instanceof Table) {
                 $this->writeShapeTable($objWriter, $shape, $shapeId);
             } elseif ($shape instanceof Line) {
                 $this->writeShapeLine($objWriter, $shape, $shapeId);
             } elseif ($shape instanceof Chart) {
                 $this->writeShapeChart($objWriter, $shape, $shapeId);
             } elseif ($shape instanceof AbstractDrawing) {
                 $this->writeShapePic($objWriter, $shape, $shapeId);
             }
         }
         $objWriter->endElement();
     }
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }
 protected function displayPhpPowerpointInfo(PhpPowerpoint $oPHPPpt)
 {
     $this->append('<div class="infoBlk" id="divPhpPowerpointInfo">');
     $this->append('<dl>');
     $this->append('<dt>Number of slides</dt><dd>' . $oPHPPpt->getSlideCount() . '</dd>');
     $this->append('<dt>Document Layout Height</dt><dd>' . $oPHPPpt->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
     $this->append('<dt>Document Layout Width</dt><dd>' . $oPHPPpt->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
     $this->append('<dt>Properties : Category</dt><dd>' . $oPHPPpt->getProperties()->getCategory() . '</dd>');
     $this->append('<dt>Properties : Company</dt><dd>' . $oPHPPpt->getProperties()->getCompany() . '</dd>');
     $this->append('<dt>Properties : Created</dt><dd>' . $oPHPPpt->getProperties()->getCreated() . '</dd>');
     $this->append('<dt>Properties : Creator</dt><dd>' . $oPHPPpt->getProperties()->getCreator() . '</dd>');
     $this->append('<dt>Properties : Description</dt><dd>' . $oPHPPpt->getProperties()->getDescription() . '</dd>');
     $this->append('<dt>Properties : Keywords</dt><dd>' . $oPHPPpt->getProperties()->getKeywords() . '</dd>');
     $this->append('<dt>Properties : Last Modified By</dt><dd>' . $oPHPPpt->getProperties()->getLastModifiedBy() . '</dd>');
     $this->append('<dt>Properties : Modified</dt><dd>' . $oPHPPpt->getProperties()->getModified() . '</dd>');
     $this->append('<dt>Properties : Subject</dt><dd>' . $oPHPPpt->getProperties()->getSubject() . '</dd>');
     $this->append('<dt>Properties : Title</dt><dd>' . $oPHPPpt->getProperties()->getTitle() . '</dd>');
     $this->append('</dl>');
     $this->append('</div>');
     foreach ($oPHPPpt->getAllSlides() as $oSlide) {
         $this->append('<div class="infoBlk" id="div' . $oSlide->getHashCode() . 'Info">');
         $this->append('<dl>');
         $this->append('<dt>HashCode</dt><dd>' . $oSlide->getHashCode() . '</dd>');
         $this->append('<dt>Slide Layout</dt><dd>' . $oSlide->getSlideLayout() . '</dd>');
         $this->append('<dt>Offset X</dt><dd>' . $oSlide->getOffsetX() . '</dd>');
         $this->append('<dt>Offset Y</dt><dd>' . $oSlide->getOffsetY() . '</dd>');
         $this->append('<dt>Extent X</dt><dd>' . $oSlide->getExtentX() . '</dd>');
         $this->append('<dt>Extent Y</dt><dd>' . $oSlide->getExtentY() . '</dd>');
         $this->append('</dl>');
         $this->append('</div>');
         foreach ($oSlide->getShapeCollection() as $oShape) {
             if ($oShape instanceof Group) {
                 foreach ($oShape->getShapeCollection() as $oShapeChild) {
                     $this->displayShapeInfo($oShapeChild);
                 }
             } else {
                 $this->displayShapeInfo($oShape);
             }
         }
     }
 }