Skip to content

Commit

Permalink
Merge pull request #377 from PHPOffice/develop
Browse files Browse the repository at this point in the history
Release 0.9.0
  • Loading branch information
Progi1984 authored Jul 5, 2017
2 parents 14b52bd f71a4a2 commit 1fcc840
Show file tree
Hide file tree
Showing 48 changed files with 17,917 additions and 146 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 1,18 @@
# Changelog

## 0.9.0 - 2017-07-05

### Bugfix
- PowerPoint2007 Writer : Margins in table cell - @Progi1984 GH-347

### Changes
- 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 visibility for axis - @kw-pr @Progi1984 GH-356
- PowerPoint2007 Writer : Implement gap width in Bar(3D) Charts - @Progi1984 GH-358

## 0.8.0 - 2017-04-03

### Bugfix
Expand Down
21 changes: 21 additions & 0 deletions docs/shapes_chart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 87,16 @@ For resetting them, you pass null as parameter to these methods.
$oShape->getPlotArea()->getAxisY()->setMinorUnit(null);
$oShape->getPlotArea()->getAxisY()->setMajorUnit(0.05);
You can define visibility for each axis (X & Y).

.. code-block:: php
$oLine = new Line();
$oShape = $oSlide->createChartShape();
$oShape->getPlotArea()->setType($oLine);
$oShape->getPlotArea()->getAxisX()->setIsVisible(false);
Title
^^^^^

Expand Down Expand Up @@ -176,6 186,17 @@ TODO
Bar & Bar3D
^^^^^^^^^^^

Gap Width
"""""""""

You can define the gap width between bar or columns clusters. It is defined in percent.
The default value is 150%. The value must be defined between 0 and 500.

.. code-block:: php
$oBarChart = new Bar();
$oBarChart->setGapWidthPercent(250);
Stacking
""""""""

Expand Down
1 change: 1 addition & 0 deletions docs/shapes_table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 51,7 @@ You can access cell object directly.
Define margins of a cell
~~~~~~~~~~~~~~~~~~~~~~~~
Margins of cells are defined by margins of the first paragraph of cell.
Margins of cells are defined in pixels.

For defining margins of cell, you can use the `setMargin*` method of a Alignment object of the active paragraph of a Cell object.

Expand Down
38 changes: 26 additions & 12 deletions samples/Sample_04_Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 61,13 @@
->setRotation(90)
->setStartColor(new Color('FFE06B20'))
->setEndColor(new Color('FFFFFFFF'));
$row->nextCell()->createTextRun('R1C1')->getFont()->setBold(true);
$row->getCell()->getActiveParagraph()->getAlignment()->setMarginLeft(20);
$row->nextCell()->createTextRun('R1C2')->getFont()->setBold(true);
$row->nextCell()->createTextRun('R1C3')->getFont()->setBold(true);
$oCell = $row->nextCell();
$oCell->createTextRun('R1C1')->getFont()->setBold(true);
$oCell->getActiveParagraph()->getAlignment()->setMarginLeft(20);
$oCell = $row->nextCell();
$oCell->createTextRun('R1C2')->getFont()->setBold(true);
$oCell = $row->nextCell();
$oCell->createTextRun('R1C3')->getFont()->setBold(true);

foreach ($row->getCells() as $cell) {
$cell->getBorders()->getTop()->setLineWidth(4)
Expand All @@ -78,23 81,34 @@
$row->getFill()->setFillType(Fill::FILL_SOLID)
->setStartColor(new Color('FFE06B20'))
->setEndColor(new Color('FFE06B20'));
$row->nextCell()->createTextRun('R2C1');
$row->getCell()->getActiveParagraph()->getAlignment()
$oCell = $row->nextCell();
$oCell->createTextRun('R2C1');
$oCell->getActiveParagraph()->getAlignment()
->setMarginLeft(30)
->setTextDirection(\PhpOffice\PhpPresentation\Style\Alignment::TEXT_DIRECTION_VERTICAL_270);
$row->nextCell()->createTextRun('R2C2');
$row->nextCell()->createTextRun('R2C3');
$oCell = $row->nextCell();
$oCell->createTextRun('R2C2');
$oCell->getActiveParagraph()->getAlignment()
->setMarginBottom(10)
->setMarginTop(20)
->setMarginRight(30)
->setMarginLeft(40);
$oCell = $row->nextCell();
$oCell->createTextRun('R2C3');

// Add row
echo date('H:i:s') . ' Add row'.EOL;
$row = $shape->createRow();
$row->getFill()->setFillType(Fill::FILL_SOLID)
->setStartColor(new Color('FFE06B20'))
->setEndColor(new Color('FFE06B20'));
$row->nextCell()->createTextRun('R3C1');
$row->getCell()->getActiveParagraph()->getAlignment()->setMarginLeft(40);
$row->nextCell()->createTextRun('R3C2');
$row->nextCell()->createTextRun('R3C3');
$oCell = $row->nextCell();
$oCell->createTextRun('R3C1');
$oCell->getActiveParagraph()->getAlignment()->setMarginLeft(40);
$oCell = $row->nextCell();
$oCell->createTextRun('R3C2');
$oCell = $row->nextCell();
$oCell->createTextRun('R3C3');

// Add row
echo date('H:i:s') . ' Add row'.EOL;
Expand Down
1 change: 1 addition & 0 deletions samples/Sample_05_Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 82,7 @@ function fnSlide_Bar(PhpPresentation $objPHPPresentation) {
// Create a bar chart (that should be inserted in a shape)
echo date('H:i:s') . ' Create a bar chart (that should be inserted in a chart shape)'.EOL;
$barChart = new Bar();
$barChart->setGapWidthPercent(158);
$series1 = new Series('2009', $series1Data);
$series1->setShowSeriesName(true);
$series1->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4F81BD'));
Expand Down
27 changes: 27 additions & 0 deletions src/PhpPresentation/Shape/Chart/Axis.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 100,11 @@ class Axis implements ComparableInterface
*/
protected $outline;

/**
* @var boolean
*/
protected $isVisible = true;

/**
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
*
Expand Down Expand Up @@ -380,10 385,32 @@ 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)
{
$this->hashIndex = $value;
return $this;
}

/**
* Axis is hidden ?
* @return boolean
*/
public function isVisible()
{
return $this->isVisible;
}

/**
* Hide an axis
*
* @param boolean $value delete
* @return $this
*/
public function setIsVisible($value)
{
$this->isVisible = (bool)$value;
return $this;
}
}
32 changes: 32 additions & 0 deletions src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 48,14 @@ class AbstractTypeBar extends AbstractType
protected $barGrouping = self::GROUPING_CLUSTERED;


/**
* Space between bar or columns clusters
*
* @var int
*/
protected $gapWidthPercent = 150;


/**
* Set bar orientation
*
Expand Down Expand Up @@ -91,6 99,30 @@ public function getBarGrouping()
{
return $this->barGrouping;
}

/**
* @return int
*/
public function getGapWidthPercent()
{
return $this->gapWidthPercent;
}

/**
* @param int $gapWidthPercent
* @return $this
*/
public function setGapWidthPercent($gapWidthPercent)
{
if ($gapWidthPercent < 0) {
$gapWidthPercent = 0;
}
if ($gapWidthPercent > 500) {
$gapWidthPercent = 500;
}
$this->gapWidthPercent = $gapWidthPercent;
return $this;
}

/**
* Get hash code
Expand Down
5 changes: 3 additions & 2 deletions src/PhpPresentation/Writer/AbstractWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 96,12 @@ protected function allDrawings()
// Get an array of all drawings
$aDrawings = array();

// Loop trough PhpPresentation
foreach ($this->getPhpPresentation()->getAllSlides() as $oSlide) {
// Loop through PhpPresentation
foreach (array_merge($this->getPhpPresentation()->getAllSlides(), $this->getPhpPresentation()->getAllMasterSlides()) as $oSlide) {
$arrayReturn = $this->iterateCollection($oSlide->getShapeCollection()->getIterator());
$aDrawings = array_merge($aDrawings, $arrayReturn);
}

return $aDrawings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 130,7 @@ protected function writeColor(XMLWriter $objWriter, Color $color, $alpha = null)

// a:alpha
$objWriter->startElement('a:alpha');
$objWriter->writeAttribute('val', $alpha * 1000);
$objWriter->writeAttribute('val', $alpha . '%');
$objWriter->endElement();

$objWriter->endElement();
Expand Down Expand Up @@ -202,13 202,13 @@ protected function writeGradientFill(XMLWriter $objWriter, Fill $pFill)
$objWriter->startElement('a:gsLst');
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '0');
$objWriter->writeAttribute('pos', '0%');
$this->writeColor($objWriter, $pFill->getStartColor());
$objWriter->endElement();

// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '100000');
$objWriter->writeAttribute('pos', '100%');
$this->writeColor($objWriter, $pFill->getEndColor());
$objWriter->endElement();

Expand Down
12 changes: 7 additions & 5 deletions src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 108,8 @@ protected function writeDrawingRelations(AbstractSlideAlias $pSlideMaster, $objW
$iterator->next();
}
}

return $relId;
}

/**
Expand Down Expand Up @@ -451,10 453,10 @@ protected function writeShapeTable(XMLWriter $objWriter, ShapeTable $shape, $sha
}

// Margins
$objWriter->writeAttribute('marL', $firstParagraphAlignment->getMarginLeft());
$objWriter->writeAttribute('marR', $firstParagraphAlignment->getMarginRight());
$objWriter->writeAttribute('marT', $firstParagraphAlignment->getMarginTop());
$objWriter->writeAttribute('marB', $firstParagraphAlignment->getMarginBottom());
$objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginLeft()));
$objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginRight()));
$objWriter->writeAttribute('marT', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginTop()));
$objWriter->writeAttribute('marB', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginBottom()));

// Determine borders
$borderLeft = $currentCell->getBorders()->getLeft();
Expand Down Expand Up @@ -521,7 523,7 @@ protected function writeParagraphs(XMLWriter $objWriter, $paragraphs, $bIsPlaceh

$objWriter->startElement('a:lnSpc');
$objWriter->startElement('a:spcPct');
$objWriter->writeAttribute('val', $paragraph->getLineSpacing() * 1000);
$objWriter->writeAttribute('val', $paragraph->getLineSpacing() . "%");
$objWriter->endElement();
$objWriter->endElement();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 306,7 @@ public function __construct()
<p:bodyStyle>
<a:lvl1pPr marL="342900" indent="-342900" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000" />
<a:spcPct val="20%" />
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0" />
<a:buChar char="&#149;" />
Expand All @@ -321,7 321,7 @@ public function __construct()
</a:lvl1pPr>
<a:lvl2pPr marL="742950" indent="-285750" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000" />
<a:spcPct val="20%" />
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0" />
<a:buChar char="-" />
Expand All @@ -336,7 336,7 @@ public function __construct()
</a:lvl2pPr>
<a:lvl3pPr marL="1143000" indent="-228600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000" />
<a:spcPct val="20%" />
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0" />
<a:buChar char="&#149;" />
Expand All @@ -351,7 351,7 @@ public function __construct()
</a:lvl3pPr>
<a:lvl4pPr marL="1600200" indent="-228600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000" />
<a:spcPct val="20%" />
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0" />
<a:buChar char="-" />
Expand All @@ -366,7 366,7 @@ public function __construct()
</a:lvl4pPr>
<a:lvl5pPr marL="2057400" indent="-228600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000" />
<a:spcPct val="20%" />
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0" />
<a:buChar char="&#187;" />
Expand All @@ -381,7 381,7 @@ public function __construct()
</a:lvl5pPr>
<a:lvl6pPr marL="2514600" indent="-228600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000" />
<a:spcPct val="20%" />
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0" />
<a:buChar char="&#149;" />
Expand All @@ -396,7 396,7 @@ public function __construct()
</a:lvl6pPr>
<a:lvl7pPr marL="2971800" indent="-228600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000" />
<a:spcPct val="20%" />
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0" />
<a:buChar char="&#149;" />
Expand All @@ -411,7 411,7 @@ public function __construct()
</a:lvl7pPr>
<a:lvl8pPr marL="3429500" indent="-228600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000" />
<a:spcPct val="20%" />
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0" />
<a:buChar char="&#149;" />
Expand All @@ -426,7 426,7 @@ public function __construct()
</a:lvl8pPr>
<a:lvl9pPr marL="3886200" indent="-228600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
<a:spcBef>
<a:spcPct val="20000" />
<a:spcPct val="20%" />
</a:spcBef>
<a:buFont typeface="Arial" pitchFamily="34" charset="0" />
<a:buChar char="&#149;" />
Expand Down Expand Up @@ -794,7 794,7 @@ public function __construct()
</a:gs>
<a:gs pos="100000">
<a:schemeClr val="phClr">
<a:shade val="20000"/>
<a:shade val="20%"/>
<a:satMod val="255000"/>
</a:schemeClr>
</a:gs>
Expand Down
Loading

0 comments on commit 1fcc840

Please sign in to comment.