offsetX = $this->offsetY = $this->width = $this->height = $this->rotation = 0; $this->fill = new Fill(); $this->shadow = new Shadow(); $this->border = new Border(); $this->border->setLineStyle(Style\Border::LINE_NONE); } /** * Magic Method : clone. */ public function __clone() { $this->container = null; $this->fill = clone $this->fill; $this->border = clone $this->border; $this->shadow = clone $this->shadow; } /** * Get Container, Slide or Group. */ public function getContainer(): ?ShapeContainerInterface { return $this->container; } /** * Set Container, Slide or Group. * * @param ShapeContainerInterface $pValue * @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide? * * @throws ShapeContainerAlreadyAssignedException * * @return $this */ public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideOld = false) { if (\is_null($this->container)) { // Add drawing to ShapeContainerInterface $this->container = $pValue; if (!\is_null($this->container)) { $this->container->getShapeCollection()->append($this); } } else { if ($pOverrideOld) { // Remove drawing from old ShapeContainerInterface $iterator = $this->container->getShapeCollection()->getIterator(); while ($iterator->valid()) { if ($iterator->current()->getHashCode() == $this->getHashCode()) { $this->container->getShapeCollection()->offsetUnset($iterator->key()); $this->container = null; break; } $iterator->next(); } // Set new \PhpOffice\PhpPresentation\Slide $this->setContainer($pValue); } else { throw new ShapeContainerAlreadyAssignedException(self::class); } } return $this; } /** * Get OffsetX. */ public function getOffsetX(): int { return $this->offsetX; } /** * Set OffsetX. * * @return $this */ public function setOffsetX(int $pValue = 0) { $this->offsetX = $pValue; return $this; } /** * Get OffsetY. * * @return int */ public function getOffsetY() { return $this->offsetY; } /** * Set OffsetY. * * @return $this */ public function setOffsetY(int $pValue = 0) { $this->offsetY = $pValue; return $this; } /** * Get Width. * * @return int */ public function getWidth() { return $this->width; } /** * Set Width. * * @return $this */ public function setWidth(int $pValue = 0) { $this->width = $pValue; return $this; } /** * Get Height. * * @return int */ public function getHeight() { return $this->height; } /** * Set Height. * * @return $this */ public function setHeight(int $pValue = 0) { $this->height = $pValue; return $this; } /** * Set width and height with proportional resize. * * @return self */ public function setWidthAndHeight(int $width = 0, int $height = 0) { $this->width = $width; $this->height = $height; return $this; } /** * Get Rotation. * * @return int */ public function getRotation() { return $this->rotation; } /** * Set Rotation. * * @param int $pValue * * @return $this */ public function setRotation($pValue = 0) { $this->rotation = $pValue; return $this; } public function getFill(): ?Fill { return $this->fill; } public function setFill(Fill $pValue = null): self { $this->fill = $pValue; return $this; } public function getBorder(): Border { return $this->border; } public function getShadow(): ?Shadow { return $this->shadow; } /** * @return $this */ public function setShadow(Shadow $pValue = null) { $this->shadow = $pValue; return $this; } /** * Has Hyperlink? * * @return bool */ public function hasHyperlink() { return !\is_null($this->hyperlink); } /** * Get Hyperlink */ public function getHyperlink(): Hyperlink { if (\is_null($this->hyperlink)) { $this->hyperlink = new Hyperlink(); } return $this->hyperlink; } /** * Set Hyperlink */ public function setHyperlink(Hyperlink $pHyperlink = null): self { $this->hyperlink = $pHyperlink; return $this; } /** * Get hash code. * * @return string Hash code */ public function getHashCode(): string { return \md5((\is_object($this->container) ? $this->container->getHashCode() : '') . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->rotation . (\is_null($this->getFill()) ? '' : $this->getFill()->getHashCode()) . (\is_null($this->shadow) ? '' : $this->shadow->getHashCode()) . (\is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__); } /** * Get hash index. * * Note that this index may vary during script execution! Only reliable moment is * while doing a write of a workbook and when changes are not allowed. * * @return int|null Hash index */ public function getHashIndex(): ?int { return $this->hashIndex; } /** * Set hash index. * * Note that this index may vary during script execution! Only reliable moment is * while doing a write of a workbook and when changes are not allowed. * * @param int $value Hash index * * @return $this */ public function setHashIndex(int $value) { $this->hashIndex = $value; return $this; } public function isPlaceholder(): bool { return !\is_null($this->placeholder); } public function getPlaceholder(): ?Placeholder { if (!$this->isPlaceholder()) { return null; } return $this->placeholder; } public function setPlaceHolder(Placeholder $placeholder): self { $this->placeholder = $placeholder; return $this; } }