Skip to content

Commit

Permalink
Merge pull request #557 from ulziibuyan/develop
Browse files Browse the repository at this point in the history
Add hyperlink parsing under pictures
  • Loading branch information
Progi1984 authored Oct 9, 2019
2 parents eaad91e + 28f86ef commit fa28cf1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions samples/Sample_Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -177,7 +177,7 @@ function createTemplatedSlide(PhpOffice\PhpPresentation\PhpPresentation $objPHPP
{
// Create slide
$slide = $objPHPPresentation->createSlide();

// Add logo
$shape = $slide->createDrawingShape();
$shape->setName('PHPPresentation logo')
Expand Down Expand Up @@ -301,7 +301,7 @@ protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt)
$this->append('<dl>');
$this->append('<dt>HashCode</dt><dd>'.$oSlide->getHashCode().'</dd>');
$this->append('<dt>Slide Layout</dt><dd>Layout::'.$this->getConstantName('\PhpOffice\PhpPresentation\Slide\Layout', $oSlide->getSlideLayout()).'</dd>');

$this->append('<dt>Offset X</dt><dd>'.$oSlide->getOffsetX().'</dd>');
$this->append('<dt>Offset Y</dt><dd>'.$oSlide->getOffsetY().'</dd>');
$this->append('<dt>Extent X</dt><dd>'.$oSlide->getExtentX().'</dd>');
Expand Down Expand Up @@ -379,6 +379,10 @@ protected function displayShapeInfo(AbstractShape $oShape)
ob_end_clean();
$this->append('<dt>Mime-Type</dt><dd>'.$oShape->getMimeType().'</dd>');
$this->append('<dt>Image</dt><dd><img src="data:'.$oShape->getMimeType().';base64,'.base64_encode($sShapeImgContents).'"></dd>');
if ($oShape->hasHyperlink()) {
$this->append('<dt>Hyperlink URL</dt><dd>'.$oShape->getHyperlink()->getUrl().'</dd>');
$this->append('<dt>Hyperlink Tooltip</dt><dd>'.$oShape->getHyperlink()->getTooltip().'</dd>');
}
} elseif($oShape instanceof Drawing\AbstractDrawingAdapter) {
$this->append('<dt>Name</dt><dd>'.$oShape->getName().'</dd>');
$this->append('<dt>Description</dt><dd>'.$oShape->getDescription().'</dd>');
Expand Down Expand Up @@ -449,7 +453,7 @@ protected function displayShapeInfo(AbstractShape $oShape)
$this->append('</dl>');
$this->append('</div>');
}

protected function getConstantName($class, $search, $startWith = '') {
$fooClass = new ReflectionClass($class);
$constants = $fooClass->getConstants();
Expand Down
11 changes: 11 additions & 0 deletions src/PhpPresentation/Reader/PowerPoint2007.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fa28cf1

Please sign in to comment.