Skip to content
Merged
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
9 changes: 5 additions & 4 deletions docs/changes/1.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

## Bug fixes

- Word2007 Reader: Fixed cast of spacing by [@Progi1984](https://github.com/Progi1984) fixing [#729](https://github.com/PHPOffice/PHPPresentation/pull/729), [#796](https://github.com/PHPOffice/PHPPresentation/pull/796) in [#818](https://github.com/PHPOffice/PHPPresentation/pull/818)
- PowerPoint2007 Reader: Fixed cast of spacing by [@Progi1984](https://github.com/Progi1984) fixing [#729](https://github.com/PHPOffice/PHPPresentation/pull/729), [#796](https://github.com/PHPOffice/PHPPresentation/pull/796) in [#818](https://github.com/PHPOffice/PHPPresentation/pull/818)
- CI : Fixed PHPCSFixer by [@kw-pr](https://github.com/kw-pr) in [#835](https://github.com/PHPOffice/PHPPresentation/pull/835)
- Word2007 Reader: Fixed cast of color by [@Progi1984](https://github.com/Progi1984) fixing [#826](https://github.com/PHPOffice/PHPPresentation/pull/826) in [#840](https://github.com/PHPOffice/PHPPresentation/pull/840)
- Word2007 Reader: Fixed panose with 20 characters by [@Progi1984](https://github.com/Progi1984) fixing [#798](https://github.com/PHPOffice/PHPPresentation/pull/798) in [#842](https://github.com/PHPOffice/PHPPresentation/pull/842)
- PowerPoint2007 Reader: Fixed cast of color by [@Progi1984](https://github.com/Progi1984) fixing [#826](https://github.com/PHPOffice/PHPPresentation/pull/826) in [#840](https://github.com/PHPOffice/PHPPresentation/pull/840)
- PowerPoint2007 Reader: Fixed panose with 20 characters by [@Progi1984](https://github.com/Progi1984) fixing [#798](https://github.com/PHPOffice/PHPPresentation/pull/798) in [#842](https://github.com/PHPOffice/PHPPresentation/pull/842)
- `Gd::setImageResource()` : Fixed when imagecreatetruecolor returns false by [@jaapdh](https://github.com/jaapdh) in [#843](https://github.com/PHPOffice/PHPPresentation/pull/843)
- Word2007 Writer: LineChart supports LabelPosition for Series by [@pal-software](https://github.com/pal-software) fixing [#606](https://github.com/PHPOffice/PHPPresentation/pull/606) in [#8434](https://github.com/PHPOffice/PHPPresentation/pull/844)
- PowerPoint2007 Writer: LineChart supports LabelPosition for Series by [@pal-software](https://github.com/pal-software) fixing [#606](https://github.com/PHPOffice/PHPPresentation/pull/606) in [#8434](https://github.com/PHPOffice/PHPPresentation/pull/844)
- `createDrawingShape` has no container defined by [@Progi1984](https://github.com/Progi1984) fixing [#820](https://github.com/PHPOffice/PHPPresentation/pull/820) in [#845](https://github.com/PHPOffice/PHPPresentation/pull/845)
- ODPresentation Reader : Read differents units for margin by [@Progi1984](https://github.com/Progi1984) fixing [#830](https://github.com/PHPOffice/PHPPresentation/pull/830) in [#847](https://github.com/PHPOffice/PHPPresentation/pull/847)
- PowerPoint2007 Reader : Fixed loading of fonts by [@ag3202](https://github.com/ag3202) and [@Progi1984](https://github.com/Progi1984) in [#851](https://github.com/PHPOffice/PHPPresentation/pull/851)

## Miscellaneous

Expand Down
21 changes: 12 additions & 9 deletions src/PhpPresentation/Reader/PowerPoint2007.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ protected function loadSlide(string $sPart, string $baseFile): void
file_put_contents($tmpBkgImg, $contentImg);
// Background
$oBackground = new Slide\Background\Image();
$oBackground->setPath($tmpBkgImg);
$oBackground
->setPath($tmpBkgImg)
->setExtension(pathinfo($pathImage, PATHINFO_EXTENSION));
// Slide Background
$oSlide = $this->oPhpPresentation->getActiveSlide();
$oSlide->setBackground($oBackground);
Expand Down Expand Up @@ -1323,22 +1325,23 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
$this->loadHyperlink($document, $oElementHlinkClick, $oText->getHyperlink())
);
}

// Font
$oElementFontFormat = null;
$oElementFontFormatLatin = $document->getElement('a:latin', $oElementrPr);
if (is_object($oElementFontFormatLatin)) {
$oText->getFont()->setFormat(Font::FORMAT_LATIN);
$oElementFontFormat = $oElementFontFormatLatin;
$oElementFontFormatComplexScript = $document->getElement('a:cs', $oElementrPr);
if (is_object($oElementFontFormatComplexScript)) {
$oText->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
$oElementFontFormat = $oElementFontFormatComplexScript;
}
$oElementFontFormatEastAsian = $document->getElement('a:ea', $oElementrPr);
if (is_object($oElementFontFormatEastAsian)) {
$oText->getFont()->setFormat(Font::FORMAT_EAST_ASIAN);
$oElementFontFormat = $oElementFontFormatEastAsian;
}
$oElementFontFormatComplexScript = $document->getElement('a:cs', $oElementrPr);
if (is_object($oElementFontFormatComplexScript)) {
$oText->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
$oElementFontFormat = $oElementFontFormatComplexScript;
$oElementFontFormatLatin = $document->getElement('a:latin', $oElementrPr);
if (is_object($oElementFontFormatLatin)) {
$oText->getFont()->setFormat(Font::FORMAT_LATIN);
$oElementFontFormat = $oElementFontFormatLatin;
}
if (is_object($oElementFontFormat) && $oElementFontFormat->hasAttribute('typeface')) {
$oText->getFont()->setName($oElementFontFormat->getAttribute('typeface'));
Expand Down
20 changes: 20 additions & 0 deletions src/PhpPresentation/Slide/Background/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class Image extends AbstractBackground
*/
protected $width;

/**
* @var string
*/
protected $extension;

/**
* Get Path.
*/
Expand Down Expand Up @@ -80,6 +85,18 @@ public function setPath(string $pValue = '', bool $pVerifyFile = true)
return $this;
}

/**
* Set Extension.
*
* @param string $pValue File Extension
*/
public function setExtension(string $pValue): self
{
$this->extension = $pValue;

return $this;
}

/**
* Get Filename.
*/
Expand All @@ -93,6 +110,9 @@ public function getFilename(): string
*/
public function getExtension(): string
{
if ($this->extension) {
return $this->extension;
}
$exploded = explode('.', $this->getFilename());

return $exploded[count($exploded) - 1];
Expand Down
16 changes: 14 additions & 2 deletions tests/PhpPresentation/Tests/Slide/Background/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,31 @@ public function testColor(): void
self::assertEmpty($object->getExtension());
self::assertEquals('background_' . $numSlide . '.', $object->getIndexedFilename($numSlide));

self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Image', $object->setPath($imagePath));
self::assertInstanceOf(Image::class, $object->setPath($imagePath));
self::assertEquals($imagePath, $object->getPath());
self::assertEquals('PhpPresentationLogo.png', $object->getFilename());
self::assertEquals('png', $object->getExtension());
self::assertEquals('background_' . $numSlide . '.png', $object->getIndexedFilename($numSlide));

self::assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Background\\Image', $object->setPath('', false));
self::assertInstanceOf(Image::class, $object->setPath('', false));
self::assertEquals('', $object->getPath());
self::assertEmpty($object->getFilename());
self::assertEmpty($object->getExtension());
self::assertEquals('background_' . $numSlide . '.', $object->getIndexedFilename($numSlide));
}

public function testExtension(): void
{
$object = new Image();
$imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';

self::assertEmpty($object->getExtension());
self::assertInstanceOf(Image::class, $object->setPath($imagePath));
self::assertEquals('png', $object->getExtension());
self::assertInstanceOf(Image::class, $object->setExtension('jpg'));
self::assertEquals('jpg', $object->getExtension());
}

public function testPathException(): void
{
$this->expectException(FileNotFoundException::class);
Expand Down