From dad7d516c6069240f1014f510762bdf0bfeb15ce Mon Sep 17 00:00:00 2001 From: Uzi Erdenebileg Date: Sat, 5 Oct 2019 05:31:10 -0600 Subject: [PATCH 1/3] Add support for image hyperlinks --- src/PhpPresentation/Reader/PowerPoint2007.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/PhpPresentation/Reader/PowerPoint2007.php b/src/PhpPresentation/Reader/PowerPoint2007.php index 2548b377f..f28425e1c 100644 --- a/src/PhpPresentation/Reader/PowerPoint2007.php +++ b/src/PhpPresentation/Reader/PowerPoint2007.php @@ -734,6 +734,17 @@ protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, Abst if ($oElement instanceof \DOMElement) { $oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : ''); $oShape->setDescription($oElement->hasAttribute('descr') ? $oElement->getAttribute('descr') : ''); + + // Hyperlink + $oElementHlinkClick = $document->getElement('a:hlinkClick', $oElement); + if (is_object($oElementHlinkClick)) { + if ($oElementHlinkClick->hasAttribute('tooltip')) { + $oShape->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip')); + } + if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target'])) { + $oShape->getHyperlink()->setUrl($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target']); + } + } } $oElement = $document->getElement('p:blipFill/a:blip', $node); From 3f54b75610689452ad03cfdd0624742cf71f14fd Mon Sep 17 00:00:00 2001 From: ulziibuyan Date: Tue, 8 Oct 2019 06:02:14 -0600 Subject: [PATCH 2/3] Update CHANGELOD.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e99e00e3..fd9325484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - PHP 7.1 is now supported - @Progi1984 GH-355 - PhpOffice\PhpPresentation\Style\Color : Define only the transparency - @Progi1984 GH-370 - PowerPoint2007 Reader : Background Color based on SchemeColor - @Progi1984 GH-397 +- PowerPoint2007 Reader : Support for hyperlinks under pictures - @ulziibuyan ### Features - ODPresentation Writer : Support for the position of Legend - @Progi1984 GH-355 From 28f86ef07b3d5c12ef240609fa33ed81b17923c9 Mon Sep 17 00:00:00 2001 From: Uzi Erdenebileg Date: Wed, 9 Oct 2019 00:30:30 -0600 Subject: [PATCH 3/3] Display hyperlink properties of Drawing\Gd shape --- samples/Sample_Header.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index 6cf01f8e0..91d04e91f 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -109,7 +109,7 @@ function write($phpPresentation, $filename, $writers) { $result = ''; - + // Write documents foreach ($writers as $writer => $extension) { $result .= date('H:i:s') . " Write to {$writer} format"; @@ -177,7 +177,7 @@ function createTemplatedSlide(PhpOffice\PhpPresentation\PhpPresentation $objPHPP { // Create slide $slide = $objPHPPresentation->createSlide(); - + // Add logo $shape = $slide->createDrawingShape(); $shape->setName('PHPPresentation logo') @@ -301,7 +301,7 @@ protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt) $this->append('
'); $this->append('
HashCode
'.$oSlide->getHashCode().'
'); $this->append('
Slide Layout
Layout::'.$this->getConstantName('\PhpOffice\PhpPresentation\Slide\Layout', $oSlide->getSlideLayout()).'
'); - + $this->append('
Offset X
'.$oSlide->getOffsetX().'
'); $this->append('
Offset Y
'.$oSlide->getOffsetY().'
'); $this->append('
Extent X
'.$oSlide->getExtentX().'
'); @@ -379,6 +379,10 @@ protected function displayShapeInfo(AbstractShape $oShape) ob_end_clean(); $this->append('
Mime-Type
'.$oShape->getMimeType().'
'); $this->append('
Image
'); + if ($oShape->hasHyperlink()) { + $this->append('
Hyperlink URL
'.$oShape->getHyperlink()->getUrl().'
'); + $this->append('
Hyperlink Tooltip
'.$oShape->getHyperlink()->getTooltip().'
'); + } } elseif($oShape instanceof Drawing\AbstractDrawingAdapter) { $this->append('
Name
'.$oShape->getName().'
'); $this->append('
Description
'.$oShape->getDescription().'
'); @@ -449,7 +453,7 @@ protected function displayShapeInfo(AbstractShape $oShape) $this->append('
'); $this->append(''); } - + protected function getConstantName($class, $search, $startWith = '') { $fooClass = new ReflectionClass($class); $constants = $fooClass->getConstants();