Skip to content

Commit

Permalink
Merge a5a2707 into 35f1155
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed May 20, 2017
2 parents 35f1155 + a5a2707 commit cf99c9d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -6,7 +6,8 @@
- PowerPoint2007 Writer : Write percentage values with a trailing percent sign instead of formatted as 1000th of a percent to comply with the standard - @k42b3 GH-307

### Features
- PowerPoint2007 Writer : Implemented XSD validation test case according to the ECMA/ISO standard - @k42b3 GH-307
- PowerPoint2007 Writer : Implement XSD validation test case according to the ECMA/ISO standard - @k42b3 GH-307
- PowerPoint2007 Writer : Implement visibility for axis - @kw-pr @Progi1984 GH-356

## 0.8.0 - 2017-04-03

Expand Down
24 changes: 12 additions & 12 deletions src/PhpPresentation/Shape/Chart/Axis.php
Expand Up @@ -101,9 +101,9 @@ class Axis implements ComparableInterface
protected $outline;

/**
* @var int
* @var boolean
*/
protected $delete = 0;
protected $isVisible = true;

/**
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
Expand Down Expand Up @@ -385,6 +385,7 @@ public function getHashIndex()
* while doing a write of a workbook and when changes are not allowed.
*
* @param string $value Hash index
* @return $this
*/
public function setHashIndex($value)
{
Expand All @@ -393,24 +394,23 @@ public function setHashIndex($value)
}

/**
* Axis deleted and not visible?
*
* @return int Hash index
* Axis is hidden ?
* @return boolean
*/
public function getDelete()
public function isVisible()
{
return $this->delete;
return $this->isVisible;
}

/**
* Remove an axis.
* 0 not deleted, 1 = deleted and not visible
* Hide an axis
*
* @param int $value delete
* @param boolean $value delete
* @return $this
*/
public function setDelete($value)
public function setIsVisible($value)
{
$this->delete = $value;
$this->isVisible = boolval($value);
return $this;
}
}
2 changes: 1 addition & 1 deletion src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
Expand Up @@ -2012,7 +2012,7 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, $typeAxis,

// $mainElement > c:delete
$objWriter->startElement('c:delete');
$objWriter->writeAttribute('val', $oAxis->getDelete());
$objWriter->writeAttribute('val', $oAxis->isVisible() ? '0' : '1');
$objWriter->endElement();

// $mainElement > c:axPos
Expand Down
10 changes: 10 additions & 0 deletions tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php
Expand Up @@ -96,6 +96,16 @@ public function testHashIndex()
$this->assertEquals($value, $object->getHashIndex());
}

public function testIsVisible()
{
$object = new Axis();
$this->assertTrue($object->isVisible());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis', $object->setIsVisible(false));
$this->assertFalse($object->isVisible());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Axis', $object->setIsVisible(true));
$this->assertTrue($object->isVisible());
}

public function testTitle()
{
$object = new Axis();
Expand Down
Expand Up @@ -165,6 +165,38 @@ public function testAxisOutline()
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', $expectedColorY);
}

public function testAxisVisibilityFalse()
{
$element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:delete';

$oSlide = $this->oPresentation->getActiveSlide();
$oShape = $oSlide->createChartShape();
$oLine = new Line();
$oShape->getPlotArea()->setType($oLine);

// Set Visible : FALSE
$this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(false));
$this->assertFalse($oShape->getPlotArea()->getAxisX()->isVisible());
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '1');
}

public function testAxisVisibilityTrue()
{
$element = '/c:chartSpace/c:chart/c:plotArea/c:catAx/c:delete';

$oSlide = $this->oPresentation->getActiveSlide();
$oShape = $oSlide->createChartShape();
$oLine = new Line();
$oShape->getPlotArea()->setType($oLine);

// Set Visible : TRUE
$this->assertInstanceOf('PhpOffice\PhpPresentation\Shape\Chart\Axis', $oShape->getPlotArea()->getAxisX()->setIsVisible(true));
$this->assertTrue($oShape->getPlotArea()->getAxisX()->isVisible());
$this->assertZipXmlElementExists('ppt/charts/' . $oShape->getIndexedFilename(), $element);
$this->assertZipXmlAttributeEquals('ppt/charts/' . $oShape->getIndexedFilename(), $element, 'val', '0');
}

public function testTypeArea()
{
$oSlide = $this->oPresentation->getActiveSlide();
Expand Down

0 comments on commit cf99c9d

Please sign in to comment.