Skip to content

Commit e0b9203

Browse files
committed
Contribution : Fixed some errors
1 parent 84fa3f2 commit e0b9203

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

src/PhpPresentation/Reader/PowerPoint2007.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ protected function loadSlide(string $sPart, string $baseFile): void
493493
// Background
494494
$oBackground = new Slide\Background\Image();
495495
$oBackground->setPath($tmpBkgImg);
496-
$extension = pathinfo( $pathImage, PATHINFO_EXTENSION );
496+
$extension = pathinfo($pathImage, PATHINFO_EXTENSION);
497497
$oBackground->setExtension($extension);
498498
// Slide Background
499499
$oSlide = $this->oPhpPresentation->getActiveSlide();

src/PhpPresentation/Slide/Background/Image.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ public function setPath(string $pValue = '', bool $pVerifyFile = true)
8989
* Set Extension.
9090
*
9191
* @param string $pValue File Extension
92-
*
93-
* @return self
9492
*/
95-
public function setExtension(string $pValue)
93+
public function setExtension(string $pValue): self
9694
{
9795
$this->extension = $pValue;
96+
9897
return $this;
9998
}
10099

@@ -111,12 +110,12 @@ public function getFilename(): string
111110
*/
112111
public function getExtension(): string
113112
{
114-
if($this->extension){
113+
if ($this->extension) {
115114
return $this->extension;
116115
}
117116
$exploded = explode('.', $this->getFilename());
118-
return $exploded[count($exploded) - 1];
119117

118+
return $exploded[count($exploded) - 1];
120119
}
121120

122121
/**

src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,11 @@ protected function writeRunStyles(XMLWriter $objWriter, Run $element): void
678678
$objWriter->startElement('a:' . $element->getFont()->getFormat());
679679
$objWriter->writeAttribute('typeface', $element->getFont()->getName());
680680
if ($element->getFont()->getPanose() !== '') {
681-
$objWriter->writeAttribute('panose', $element->getFont()->getPanose());
681+
$panose = array_map(function (string $value) {
682+
return '0' . $value;
683+
}, str_split($element->getFont()->getPanose()));
684+
685+
$objWriter->writeAttribute('panose', implode('', $panose));
682686
}
683687
$objWriter->writeAttributeIf(
684688
$element->getFont()->getPitchFamily() !== 0,
@@ -689,7 +693,7 @@ protected function writeRunStyles(XMLWriter $objWriter, Run $element): void
689693
$objWriter->writeAttributeIf(
690694
$element->getFont()->getCharset() !== Font::CHARSET_DEFAULT,
691695
'charset',
692-
$charset
696+
dechex($element->getFont()->getCharset())
693697
);
694698
$objWriter->endElement();
695699

tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptSlidesTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ public function testRichTextRunFontCharset(): void
886886
$this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'typeface');
887887
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'typeface', 'Calibri');
888888
$this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $latinElement, 'charset');
889-
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'charset', '18');
889+
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $latinElement, 'charset', '12');
890890
$this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $eastAsianElement);
891891
$this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
892892
$this->assertIsSchemaECMA376Valid();
@@ -899,7 +899,7 @@ public function testRichTextRunFontCharset(): void
899899
$this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'typeface');
900900
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'typeface', 'Calibri');
901901
$this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $eastAsianElement, 'charset');
902-
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'charset', '18');
902+
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $eastAsianElement, 'charset', '12');
903903
$this->assertZipXmlElementNotExists('ppt/slides/slide1.xml', $complexScriptElement);
904904
$this->assertIsSchemaECMA376Valid();
905905

@@ -912,7 +912,7 @@ public function testRichTextRunFontCharset(): void
912912
$this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'typeface');
913913
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'typeface', 'Calibri');
914914
$this->assertZipXmlAttributeExists('ppt/slides/slide1.xml', $complexScriptElement, 'charset');
915-
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'charset', '18');
915+
$this->assertZipXmlAttributeEquals('ppt/slides/slide1.xml', $complexScriptElement, 'charset', '12');
916916
$this->assertIsSchemaECMA376Valid();
917917
}
918918

0 commit comments

Comments
 (0)