7
7
use PhpOffice \PhpPresentation \Slide ;
8
8
use PhpOffice \PhpPresentation \Slide \SlideLayout ;
9
9
use PhpOffice \PhpPresentation \Style \ColorMap ;
10
+ use PhpOffice \PhpPresentation \Slide \Background \Image ;
10
11
11
12
class PptSlideLayouts extends AbstractSlide
12
13
{
@@ -20,6 +21,12 @@ public function render()
20
21
foreach ($ oSlideMaster ->getAllSlideLayouts () as $ oSlideLayout ) {
21
22
$ this ->oZip ->addFromString ('ppt/slideLayouts/_rels/slideLayout ' . $ oSlideLayout ->layoutNr . '.xml.rels ' , $ this ->writeSlideLayoutRelationships ($ oSlideLayout ));
22
23
$ this ->oZip ->addFromString ('ppt/slideLayouts/slideLayout ' . $ oSlideLayout ->layoutNr . '.xml ' , $ this ->writeSlideLayout ($ oSlideLayout ));
24
+
25
+ // Add background image slide
26
+ $ oBkgImage = $ oSlideLayout ->getBackground ();
27
+ if ($ oBkgImage instanceof Image) {
28
+ $ this ->oZip ->addFromString ('ppt/media/ ' . $ oBkgImage ->getIndexedFilename ($ oSlideLayout ->getRelsIndex ()), file_get_contents ($ oBkgImage ->getPath ()));
29
+ }
23
30
}
24
31
}
25
32
@@ -53,6 +60,15 @@ public function writeSlideLayoutRelationships(SlideLayout $oSlideLayout)
53
60
// Write drawing relationships?
54
61
$ relId = $ this ->writeDrawingRelations ($ oSlideLayout , $ objWriter , ++$ relId );
55
62
63
+ // Write background relationships?
64
+ $ oBackground = $ oSlideLayout ->getBackground ();
65
+ if ($ oBackground instanceof Image) {
66
+ $ this ->writeRelationship ($ objWriter , $ relId , 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image ' , '../media/ ' . $ oBackground ->getIndexedFilename ($ oSlideLayout ->getRelsIndex ()));
67
+ $ oBackground ->relationId = 'rId ' . $ relId ;
68
+
69
+ $ relId ++;
70
+ }
71
+
56
72
$ objWriter ->endElement ();
57
73
58
74
// Return
0 commit comments