/** * Create a new slideMaster * * @param PhpPresentation $pParent */ public function __construct(PhpPresentation $pParent = null) { // Set parent $this->parent = $pParent; // Shape collection $this->shapeCollection = new \ArrayObject(); // Set identifier $this->identifier = md5(rand(0, 9999) . time()); // Set a basic colorMap $this->colorMap = new ColorMap(); // Set a white background $this->background = new BackgroundColor(); $this->background->setColor(new Color(Color::COLOR_WHITE)); // Set basic textStyles $this->textStyles = new TextStyle(true); // Set basic scheme colors foreach ($this->defaultSchemeColor as $key => $value) { $oSchemeColor = new SchemeColor(); $oSchemeColor->setValue($key); $oSchemeColor->setRGB($value); $this->addSchemeColor($oSchemeColor); } }
/** * @param XMLReader $xmlReader * @param \DOMElement $oElement * @param AbstractSlide $oSlide */ private function loadSlideBackground(XMLReader $xmlReader, \DOMElement $oElement, AbstractSlide $oSlide) { // Background color $oElementColor = $xmlReader->getElement('p:bgPr/a:solidFill/a:srgbClr', $oElement); if ($oElementColor) { // Color $oColor = new Color(); $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null); // Background $oBackground = new \PhpOffice\PhpPresentation\Slide\Background\Color(); $oBackground->setColor($oColor); // Slide Background $oSlide->setBackground($oBackground); } // Background scheme color $oElementSchemeColor = $xmlReader->getElement('p:bgRef/a:schemeClr', $oElement); if ($oElementSchemeColor) { // Color $oColor = new SchemeColor(); $oColor->setValue($oElementSchemeColor->hasAttribute('val') ? $oElementSchemeColor->getAttribute('val') : null); // Background $oBackground = new \PhpOffice\PhpPresentation\Slide\Background\SchemeColor(); $oBackground->setSchemeColor($oColor); // Slide Background $oSlide->setBackground($oBackground); } // Background image $oElementImage = $xmlReader->getElement('p:bgPr/a:blipFill/a:blip', $oElement); if ($oElementImage) { $relImg = $this->arrayRels[$oSlide->getRelsIndex()][$oElementImage->getAttribute('r:embed')]; if (is_array($relImg)) { // File $pathImage = 'ppt/slides/' . $relImg['Target']; $pathImage = explode('/', $pathImage); foreach ($pathImage as $key => $partPath) { if ($partPath == '..') { unset($pathImage[$key - 1]); unset($pathImage[$key]); } } $pathImage = implode('/', $pathImage); $contentImg = $this->oZip->getFromName($pathImage); $tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg'); file_put_contents($tmpBkgImg, $contentImg); // Background $oBackground = new Image(); $oBackground->setPath($tmpBkgImg); // Slide Background $oSlide->setBackground($oBackground); } } }