예제 #1
0
 /**
  */
 public function testPixelsEMU()
 {
     $value = rand(1, 100);
     $this->assertEquals(0, Drawing::pixelsToEmu());
     $this->assertEquals(round($value * 9525), Drawing::pixelsToEmu($value));
     $this->assertEquals(0, Drawing::emuToPixels());
     $this->assertEquals(round($value / 9525), Drawing::emuToPixels($value));
 }
예제 #2
0
 /**
  * The OfficeArtFOPT record specifies a table of OfficeArtRGFOPTE records.
  * @param string $stream
  * @param integer $pos
  * @link https://msdn.microsoft.com/en-us/library/dd943404(v=office.12).aspx
  */
 private function readRecordOfficeArtFOPT($stream, $pos)
 {
     $arrayReturn = array('length' => 0);
     $data = $this->loadRecordHeader($stream, $pos);
     if ($data['recVer'] == 0x3 && $data['recType'] == 0xf00b) {
         // Record Header
         $arrayReturn['length'] += 8;
         //@link : http://msdn.microsoft.com/en-us/library/dd906086(v=office.12).aspx
         $officeArtFOPTE = array();
         for ($inc = 0; $inc < $data['recInstance']; $inc++) {
             $opid = self::getInt2d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
             $arrayReturn['length'] += 2;
             $data['recLen'] -= 2;
             $optOp = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
             $arrayReturn['length'] += 4;
             $data['recLen'] -= 4;
             $officeArtFOPTE[] = array('opid' => $opid >> 0 & bindec('11111111111111'), 'fBid' => $opid >> 14 & bindec('1'), 'fComplex' => $opid >> 15 & bindec('1'), 'op' => $optOp);
         }
         //@link : http://code.metager.de/source/xref/kde/calligra/filters/libmso/OPID
         foreach ($officeArtFOPTE as $opt) {
             // echo $opt['opid'].'-0x'.dechex($opt['opid']).EOL;
             switch ($opt['opid']) {
                 case 0x4:
                     // Transform : rotation
                     //@link : https://msdn.microsoft.com/en-us/library/dd949750(v=office.12).aspx
                     $arrayReturn['rotation'] = $opt['op'];
                     break;
                 case 0x7f:
                     // Transform : Protection Boolean Properties
                     //@link : http://msdn.microsoft.com/en-us/library/dd909131(v=office.12).aspx
                     break;
                 case 0x80:
                     // Text : ltxid
                     //@link : http://msdn.microsoft.com/en-us/library/dd947446(v=office.12).aspx
                     break;
                 case 0x81:
                     // Text : dxTextLeft
                     //@link : http://msdn.microsoft.com/en-us/library/dd953234(v=office.12).aspx
                     $arrayReturn['insetLeft'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
                     break;
                 case 0x82:
                     // Text : dyTextTop
                     //@link : http://msdn.microsoft.com/en-us/library/dd925068(v=office.12).aspx
                     $arrayReturn['insetTop'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
                     break;
                 case 0x83:
                     // Text : dxTextRight
                     //@link : http://msdn.microsoft.com/en-us/library/dd906782(v=office.12).aspx
                     $arrayReturn['insetRight'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
                     break;
                 case 0x84:
                     // Text : dyTextBottom
                     //@link : http://msdn.microsoft.com/en-us/library/dd772858(v=office.12).aspx
                     $arrayReturn['insetBottom'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
                     break;
                 case 0x85:
                     // Text : WrapText
                     //@link : http://msdn.microsoft.com/en-us/library/dd924770(v=office.12).aspx
                     break;
                 case 0x87:
                     // Text : anchorText
                     //@link : http://msdn.microsoft.com/en-us/library/dd948575(v=office.12).aspx
                     break;
                 case 0xbf:
                     // Text : Text Boolean Properties
                     //@link : http://msdn.microsoft.com/en-us/library/dd950905(v=office.12).aspx
                     break;
                 case 0x104:
                     // Blip : pib
                     //@link : http://msdn.microsoft.com/en-us/library/dd772837(v=office.12).aspx
                     if ($opt['fComplex'] == 0) {
                         $arrayReturn['pib'] = $opt['op'];
                         $data['recLen'] -= $opt['op'];
                     } else {
                         // pib Complex
                     }
                     break;
                 case 0x13f:
                     // Blip Boolean Properties
                     //@link : https://msdn.microsoft.com/en-us/library/dd944215(v=office.12).aspx
                     break;
                 case 0x140:
                     // Geometry : geoLeft
                     //@link : http://msdn.microsoft.com/en-us/library/dd947489(v=office.12).aspx
                     // print_r('geoLeft : '.$opt['op'].EOL);
                     break;
                 case 0x141:
                     // Geometry : geoTop
                     //@link : http://msdn.microsoft.com/en-us/library/dd949459(v=office.12).aspx
                     // print_r('geoTop : '.$opt['op'].EOL);
                     break;
                 case 0x142:
                     // Geometry : geoRight
                     //@link : http://msdn.microsoft.com/en-us/library/dd947117(v=office.12).aspx
                     // print_r('geoRight : '.$opt['op'].EOL);
                     break;
                 case 0x143:
                     // Geometry : geoBottom
                     //@link : http://msdn.microsoft.com/en-us/library/dd948602(v=office.12).aspx
                     // print_r('geoBottom : '.$opt['op'].EOL);
                     break;
                 case 0x144:
                     // Geometry : shapePath
                     //@link : http://msdn.microsoft.com/en-us/library/dd945249(v=office.12).aspx
                     $arrayReturn['line'] = true;
                     break;
                 case 0x145:
                     // Geometry : pVertices
                     //@link : http://msdn.microsoft.com/en-us/library/dd949814(v=office.12).aspx
                     if ($opt['fComplex'] == 1) {
                         $arrayReturn['length'] += $opt['op'];
                         $data['recLen'] -= $opt['op'];
                     }
                     break;
                 case 0x146:
                     // Geometry : pSegmentInfo
                     //@link : http://msdn.microsoft.com/en-us/library/dd905742(v=office.12).aspx
                     if ($opt['fComplex'] == 1) {
                         $arrayReturn['length'] += $opt['op'];
                         $data['recLen'] -= $opt['op'];
                     }
                     break;
                 case 0x155:
                     // Geometry : pAdjustHandles
                     //@link : http://msdn.microsoft.com/en-us/library/dd905890(v=office.12).aspx
                     if ($opt['fComplex'] == 1) {
                         $arrayReturn['length'] += $opt['op'];
                         $data['recLen'] -= $opt['op'];
                     }
                     break;
                 case 0x156:
                     // Geometry : pGuides
                     //@link : http://msdn.microsoft.com/en-us/library/dd910801(v=office.12).aspx
                     if ($opt['fComplex'] == 1) {
                         $arrayReturn['length'] += $opt['op'];
                         $data['recLen'] -= $opt['op'];
                     }
                     break;
                 case 0x157:
                     // Geometry : pInscribe
                     //@link : http://msdn.microsoft.com/en-us/library/dd904889(v=office.12).aspx
                     if ($opt['fComplex'] == 1) {
                         $arrayReturn['length'] += $opt['op'];
                         $data['recLen'] -= $opt['op'];
                     }
                     break;
                 case 0x17f:
                     // Geometry Boolean Properties
                     //@link : http://msdn.microsoft.com/en-us/library/dd944968(v=office.12).aspx
                     break;
                 case 0x180:
                     // Fill : fillType
                     //@link : http://msdn.microsoft.com/en-us/library/dd947909(v=office.12).aspx
                     break;
                 case 0x181:
                     // Fill : fillColor
                     //@link : http://msdn.microsoft.com/en-us/library/dd921332(v=office.12).aspx
                     $strColor = str_pad(dechex($opt['op'] >> 0 & bindec('11111111')), 2, STR_PAD_LEFT, '0');
                     $strColor .= str_pad(dechex($opt['op'] >> 8 & bindec('11111111')), 2, STR_PAD_LEFT, '0');
                     $strColor .= str_pad(dechex($opt['op'] >> 16 & bindec('11111111')), 2, STR_PAD_LEFT, '0');
                     // echo 'fillColor  : '.$strColor.EOL;
                     break;
                 case 0x183:
                     // Fill : fillBackColor
                     //@link : http://msdn.microsoft.com/en-us/library/dd950634(v=office.12).aspx
                     $strColor = str_pad(dechex($opt['op'] >> 0 & bindec('11111111')), 2, STR_PAD_LEFT, '0');
                     $strColor .= str_pad(dechex($opt['op'] >> 8 & bindec('11111111')), 2, STR_PAD_LEFT, '0');
                     $strColor .= str_pad(dechex($opt['op'] >> 16 & bindec('11111111')), 2, STR_PAD_LEFT, '0');
                     // echo 'fillBackColor  : '.$strColor.EOL;
                     break;
                 case 0x193:
                     // Fill : fillRectRight
                     //@link : http://msdn.microsoft.com/en-us/library/dd951294(v=office.12).aspx
                     // echo 'fillRectRight  : '.\PhpOffice\Common\Drawing::emuToPixels($opt['op']).EOL;
                     break;
                 case 0x194:
                     // Fill : fillRectBottom
                     //@link : http://msdn.microsoft.com/en-us/library/dd910194(v=office.12).aspx
                     // echo 'fillRectBottom   : '.\PhpOffice\Common\Drawing::emuToPixels($opt['op']).EOL;
                     break;
                 case 0x1bf:
                     // Fill : Fill Style Boolean Properties
                     //@link : http://msdn.microsoft.com/en-us/library/dd909380(v=office.12).aspx
                     break;
                 case 0x1c0:
                     // Line Style : lineColor
                     //@link : http://msdn.microsoft.com/en-us/library/dd920397(v=office.12).aspx
                     $strColor = str_pad(dechex($opt['op'] >> 0 & bindec('11111111')), 2, STR_PAD_LEFT, '0');
                     $strColor .= str_pad(dechex($opt['op'] >> 8 & bindec('11111111')), 2, STR_PAD_LEFT, '0');
                     $strColor .= str_pad(dechex($opt['op'] >> 16 & bindec('11111111')), 2, STR_PAD_LEFT, '0');
                     $arrayReturn['lineColor'] = $strColor;
                     break;
                 case 0x1c1:
                     // Line Style : lineOpacity
                     //@link : http://msdn.microsoft.com/en-us/library/dd923433(v=office.12).aspx
                     // echo 'lineOpacity : '.dechex($opt['op']).EOL;
                     break;
                 case 0x1c2:
                     // Line Style : lineBackColor
                     //@link : http://msdn.microsoft.com/en-us/library/dd947669(v=office.12).aspx
                     break;
                 case 0x1cb:
                     // Line Style : lineWidth
                     //@link : http://msdn.microsoft.com/en-us/library/dd926964(v=office.12).aspx
                     $arrayReturn['lineWidth'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
                     break;
                 case 0x1d6:
                     // Line Style : lineJoinStyle
                     //@link : http://msdn.microsoft.com/en-us/library/dd909643(v=office.12).aspx
                     break;
                 case 0x1d7:
                     // Line Style : lineEndCapStyle
                     //@link : http://msdn.microsoft.com/en-us/library/dd925071(v=office.12).aspx
                     break;
                 case 0x1ff:
                     // Line Style : Line Style Boolean Properties
                     //@link : http://msdn.microsoft.com/en-us/library/dd951605(v=office.12).aspx
                     break;
                 case 0x201:
                     // Shadow Style : shadowColor
                     //@link : http://msdn.microsoft.com/en-us/library/dd923454(v=office.12).aspx
                     break;
                 case 0x204:
                     // Shadow Style : shadowOpacity
                     //@link : http://msdn.microsoft.com/en-us/library/dd920720(v=office.12).aspx
                     break;
                 case 0x205:
                     // Shadow Style : shadowOffsetX
                     //@link : http://msdn.microsoft.com/en-us/library/dd945280(v=office.12).aspx
                     $arrayReturn['shadowOffsetX'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
                     break;
                 case 0x206:
                     // Shadow Style : shadowOffsetY
                     //@link : http://msdn.microsoft.com/en-us/library/dd907855(v=office.12).aspx
                     $arrayReturn['shadowOffsetY'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
                     break;
                 case 0x23f:
                     // Shadow Style : Shadow Style Boolean Properties
                     //@link : http://msdn.microsoft.com/en-us/library/dd947887(v=office.12).aspx
                     break;
                 case 0x304:
                     // Shape : bWMode
                     //@link : http://msdn.microsoft.com/en-us/library/dd947659(v=office.12).aspx
                     break;
                 case 0x33f:
                     // Shape Boolean Properties
                     //@link : http://msdn.microsoft.com/en-us/library/dd951345(v=office.12).aspx
                     break;
                 case 0x380:
                     // Group Shape Property Set : wzName
                     //@link : http://msdn.microsoft.com/en-us/library/dd950681(v=office.12).aspx
                     if ($opt['fComplex'] == 1) {
                         $arrayReturn['length'] += $opt['op'];
                         $data['recLen'] -= $opt['op'];
                     }
                     break;
                 case 0x3bf:
                     // Group Shape Property Set : Group Shape Boolean Properties
                     //@link : http://msdn.microsoft.com/en-us/library/dd949807(v=office.12).aspx
                     break;
                 default:
                     throw new \Exception('Feature not implemented (l.' . __LINE__ . ' : 0x' . dechex($opt['opid']) . ')');
             }
         }
         if ($data['recLen'] > 0) {
             $arrayReturn['length'] += $data['recLen'];
         }
     }
     return $arrayReturn;
 }
예제 #3
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);
     }
 }
예제 #4
0
 /**
  * Convert EMUs to differents units
  * @param $value
  * @param string $fromUnit
  * @param string $toUnit
  */
 protected function convertUnit($value, $fromUnit, $toUnit)
 {
     // Convert from $fromUnit to EMU
     switch ($fromUnit) {
         case self::UNIT_MILLIMETER:
             $value *= 36000;
             break;
         case self::UNIT_CENTIMETER:
             $value *= 360000;
             break;
         case self::UNIT_INCH:
             $value *= 914400;
             break;
         case self::UNIT_PIXEL:
             $value = Drawing::pixelsToEmu($value);
             break;
         case self::UNIT_POINT:
             $value *= 12700;
             break;
         case self::UNIT_EMU:
         default:
             // no changes
     }
     // Convert from EMU to $toUnit
     switch ($toUnit) {
         case self::UNIT_MILLIMETER:
             $value /= 36000;
             break;
         case self::UNIT_CENTIMETER:
             $value /= 360000;
             break;
         case self::UNIT_INCH:
             $value /= 914400;
             break;
         case self::UNIT_PIXEL:
             $value = Drawing::emuToPixels($value);
             break;
         case self::UNIT_POINT:
             $value /= 12700;
             break;
         case self::UNIT_EMU:
         default:
             // no changes
     }
     return $value;
 }
예제 #5
0
 /**
  * Write Meta file to XML format
  *
  * @return string        XML Output
  * @throws \Exception
  */
 protected function writePart()
 {
     // Create XML writer
     $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
     $objWriter->startDocument('1.0', 'UTF-8');
     // office:document-meta
     $objWriter->startElement('office:document-styles');
     $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: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:xhtml', 'http://www.w3.org/1999/xhtml');
     $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
     $objWriter->writeAttribute('xmlns:officeooo', 'http://openoffice.org/2009/office');
     $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
     $objWriter->writeAttribute('xmlns:drawooo', 'http://openoffice.org/2010/draw');
     $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
     $objWriter->writeAttribute('office:version', '1.2');
     // Variables
     $stylePageLayout = $this->getPresentation()->getLayout()->getDocumentLayout();
     if (empty($stylePageLayout)) {
         $stylePageLayout = 'sPL0';
     }
     // office:styles
     $objWriter->startElement('office:styles');
     // style:style
     $objWriter->startElement('style:style');
     $objWriter->writeAttribute('style:name', 'sPres0');
     $objWriter->writeAttribute('style:display-name', 'sPres0');
     $objWriter->writeAttribute('style:family', 'presentation');
     // style:graphic-properties
     $objWriter->startElement('style:graphic-properties');
     $objWriter->writeAttribute('draw:fill-color', '#ffffff');
     // > style:graphic-properties
     $objWriter->endElement();
     // > style:style
     $objWriter->endElement();
     foreach ($this->getPresentation()->getAllSlides() as $keySlide => $oSlide) {
         foreach ($oSlide->getShapeCollection() as $shape) {
             if ($shape instanceof Table) {
                 $this->writeTableStyle($objWriter, $shape);
             } elseif ($shape instanceof Group) {
                 $this->writeGroupStyle($objWriter, $shape);
             } elseif ($shape instanceof RichText) {
                 $this->writeRichTextStyle($objWriter, $shape);
             }
         }
         $oBkgImage = $oSlide->getBackground();
         if ($oBkgImage instanceof Image) {
             $this->writeBackgroundStyle($objWriter, $oBkgImage, $keySlide);
         }
     }
     // > office:styles
     $objWriter->endElement();
     // office:automatic-styles
     $objWriter->startElement('office:automatic-styles');
     // style:page-layout
     $objWriter->startElement('style:page-layout');
     $objWriter->writeAttribute('style:name', $stylePageLayout);
     // style:page-layout-properties
     $objWriter->startElement('style:page-layout-properties');
     $objWriter->writeAttribute('fo:margin-top', '0cm');
     $objWriter->writeAttribute('fo:margin-bottom', '0cm');
     $objWriter->writeAttribute('fo:margin-left', '0cm');
     $objWriter->writeAttribute('fo:margin-right', '0cm');
     $objWriter->writeAttribute('fo:page-width', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::emuToPixels($this->getPresentation()->getLayout()->getCX())), 1) . 'cm');
     $objWriter->writeAttribute('fo:page-height', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::emuToPixels($this->getPresentation()->getLayout()->getCY())), 1) . 'cm');
     $printOrientation = 'portrait';
     if ($this->getPresentation()->getLayout()->getCX() > $this->getPresentation()->getLayout()->getCY()) {
         $printOrientation = 'landscape';
     }
     $objWriter->writeAttribute('style:print-orientation', $printOrientation);
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     // office:master-styles
     $objWriter->startElement('office:master-styles');
     // style:master-page
     $objWriter->startElement('style:master-page');
     $objWriter->writeAttribute('style:name', 'Standard');
     $objWriter->writeAttribute('style:display-name', 'Standard');
     $objWriter->writeAttribute('style:page-layout-name', $stylePageLayout);
     $objWriter->writeAttribute('draw:style-name', 'sPres0');
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }