Skip to content

Commit 350fd46

Browse files
committed
#255 : PowerPoint2007 Writer : Add support for Outline in Axis (Fix Outline when FILL_NONE)
1 parent cb69a1d commit 350fd46

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

samples/Sample_05_Chart_Line.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
$lineChart1->setSeries($series1);
8888

8989
// Create a shape (chart)
90-
echo date('H:i:s') . ' Create a shape (chart)' . EOL;
90+
echo date('H:i:s') . ' Create a shape (chart1)' . EOL;
9191
echo date('H:i:s') . ' Differences with previous : Values on right axis and Legend hidden' . EOL;
9292
$shape1 = clone $shape;
9393
$shape1->getLegend()->setVisible(false);
@@ -111,7 +111,7 @@
111111
$lineChart2->setSeries($series2);
112112

113113
// Create a shape (chart)
114-
echo date('H:i:s') . ' Create a shape (chart)' . EOL;
114+
echo date('H:i:s') . ' Create a shape (chart2)' . EOL;
115115
echo date('H:i:s') . ' Differences with previous : Values on right axis and Legend hidden' . EOL;
116116
$shape2 = clone $shape;
117117
$shape2->getLegend()->setVisible(false);
@@ -122,7 +122,7 @@
122122
$currentSlide->addShape($shape2);
123123

124124
// Create templated slide
125-
echo EOL . date('H:i:s') . ' Create templated slide' . EOL;
125+
echo EOL . date('H:i:s') . ' Create templated slide #3' . EOL;
126126
$currentSlide = createTemplatedSlide($objPHPPresentation);
127127

128128
// Create a line chart (that should be inserted in a shape)
@@ -149,7 +149,7 @@
149149
$currentSlide->addShape($shape3);
150150

151151
// Create templated slide
152-
echo EOL . date('H:i:s') . ' Create templated slide' . EOL;
152+
echo EOL . date('H:i:s') . ' Create templated slide #4' . EOL;
153153
$currentSlide = createTemplatedSlide($objPHPPresentation);
154154

155155
// Create a line chart (that should be inserted in a shape)
@@ -178,7 +178,7 @@
178178
$currentSlide->addShape($shape4);
179179

180180
// Create templated slide
181-
echo EOL . date('H:i:s') . ' Create templated slide' . EOL;
181+
echo EOL . date('H:i:s') . ' Create templated slide #5' . EOL;
182182
$currentSlide = createTemplatedSlide($objPHPPresentation);
183183

184184
// Create a shape (chart)

src/PhpPresentation/Shape/Chart/Axis.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class Axis implements ComparableInterface
108108
public function __construct($title = 'Axis Title')
109109
{
110110
$this->title = $title;
111+
$this->outline = new Outline();
111112
$this->font = new Font();
112113
}
113114

src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ protected function writeFill(XMLWriter $objWriter, $pFill)
151151

152152
// Is it a fill?
153153
if ($pFill->getFillType() == Fill::FILL_NONE) {
154+
$objWriter->writeElement('a:noFill');
154155
return;
155156
}
156157

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,22 @@ public function testAxisOutline()
147147
$oShape->getPlotArea()->getAxisY()->getOutline()->getFill()->getStartColor()->setRGB($expectedColorY);
148148

149149

150-
$oXMLDoc = TestHelperDOCX::getDocument($this->oPresentation, 'PowerPoint2007');
151150
$element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr';
152-
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/'.$oShape->getIndexedFilename()));
151+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
153152
$element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln';
154-
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/'.$oShape->getIndexedFilename()));
155-
$this->assertEquals(Drawing::pixelsToEmu(Drawing::pointsToPixels($expectedWidthX)), $oXMLDoc->getElementAttribute($element, 'w', 'ppt/charts/'.$oShape->getIndexedFilename()));
153+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
154+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu(Drawing::pointsToPixels($expectedWidthX)));
156155
$element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:spPr/a:ln/a:solidFill/a:srgbClr';
157-
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/'.$oShape->getIndexedFilename()));
158-
$this->assertEquals($expectedColorX, $oXMLDoc->getElementAttribute($element, 'val', 'ppt/charts/'.$oShape->getIndexedFilename()));
156+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
157+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorX);
159158
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr';
160-
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/'.$oShape->getIndexedFilename()));
159+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
161160
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln';
162-
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/'.$oShape->getIndexedFilename()));
163-
$this->assertEquals(Drawing::pixelsToEmu(Drawing::pointsToPixels($expectedWidthY)), $oXMLDoc->getElementAttribute($element, 'w', 'ppt/charts/'.$oShape->getIndexedFilename()));
161+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
162+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'w', Drawing::pixelsToEmu(Drawing::pointsToPixels($expectedWidthY)));
164163
$element = '/c:chartSpace/c:chart/c:plotArea/c:valAx/c:spPr/a:ln/a:solidFill/a:srgbClr';
165-
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/'.$oShape->getIndexedFilename()));
166-
$this->assertEquals($expectedColorY, $oXMLDoc->getElementAttribute($element, 'val', 'ppt/charts/'.$oShape->getIndexedFilename()));
164+
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
165+
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorY);
167166
}
168167

169168
public function testTypeArea()
@@ -549,10 +548,8 @@ public function testTypeLineSeriesOutline()
549548
$expectedElement = '/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:spPr/a:ln';
550549

551550
$oOutline = new Outline();
552-
// Define the color
553551
$oOutline->getFill()->setFillType(Fill::FILL_SOLID);
554552
$oOutline->getFill()->setStartColor(new Color(Color::COLOR_YELLOW));
555-
// Define the width (in points)
556553
$oOutline->setWidth($expectedWidth);
557554

558555
$oSlide = $this->oPresentation->getActiveSlide();

0 commit comments

Comments
 (0)