diff --git a/docs/changes/1.1.0.md b/docs/changes/1.1.0.md
index 81ba6ae1e..103d901a0 100644
--- a/docs/changes/1.1.0.md
+++ b/docs/changes/1.1.0.md
@@ -17,9 +17,22 @@
- PowerPoint2007 Reader
- PowerPoint2007 Writer
- PowerPoint2007 Writer: Enable style and position of a Placeholder - [@qmachard](https://github.com/qmachard) in [#787](https://github.com/PHPOffice/PHPPresentation/pull/787)
+- PowerPoint2007 Reader: Added support for thumbnail - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
## Improvements
- Slide : Raised max value for identifier rand call - [@Scheissy](https://github.com/Scheissy) in [#777](https://github.com/PHPOffice/PHPPresentation/pull/777)
+- Document Properties : Support for Revision & Status - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+ - PowerPoint2007 Reader
+ - PowerPoint2007 Writer
+- Presentation Properties : Added support to define content of the thumbnail - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+- Font : Support for Strikethrough mode - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+ - PowerPoint2007 Reader
+ - PowerPoint2007 Writer
+- Font : Support for Pitch Family, Charset & Panose - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
+ - PowerPoint2007 Reader
+ - PowerPoint2007 Writer
+(@todo Doc)
+- Font : Replaced Superscript/Subscript by baseline in PowerPoint2007 Writer - [@devX2712](https://github.com/devX2712) in [#788](https://github.com/PHPOffice/PHPPresentation/pull/787)
## Bugfixes
diff --git a/docs/usage/presentation.md b/docs/usage/presentation.md
index 03080aa1c..a06e0958b 100644
--- a/docs/usage/presentation.md
+++ b/docs/usage/presentation.md
@@ -62,6 +62,8 @@ $properties->setCreated(mktime(0, 0, 0, 3, 12, 2014));
$properties->setModified(mktime(0, 0, 0, 3, 14, 2014));
$properties->setSubject('My subject');
$properties->setKeywords('my, key, word');
+$properties->setStatus('Work in Progress');
+$properties->setRevision('Version 1.2.3');
```
### Custom Properties
@@ -203,16 +205,44 @@ echo $properties->getSlideshowType();
You can define the thumbnail of the presentation with the method `setThumbnailPath`.
+
+#### From a file
``` php
getPresentationProperties();
// Set path of the thumbnail
-$properties->setThumbnailPath(__DIR__.'\resources\phppowerpoint_logo.gif');
+$properties->setThumbnailPath(
+ __DIR__.'\resources\phppowerpoint_logo.gif',
+ PresentationProperties::THUMBNAIL_FILE
+);
// Get path of the thumbnail
echo $properties->getThumbnailPath();
+// Get content of the thumbnail
+echo $properties->getThumbnail();
+```
+
+#### From the content of the file
+``` php
+getPresentationProperties();
+// Set path of the thumbnail
+$properties->setThumbnailPath(
+ '',
+ PresentationProperties::THUMBNAIL_DATA,
+ file_get_contents(__DIR__.'\resources\phppowerpoint_logo.gif')
+);
+// Get content of the thumbnail
+echo $properties->getThumbnail();
```
### Zoom
diff --git a/docs/usage/styles.md b/docs/usage/styles.md
index e9ff72c60..97eb199e9 100644
--- a/docs/usage/styles.md
+++ b/docs/usage/styles.md
@@ -97,12 +97,24 @@ echo $alignment->isRTL();
- `name`
- `bold`
- `italic`
-- `superScript`
-- `subScript`
+- `superScript` (deprecated)
+- `subScript` (deprecated)
- `underline`
- `strikethrough`
- `color`
-- `capitalization`
+- `pitchFamily`
+- `charset`
+
+### Baseline
+
+The baseline set the position relative to the line.
+The value is a percentage.
+
+You can use some predefined values :
+
+* `Font::BASELINE_SUPERSCRIPT` (= 30000 = 300%)
+* `Font::BASELINE_SUBSCRIPT` (= -25000 = -250%)
+
### Capitalization
@@ -145,6 +157,23 @@ $font->setFormat(Font::FORMAT_EAST_ASIAN);
// Get format of font
echo $font->getFormat();
```
+
+### Panose
+The support of Panose 1.0 is only used.
+
+``` php
+setPanose('4494D72242');
+// Get panose of font
+echo $font->getPanose();
+```
+
## Bullet
- `bulletType`
diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php
index 61796fe6f..ae0dcc75e 100644
--- a/samples/Sample_Header.php
+++ b/samples/Sample_Header.php
@@ -442,6 +442,7 @@ protected function displayShapeInfo(AbstractShape $oShape): void
$this->append('Italic : ' . ($oRichText->getFont()->isItalic() ? 'Y' : 'N') . ' - ');
$this->append('Underline : Underline::' . $this->getConstantName('\PhpOffice\PhpPresentation\Style\Font', $oRichText->getFont()->getUnderline()) . ' - ');
$this->append('Strikethrough : ' . ($oRichText->getFont()->isStrikethrough() ? 'Y' : 'N') . ' - ');
+ $this->append('Baseline : ' . $oRichText->getFont()->getBaseline() . ' - ');
$this->append('SubScript : ' . ($oRichText->getFont()->isSubScript() ? 'Y' : 'N') . ' - ');
$this->append('SuperScript : ' . ($oRichText->getFont()->isSuperScript() ? 'Y' : 'N'));
$this->append('');
diff --git a/src/PhpPresentation/DocumentProperties.php b/src/PhpPresentation/DocumentProperties.php
index c6a24e453..96d545b84 100644
--- a/src/PhpPresentation/DocumentProperties.php
+++ b/src/PhpPresentation/DocumentProperties.php
@@ -102,11 +102,18 @@ class DocumentProperties
private $company;
/**
- * revision
+ * Revision.
*
* @var string
*/
private $revision;
+
+ /**
+ * Status.
+ *
+ * @var string
+ */
+ private $status;
/**
* Custom Properties.
@@ -116,14 +123,7 @@ class DocumentProperties
private $customProperties = [];
/**
- * status
- *
- * @var string
- */
- private $status;
-
- /**
- * Create a new \PhpOffice\PhpPresentation\DocumentProperties
+ * Create a new \PhpOffice\PhpPresentation\DocumentProperties.
*/
public function __construct()
{
@@ -139,7 +139,7 @@ public function __construct()
$this->category = '';
$this->company = 'Microsoft Corporation';
$this->revision = '';
- $this->status = '';
+ $this->status = '';
}
/**
@@ -479,7 +479,7 @@ public function getRevision(): string
}
/**
- * Set Revision
+ * Set Revision.
*/
public function setRevision(string $pValue = ''): self
{
@@ -489,22 +489,17 @@ public function setRevision(string $pValue = ''): self
}
/**
- * Get Status
- *
- * @return string
+ * Get Status.
*/
- public function getStatus()
+ public function getStatus(): string
{
return $this->status;
}
/**
- * Set Status
- *
- * @param string $pValue
- * @return \PhpOffice\PhpPresentation\DocumentProperties
+ * Set Status.
*/
- public function setStatus($pValue = '')
+ public function setStatus(string $pValue = ''): self
{
$this->status = $pValue;
diff --git a/src/PhpPresentation/Exception/InvalidParameterException.php b/src/PhpPresentation/Exception/InvalidParameterException.php
index 961809623..502705e67 100644
--- a/src/PhpPresentation/Exception/InvalidParameterException.php
+++ b/src/PhpPresentation/Exception/InvalidParameterException.php
@@ -21,12 +21,17 @@
class InvalidParameterException extends PhpPresentationException
{
- public function __construct(string $parameter, string $value)
+ public function __construct(string $parameter, string $value, string $error = null)
{
- parent::__construct(sprintf(
+ $message = sprintf(
'The parameter %s can\'t have the value "%s"',
$parameter,
$value
- ));
+ );
+ if ($error) {
+ $message = sprintf('%s (Validation: %s)', $message, $error);
+ }
+
+ parent::__construct($message);
}
}
diff --git a/src/PhpPresentation/PresentationProperties.php b/src/PhpPresentation/PresentationProperties.php
index 63eca8fb5..ff2cc5aaa 100644
--- a/src/PhpPresentation/PresentationProperties.php
+++ b/src/PhpPresentation/PresentationProperties.php
@@ -30,8 +30,8 @@ class PresentationProperties
public const VIEW_SLIDE_SORTER = 'sldSorterView';
public const VIEW_SLIDE_THUMBNAIL = 'sldThumbnailView';
- public const THUMBNAIL_FILE = 'file'; // Thumbnail path is out of PPT
- public const THUMBNAIL_ZIP = 'zip'; // Thumbnail path point to an image store into file loaded
+ public const THUMBNAIL_FILE = 'file';
+ public const THUMBNAIL_DATA = 'data';
/**
* @var array
@@ -72,17 +72,17 @@ class PresentationProperties
*/
protected $markAsFinal = false;
- /*
- * @var string Define the thumbnail content (if content into zip file)
+ /**
+ * @var string|null Define the thumbnail content (if content into zip file)
*/
protected $thumbnail = null;
- /*
- * @var string Define the thumbnail place
+ /**
+ * @var string|null Define the thumbnail place
*/
- protected $thumbnailPath = '';
+ protected $thumbnailPath = null;
- /*
+ /**
* @var string Define if thumbnail is out of PPT or previouly store into PPT
*/
protected $thumbnailType = self::THUMBNAIL_FILE;
@@ -130,36 +130,38 @@ public function getThumbnailPath(): ?string
}
/**
- * Return the content of thumbnail
- *
- * @return binary Content of image
+ * Return the content of thumbnail.
*/
- public function getThumbnail()
+ public function getThumbnail(): ?string
{
// Return content of local file
if ($this->getThumbnailType() == self::THUMBNAIL_FILE) {
- if (file_exists($this->getThumbnailPath()))
+ if ($this->getThumbnailPath()) {
return file_get_contents($this->getThumbnailPath());
+ }
+
+ return null;
}
+
// Return content of image stored into zip file
- if ($this->getThumbnailType() == self::THUMBNAIL_ZIP) {
+ if ($this->getThumbnailType() == self::THUMBNAIL_DATA) {
return $this->thumbnail;
}
- // Return null if no thumbnail
+
return null;
}
/**
* Define the path for the thumbnail file / preview picture.
*/
- public function setThumbnailPath(string $path = '', $type = self::THUMBNAIL_FILE, $content = null)
+ public function setThumbnailPath(string $path = '', string $type = self::THUMBNAIL_FILE, string $content = null): self
{
- if (file_exists($path) && ($type == self::THUMBNAIL_FILE)) {
+ if (file_exists($path) && $type == self::THUMBNAIL_FILE) {
$this->thumbnailPath = $path;
$this->thumbnailType = $type;
}
- if (($path != '') && ($type == self::THUMBNAIL_ZIP)) {
- $this->thumbnailPath = $path;
+ if ($content != '' && $type == self::THUMBNAIL_DATA) {
+ $this->thumbnailPath = '';
$this->thumbnailType = $type;
$this->thumbnail = $content;
}
@@ -168,10 +170,9 @@ public function setThumbnailPath(string $path = '', $type = self::THUMBNAIL_FILE
}
/**
- * Return the thumbnail type
- * @return string
+ * Return the thumbnail type.
*/
- public function getThumbnailType()
+ public function getThumbnailType(): string
{
return $this->thumbnailType;
}
diff --git a/src/PhpPresentation/Reader/PowerPoint2007.php b/src/PhpPresentation/Reader/PowerPoint2007.php
index e619a2607..b2ef355ff 100644
--- a/src/PhpPresentation/Reader/PowerPoint2007.php
+++ b/src/PhpPresentation/Reader/PowerPoint2007.php
@@ -230,7 +230,7 @@ protected function loadDocumentProperties(string $sPart): void
'/cp:coreProperties/dcterms:modified' => 'setModified',
'/cp:coreProperties/cp:revision' => 'setRevision',
'/cp:coreProperties/cp:contentStatus' => 'setStatus',
- );
+ ];
$oProperties = $this->oPhpPresentation->getDocumentProperties();
foreach ($arrayProperties as $path => $property) {
$oElement = $xmlReader->getElement($path);
@@ -248,9 +248,8 @@ protected function loadDocumentProperties(string $sPart): void
/**
* Read information of the document thumbnail
- * @param string $sPart Content of XML file for retrieving data
*/
- protected function loadThumbnailProperties($sPart)
+ protected function loadThumbnailProperties(string $sPart): void
{
$xmlReader = new XMLReader();
if ($xmlReader->getDomFromString($sPart)) {
@@ -259,16 +258,13 @@ protected function loadThumbnailProperties($sPart)
$path = $oElement->getAttribute('Target');
$this->oPhpPresentation
->getPresentationProperties()
- ->setThumbnailPath($path
- , \PhpOffice\PhpPresentation\PresentationProperties::THUMBNAIL_ZIP
- , $this->oZip->getFromName($path));
+ ->setThumbnailPath('', PresentationProperties::THUMBNAIL_DATA, $this->oZip->getFromName($path));
}
}
}
/**
- * Read Custom Properties
- * @param string $sPart
+ * Read Custom Properties.
*/
protected function loadCustomProperties(string $sPart): void
{
@@ -913,15 +909,15 @@ protected function loadEffect(XMLReader $document, \DOMElement $nodeEffect)
$effect = new \PhpOffice\PhpPresentation\Style\Effect($type);
// load blur radius
if ($node->hasAttribute('blurRad')) {
- $effect->setBlurRadius(CommonDrawing::emuToPixels($node->getAttribute('blurRad')));
+ $effect->setBlurRadius(CommonDrawing::emuToPixels((int) $node->getAttribute('blurRad')));
}
// load distance
if ($node->hasAttribute('dist')) {
- $effect->setDistance(CommonDrawing::emuToPixels($node->getAttribute('dist')));
+ $effect->setDistance(CommonDrawing::emuToPixels((int) $node->getAttribute('dist')));
}
// load direction
if ($node->hasAttribute('dir')) {
- $effect->setDirection(CommonDrawing::angleToDegrees($node->getAttribute('dir')));
+ $effect->setDirection((int) CommonDrawing::angleToDegrees((int) $node->getAttribute('dir')));
}
// load alignment
if ($node->hasAttribute('algn')) {
@@ -1365,10 +1361,10 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
$oText->getFont()->setPanose($oElementFont->getAttribute('panose'));
}
if (($oElementFont instanceof \DOMElement) && $oElementFont->hasAttribute('pitchFamily')) {
- $oText->getFont()->setPitchFamily($oElementFont->getAttribute('pitchFamily'));
+ $oText->getFont()->setPitchFamily((int) $oElementFont->getAttribute('pitchFamily'));
}
if (($oElementFont instanceof \DOMElement) && $oElementFont->hasAttribute('charset')) {
- $oText->getFont()->setCharset($oElementFont->getAttribute('charset'));
+ $oText->getFont()->setCharset((int) $oElementFont->getAttribute('charset'));
}
// Load shape effects
$oEffect = $document->getElement('a:effectLst', $oElementrPr);
diff --git a/src/PhpPresentation/Style/Effect.php b/src/PhpPresentation/Style/Effect.php
index 5c25ca4f4..500ce891a 100644
--- a/src/PhpPresentation/Style/Effect.php
+++ b/src/PhpPresentation/Style/Effect.php
@@ -90,9 +90,9 @@ class Effect implements ComparableInterface
/**
* Hash index
*
- * @var string
+ * @var ?int
*/
- private string $hashIndex;
+ private $hashIndex;
/**
* Create a new \PhpOffice\PhpPresentation\Shape\Effect instance
@@ -276,7 +276,7 @@ public function getAlpha():int
*
* @return string Hash code
*/
- public function getHashCode()
+ public function getHashCode(): string
{
return md5($this->effectType . $this->blurRadius . $this->distance . $this->direction . $this->alignment . $this->color->getHashCode() . $this->alpha . __CLASS__);
}
@@ -289,7 +289,7 @@ public function getHashCode()
*
* @return string Hash index
*/
- public function getHashIndex()
+ public function getHashIndex(): ?int
{
return $this->hashIndex;
}
diff --git a/src/PhpPresentation/Style/Font.php b/src/PhpPresentation/Style/Font.php
index 474d3e0e3..48a6e258b 100644
--- a/src/PhpPresentation/Style/Font.php
+++ b/src/PhpPresentation/Style/Font.php
@@ -20,6 +20,7 @@
namespace PhpOffice\PhpPresentation\Style;
use PhpOffice\PhpPresentation\ComparableInterface;
+use PhpOffice\PhpPresentation\Exception\InvalidParameterException;
use PhpOffice\PhpPresentation\Exception\NotAllowedValueException;
/**
@@ -27,6 +28,24 @@
*/
class Font implements ComparableInterface
{
+ // Capitalization type
+ public const CAPITALIZATION_NONE = 'none';
+ public const CAPITALIZATION_SMALL = 'small';
+ public const CAPITALIZATION_ALL = 'all';
+
+ // Charset type
+ public const CHARSET_DEFAULT = 0x01;
+
+ // Format type
+ public const FORMAT_LATIN = 'latin';
+ public const FORMAT_EAST_ASIAN = 'ea';
+ public const FORMAT_COMPLEX_SCRIPT = 'cs';
+
+ // Strike type
+ public const STRIKE_NONE = 'noStrike';
+ public const STRIKE_SINGLE = 'sngStrike';
+ public const STRIKE_DOUBLE = 'dblStrike';
+
// Underline types
public const UNDERLINE_NONE = 'none';
public const UNDERLINE_DASH = 'dash';
@@ -46,23 +65,10 @@ class Font implements ComparableInterface
public const UNDERLINE_WAVYDOUBLE = 'wavyDbl';
public const UNDERLINE_WAVYHEAVY = 'wavyHeavy';
public const UNDERLINE_WORDS = 'words';
-
- /* Strike types */
- public const STRIKE_NONE = 'noStrike';
- public const STRIKE_SINGLE = 'sngStrike';
- public const STRIKE_DOUBLE = 'dblStrike';
-
- public const FORMAT_LATIN = 'latin';
- public const FORMAT_EAST_ASIAN = 'ea';
- public const FORMAT_COMPLEX_SCRIPT = 'cs';
-
- public const CAPITALIZATION_NONE = 'none';
- public const CAPITALIZATION_SMALL = 'small';
- public const CAPITALIZATION_ALL = 'all';
/* Script sub and super values */
- const SCRIPT_SUPER = 30000;
- const SCRIPT_SUB = -25000;
+ public const BASELINE_SUPERSCRIPT = 30000;
+ public const BASELINE_SUBSCRIPT = -25000;
/**
* Name.
@@ -72,23 +78,25 @@ class Font implements ComparableInterface
private $name = 'Calibri';
/**
- * panose
+ * Panose
*
* @var string
*/
- private $panose;
+ private $panose = '';
+
/**
- * pitchFamily
+ * Pitch Family
*
- * @var string
+ * @var int
*/
- private $pitchFamily;
+ private $pitchFamily = 0;
+
/**
- * charset
+ * Charset
*
- * @var string
+ * @var int
*/
- private $charset;
+ private $charset = self::CHARSET_DEFAULT;
/**
* Font Size
@@ -112,18 +120,11 @@ class Font implements ComparableInterface
private $italic = false;
/**
- * Superscript.
+ * Baseline.
*
- * @var bool
- */
- private $superScript = false;
-
- /**
- * Subscript.
- *
- * @var bool
+ * @var int
*/
- private $subScript = false;
+ private $baseline = 0;
/**
* Capitalization.
@@ -144,7 +145,7 @@ class Font implements ComparableInterface
*
* @var bool
*/
- private $strikethrough = false;
+ private $strikethrough = self::STRIKE_NONE;
/**
* Foreground color.
@@ -177,9 +178,6 @@ class Font implements ComparableInterface
public function __construct()
{
$this->color = new Color(Color::COLOR_BLACK);
- $this->superScript = 0;
- $this->subScript = 0;
- $this->strikethrough = self::STRIKE_NONE;
}
/**
@@ -203,51 +201,50 @@ public function setName(string $pValue = 'Calibri'): self
}
/**
- * Get panose
- *
- * @return string
+ * Get panose.
*/
- public function getPanose()
+ public function getPanose(): string
{
return $this->panose;
}
/**
- * Set panose
- *
- * @param string $pValue
- * @return \PhpOffice\PhpPresentation\Style\Font
+ * Set panose.
*/
- public function setPanose($pValue)
+ public function setPanose(string $pValue): self
{
- if ($pValue == '') {
- $pValue = '';
+ if (mb_strlen($pValue) !== 10) {
+ throw new InvalidParameterException('pValue', $pValue, 'The length is not equals to 10');
+ }
+
+ $allowedChars = ['0', '1', '2', '3', '4', '5', '6' ,'7' ,'8' ,'9' ,'A' ,'B' ,'C' ,'D' ,'E' ,'F'];
+ foreach(mb_str_split($pValue) as $char) {
+ if (!in_array($char, $allowedChars)) {
+ throw new InvalidParameterException(
+ 'pValue',
+ $pValue,
+ sprintf('The character "%s" is not allowed', $char)
+ );
+ }
}
+
$this->panose = $pValue;
return $this;
}
/**
- * Get pitchFamily
- *
- * @return string
+ * Get pitchFamily.
*/
- public function getPitchFamily()
+ public function getPitchFamily(): int
{
return $this->pitchFamily;
}
/**
- * Set pitchFamily
- *
- * @param string $pValue
- * @return \PhpOffice\PhpPresentation\Style\Font
+ * Set pitchFamily.
*/
- public function setPitchFamily($pValue)
+ public function setPitchFamily(int $pValue): self
{
- if ($pValue == '') {
- $pValue = '';
- }
$this->pitchFamily = $pValue;
return $this;
@@ -255,24 +252,18 @@ public function setPitchFamily($pValue)
/**
* Get charset
*
- * @return string
+ * @return int
*/
- public function getCharset()
+ public function getCharset(): int
{
return $this->charset;
}
/**
- * Set charset
- *
- * @param string $pValue
- * @return \PhpOffice\PhpPresentation\Style\Font
+ * Set charset.
*/
- public function setCharset($pValue)
+ public function setCharset(int $pValue): self
{
- if ($pValue == '') {
- $pValue = '';
- }
$this->charset = $pValue;
return $this;
@@ -352,65 +343,57 @@ public function setItalic(bool $pValue = false): self
}
/**
- * Get SuperScript.
+ * Set Baseline.
*/
- public function isSuperScript(): int
+ public function setBaseline(int $pValue): self
{
- return $this->superScript;
+ $this->baseline = $pValue;
+
+ return $this;
}
/**
- * Set SuperScript
- *
- * @param integer $pValue
- * @return \PhpOffice\PhpPresentation\Style\Font
+ * Get Baseline.
*/
- public function setSuperScript($pValue = 0)
+ public function getBaseline(): int
{
- if ($pValue == '') {
- $pValue = 0;
- }
-
- $this->superScript = $pValue;
+ return $this->baseline;
+ }
- // Set SubScript at false only if SuperScript is true
- if ($pValue != 0) {
- $this->subScript = 0;
- }
+ /**
+ * Get SuperScript.
+ * @deprecated getBaseline() === self::BASELINE_SUPERSCRIPT
+ */
+ public function isSuperScript(): bool
+ {
+ return $this->getBaseline() === self::BASELINE_SUPERSCRIPT;
+ }
- return $this;
+ /**
+ * Set SuperScript
+ * @deprecated setBaseline(self::BASELINE_SUPERSCRIPT)
+ */
+ public function setSuperScript(bool $pValue = false): self
+ {
+ return $this->setBaseline($pValue ? self::BASELINE_SUPERSCRIPT : ($this->getBaseline() == self::BASELINE_SUBSCRIPT ? $this->getBaseline() : 0));
}
/**
* Get SubScript
- *
- * @return integer
+ * @deprecated getBaseline() === self::BASELINE_SUBSCRIPT
*/
- public function isSubScript()
+ public function isSubScript(): bool
{
- return $this->subScript;
+ return $this->getBaseline() === self::BASELINE_SUBSCRIPT;
}
/**
* Set SubScript
- *
- * @param integer $pValue
- * @return \PhpOffice\PhpPresentation\Style\Font
+ * @deprecated setBaseline(self::BASELINE_SUBSCRIPT)
*/
- public function setSubScript($pValue = 0)
+ public function setSubScript(bool $pValue = false): self
{
- if ($pValue == '') {
- $pValue = 0;
- }
-
- $this->subScript = $pValue;
-
- // Set SuperScript at false only if SubScript is true
- if ($pValue != 0) {
- $this->superScript = 0;
- }
-
- return $this;
+ return $this->setBaseline($pValue ? self::BASELINE_SUBSCRIPT : ($this->getBaseline() == self::BASELINE_SUPERSCRIPT ? $this->getBaseline() : 0));
}
/**
@@ -463,21 +446,39 @@ public function setUnderline(string $pValue = self::UNDERLINE_NONE): self
/**
* Get Strikethrough.
+ * @deprecated Use `getStrikethrough`
*/
public function isStrikethrough(): bool
+ {
+ return $this->strikethrough !== self::STRIKE_NONE;
+ }
+
+ /**
+ * Get Strikethrough.
+ */
+ public function getStrikethrough(): string
{
return $this->strikethrough;
}
/**
* Set Strikethrough.
+ *
+ * @deprecated $pValue as boolean
+ * @param bool|string $pValue
*/
- public function setStrikethrough($pValue = self::STRIKE_NONE)
+ public function setStrikethrough($pValue = false)
{
- if ($pValue == '') {
- $pValue = self::STRIKE_NONE;
+ if (is_bool($pValue)) {
+ $pValue = $pValue ? self::STRIKE_SINGLE : self::STRIKE_NONE;
+ }
+ if (in_array($pValue, [
+ self::STRIKE_NONE,
+ self::STRIKE_SINGLE,
+ self::STRIKE_DOUBLE
+ ])) {
+ $this->strikethrough = $pValue;
}
- $this->strikethrough = $pValue;
return $this;
}
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php
index 79ea0c22a..4c316986b 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php
@@ -49,6 +49,7 @@
use PhpOffice\PhpPresentation\Style\Border;
use PhpOffice\PhpPresentation\Style\Bullet;
use PhpOffice\PhpPresentation\Style\Color;
+use PhpOffice\PhpPresentation\Style\Font;
use PhpOffice\PhpPresentation\Style\Shadow;
abstract class AbstractSlide extends AbstractDecoratorWriter
@@ -655,7 +656,9 @@ protected function writeRunStyles(XMLWriter $objWriter, RichText\Run $element):
$objWriter->writeAttributeIf($element->getFont()->isBold(), 'b', '1');
$objWriter->writeAttributeIf($element->getFont()->isItalic(), 'i', '1');
- $objWriter->writeAttributeIf($element->getFont()->isStrikethrough(), 'strike', $element->getFont()->isStrikethrough());
+
+ // Strikethrough
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
// Size
$objWriter->writeAttribute('sz', ($element->getFont()->getSize() * 100));
@@ -669,9 +672,8 @@ protected function writeRunStyles(XMLWriter $objWriter, RichText\Run $element):
// Capitalization
$objWriter->writeAttribute('cap', $element->getFont()->getCapitalization());
- // Superscript / subscript
- $objWriter->writeAttributeIf($element->getFont()->isSuperScript() != 0, 'baseline', (int)$element->getFont()->isSuperScript());
- $objWriter->writeAttributeIf($element->getFont()->isSubScript() != 0, 'baseline', (int)$element->getFont()->isSubScript());
+ // Baseline
+ $objWriter->writeAttributeIf($element->getFont()->getBaseline() !== 0, 'baseline', $element->getFont()->getBaseline());
// Color - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -687,12 +689,23 @@ protected function writeRunStyles(XMLWriter $objWriter, RichText\Run $element):
// - a:cs
$objWriter->startElement('a:' . $element->getFont()->getFormat());
$objWriter->writeAttribute('typeface', $element->getFont()->getName());
- if ($element->getFont()->getPanose()!="")
- $objWriter->writeAttribute('panose', $element->getFont()->getPanose());
- if ($element->getFont()->getPitchFamily()!="")
- $objWriter->writeAttribute('pitchFamily', $element->getFont()->getPitchFamily());
- if ($element->getFont()->getCharset()!="")
- $objWriter->writeAttribute('charset', $element->getFont()->getCharset());
+ if ($element->getFont()->getPanose() !== '') {
+ $panose = array_map(function(string $value) {
+ return '0' . $value;
+ }, str_split($element->getFont()->getPanose()));
+
+ $objWriter->writeAttribute('panose', implode('', $panose));
+ }
+ $objWriter->writeAttributeIf(
+ $element->getFont()->getPitchFamily() !== 0,
+ 'pitchFamily',
+ $element->getFont()->getPitchFamily()
+ );
+ $objWriter->writeAttributeIf(
+ $element->getFont()->getCharset() !== Font::CHARSET_DEFAULT,
+ 'charset',
+ dechex($element->getFont()->getCharset())
+ );
$objWriter->endElement();
// a:hlinkClick
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCore.php b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCore.php
index 6df85cde0..d21f6863a 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCore.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsCore.php
@@ -70,18 +70,17 @@ public function render(): ZipInterface
// cp:keywords
$objWriter->writeElement('cp:keywords', $this->oPresentation->getDocumentProperties()->getKeywords());
+ // cp:category
+ $objWriter->writeElement('cp:category', $this->oPresentation->getDocumentProperties()->getCategory());
+
// cp:revision
$objWriter->writeElement('cp:revision', $this->oPresentation->getDocumentProperties()->getRevision());
// cp:contentStatus
- $objWriter->writeElement('cp:contentStatus', $this->oPresentation->getDocumentProperties()->getStatus());
-
- // cp:category
- $objWriter->writeElement('cp:category', $this->oPresentation->getDocumentProperties()->getCategory());
-
if ($this->oPresentation->getPresentationProperties()->isMarkedAsFinal()) {
- // cp:contentStatus = Final
$objWriter->writeElement('cp:contentStatus', 'Final');
+ } else {
+ $objWriter->writeElement('cp:contentStatus', $this->oPresentation->getDocumentProperties()->getStatus());
}
$objWriter->endElement();
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php
index 103309e5c..fde2f6f36 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php
@@ -20,31 +20,15 @@
namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007;
use PhpOffice\Common\Adapter\Zip\ZipInterface;
+use PhpOffice\PhpPresentation\PresentationProperties;
class DocPropsThumbnail extends AbstractDecoratorWriter
{
public function render(): ZipInterface
{
- $pathThumbnail = $this->getPresentation()->getPresentationProperties()->getThumbnailPath();
- $type = $this->getPresentation()->getPresentationProperties()->getThumbnailType();
-
- // From local file
- if ($pathThumbnail && $type == \PhpOffice\PhpPresentation\PresentationProperties::THUMBNAIL_FILE) {
- $fileThumbnail = file_get_contents($pathThumbnail);
- $gdImage = imagecreatefromstring($fileThumbnail);
- if ($gdImage) {
- ob_start();
- imagejpeg($gdImage);
- $imageContents = ob_get_contents();
- ob_end_clean();
- imagedestroy($gdImage);
- $this->getZip()->addFromString('docProps/thumbnail.jpeg', $imageContents);
- }
- }
-
- // From ZIP original file
- if ($pathThumbnail && $type == \PhpOffice\PhpPresentation\PresentationProperties::THUMBNAIL_ZIP) {
- $gdImage = imagecreatefromstring($this->getPresentation()->getPresentationProperties()->getThumbnail());
+ $thumnbail = $this->getPresentation()->getPresentationProperties()->getThumbnail();
+ if ($thumnbail) {
+ $gdImage = imagecreatefromstring($thumnbail);
if ($gdImage) {
ob_start();
imagejpeg($gdImage);
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
index d2cd90410..eddc08686 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
@@ -447,11 +447,10 @@ protected function writeTitle(XMLWriter $objWriter, Title $subject): void
$objWriter->writeAttribute('dirty', '0');
$objWriter->writeAttribute('b', ($subject->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($subject->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($subject->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($subject->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $subject->getFont()->getUnderline());
- $objWriter->writeAttributeIf($subject->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($subject->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($subject->getFont()->getBaseline() !== 0, 'baseline', $subject->getFont()->getBaseline());
$objWriter->writeAttribute('cap', $subject->getFont()->getCapitalization());
// Font - a:solidFill
@@ -609,11 +608,10 @@ protected function writeLegend(XMLWriter $objWriter, Legend $subject): void
$objWriter->writeAttribute('b', ($subject->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($subject->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($subject->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($subject->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $subject->getFont()->getUnderline());
- $objWriter->writeAttributeIf($subject->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($subject->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($subject->getFont()->getBaseline() !== 0, 'baseline', $subject->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -895,11 +893,10 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ
$objWriter->startElement('a:defRPr');
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1102,11 +1099,10 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1311,11 +1307,10 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo
$objWriter->startElement('a:defRPr');
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// c:dLbls\c:txPr\a:p\a:pPr\a:defRPr\a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1454,11 +1449,10 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1618,11 +1612,10 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1771,11 +1764,10 @@ protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $incl
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -1947,11 +1939,10 @@ protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $in
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '30000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-25000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -2113,11 +2104,10 @@ protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool
$objWriter->writeAttribute('b', ($series->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($series->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($series->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($series->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $series->getFont()->getUnderline());
- $objWriter->writeAttributeIf($series->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($series->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($series->getFont()->getBaseline() !== 0, 'baseline', $series->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -2392,11 +2382,10 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->writeAttribute('b', ($oAxis->getFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($oAxis->getFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($oAxis->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($oAxis->getFont()->getSize() * 100));
$objWriter->writeAttribute('u', $oAxis->getFont()->getUnderline());
- $objWriter->writeAttributeIf($oAxis->getFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($oAxis->getFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($oAxis->getFont()->getBaseline() !== 0, 'baseline', $oAxis->getFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
@@ -2496,11 +2485,10 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->startElement('a:defRPr');
$objWriter->writeAttribute('b', ($oAxis->getTickLabelFont()->isBold() ? 'true' : 'false'));
$objWriter->writeAttribute('i', ($oAxis->getTickLabelFont()->isItalic() ? 'true' : 'false'));
- $objWriter->writeAttribute('strike', ($oAxis->getTickLabelFont()->isStrikethrough() ? 'sngStrike' : 'noStrike'));
+ $objWriter->writeAttribute('strike', $element->getFont()->getStrikethrough());
$objWriter->writeAttribute('sz', ($oAxis->getTickLabelFont()->getSize() * 100));
$objWriter->writeAttribute('u', $oAxis->getTickLabelFont()->getUnderline());
- $objWriter->writeAttributeIf($oAxis->getTickLabelFont()->isSuperScript(), 'baseline', '300000');
- $objWriter->writeAttributeIf($oAxis->getTickLabelFont()->isSubScript(), 'baseline', '-250000');
+ $objWriter->writeAttributeIf($oAxis->getTickLabelFont()->getBaseline() !== 0, 'baseline', $oAxis->getTickLabelFont()->getBaseline());
// Font - a:solidFill
$objWriter->startElement('a:solidFill');
diff --git a/src/PhpPresentation/Writer/PowerPoint2007/Relationships.php b/src/PhpPresentation/Writer/PowerPoint2007/Relationships.php
index 804c175e2..7d652778c 100644
--- a/src/PhpPresentation/Writer/PowerPoint2007/Relationships.php
+++ b/src/PhpPresentation/Writer/PowerPoint2007/Relationships.php
@@ -63,29 +63,18 @@ protected function writeRelationships(): string
$this->writeRelationship($objWriter, 4, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties', 'docProps/custom.xml');
$idxRelation = 5;
- // Thumbnail
- $path = $this->getPresentation()->getPresentationProperties()->getThumbnailPath();
- $type = $this->getPresentation()->getPresentationProperties()->getThumbnailType();
- // From local file
- if ($path && $type == \PhpOffice\PhpPresentation\PresentationProperties::THUMBNAIL_FILE) {
- $pathThumbnail = file_get_contents($path);
- $gdImage = imagecreatefromstring($pathThumbnail);
- if ($gdImage) {
- imagedestroy($gdImage);
- // Relationship docProps/thumbnail.jpeg
- $this->writeRelationship($objWriter, $idxRelation, 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail', 'docProps/thumbnail.jpeg');
- }
- }
- // From ZIP original file
- if ($path && $type == \PhpOffice\PhpPresentation\PresentationProperties::THUMBNAIL_ZIP) {
- $gdImage = imagecreatefromstring($this->getPresentation()->getPresentationProperties()->getThumbnail());
+
+ // Relationship docProps/thumbnail.jpeg
+ $thumnbail = $this->getPresentation()->getPresentationProperties()->getThumbnail();
+ if ($thumnbail) {
+ $gdImage = imagecreatefromstring($thumnbail);
if ($gdImage) {
imagedestroy($gdImage);
// Relationship docProps/thumbnail.jpeg
$this->writeRelationship($objWriter, $idxRelation, 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail', 'docProps/thumbnail.jpeg');
+ // $idxRelation++;
}
}
- // ++$idxRelation
$objWriter->endElement();
diff --git a/tests/PhpPresentation/Tests/DocumentPropertiesTest.php b/tests/PhpPresentation/Tests/DocumentPropertiesTest.php
index 5d0b37259..dd2a4d922 100644
--- a/tests/PhpPresentation/Tests/DocumentPropertiesTest.php
+++ b/tests/PhpPresentation/Tests/DocumentPropertiesTest.php
@@ -46,6 +46,8 @@ public function testGetSet(): void
'keywords' => '',
'category' => '',
'company' => '',
+ 'revision' => '',
+ 'status' => '',
];
foreach ($properties as $key => $val) {
diff --git a/tests/PhpPresentation/Tests/PresentationPropertiesTest.php b/tests/PhpPresentation/Tests/PresentationPropertiesTest.php
index db361430e..88b0920d7 100644
--- a/tests/PhpPresentation/Tests/PresentationPropertiesTest.php
+++ b/tests/PhpPresentation/Tests/PresentationPropertiesTest.php
@@ -130,14 +130,36 @@ public function testThumbnail(): void
$object = new PresentationProperties();
self::assertNull($object->getThumbnailPath());
- self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath('AAAA'));
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath('AAAA', PresentationProperties::THUMBNAIL_FILE));
self::assertNull($object->getThumbnailPath());
self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath());
self::assertNull($object->getThumbnailPath());
- self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath($imagePath));
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_FILE));
self::assertEquals($imagePath, $object->getThumbnailPath());
+ self::assertIsString($object->getThumbnail());
self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath());
self::assertEquals($imagePath, $object->getThumbnailPath());
+ self::assertIsString($object->getThumbnail());
+ }
+
+ public function testThumbnailFileNotExisting(): void
+ {
+ $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'NotExistingFile.png';
+
+ $object = new PresentationProperties();
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_FILE));
+ self::assertNull($object->getThumbnailPath());
+ self::assertNull($object->getThumbnail());
+ }
+
+ public function testThumbnailFileData(): void
+ {
+ $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
+
+ $object = new PresentationProperties();
+ self::assertInstanceOf(PresentationProperties::class, $object->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_DATA, file_get_contents($imagePath)));
+ self::assertEquals('', $object->getThumbnailPath());
+ self::assertIsString($object->getThumbnail());
}
public function testZoom(): void
diff --git a/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php b/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php
index 8d04038ef..51b6ac3bf 100644
--- a/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php
+++ b/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php
@@ -101,6 +101,8 @@ public function testLoadFile01(): void
self::assertEquals('Sample 02 Description', $oPhpPresentation->getDocumentProperties()->getDescription());
self::assertEquals('office 2007 openxml libreoffice odt php', $oPhpPresentation->getDocumentProperties()->getKeywords());
self::assertEquals('Sample Category', $oPhpPresentation->getDocumentProperties()->getCategory());
+ self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getRevision());
+ self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getStatus());
self::assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
self::assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());
diff --git a/tests/PhpPresentation/Tests/Style/FontTest.php b/tests/PhpPresentation/Tests/Style/FontTest.php
index 711c2da53..ae33838be 100644
--- a/tests/PhpPresentation/Tests/Style/FontTest.php
+++ b/tests/PhpPresentation/Tests/Style/FontTest.php
@@ -19,6 +19,7 @@
namespace PhpOffice\PhpPresentation\Tests\Style;
+use PhpOffice\PhpPresentation\Exception\InvalidParameterException;
use PhpOffice\PhpPresentation\Exception\NotAllowedValueException;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\Style\Font;
@@ -49,6 +50,18 @@ public function testConstruct(): void
self::assertEquals(Font::CAPITALIZATION_NONE, $object->getCapitalization());
self::assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->getColor());
self::assertEquals(Color::COLOR_BLACK, $object->getColor()->getARGB());
+ self::assertEquals(0, $object->getBaseline());
+ }
+
+ /**
+ * Test get/set Baseline.
+ */
+ public function testBaseline(): void
+ {
+ $object = new Font();
+ self::assertEquals(0, $object->getBaseline());
+ self::assertInstanceOf(Font::class, $object->setBaseline(Font::BASELINE_SUBSCRIPT));
+ self::assertEquals(Font::BASELINE_SUBSCRIPT, $object->getBaseline());
}
/**
@@ -76,6 +89,17 @@ public function testCapitalizationException(): void
$object->setCapitalization('Invalid');
}
+ /**
+ * Test get/set charset.
+ */
+ public function testCharset(): void
+ {
+ $object = new Font();
+ self::assertEquals(Font::CHARSET_DEFAULT, $object->getCharset());
+ self::assertInstanceOf(Font::class, $object->setCharset(12));
+ self::assertEquals(12, $object->getCharset());
+ }
+
/**
* Test get/set Character Spacing.
*/
@@ -134,6 +158,52 @@ public function testName(): void
self::assertEquals('Arial', $object->getName());
}
+ /**
+ * Test get/set panose.
+ */
+ public function testPanose(): void
+ {
+ $object = new Font();
+ self::assertEquals('', $object->getPanose());
+ self::assertInstanceOf(Font::class, $object->setPanose('4494D72242'));
+ self::assertEquals('4494D72242', $object->getPanose());
+ }
+
+ /**
+ * Test get/set panose (Exception : Invalid Length).
+ */
+ public function testPanoseExceptionInvalidLength(): void
+ {
+ $this->expectException(InvalidParameterException::class);
+ $this->expectExceptionMessage('The parameter pValue can\'t have the value "12345" (Validation: The length is not equals to 10)');
+
+ $object = new Font();
+ $object->setPanose('12345');
+ }
+
+ /**
+ * Test get/set panose (Exception : Invalid Char).
+ */
+ public function testPanoseExceptionInvalidChar(): void
+ {
+ $this->expectException(InvalidParameterException::class);
+ $this->expectExceptionMessage('The parameter pValue can\'t have the value "4494D7224X" (Validation: The character "X" is not allowed)');
+
+ $object = new Font();
+ $object->setPanose('4494D7224X');
+ }
+
+ /**
+ * Test get/set pitch family.
+ */
+ public function testPitchFamily(): void
+ {
+ $object = new Font();
+ self::assertEquals(0, $object->getPitchFamily());
+ self::assertInstanceOf(Font::class, $object->setPitchFamily(12));
+ self::assertEquals(12, $object->getPitchFamily());
+ }
+
/**
* Test get/set size.
*/
@@ -197,10 +267,18 @@ public function testSetIsStriketrough(): void
$object = new Font();
self::assertInstanceOf(Font::class, $object->setStrikethrough());
self::assertFalse($object->isStrikethrough());
+ self::assertEquals(Font::STRIKE_NONE, $object->getStrikethrough());
+ // boolean
self::assertInstanceOf(Font::class, $object->setStrikethrough(false));
self::assertFalse($object->isStrikethrough());
+ self::assertEquals(Font::STRIKE_NONE, $object->getStrikethrough());
self::assertInstanceOf(Font::class, $object->setStrikethrough(true));
self::assertTrue($object->isStrikethrough());
+ self::assertEquals(Font::STRIKE_SINGLE, $object->getStrikethrough());
+ // string
+ self::assertInstanceOf(Font::class, $object->setStrikethrough(Font::STRIKE_DOUBLE));
+ self::assertTrue($object->isStrikethrough());
+ self::assertEquals(Font::STRIKE_DOUBLE, $object->getStrikethrough());
}
/**
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCoreTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCoreTest.php
index 3a87a2613..5c79a1ee8 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCoreTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsCoreTest.php
@@ -25,13 +25,6 @@ class DocPropsCoreTest extends PhpPresentationTestCase
{
protected $writerName = 'PowerPoint2007';
- public function testRender(): void
- {
- $this->assertZipFileExists('docProps/core.xml');
- $this->assertZipXmlElementNotExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
- $this->assertIsSchemaECMA376Valid();
- }
-
public function testDocumentProperties(): void
{
$expected = 'aAbBcDeE';
@@ -42,7 +35,9 @@ public function testDocumentProperties(): void
->setDescription($expected)
->setSubject($expected)
->setKeywords($expected)
- ->setCategory($expected);
+ ->setCategory($expected)
+ ->setRevision($expected)
+ ->setStatus($expected);
$this->assertZipFileExists('docProps/core.xml');
$this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/dc:creator');
@@ -57,6 +52,10 @@ public function testDocumentProperties(): void
$this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:keywords', $expected);
$this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:category');
$this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:category', $expected);
+ $this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:revision');
+ $this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:revision', $expected);
+ $this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
+ $this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:contentStatus', $expected);
$this->assertIsSchemaECMA376Valid();
}
@@ -73,7 +72,8 @@ public function testMarkAsFinalFalse(): void
{
$this->oPresentation->getPresentationProperties()->markAsFinal(false);
- $this->assertZipXmlElementNotExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
+ $this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
+ $this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:contentStatus', '');
$this->assertIsSchemaECMA376Valid();
}
}
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsThumbnailTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsThumbnailTest.php
index cd29a9733..ddab8a1cc 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsThumbnailTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/DocPropsThumbnailTest.php
@@ -19,6 +19,7 @@
namespace PhpPresentation\Tests\Writer\PowerPoint2007;
+use PhpOffice\PhpPresentation\PresentationProperties;
use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase;
/**
@@ -31,15 +32,40 @@ class DocPropsThumbnailTest extends PhpPresentationTestCase
public function testRender(): void
{
$this->assertZipFileNotExists('docProps/thumbnail.jpeg');
+ $this->assertZipXmlElementNotExists('_rels/.rels', '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"]');
$this->assertIsSchemaECMA376Valid();
}
- public function testFeatureThumbnail(): void
+ public function testFeatureThumbnailFile(): void
{
$imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
- $this->oPresentation->getPresentationProperties()->setThumbnailPath($imagePath);
+ $this->oPresentation->getPresentationProperties()
+ ->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_FILE);
$this->assertZipFileExists('docProps/thumbnail.jpeg');
+ $this->assertZipXmlElementExists('_rels/.rels', '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"]');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
+ public function testFeatureThumbnailFileNotExisting(): void
+ {
+ $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'NotExistingFile.png';
+
+ $this->oPresentation->getPresentationProperties()
+ ->setThumbnailPath($imagePath, PresentationProperties::THUMBNAIL_FILE);
+ $this->assertZipFileNotExists('docProps/thumbnail.jpeg');
+ $this->assertZipXmlElementNotExists('_rels/.rels', '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"]');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
+ public function testFeatureThumbnailData(): void
+ {
+ $imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
+
+ $this->oPresentation->getPresentationProperties()
+ ->setThumbnailPath('', PresentationProperties::THUMBNAIL_DATA, file_get_contents($imagePath));
+ $this->assertZipFileExists('docProps/thumbnail.jpeg');
+ $this->assertZipXmlElementExists('_rels/.rels', '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"]');
$this->assertIsSchemaECMA376Valid();
}
}
diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php
index 9e0640477..652ebd5b4 100644
--- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php
+++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php
@@ -868,6 +868,53 @@ public function testRichTextHyperlink(): void
$this->assertIsSchemaECMA376Valid();
}
+ public function testRichTextRunFontCharset(): void
+ {
+ $latinElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:latin';
+ $eastAsianElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:ea';
+ $complexScriptElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:cs';
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRun = $oRichText->createTextRun('MyText');
+ $oRun->getFont()->setCharset(18);
+
+ $oRun->getFont()->setFormat(Font::FORMAT_LATIN);
+
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'charset');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'charset', '12');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'charset');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'charset', '12');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'charset');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'charset', '12');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
public function testRichTextRunFontFormat(): void
{
$latinElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:latin';
@@ -907,6 +954,100 @@ public function testRichTextRunFontFormat(): void
$this->assertIsSchemaECMA376Valid();
}
+ public function testRichTextRunFontPanose(): void
+ {
+ $latinElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:latin';
+ $eastAsianElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:ea';
+ $complexScriptElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:cs';
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRun = $oRichText->createTextRun('MyText');
+ $oRun->getFont()->setPanose('4494D72242');
+
+ $oRun->getFont()->setFormat(Font::FORMAT_LATIN);
+
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'panose');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'panose', '040409040D0702020402');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'panose');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'panose', '040409040D0702020402');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'panose');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'panose', '040409040D0702020402');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
+ public function testRichTextRunFontPitchFamily(): void
+ {
+ $latinElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:latin';
+ $eastAsianElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:ea';
+ $complexScriptElement = '/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr/a:cs';
+
+ $oSlide = $this->oPresentation->getActiveSlide();
+ $oRichText = $oSlide->createRichTextShape();
+ $oRun = $oRichText->createTextRun('MyText');
+ $oRun->getFont()->setPitchFamily(42);
+
+ $oRun->getFont()->setFormat(Font::FORMAT_LATIN);
+
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'pitchFamily');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'pitchFamily', '42');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_EAST_ASIAN);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'pitchFamily');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'pitchFamily', '42');
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertIsSchemaECMA376Valid();
+
+ $oRun->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
+ $this->resetPresentationFile();
+
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $latinElement);
+ $this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
+ $this->assertZipXmlElementExists('ppt/slides/slide1.xml', $complexScriptElement);
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'typeface');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'typeface', 'Calibri');
+ $this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'pitchFamily');
+ $this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'pitchFamily', '42');
+ $this->assertIsSchemaECMA376Valid();
+ }
+
public function testRichTextRunLanguage(): void
{
$oSlide = $this->oPresentation->getActiveSlide();
diff --git a/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php b/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php
index 0fc395d3a..120ffe0c9 100644
--- a/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php
+++ b/tests/PhpPresentation/Tests/_includes/PhpPresentationTestCase.php
@@ -320,6 +320,18 @@ public function assertZipXmlElementEquals($filePath, $xPath, $value): void
self::assertEquals($nodeList->item(0)->nodeValue, $value);
}
+ /**
+ * @param string $filePath
+ * @param string $xPath
+ * @param mixed $value
+ */
+ public function assertZipXmlElementNotEquals($filePath, $xPath, $value): void
+ {
+ $this->writePresentationFile($this->oPresentation, $this->writerName);
+ $nodeList = $this->getXmlNodeList($filePath, $xPath);
+ self::assertNotEquals($nodeList->item(0)->nodeValue, $value);
+ }
+
/**
* @param mixed $value
*/