Skip to content

Commit 8e8ae7c

Browse files
devX2712Progi1984
authored andcommitted
EVOL Move Shape name to AbstractShape
Evolution : - move Shape::name to AbstractShape - add reading name for Shape in PowerPoint2007
1 parent 24839e6 commit 8e8ae7c

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/PhpPresentation/AbstractShape.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,22 @@ abstract class AbstractShape implements ComparableInterface
110110
private $hashIndex;
111111

112112
/**
113-
* Create a new self.
113+
* Name
114+
*
115+
* @var string
116+
*/
117+
protected $name = '';
118+
119+
/**
120+
* Create a new self
114121
*/
115122
public function __construct()
116123
{
117124
$this->offsetX = $this->offsetY = $this->width = $this->height = $this->rotation = 0;
118125
$this->fill = new Fill();
119126
$this->shadow = new Shadow();
120127
$this->border = new Border();
128+
121129
$this->border->setLineStyle(Style\Border::LINE_NONE);
122130
}
123131

@@ -181,7 +189,31 @@ public function setContainer(?ShapeContainerInterface $pValue = null, $pOverride
181189
}
182190

183191
/**
184-
* Get OffsetX.
192+
* Get Name
193+
*
194+
* @return string
195+
*/
196+
public function getName()
197+
{
198+
return $this->name;
199+
}
200+
201+
/**
202+
* Set Name
203+
*
204+
* @param string $pValue
205+
* @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic
206+
*/
207+
public function setName($pValue = '')
208+
{
209+
$this->name = $pValue;
210+
return $this;
211+
}
212+
213+
/**
214+
* Get OffsetX
215+
*
216+
* @return int
185217
*/
186218
public function getOffsetX(): int
187219
{

src/PhpPresentation/Reader/PowerPoint2007.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,10 @@ protected function loadShapeRichText(XMLReader $document, DOMElement $node, $oSl
933933
$this->fileRels = $oSlide->getRelsIndex();
934934
}
935935

936+
$oElement = $document->getElement('p:nvSpPr/p:cNvPr', $node);
937+
if ($oElement instanceof \DOMElement)
938+
$oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : '');
939+
936940
$oElement = $document->getElement('p:spPr/a:xfrm', $node);
937941
if ($oElement instanceof DOMElement && $oElement->hasAttribute('rot')) {
938942
$oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot')));

0 commit comments

Comments
 (0)