Open TrevorBradleyCDN opened 5 years ago
It's not implemented for the moment :).
Here's hoping for Hacktoberfest then. :)
I wasn't patient enough for Hacktoberfest. :)
Note that this is NOT a complete solution. It only takes into account solid backgrounds. But it might be a strong hint to anyone who wishes to tackle this.
I subclassed Reader/PowerPoint2007.php for my own purposes. Here's my revised loadShapeRichText(). Note that the initial return statement has been dropped, that a final else statement has been handled to add a paragraph in case one has been missing, and a new $oElement block that watches for a p:spPr/a:solidFill/a:srgbClr block.
protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $oSlide)
{
// Core
$oShape = $oSlide->createRichTextShape();
$oShape->setParagraphs(array());
// Variables
if ($oSlide instanceof AbstractSlide) {
$this->fileRels = $oSlide->getRelsIndex();
}
$oElement = $document->getElement('p:spPr/a:xfrm', $node);
if ($oElement instanceof \DOMElement && $oElement->hasAttribute('rot')) {
$oShape->setRotation(CommonDrawing::angleToDegrees($oElement->getAttribute('rot')));
}
$oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node);
if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('x')) {
$oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x')));
}
if ($oElement->hasAttribute('y')) {
$oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y')));
}
}
$oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node);
if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('cx')) {
$oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx')));
}
if ($oElement->hasAttribute('cy')) {
$oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy')));
}
}
$oElement = $document->getElement('p:spPr/a:solidFill/a:srgbClr', $node);
if (is_object($oElement) && $oElement->hasAttribute('val')) {
$oColor = new Color();
$oColor->setRGB($oElement->getAttribute('val'));
$oShape->getFill()->setFillType(Fill::FILL_SOLID)
->setStartColor($oColor)
->setEndColor($oColor);
}
$oElement = $document->getElement('p:nvSpPr/p:nvPr/p:ph', $node);
if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('type')) {
$placeholder = new Placeholder($oElement->getAttribute('type'));
$oShape->setPlaceHolder($placeholder);
}
}
$arrayElements = $document->getElements('p:txBody/a:p', $node);
foreach ($arrayElements as $oElement) {
$this->loadParagraph($document, $oElement, $oShape);
}
if (count($oShape->getParagraphs()) > 0) {
$oShape->setActiveParagraph(0);
} else {
// Create missing shape
$oShape->createParagraph();
}
}
I'm having an issue where I'm attempting to load an existing PPTX file, with a background fill colour, defined as an "Area" in LibreOffice Impress, or as a solidFill in the slide XML.
All background fill colours, or "Area" shapes, appear to be completely discarded by IOFactory's load function.
I thought it was just me, so I modified Sample_06_Fill.php to attempt to reload, then resave the PPTX file it just generated, adding the following block of code just before the Sample_Footer:
$oReaderPPTX = IOFactory::createReader('PowerPoint2007');
$phpPowerpoint = $oReaderPPTX->load('results/Sample_06_Fill.pptx');
$oWriterPPTX = IOFactory::createWriter($phpPowerpoint, 'PowerPoint2007');
$oWriterPPTX->save("results/Sample_06_Fill_Reload.pptx");
The resultant PPTX file has all its background colours stripped out.
I've done tests with very simple PPTX files, where there's a single area of colour on the page and nothing else, and the slide's shape collection is entirely empty.
Does the load function discard areas?
Sample_06_Fill_Reload.php.txt
Sample_06_Fill.pptx
Sample_06_Fill_Reload.pptx
SampleArea.pptx
SampleArea's Slide XML:
`