Skip to content

Commit ec313ef

Browse files
committed
PowerPoint2007 Reader : Initial Commit - GH-44 (Fixes Scrutinizer CI)
1 parent aee6381 commit ec313ef

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

src/PhpPresentation/Reader/PowerPoint2007.php

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,11 @@
1818
namespace PhpOffice\PhpPresentation\Reader;
1919

2020
use ZipArchive;
21-
use PhpOffice\Common\Text;
2221
use PhpOffice\Common\XMLReader;
2322
use PhpOffice\Common\Drawing as CommonDrawing;
24-
use PhpOffice\PhpPresentation\AbstractShape;
2523
use PhpOffice\PhpPresentation\PhpPresentation;
26-
use PhpOffice\PhpPresentation\Shape\Drawing;
27-
use PhpOffice\PhpPresentation\Shape\Group;
2824
use PhpOffice\PhpPresentation\Shape\Hyperlink;
29-
use PhpOffice\PhpPresentation\Shape\Line;
3025
use PhpOffice\PhpPresentation\Shape\MemoryDrawing;
31-
use PhpOffice\PhpPresentation\Shape\RichText;
32-
use PhpOffice\PhpPresentation\Style\Alignment;
3326
use PhpOffice\PhpPresentation\Style\Bullet;
3427
use PhpOffice\PhpPresentation\Style\Color;
3528

@@ -142,28 +135,29 @@ protected function loadFile($pFilename)
142135
protected function loadDocumentProperties($sPart)
143136
{
144137
$xmlReader = new XMLReader();
145-
if ($xmlReader->getDomFromString($sPart)) {
146-
$arrayProperties = array(
147-
'/cp:coreProperties/dc:creator' => 'setCreator',
148-
'/cp:coreProperties/cp:lastModifiedBy' => 'setLastModifiedBy',
149-
'/cp:coreProperties/dc:title' => 'setTitle',
150-
'/cp:coreProperties/dc:description' => 'setDescription',
151-
'/cp:coreProperties/dc:subject' => 'setSubject',
152-
'/cp:coreProperties/cp:keywords' => 'setKeywords',
153-
'/cp:coreProperties/cp:category' => 'setCategory',
154-
'/cp:coreProperties/dcterms:created' => 'setCreated',
155-
'/cp:coreProperties/dcterms:modified' => 'setModified',
156-
);
157-
$oProperties = $this->oPhpPresentation->getProperties();
158-
foreach ($arrayProperties as $path => $property) {
159-
if (is_object($oElement = $xmlReader->getElement($path))) {
160-
if ($oElement->hasAttribute('xsi:type') && $oElement->getAttribute('xsi:type') == 'dcterms:W3CDTF') {
161-
$oDateTime = new \DateTime();
162-
$oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
163-
$oProperties->{$property}($oDateTime->getTimestamp());
164-
} else {
165-
$oProperties->{$property}($oElement->nodeValue);
166-
}
138+
if (!$xmlReader->getDomFromString($sPart)) {
139+
return false;
140+
}
141+
$arrayProperties = array(
142+
'/cp:coreProperties/dc:creator' => 'setCreator',
143+
'/cp:coreProperties/cp:lastModifiedBy' => 'setLastModifiedBy',
144+
'/cp:coreProperties/dc:title' => 'setTitle',
145+
'/cp:coreProperties/dc:description' => 'setDescription',
146+
'/cp:coreProperties/dc:subject' => 'setSubject',
147+
'/cp:coreProperties/cp:keywords' => 'setKeywords',
148+
'/cp:coreProperties/cp:category' => 'setCategory',
149+
'/cp:coreProperties/dcterms:created' => 'setCreated',
150+
'/cp:coreProperties/dcterms:modified' => 'setModified',
151+
);
152+
$oProperties = $this->oPhpPresentation->getProperties();
153+
foreach ($arrayProperties as $path => $property) {
154+
if (is_object($oElement = $xmlReader->getElement($path))) {
155+
if ($oElement->hasAttribute('xsi:type') && $oElement->getAttribute('xsi:type') == 'dcterms:W3CDTF') {
156+
$oDateTime = new \DateTime();
157+
$oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
158+
$oProperties->{$property}($oDateTime->getTimestamp());
159+
} else {
160+
$oProperties->{$property}($oElement->nodeValue);
167161
}
168162
}
169163
}
@@ -196,6 +190,8 @@ protected function loadSlides($sPart)
196190

197191
/**
198192
* Extract data from slide
193+
* @param string $sPart
194+
* @param string $baseFile
199195
*/
200196
protected function loadSlide($sPart, $baseFile)
201197
{
@@ -454,7 +450,7 @@ protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $ba
454450
$oText->getHyperlink()->setUrl($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]);
455451
}
456452
}
457-
} else {
453+
//} else {
458454
// $oText = $oParagraph->createText();
459455
}
460456

@@ -471,7 +467,7 @@ protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $ba
471467

472468
/**
473469
*
474-
* @param string $rId
470+
* @param string $fileRels
475471
* @return string
476472
*/
477473
protected function loadRels($fileRels)

src/PhpPresentation/Shape/RichText.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,13 @@ public function createParagraph()
242242
$this->richTextParagraphs[] = new Paragraph();
243243
$this->activeParagraph = count($this->richTextParagraphs) - 1;
244244

245-
if ($numParagraphs > 0) {
245+
if (isset($alignment)) {
246246
$this->getActiveParagraph()->setAlignment($alignment);
247+
}
248+
if (isset($font)) {
247249
$this->getActiveParagraph()->setFont($font);
250+
}
251+
if (isset($bulletStyle)) {
248252
$this->getActiveParagraph()->setBulletStyle($bulletStyle);
249253
}
250254
return $this->getActiveParagraph();

0 commit comments

Comments
 (0)