Skip to content

Commit 274e8b4

Browse files
author
Peter Lind
committed
Merge branch 'masterslide-background-images' into develop
2 parents 6e8bda5 + f5852ab commit 274e8b4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PhpOffice\PhpPresentation\Slide;
1212
use PhpOffice\PhpPresentation\Slide\SlideMaster;
1313
use PhpOffice\PhpPresentation\Style\SchemeColor;
14+
use PhpOffice\PhpPresentation\Slide\Background\Image;
1415

1516
class PptSlideMasters extends AbstractSlide
1617
{
@@ -24,6 +25,12 @@ public function render()
2425
$this->oZip->addFromString('ppt/slideMasters/_rels/slideMaster' . $oMasterSlide->getRelsIndex() . '.xml.rels', $this->writeSlideMasterRelationships($oMasterSlide));
2526
// Add the information from the masterSlide to the ZIP file
2627
$this->oZip->addFromString('ppt/slideMasters/slideMaster' . $oMasterSlide->getRelsIndex() . '.xml', $this->writeSlideMaster($oMasterSlide));
28+
29+
// Add background image slide
30+
$oBkgImage = $oMasterSlide->getBackground();
31+
if ($oBkgImage instanceof Image) {
32+
$this->oZip->addFromString('ppt/media/' . $oBkgImage->getIndexedFilename($oMasterSlide->getRelsIndex()), file_get_contents($oBkgImage->getPath()));
33+
}
2734
}
2835

2936
return $this->oZip;
@@ -58,10 +65,17 @@ public function writeSlideMasterRelationships(SlideMaster $oMasterSlide)
5865
// Write drawing relationships?
5966
$relId = $this->writeDrawingRelations($oMasterSlide, $objWriter, ++$relId);
6067

68+
// Write background relationships?
69+
$oBackground = $oMasterSlide->getBackground();
70+
if ($oBackground instanceof Image) {
71+
$this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $oBackground->getIndexedFilename($oMasterSlide->getRelsIndex()));
72+
$oBackground->relationId = 'rId' . $relId;
73+
}
74+
6175
// TODO: Write hyperlink relationships?
6276
// TODO: Write comment relationships
6377
// Relationship theme/theme1.xml
64-
$this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', '../theme/theme' . $oMasterSlide->getRelsIndex() . '.xml');
78+
$this->writeRelationship($objWriter, ++$relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', '../theme/theme' . $oMasterSlide->getRelsIndex() . '.xml');
6579
$objWriter->endElement();
6680
// Return
6781
return $objWriter->getData();

0 commit comments

Comments
 (0)