Skip to content

Commit 2482614

Browse files
committed
#161 : Fix PHPCS & PHPMD
1 parent 5de5693 commit 2482614

File tree

7 files changed

+37
-22
lines changed

7 files changed

+37
-22
lines changed

src/PhpPresentation/Reader/PowerPoint2007.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,39 +408,39 @@ private function loadMasterSlide($sPart, $baseFile)
408408
$level = str_replace('pPr', '', $level);
409409
}
410410

411-
if($oElementLvl->hasAttribute('algn')) {
411+
if ($oElementLvl->hasAttribute('algn')) {
412412
$oRTParagraph->getAlignment()->setHorizontal($oElementLvl->getAttribute('algn'));
413413
}
414-
if($oElementLvl->hasAttribute('marL')) {
414+
if ($oElementLvl->hasAttribute('marL')) {
415415
$val = $oElementLvl->getAttribute('marL');
416416
$val = CommonDrawing::emuToPixels($val);
417417
$oRTParagraph->getAlignment()->setMarginLeft($val);
418418
}
419-
if($oElementLvl->hasAttribute('marR')) {
419+
if ($oElementLvl->hasAttribute('marR')) {
420420
$val = $oElementLvl->getAttribute('marR');
421421
$val = CommonDrawing::emuToPixels($val);
422422
$oRTParagraph->getAlignment()->setMarginRight($val);
423423
}
424-
if($oElementLvl->hasAttribute('indent')) {
424+
if ($oElementLvl->hasAttribute('indent')) {
425425
$val = $oElementLvl->getAttribute('indent');
426426
$val = CommonDrawing::emuToPixels($val);
427427
$oRTParagraph->getAlignment()->setIndent($val);
428428
}
429429
$oElementLvlDefRPR = $xmlReader->getElement('a:defRPr', $oElementLvl);
430430
if ($oElementLvlDefRPR) {
431-
if($oElementLvlDefRPR->hasAttribute('sz')) {
431+
if ($oElementLvlDefRPR->hasAttribute('sz')) {
432432
$oRTParagraph->getFont()->setSize($oElementLvlDefRPR->getAttribute('sz') / 100);
433433
}
434-
if($oElementLvlDefRPR->hasAttribute('b') && $oElementLvlDefRPR->getAttribute('b') == 1) {
434+
if ($oElementLvlDefRPR->hasAttribute('b') && $oElementLvlDefRPR->getAttribute('b') == 1) {
435435
$oRTParagraph->getFont()->setBold(true);
436436
}
437-
if($oElementLvlDefRPR->hasAttribute('i') && $oElementLvlDefRPR->getAttribute('i') == 1) {
437+
if ($oElementLvlDefRPR->hasAttribute('i') && $oElementLvlDefRPR->getAttribute('i') == 1) {
438438
$oRTParagraph->getFont()->setItalic(true);
439439
}
440440
}
441441
$oElementSchemeColor = $xmlReader->getElement('a:defRPr/a:solidFill/a:schemeClr', $oElementLvl);
442442
if ($oElementSchemeColor) {
443-
if($oElementSchemeColor->hasAttribute('val')) {
443+
if ($oElementSchemeColor->hasAttribute('val')) {
444444
$oRTParagraph->getFont()->setColor(new SchemeColor())->getColor()->setValue($oElementSchemeColor->getAttribute('val'));
445445
}
446446
}

src/PhpPresentation/Style/ColorMap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ColorMap
4242
*/
4343
protected $mapping = array();
4444

45-
public static $MAPPING_DEFAULT = array(
45+
public static $mappingDefault = array(
4646
self::COLOR_BG1 => 'lt1',
4747
self::COLOR_TX1 => 'dk1',
4848
self::COLOR_BG2 => 'lt2',
@@ -63,7 +63,7 @@ class ColorMap
6363
*/
6464
public function __construct()
6565
{
66-
$this->mapping = self::$MAPPING_DEFAULT;
66+
$this->mapping = self::$mappingDefault;
6767
}
6868

6969
/**

src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/AbstractLayoutPack.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function findLayout($name = '', $masterId = 1)
194194
* @return int
195195
* @throws \Exception
196196
*/
197-
public function findLayoutId($name = '', $masterId = 1)
197+
public function findLayoutId($name = '')
198198
{
199199
foreach ($this->layouts as $layoutId => $layout) {
200200
if ($layout['name'] == $name) {
@@ -213,7 +213,7 @@ public function findLayoutId($name = '', $masterId = 1)
213213
* @return int
214214
* @throws \Exception
215215
*/
216-
public function findLayoutName($idLayout = '', $masterId = 1)
216+
public function findLayoutName($idLayout = '')
217217
{
218218
foreach ($this->layouts as $layoutId => $layout) {
219219
if ($layoutId == $idLayout) {

src/PhpPresentation/Writer/PowerPoint2007/PptPresentation.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public function render()
3030
// Add slide masters
3131
$relationId = 1;
3232
$slideMasterId = 2147483648;
33-
foreach ($this->oPresentation->getAllMasterSlides() as $oMasterSlide) {
33+
34+
$countMasterSlides = count($this->oPresentation->getAllMasterSlides());
35+
for ($inc = 1; $inc <= $countMasterSlides; $inc++) {
3436
// p:sldMasterId
3537
$objWriter->startElement('p:sldMasterId');
3638
$objWriter->writeAttribute('id', $slideMasterId);

src/PhpPresentation/Writer/PowerPoint2007/PptSlideLayouts.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class PptSlideLayouts extends AbstractSlide
1515
*/
1616
public function render()
1717
{
18-
foreach ($this->oPresentation->getAllMasterSlides() as $idx => $oSlideMaster) {
18+
foreach ($this->oPresentation->getAllMasterSlides() as $oSlideMaster) {
1919
foreach ($oSlideMaster->getAllSlideLayouts() as &$oSlideLayout) {
2020
$this->oZip->addFromString('ppt/slideLayouts/_rels/slideLayout' . $oSlideLayout->layoutNr . '.xml.rels', $this->writeSlideLayoutRelationships($oSlideLayout->layoutNr, $oSlideMaster->getRelsIndex()));
2121
$this->oZip->addFromString('ppt/slideLayouts/slideLayout' . $oSlideLayout->layoutNr . '.xml', $this->writeSlideLayout($oSlideLayout));
@@ -59,6 +59,8 @@ public function writeSlideLayoutRelationships($slideLayoutIndex, $masterId = 1)
5959
$this->writeRelationship($objWriter, 1, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster', '../slideMasters/slideMaster' . $masterId . '.xml');
6060

6161
// Other relationships
62+
//@todo
63+
$slideLayoutIndex;
6264
/*
6365
foreach ($oLayoutPack->getLayoutRelations() as $otherRelation) {
6466
if ($otherRelation['layoutId'] == $slideLayoutIndex) {
@@ -149,7 +151,7 @@ public function writeSlideLayout(SlideLayout $pSlideLayout)
149151

150152
// p:sldLayout\p:clrMapOvr
151153
$objWriter->startElement('p:clrMapOvr');
152-
$arrayDiff = array_diff_assoc(ColorMap::$MAPPING_DEFAULT, $pSlideLayout->colorMap->getMapping());
154+
$arrayDiff = array_diff_assoc(ColorMap::$mappingDefault, $pSlideLayout->colorMap->getMapping());
153155
if (!empty($arrayDiff)) {
154156
// p:sldLayout\p:clrMapOvr\a:overrideClrMapping
155157
$objWriter->startElement('a:overrideClrMapping');

src/PhpPresentation/Writer/PowerPoint2007/PptSlideMasters.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PptSlideMasters extends AbstractSlide
1919
*/
2020
public function render()
2121
{
22-
foreach ($this->oPresentation->getAllMasterSlides() as $idx => $oMasterSlide) {
22+
foreach ($this->oPresentation->getAllMasterSlides() as $oMasterSlide) {
2323
// Add the relations from the masterSlide to the ZIP file
2424
$this->oZip->addFromString('ppt/slideMasters/_rels/slideMaster' . $oMasterSlide->getRelsIndex() . '.xml.rels', $this->writeSlideMasterRelationships($oMasterSlide));
2525
// Add the information from the masterSlide to the ZIP file
@@ -181,12 +181,21 @@ public function writeSlideMaster(SlideMaster $pSlide)
181181
$elementName = ($lvl == 0 ? 'a:defPPr' : 'a:lvl' . $lvl . 'pPr');
182182
$objWriter->startElement($elementName);
183183
$objWriter->writeAttribute('algn', $oParagraph->getAlignment()->getHorizontal());
184-
$objWriter->writeAttributeIf($oParagraph->getAlignment()->getMarginLeft() != 0, 'marL',
185-
CommonDrawing::pixelsToEmu($oParagraph->getAlignment()->getMarginLeft()));
186-
$objWriter->writeAttributeIf($oParagraph->getAlignment()->getMarginRight() != 0, 'marR',
187-
CommonDrawing::pixelsToEmu($oParagraph->getAlignment()->getMarginRight()));
188-
$objWriter->writeAttributeIf($oParagraph->getAlignment()->getIndent() != 0, 'indent',
189-
CommonDrawing::pixelsToEmu($oParagraph->getAlignment()->getIndent()));
184+
$objWriter->writeAttributeIf(
185+
$oParagraph->getAlignment()->getMarginLeft() != 0,
186+
'marL',
187+
CommonDrawing::pixelsToEmu($oParagraph->getAlignment()->getMarginLeft())
188+
);
189+
$objWriter->writeAttributeIf(
190+
$oParagraph->getAlignment()->getMarginRight() != 0,
191+
'marR',
192+
CommonDrawing::pixelsToEmu($oParagraph->getAlignment()->getMarginRight())
193+
);
194+
$objWriter->writeAttributeIf(
195+
$oParagraph->getAlignment()->getIndent() != 0,
196+
'indent',
197+
CommonDrawing::pixelsToEmu($oParagraph->getAlignment()->getIndent())
198+
);
190199
$objWriter->startElement('a:defRPr');
191200
$objWriter->writeAttributeIf($oParagraph->getFont()->getSize() != 10, 'sz', $oParagraph->getFont()->getSize() * 100);
192201
$objWriter->writeAttributeIf($oParagraph->getFont()->isBold(), 'b', 1);

src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ public function writeThemeRelationships($masterId = 1)
146146
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
147147

148148
// Other relationships
149+
//@todo
150+
$masterId;
149151
/*
150152
$otherRelations = $oLayoutPack->getThemeRelations();
151153
foreach ($otherRelations as $otherRelation) {

0 commit comments

Comments
 (0)