Skip to content

Commit

Permalink
Merge pull request #6 from Progi1984/Progi1984-issue382
Browse files Browse the repository at this point in the history
#382 : Fixes OpenDocument/ECMA-376
  • Loading branch information
Progi1984 authored May 28, 2019
2 parents 47ad4e9 + 4d3a9ff commit 9e5b584
Show file tree
Hide file tree
Showing 20 changed files with 301 additions and 218 deletions.
2 changes: 1 addition & 1 deletion src/PhpPresentation/Style/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function getAlpha()
$dec = hexdec(substr($this->argb, 0, 2));
$alpha = number_format(($dec/255) * 100, 2);
}
return round($alpha);
return $alpha;
}

/**
Expand Down
24 changes: 11 additions & 13 deletions src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,17 +600,17 @@ private function writeSeries(Chart $chart, Chart\Series $series)
$this->xmlContent->startElement('chart:series');
$this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$'.$this->rangeCol.'$2:.$'.$this->rangeCol.'$'.($numRange+1));
$this->xmlContent->writeAttribute('chart:label-cell-address', 'table-local.$'.$this->rangeCol.'$1');
if ($chartType instanceof Area) {
$this->xmlContent->writeAttribute('chart:class', 'chart:area');
} elseif ($chartType instanceof AbstractTypeBar) {
$this->xmlContent->writeAttribute('chart:class', 'chart:bar');
} elseif ($chartType instanceof Line) {
$this->xmlContent->writeAttribute('chart:class', 'chart:line');
} elseif ($chartType instanceof AbstractTypePie) {
$this->xmlContent->writeAttribute('chart:class', 'chart:circle');
} elseif ($chartType instanceof Scatter) {
$this->xmlContent->writeAttribute('chart:class', 'chart:scatter');
}
// if ($chartType instanceof Area) {
// $this->xmlContent->writeAttribute('chart:class', 'chart:area');
// } elseif ($chartType instanceof AbstractTypeBar) {
// $this->xmlContent->writeAttribute('chart:class', 'chart:bar');
// } elseif ($chartType instanceof Line) {
// $this->xmlContent->writeAttribute('chart:class', 'chart:line');
// } elseif ($chartType instanceof AbstractTypePie) {
// $this->xmlContent->writeAttribute('chart:class', 'chart:circle');
// } elseif ($chartType instanceof Scatter) {
// $this->xmlContent->writeAttribute('chart:class', 'chart:scatter');
// }
$this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries);
if ($chartType instanceof Area || $chartType instanceof AbstractTypeBar || $chartType instanceof Line || $chartType instanceof Scatter) {
$dataPointFills = $series->getDataPointFills();
Expand Down Expand Up @@ -910,7 +910,6 @@ private function writeTitle(Title $oTitle)
// > text:p
$this->xmlContent->startElement('text:p');
$this->xmlContent->text($oTitle->getText());
// > text:p
$this->xmlContent->endElement();
// > chart:title
$this->xmlContent->endElement();
Expand Down Expand Up @@ -945,7 +944,6 @@ private function writeWall()
// chart:wall
$this->xmlContent->startElement('chart:wall');
$this->xmlContent->writeAttribute('chart:style-name', 'styleWall');
// > chart:wall
$this->xmlContent->endElement();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/PhpPresentation/Tests/Shape/Drawing/DrawingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ function function_exists($function)
namespace PhpOffice\PhpPresentation\Tests\Shape\Drawing;

// @codingStandardsIgnoreStart
use PhpOffice\PhpPresentation\Tests\PhpPresentationTestCase;
use PHPUnit\Framework\TestCase;

// @codingStandardsIgnoreEnd
class DrawingTest extends PhpPresentationTestCase
class DrawingTest extends TestCase
{
public static $getimagesizefromstringExists = true;

Expand Down
141 changes: 93 additions & 48 deletions tests/PhpPresentation/Tests/Writer/ODPresentation/ObjectsChartTest.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function testComments()
$this->assertZipXmlAttributeEquals('ppt/commentAuthors.xml', $expectedElement, 'id', 0);
$this->assertZipXmlAttributeEquals('ppt/commentAuthors.xml', $expectedElement, 'name', $expectedName);
$this->assertZipXmlAttributeEquals('ppt/commentAuthors.xml', $expectedElement, 'initials', $expectedInitials);
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testWithoutComment()
{
$this->assertZipFileNotExists('ppt/commentAuthors.xml');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testWithoutCommentAuthor()
Expand All @@ -42,7 +42,7 @@ public function testWithoutCommentAuthor()
$this->oPresentation->getActiveSlide()->addShape($oComment);

$this->assertZipFileNotExists('ppt/commentAuthors.xml');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testWithSameAuthor()
Expand All @@ -61,6 +61,6 @@ public function testWithSameAuthor()
$this->assertZipFileExists('ppt/commentAuthors.xml');
$this->assertZipXmlElementExists('ppt/commentAuthors.xml', $expectedElement);
$this->assertZipXmlElementCount('ppt/commentAuthors.xml', $expectedElement, 1);
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DocPropsAppTest extends PhpPresentationTestCase
public function testRender()
{
$this->assertZipFileExists('docProps/app.xml');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testCompany()
Expand All @@ -29,6 +29,6 @@ public function testCompany()
$this->assertZipFileExists('docProps/app.xml');
$this->assertZipXmlElementExists('docProps/app.xml', '/Properties/Company');
$this->assertZipXmlElementEquals('docProps/app.xml', '/Properties/Company', $expected);
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function testRender()
{
$this->assertZipFileExists('docProps/core.xml');
$this->assertZipXmlElementNotExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testDocumentProperties()
Expand Down Expand Up @@ -40,7 +40,7 @@ public function testDocumentProperties()
$this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:keywords', $expected);
$this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:category');
$this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:category', $expected);
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testMarkAsFinalTrue()
Expand All @@ -49,14 +49,14 @@ public function testMarkAsFinalTrue()

$this->assertZipXmlElementExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
$this->assertZipXmlElementEquals('docProps/core.xml', '/cp:coreProperties/cp:contentStatus', 'Final');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testMarkAsFinalFalse()
{
$this->oPresentation->getPresentationProperties()->markAsFinal(false);

$this->assertZipXmlElementNotExists('docProps/core.xml', '/cp:coreProperties/cp:contentStatus');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function testRender()
{
$this->assertZipFileExists('docProps/custom.xml');
$this->assertZipXmlElementNotExists('docProps/custom.xml', '/Properties/property[@name="_MarkAsFinal"]');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testMarkAsFinalTrue()
Expand All @@ -23,14 +23,14 @@ public function testMarkAsFinalTrue()
$this->assertZipXmlElementExists('docProps/custom.xml', '/Properties/property');
$this->assertZipXmlElementExists('docProps/custom.xml', '/Properties/property[@pid="2"][@fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"][@name="_MarkAsFinal"]');
$this->assertZipXmlElementExists('docProps/custom.xml', '/Properties/property[@pid="2"][@fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"][@name="_MarkAsFinal"]/vt:bool');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testMarkAsFinalFalse()
{
$this->oPresentation->getPresentationProperties()->markAsFinal(false);

$this->assertZipXmlElementNotExists('docProps/custom.xml', '/Properties/property[@name="_MarkAsFinal"]');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DocPropsThumbnailTest extends PhpPresentationTestCase
public function testRender()
{
$this->assertZipFileNotExists('docProps/thumbnail.jpeg');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}

public function testFeatureThumbnail()
Expand All @@ -24,6 +24,6 @@ public function testFeatureThumbnail()

$this->oPresentation->getPresentationProperties()->setThumbnailPath($imagePath);
$this->assertZipFileExists('docProps/thumbnail.jpeg');
$this->assertIsSchemaOOXMLValid();
$this->assertIsSchemaECMA376Valid();
}
}
Loading

0 comments on commit 9e5b584

Please sign in to comment.