Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/PhpPresentation/Style/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ class Font implements ComparableInterface
*/
private $characterSpacing = 0;

/**
* Outline.
*
* @var Outline
*/
private $outline;

/**
* Filled.
*
* @var bool
*/
private $isFilled = true;

/**
* Format.
*
Expand All @@ -179,6 +193,7 @@ class Font implements ComparableInterface
public function __construct()
{
$this->color = new Color(Color::COLOR_BLACK);
$this->outline = new Outline();
}

/**
Expand Down Expand Up @@ -515,6 +530,46 @@ public function setColor(Color $pValue): self
return $this;
}

/**
* Get Outline.
*/
public function getOutline(): Outline
{
return $this->outline;
}

/**
* Set outline.
*
* @param string $color ARGB or RGB color
* @param null|int $width Width in pixels
* @return $this
*/
public function setOutline(string $color, ?int $width = null): self
{
$this->getOutline()->setSolid($color, $width);

return $this;
}

/**
* Is Filled?
*/
public function isFilled(): bool
{
return $this->isFilled;
}

/**
* Set Filled.
*/
public function setFilled(bool $value): self
{
$this->isFilled = $value;

return $this;
}

/**
* Get format.
*/
Expand Down Expand Up @@ -556,6 +611,8 @@ public function getHashCode(): string
. ($this->strikethrough ? 't' : 'f')
. $this->format
. $this->color->getHashCode()
. $this->outline->getHashCode()
. ($this->isFilled ? 't' : 'f')
. __CLASS__
);
}
Expand Down
67 changes: 66 additions & 1 deletion src/PhpPresentation/Style/Outline.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

namespace PhpOffice\PhpPresentation\Style;

use PhpOffice\PhpPresentation\ComparableInterface;

/**
* \PhpOffice\PhpPresentation\Style\Outline.
*/
class Outline
class Outline implements ComparableInterface
{
/**
* @var Fill
Expand All @@ -35,6 +37,13 @@ class Outline
*/
protected $width = 1;

/**
* Hash index.
*
* @var int
*/
protected $hashIndex;

public function __construct()
{
$this->fill = new Fill();
Expand Down Expand Up @@ -69,4 +78,60 @@ public function setWidth(int $pValue = 1): self

return $this;
}

/**
* Set outline as a solid fill.
*
* @param string $color ARGB or RGB color
* @param null|int $width Width in pixels
* @return $this
*/
public function setSolid(string $color, ?int $width = null): self
{
$this->getFill()->setFillType(Fill::FILL_SOLID);
$this->getFill()->setStartColor(new Color($color));
if (null !== $width) {
$this->setWidth($width);
}

return $this;
}

/**
* Get hash code.
*
* @return string Hash code
*/
public function getHashCode(): string
{
return md5(
$this->fill->getHashCode()
. $this->width
. __CLASS__
);
}

/**
* Get hash index.
*
* @return null|int Hash index
*/
public function getHashIndex(): ?int
{
return $this->hashIndex;
}

/**
* Set hash index.
*
* @param int $value Hash index
*
* @return $this
*/
public function setHashIndex(int $value)
{
$this->hashIndex = $value;

return $this;
}
}
17 changes: 12 additions & 5 deletions src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh
$objWriter->startElement('a:fld');
$objWriter->writeAttribute('id', $this->getGUID());
$objWriter->writeAttribute('type', (
Placeholder::PH_TYPE_SLIDENUM == $shape->getPlaceholder()->getType() ? 'slidenum' : 'datetime'
Placeholder::PH_TYPE_SLIDENUM == $shape->getPlaceholder()->getType() ? 'slidenum' : 'datetime'
));

if (isset($paragraph)) {
Expand All @@ -309,7 +309,7 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh
}

$objWriter->writeElement('a:t', (
Placeholder::PH_TYPE_SLIDENUM == $shape->getPlaceholder()->getType() ? '<nr.>' : '03-04-05'
Placeholder::PH_TYPE_SLIDENUM == $shape->getPlaceholder()->getType() ? '<nr.>' : '03-04-05'
));
$objWriter->endElement();
$objWriter->endElement();
Expand Down Expand Up @@ -666,10 +666,17 @@ protected function writeRunStyles(XMLWriter $objWriter, Run $element): void
// Baseline
$objWriter->writeAttributeIf($element->getFont()->getBaseline() !== 0, 'baseline', $element->getFont()->getBaseline());

// Outline
$this->writeOutline($objWriter, $element->getFont()->getOutline());

// Color - a:solidFill
$objWriter->startElement('a:solidFill');
$this->writeColor($objWriter, $element->getFont()->getColor());
$objWriter->endElement();
if ($element->getFont()->isFilled()) {
$objWriter->startElement('a:solidFill');
$this->writeColor($objWriter, $element->getFont()->getColor());
$objWriter->endElement();
} else {
$objWriter->writeElement('a:noFill');
}

// Font
// - a:latin
Expand Down
Loading