Skip to content

Commit aee6381

Browse files
committed
PowerPoint2007 Reader : Initial Commit - GH-44 (Fixes PHPCS / PHPMd)
1 parent 02e6f62 commit aee6381

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

src/PhpPresentation/Reader/PowerPoint2007.php

+44-44
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected function loadDocumentProperties($sPart)
157157
$oProperties = $this->oPhpPresentation->getProperties();
158158
foreach ($arrayProperties as $path => $property) {
159159
if (is_object($oElement = $xmlReader->getElement($path))) {
160-
if($oElement->hasAttribute('xsi:type') && $oElement->getAttribute('xsi:type') == 'dcterms:W3CDTF') {
160+
if ($oElement->hasAttribute('xsi:type') && $oElement->getAttribute('xsi:type') == 'dcterms:W3CDTF') {
161161
$oDateTime = new \DateTime();
162162
$oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
163163
$oProperties->{$property}($oDateTime->getTimestamp());
@@ -222,7 +222,7 @@ protected function loadSlide($sPart, $baseFile)
222222
}
223223

224224
/**
225-
*
225+
*
226226
* @param XMLReader $document
227227
* @param \DOMElement $node
228228
* @param string $baseFile
@@ -236,7 +236,7 @@ protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, $bas
236236
$fileRels = 'ppt/slides/_rels/'.$baseFile.'.rels';
237237

238238
$oElement = $document->getElement('p:nvPicPr/p:cNvPr', $node);
239-
if($oElement) {
239+
if ($oElement) {
240240
$oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : '');
241241
$oShape->setDescription($oElement->hasAttribute('descr') ? $oElement->getAttribute('descr') : '');
242242
}
@@ -247,7 +247,7 @@ protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, $bas
247247
$pathImage = 'ppt/slides/'.$this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')];
248248
$pathImage = explode('/', $pathImage);
249249
foreach ($pathImage as $key => $partPath) {
250-
if($partPath == '..') {
250+
if ($partPath == '..') {
251251
unset($pathImage[$key - 1]);
252252
unset($pathImage[$key]);
253253
}
@@ -387,71 +387,71 @@ protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $ba
387387
$oParagraph->getAlignment()->setLevel($oSubElement->getAttribute('lvl'));
388388
}
389389

390-
$oElement_buFont = $document->getElement('a:buFont', $oSubElement);
390+
$oElementBuFont = $document->getElement('a:buFont', $oSubElement);
391391
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE);
392-
if ($oElement_buFont) {
393-
if ($oElement_buFont->hasAttribute('typeface')) {
394-
$oParagraph->getBulletStyle()->setBulletFont($oElement_buFont->getAttribute('typeface'));
392+
if ($oElementBuFont) {
393+
if ($oElementBuFont->hasAttribute('typeface')) {
394+
$oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface'));
395395
}
396396
}
397-
$oElement_buChar = $document->getElement('a:buChar', $oSubElement);
398-
if ($oElement_buChar) {
397+
$oElementBuChar = $document->getElement('a:buChar', $oSubElement);
398+
if ($oElementBuChar) {
399399
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
400-
if ($oElement_buChar->hasAttribute('char')) {
401-
$oParagraph->getBulletStyle()->setBulletChar($oElement_buChar->getAttribute('char'));
400+
if ($oElementBuChar->hasAttribute('char')) {
401+
$oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char'));
402402
}
403403
}
404-
/*$oElement_buAutoNum = $document->getElement('a:buAutoNum', $oSubElement);
405-
if ($oElement_buAutoNum) {
404+
/*$oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement);
405+
if ($oElementBuAutoNum) {
406406
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC);
407-
if ($oElement_buAutoNum->hasAttribute('type')) {
408-
$oParagraph->getBulletStyle()->setBulletNumericStyle($oElement_buAutoNum->getAttribute('type'));
407+
if ($oElementBuAutoNum->hasAttribute('type')) {
408+
$oParagraph->getBulletStyle()->setBulletNumericStyle($oElementBuAutoNum->getAttribute('type'));
409409
}
410-
if ($oElement_buAutoNum->hasAttribute('startAt') && $oElement_buAutoNum->getAttribute('startAt') != 1) {
411-
$oParagraph->getBulletStyle()->setBulletNumericStartAt($oElement_buAutoNum->getAttribute('startAt'));
410+
if ($oElementBuAutoNum->hasAttribute('startAt') && $oElementBuAutoNum->getAttribute('startAt') != 1) {
411+
$oParagraph->getBulletStyle()->setBulletNumericStartAt($oElementBuAutoNum->getAttribute('startAt'));
412412
}
413413
}*/
414414
}
415415
$arraySubElements = $document->getElements('(a:r|a:br)', $oElement);
416416
foreach ($arraySubElements as $oSubElement) {
417-
if($oSubElement->tagName == 'a:br') {
417+
if ($oSubElement->tagName == 'a:br') {
418418
$oParagraph->createBreak();
419419
}
420-
if($oSubElement->tagName == 'a:r') {
421-
$oElement_rPr = $document->getElement('a:rPr', $oSubElement);
422-
if(is_object($oElement_rPr)) {
420+
if ($oSubElement->tagName == 'a:r') {
421+
$oElementrPr = $document->getElement('a:rPr', $oSubElement);
422+
if (is_object($oElementrPr)) {
423423
$oText = $oParagraph->createTextRun();
424424

425-
if ($oElement_rPr->hasAttribute('b')) {
426-
$oText->getFont()->setBold($oElement_rPr->getAttribute('b') == 'true' ? true : false);
425+
if ($oElementrPr->hasAttribute('b')) {
426+
$oText->getFont()->setBold($oElementrPr->getAttribute('b') == 'true' ? true : false);
427427
}
428-
if ($oElement_rPr->hasAttribute('i')) {
429-
$oText->getFont()->setItalic($oElement_rPr->getAttribute('i') == 'true' ? true : false);
428+
if ($oElementrPr->hasAttribute('i')) {
429+
$oText->getFont()->setItalic($oElementrPr->getAttribute('i') == 'true' ? true : false);
430430
}
431-
if ($oElement_rPr->hasAttribute('strike')) {
432-
$oText->getFont()->setStrikethrough($oElement_rPr->getAttribute('strike') == 'noStrike' ? false : true);
431+
if ($oElementrPr->hasAttribute('strike')) {
432+
$oText->getFont()->setStrikethrough($oElementrPr->getAttribute('strike') == 'noStrike' ? false : true);
433433
}
434-
if ($oElement_rPr->hasAttribute('sz')) {
435-
$oText->getFont()->setSize((int)($oElement_rPr->getAttribute('sz') / 100));
434+
if ($oElementrPr->hasAttribute('sz')) {
435+
$oText->getFont()->setSize((int)($oElementrPr->getAttribute('sz') / 100));
436436
}
437-
if ($oElement_rPr->hasAttribute('u')) {
438-
$oText->getFont()->setUnderline($oElement_rPr->getAttribute('u'));
437+
if ($oElementrPr->hasAttribute('u')) {
438+
$oText->getFont()->setUnderline($oElementrPr->getAttribute('u'));
439439
}
440440
// Color
441-
$oElement_srgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElement_rPr);
442-
if (is_object($oElement_srgbClr) && $oElement_srgbClr->hasAttribute('val')) {
441+
$oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr);
442+
if (is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) {
443443
$oColor = new Color();
444-
$oColor->setRGB($oElement_srgbClr->getAttribute('val'));
444+
$oColor->setRGB($oElementSrgbClr->getAttribute('val'));
445445
$oText->getFont()->setColor($oColor);
446446
}
447447
// Hyperlink
448-
$oElement_hlinkClick = $document->getElement('a:hlinkClick', $oElement_rPr);
449-
if (is_object($oElement_hlinkClick)) {
450-
if ($oElement_hlinkClick->hasAttribute('tooltip')) {
451-
$oText->getHyperlink()->setTooltip($oElement_hlinkClick->getAttribute('tooltip'));
448+
$oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr);
449+
if (is_object($oElementHlinkClick)) {
450+
if ($oElementHlinkClick->hasAttribute('tooltip')) {
451+
$oText->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip'));
452452
}
453-
if ($oElement_hlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$fileRels][$oElement_hlinkClick->getAttribute('r:id')])) {
454-
$oText->getHyperlink()->setUrl($this->arrayRels[$fileRels][$oElement_hlinkClick->getAttribute('r:id')]);
453+
if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')])) {
454+
$oText->getHyperlink()->setUrl($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]);
455455
}
456456
}
457457
} else {
@@ -461,7 +461,7 @@ protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $ba
461461
$oSubSubElement = $document->getElement('a:t', $oSubElement);
462462
$oText->setText($oSubSubElement->nodeValue);
463463
}
464-
}
464+
}
465465
}
466466

467467
if (count($oShape->getParagraphs()) > 0) {
@@ -470,14 +470,14 @@ protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $ba
470470
}
471471

472472
/**
473-
*
473+
*
474474
* @param string $rId
475475
* @return string
476476
*/
477477
protected function loadRels($fileRels)
478478
{
479479
$sPart = $this->oZip->getFromName($fileRels);
480-
if($sPart !== false) {
480+
if ($sPart !== false) {
481481
$xmlReader = new XMLReader();
482482
if ($xmlReader->getDomFromString($sPart)) {
483483
foreach ($xmlReader->getElements('*') as $oNode) {

src/PhpPresentation/Shape/RichText.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ public function getParagraph($index = 0)
232232
*/
233233
public function createParagraph()
234234
{
235-
$numParagraphs = count($this->richTextParagraphs);
236-
if ($numParagraphs > 0) {
235+
$numParagraphs = count($this->richTextParagraphs);
236+
if ($numParagraphs > 0) {
237237
$alignment = clone $this->getActiveParagraph()->getAlignment();
238238
$font = clone $this->getActiveParagraph()->getFont();
239239
$bulletStyle = clone $this->getActiveParagraph()->getBulletStyle();
240-
}
240+
}
241241

242242
$this->richTextParagraphs[] = new Paragraph();
243243
$this->activeParagraph = count($this->richTextParagraphs) - 1;

tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testLoadFile01()
9090
$this->assertEquals('Sample 02 Description', $oPhpPresentation->getProperties()->getDescription());
9191
$this->assertEquals('office 2007 openxml libreoffice odt php', $oPhpPresentation->getProperties()->getKeywords());
9292
$this->assertEquals('Sample Category', $oPhpPresentation->getProperties()->getCategory());
93-
//
93+
//
9494
$this->assertCount(4, $oPhpPresentation->getAllSlides());
9595

9696
// Slide 1

0 commit comments

Comments
 (0)