Skip to content

Commit fa6fc54

Browse files
authored
Merge pull request #776 from Progi1984/pr697
PowerPoint2007 Writer : Fixed broken video file relationship
2 parents 1aa28c4 + 27ed8b9 commit fa6fc54

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

docs/changes/1.1.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- PowerPoint2007 Writer : Outline : Fixed the base unit - [@Pakku](https://github.com/Pakku) in [#772](https://github.com/PHPOffice/PHPPresentation/pull/772)
2121
- PowerPoint2007 Writer : Fixed column indices for embedded spreadsheets - [@michael-roth](https://github.com/michael-roth) in [#773](https://github.com/PHPOffice/PHPPresentation/pull/773)
2222
- PowerPoint2007 Reader : Load images from file only if valid - [@aelliott1485](https://github.com/aelliott1485) in [#775](https://github.com/PHPOffice/PHPPresentation/pull/775)
23+
- PowerPoint2007 Writer : Fixed broken video file relationship - [@potofcoffee](https://github.com/potofcoffee) in [#776](https://github.com/PHPOffice/PHPPresentation/pull/776)
2324

2425
## BC Breaks
2526
- `PhpOffice\PhpPresentation\Style\Outline` : the width is now based on pixels (before in points)

src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ protected function writeShapePic(XMLWriter $objWriter, AbstractGraphic $shape, i
13041304
$objWriter->writeAttribute('uri', '{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}');
13051305
// p:nvPr > p:extLst > p:ext > p14:media
13061306
$objWriter->startElement('p14:media');
1307-
$objWriter->writeAttribute('r:embed', ((int) $shape->relationId + 1));
1307+
$objWriter->writeAttribute('r:embed', 'rId' . ((int) substr($shape->relationId, strlen('rId')) + 1));
13081308
$objWriter->writeAttribute('xmlns:p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
13091309
// p:nvPr > p:extLst > p:ext > ##p14:media
13101310
$objWriter->endElement();

tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,14 @@ public function testMedia(): void
589589

590590
$element = '/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/a:videoFile';
591591
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
592+
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'r:link', 'rId2');
592593
$element = '/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/p:extLst/p:ext';
593594
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
594595
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'uri', '{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}');
596+
$element = '/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/p:extLst/p:ext/p14:media';
597+
$this->assertZipXmlElementExists('ppt/slides/slide1.xml', $element);
598+
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'r:embed', 'rId3');
599+
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $element, 'xmlns:p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
595600

596601
$this->assertIsSchemaECMA376Valid();
597602
}

tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ private function getXmlNodeList(string $file, string $xpath): DOMNodeList
190190

191191
if (null === $this->xmlXPath) {
192192
$this->xmlXPath = new DOMXPath($this->xmlDom);
193+
$this->xmlXPath->registerNamespace('p14', 'http://schemas.microsoft.com/office/powerpoint/2010/main');
193194
}
194195

195196
return $this->xmlXPath->query($xpath);

0 commit comments

Comments
 (0)