11
11
use PhpOffice \PhpPresentation \Slide ;
12
12
use PhpOffice \PhpPresentation \Slide \SlideMaster ;
13
13
use PhpOffice \PhpPresentation \Style \SchemeColor ;
14
+ use PhpOffice \PhpPresentation \Slide \Background \Image ;
14
15
15
16
class PptSlideMasters extends AbstractSlide
16
17
{
@@ -24,6 +25,12 @@ public function render()
24
25
$ this ->oZip ->addFromString ('ppt/slideMasters/_rels/slideMaster ' . $ oMasterSlide ->getRelsIndex () . '.xml.rels ' , $ this ->writeSlideMasterRelationships ($ oMasterSlide ));
25
26
// Add the information from the masterSlide to the ZIP file
26
27
$ 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
+ }
27
34
}
28
35
29
36
return $ this ->oZip ;
@@ -58,10 +65,17 @@ public function writeSlideMasterRelationships(SlideMaster $oMasterSlide)
58
65
// Write drawing relationships?
59
66
$ relId = $ this ->writeDrawingRelations ($ oMasterSlide , $ objWriter , ++$ relId );
60
67
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
+
61
75
// TODO: Write hyperlink relationships?
62
76
// TODO: Write comment relationships
63
77
// 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 ' );
65
79
$ objWriter ->endElement ();
66
80
// Return
67
81
return $ objWriter ->getData ();
0 commit comments