Skip to content

Commit

Permalink
ODPresentation Writer : Title in Legend in chart doesn't displayed - @…
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Jun 3, 2015
1 parent 3d80595 commit e08f708
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### Bugfix
- PSR-0 via composer broken - @Progi1984 GH-51
- ODPresentation Writer : Title in Legend in chart doesn't displayed - @Progi1984 GH-79
- PowerPoint2007 Writer : Fill don't work for RichTextShapes - @Progi1984 GH-61
- PowerPoint2007 Writer : Border don't work for RichTextShapes - @Progi1984 GH-61
- PowerPoint2007 Writer : Hyperlink in table doesn't work - @Progi1984 GH-70
Expand Down
4 changes: 2 additions & 2 deletions src/PhpPowerpoint/Writer/ODPresentation/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public function writeShapePic(XMLWriter $objWriter, AbstractDrawing $shape)
$objWriter->writeElement('text:p');
$objWriter->endElement();

if ($shape->getHyperlink()) {
if ($shape->hasHyperlink()) {
// office:event-listeners
$objWriter->startElement('office:event-listeners');
// presentation:event-listener
Expand Down Expand Up @@ -574,7 +574,7 @@ public function writeShapeTable(XMLWriter $objWriter, Table $shape)
if ($shapeRichText instanceof Run) {
$objWriter->writeAttribute('text:style-name', 'T_' . $shapeRichText->getFont()->getHashCode());
}
if ($shapeRichText->hasHyperlink() == true && $shapeRichText->getHyperlink()->getUrl() != '') {
if ($shapeRichText->hasHyperlink()) {
// text:a
$objWriter->startElement('text:a');
$objWriter->writeAttribute('xlink:href', $shapeRichText->getHyperlink()->getUrl());
Expand Down
17 changes: 16 additions & 1 deletion src/PhpPowerpoint/Writer/ODPresentation/ObjectsChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,19 @@ private function writeTable()
$this->xmlContent->endElement();
// > table:table-header-columns
$this->xmlContent->endElement();

// table:table-columns
$this->xmlContent->startElement('table:table-columns');
// table:table-column
$this->xmlContent->startElement('table:table-column');
if (!empty($this->arrayData)) {
$rowFirst = reset($this->arrayData);
$this->xmlContent->writeAttribute('table:number-columns-repeated', count($rowFirst) - 1);
}
// > table:table-column
$this->xmlContent->endElement();
// > table:table-columns
$this->xmlContent->endElement();

// table:table-header-rows
$this->xmlContent->startElement('table:table-header-rows');
Expand All @@ -633,7 +646,9 @@ private function writeTable()
foreach ($rowFirst as $key => $cell) {
// table:table-cell
$this->xmlContent->startElement('table:table-cell');
$this->xmlContent->writeAttribute('office:value', 'string');
if (isset($this->arrayTitle[$key - 1])) {
$this->xmlContent->writeAttribute('office:value-type', 'string');
}
// text:p
$this->xmlContent->startElement('text:p');
if (isset($this->arrayTitle[$key - 1])) {
Expand Down
27 changes: 27 additions & 0 deletions tests/PhpPowerpoint/Tests/Writer/ODPresentation/ChartsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,31 @@ public function testChartScatter()
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$this->assertEquals('chart:scatter', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
}

public function testLegend()
{
$oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
$oSeries->setShowSeriesName(true);

$oLine = new Line();
$oLine->addSeries($oSeries);

$phpPowerPoint = new PhpPowerpoint();
$oSlide = $phpPowerPoint->getActiveSlide();
$oChart = $oSlide->createChartShape();
$oChart->getPlotArea()->setType($oLine);

$pres = TestHelperDOCX::getDocument($phpPowerPoint, 'ODPresentation');

$element = '/office:document-content/office:body/office:chart/chart:chart/chart:legend';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row/table:table-cell';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$element = '/office:document-content/office:body/office:chart/chart:chart/table:table/table:table-header-rows/table:table-row/table:table-cell[@office:value-type=\'string\']';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
}
}

0 comments on commit e08f708

Please sign in to comment.