/**
  * Create a new Title Element
  *
  * @param string $text
  * @param int $depth
  */
 public function __construct($text, $depth = 1)
 {
     $this->text = CommonText::toUTF8($text);
     $this->depth = $depth;
     if (array_key_exists("Heading_{$this->depth}", Style::getStyles())) {
         $this->style = "Heading{$this->depth}";
     }
     return $this;
 }
Пример #2
0
 /**
  * Create a new Link Element
  *
  * @param string $source
  * @param string $text
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  */
 public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
 {
     $this->source = CommonText::toUTF8($source);
     $this->text = is_null($text) ? $this->source : CommonText::toUTF8($text);
     $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
     $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
     $this->internal = $internal;
     return $this;
 }
 /**
  * Create a new ListItem
  *
  * @param string $text
  * @param int $depth
  * @param mixed $fontStyle
  * @param array|string|null $listStyle
  * @param mixed $paragraphStyle
  */
 public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
 {
     $this->textObject = new Text(CommonText::toUTF8($text), $fontStyle, $paragraphStyle);
     $this->depth = $depth;
     // Version >= 0.10.0 will pass numbering style name. Older version will use old method
     if (!is_null($listStyle) && is_string($listStyle)) {
         $this->style = new ListItemStyle($listStyle);
     } else {
         $this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
     }
 }
 /**
  * Create a new Preserve Text Element
  *
  * @param string $text
  * @param mixed $fontStyle
  * @param mixed $paragraphStyle
  * @return self
  */
 public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
 {
     $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
     $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
     $this->text = CommonText::toUTF8($text);
     $matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     if (isset($matches[0])) {
         $this->text = $matches;
     }
     return $this;
 }
Пример #5
0
 /**
  * Set text content
  *
  * @param string $text
  * @return self
  */
 public function setText($text)
 {
     $this->text = CommonText::toUTF8($text);
     return $this;
 }
 /**
  * Create a new Bookmark Element
  *
  * @param string $name
  */
 public function __construct($name)
 {
     $this->name = CommonText::toUTF8($name);
     return $this;
 }
 /**
  * Test remove underscore prefix
  */
 public function testRemoveUnderscorePrefix()
 {
     $this->assertEquals('item', Text::removeUnderscorePrefix('_item'));
 }
Пример #8
0
 /**
  * @param Title $oTitle
  */
 private function writeTitle(Title $oTitle)
 {
     if ($oTitle->isVisible()) {
         // chart:title
         $this->xmlContent->startElement('chart:title');
         $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetX()), 3) . 'cm');
         $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetY()), 3) . 'cm');
         $this->xmlContent->writeAttribute('chart:style-name', 'styleTitle');
         // > text:p
         $this->xmlContent->startElement('text:p');
         $this->xmlContent->text($oTitle->getText());
         // > text:p
         $this->xmlContent->endElement();
         // > chart:title
         $this->xmlContent->endElement();
     }
 }
Пример #9
0
 /**
  * Write paragraphs
  *
  * @param  \PhpOffice\Common\XMLWriter           $objWriter  XML Writer
  * @param  \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] $paragraphs
  * @throws \Exception
  */
 private function writeParagraphs(XMLWriter $objWriter, $paragraphs)
 {
     // Loop trough paragraphs
     foreach ($paragraphs as $paragraph) {
         // a:p
         $objWriter->startElement('a:p');
         // a:pPr
         $objWriter->startElement('a:pPr');
         $objWriter->writeAttribute('algn', $paragraph->getAlignment()->getHorizontal());
         $objWriter->writeAttribute('fontAlgn', $paragraph->getAlignment()->getVertical());
         $objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginLeft()));
         $objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginRight()));
         $objWriter->writeAttribute('indent', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getIndent()));
         $objWriter->writeAttribute('lvl', $paragraph->getAlignment()->getLevel());
         // Bullet type specified?
         if ($paragraph->getBulletStyle()->getBulletType() != Bullet::TYPE_NONE) {
             // a:buFont
             $objWriter->startElement('a:buFont');
             $objWriter->writeAttribute('typeface', $paragraph->getBulletStyle()->getBulletFont());
             $objWriter->endElement();
             if ($paragraph->getBulletStyle()->getBulletType() == Bullet::TYPE_BULLET) {
                 // a:buChar
                 $objWriter->startElement('a:buChar');
                 $objWriter->writeAttribute('char', $paragraph->getBulletStyle()->getBulletChar());
                 $objWriter->endElement();
             } elseif ($paragraph->getBulletStyle()->getBulletType() == Bullet::TYPE_NUMERIC) {
                 // a:buAutoNum
                 $objWriter->startElement('a:buAutoNum');
                 $objWriter->writeAttribute('type', $paragraph->getBulletStyle()->getBulletNumericStyle());
                 if ($paragraph->getBulletStyle()->getBulletNumericStartAt() != 1) {
                     $objWriter->writeAttribute('startAt', $paragraph->getBulletStyle()->getBulletNumericStartAt());
                 }
                 $objWriter->endElement();
             }
         }
         $objWriter->endElement();
         // Loop trough rich text elements
         $elements = $paragraph->getRichTextElements();
         foreach ($elements as $element) {
             if ($element instanceof BreakElement) {
                 // a:br
                 $objWriter->writeElement('a:br', null);
             } elseif ($element instanceof Run || $element instanceof TextElement) {
                 // a:r
                 $objWriter->startElement('a:r');
                 // a:rPr
                 if ($element instanceof Run) {
                     // a:rPr
                     $objWriter->startElement('a:rPr');
                     // Bold
                     $objWriter->writeAttribute('b', $element->getFont()->isBold() ? '1' : '0');
                     // Italic
                     $objWriter->writeAttribute('i', $element->getFont()->isItalic() ? '1' : '0');
                     // Strikethrough
                     $objWriter->writeAttribute('strike', $element->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike');
                     // Size
                     $objWriter->writeAttribute('sz', $element->getFont()->getSize() * 100);
                     // Underline
                     $objWriter->writeAttribute('u', $element->getFont()->getUnderline());
                     // Superscript / subscript
                     if ($element->getFont()->isSuperScript() || $element->getFont()->isSubScript()) {
                         if ($element->getFont()->isSuperScript()) {
                             $objWriter->writeAttribute('baseline', '30000');
                         } elseif ($element->getFont()->isSubScript()) {
                             $objWriter->writeAttribute('baseline', '-25000');
                         }
                     }
                     // Color - a:solidFill
                     $objWriter->startElement('a:solidFill');
                     // a:srgbClr
                     $objWriter->startElement('a:srgbClr');
                     $objWriter->writeAttribute('val', $element->getFont()->getColor()->getRGB());
                     $objWriter->endElement();
                     $objWriter->endElement();
                     // Font - a:latin
                     $objWriter->startElement('a:latin');
                     $objWriter->writeAttribute('typeface', $element->getFont()->getName());
                     $objWriter->endElement();
                     // a:hlinkClick
                     if ($element->hasHyperlink()) {
                         $this->writeHyperlink($objWriter, $element);
                     }
                     $objWriter->endElement();
                 }
                 // t
                 $objWriter->startElement('a:t');
                 $objWriter->writeCData(Text::controlCharacterPHP2OOXML($element->getText()));
                 $objWriter->endElement();
                 $objWriter->endElement();
             }
         }
         $objWriter->endElement();
     }
 }
Пример #10
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();
 }
Пример #11
0
 /**
  * Write the default style information for a Table shape
  *
  * @param XMLWriter $objWriter
  * @param Table $shape
  */
 public function writeTableStyle(XMLWriter $objWriter, Table $shape)
 {
     foreach ($shape->getRows() as $keyRow => $shapeRow) {
         // style:style
         $objWriter->startElement('style:style');
         $objWriter->writeAttribute('style:name', 'gr' . $this->shapeId . 'r' . $keyRow);
         $objWriter->writeAttribute('style:family', 'table-row');
         // style:table-row-properties
         $objWriter->startElement('style:table-row-properties');
         $objWriter->writeAttribute('style:row-height', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::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' . $this->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 = Text::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 = Text::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 = Text::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 = Text::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 = Text::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($this->arrStyleTextFont[$shapeRichText->getFont()->getHashCode()])) {
                             $this->arrStyleTextFont[$shapeRichText->getFont()->getHashCode()] = $shapeRichText->getFont();
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Set name content
  *
  * @param string $name
  * @return self
  */
 public function setName($name)
 {
     $this->name = CommonText::toUTF8($name);
     return $this;
 }
 /**
  * Set style value template method
  *
  * Some child classes have their own specific overrides.
  * Backward compability check for versions < 0.10.0 which use underscore
  * prefix for their private properties.
  * Check if the set method is exists. Throws an exception?
  *
  * @param string $key
  * @param string $value
  * @return self
  */
 public function setStyleValue($key, $value)
 {
     if (isset($this->aliases[$key])) {
         $key = $this->aliases[$key];
     }
     $method = 'set' . Text::removeUnderscorePrefix($key);
     if (method_exists($this, $method)) {
         $this->{$method}($value);
     }
     return $this;
 }
 /**
  * Set Style value
  *
  * @param string $key
  * @param mixed $value
  * @return self
  */
 public function setStyleValue($key, $value)
 {
     $key = Text::removeUnderscorePrefix($key);
     if ('indent' == $key || 'hanging' == $key) {
         $value = $value * 720;
     } elseif ('spacing' == $key) {
         $value += 240;
         // because line height of 1 matches 240 twips
     }
     return parent::setStyleValue($key, $value);
 }
Пример #15
0
 public function testMedia()
 {
     $expectedName = 'MyName';
     $expectedWidth = rand(1, 100);
     $expectedHeight = rand(1, 100);
     $expectedX = rand(1, 100);
     $expectedY = rand(1, 100);
     $oMedia = new Media();
     $oMedia->setPath(PHPPRESENTATION_TESTS_BASE_DIR . '/resources/videos/sintel_trailer-480p.ogv')->setName($expectedName)->setResizeProportional(false)->setHeight($expectedHeight)->setWidth($expectedWidth)->setOffsetX($expectedX)->setOffsetY($expectedY);
     $expectedWidth = Text::numberFormat(CommonDrawing::pixelsToCentimeters($expectedWidth), 3) . 'cm';
     $expectedHeight = Text::numberFormat(CommonDrawing::pixelsToCentimeters($expectedHeight), 3) . 'cm';
     $expectedX = Text::numberFormat(CommonDrawing::pixelsToCentimeters($expectedX), 3) . 'cm';
     $expectedY = Text::numberFormat(CommonDrawing::pixelsToCentimeters($expectedY), 3) . 'cm';
     $oPhpPresentation = new PhpPresentation();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oSlide->addShape($oMedia);
     $xmlObject = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
     $element = '/office:document-content/office:body/office:presentation/draw:page/draw:frame';
     $this->assertTrue($xmlObject->elementExists($element, 'content.xml'));
     $this->assertEquals($expectedName, $xmlObject->getElementAttribute($element, 'draw:name', 'content.xml'));
     $this->assertEquals($expectedWidth, $xmlObject->getElementAttribute($element, 'svg:width', 'content.xml'));
     $this->assertEquals($expectedHeight, $xmlObject->getElementAttribute($element, 'svg:height', 'content.xml'));
     $this->assertEquals($expectedX, $xmlObject->getElementAttribute($element, 'svg:x', 'content.xml'));
     $this->assertEquals($expectedY, $xmlObject->getElementAttribute($element, 'svg:y', 'content.xml'));
     $element = '/office:document-content/office:body/office:presentation/draw:page/draw:frame/draw:plugin';
     $this->assertTrue($xmlObject->elementExists($element, 'content.xml'));
     $this->assertEquals('application/vnd.sun.star.media', $xmlObject->getElementAttribute($element, 'draw:mime-type', 'content.xml'));
     $this->assertStringStartsWith('Pictures/', $xmlObject->getElementAttribute($element, 'xlink:href', 'content.xml'));
     $this->assertStringEndsWith('ogv', $xmlObject->getElementAttribute($element, 'xlink:href', 'content.xml'));
 }
Пример #16
0
 /**
  * An atom record that specifies the name of a slide.
  * @param string $stream
  * @param integer $pos
  * @link https://msdn.microsoft.com/en-us/library/dd906297(v=office.12).aspx
  */
 private function readRecordSlideNameAtom($stream, $pos)
 {
     $arrayReturn = array('length' => 0, 'slideName' => '');
     $data = $this->loadRecordHeader($stream, $pos);
     if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x3 && $data['recType'] == self::RT_CSTRING && $data['recLen'] % 2 == 0) {
         // Record Header
         $arrayReturn['length'] += 8;
         // Length
         $strLen = $data['recLen'] / 2;
         for ($inc = 0; $inc < $strLen; $inc++) {
             $char = self::getInt2d($stream, $pos + $arrayReturn['length']);
             $arrayReturn['length'] += 2;
             $arrayReturn['slideName'] .= Text::chr($char);
         }
     }
     return $arrayReturn;
 }
 /**
  * Convert text to valid format
  *
  * @param string $text
  * @return string
  */
 protected function getText($text)
 {
     return CommonText::controlCharacterPHP2OOXML($text);
 }