Skip to content

Commit 1fcc840

Browse files
authored
Merge pull request #377 from PHPOffice/develop
Release 0.9.0
2 parents 14b52bd + f71a4a2 commit 1fcc840

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+17917
-146
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## 0.9.0 - 2017-07-05
4+
5+
### Bugfix
6+
- PowerPoint2007 Writer : Margins in table cell - @Progi1984 GH-347
7+
8+
### Changes
9+
- 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
10+
11+
### Features
12+
- PowerPoint2007 Writer : Implemented XSD validation test case according to the ECMA/ISO standard - @k42b3 GH-307
13+
- PowerPoint2007 Writer : Implement visibility for axis - @kw-pr @Progi1984 GH-356
14+
- PowerPoint2007 Writer : Implement gap width in Bar(3D) Charts - @Progi1984 GH-358
15+
316
## 0.8.0 - 2017-04-03
417

518
### Bugfix

docs/shapes_chart.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ For resetting them, you pass null as parameter to these methods.
8787
$oShape->getPlotArea()->getAxisY()->setMinorUnit(null);
8888
$oShape->getPlotArea()->getAxisY()->setMajorUnit(0.05);
8989
90+
You can define visibility for each axis (X & Y).
91+
92+
.. code-block:: php
93+
94+
$oLine = new Line();
95+
96+
$oShape = $oSlide->createChartShape();
97+
$oShape->getPlotArea()->setType($oLine);
98+
$oShape->getPlotArea()->getAxisX()->setIsVisible(false);
99+
90100
Title
91101
^^^^^
92102

@@ -176,6 +186,17 @@ TODO
176186
Bar & Bar3D
177187
^^^^^^^^^^^
178188

189+
Gap Width
190+
"""""""""
191+
192+
You can define the gap width between bar or columns clusters. It is defined in percent.
193+
The default value is 150%. The value must be defined between 0 and 500.
194+
195+
.. code-block:: php
196+
197+
$oBarChart = new Bar();
198+
$oBarChart->setGapWidthPercent(250);
199+
179200
Stacking
180201
""""""""
181202

docs/shapes_table.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ You can access cell object directly.
5151
Define margins of a cell
5252
~~~~~~~~~~~~~~~~~~~~~~~~
5353
Margins of cells are defined by margins of the first paragraph of cell.
54+
Margins of cells are defined in pixels.
5455

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

samples/Sample_04_Table.php

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@
6161
->setRotation(90)
6262
->setStartColor(new Color('FFE06B20'))
6363
->setEndColor(new Color('FFFFFFFF'));
64-
$row->nextCell()->createTextRun('R1C1')->getFont()->setBold(true);
65-
$row->getCell()->getActiveParagraph()->getAlignment()->setMarginLeft(20);
66-
$row->nextCell()->createTextRun('R1C2')->getFont()->setBold(true);
67-
$row->nextCell()->createTextRun('R1C3')->getFont()->setBold(true);
64+
$oCell = $row->nextCell();
65+
$oCell->createTextRun('R1C1')->getFont()->setBold(true);
66+
$oCell->getActiveParagraph()->getAlignment()->setMarginLeft(20);
67+
$oCell = $row->nextCell();
68+
$oCell->createTextRun('R1C2')->getFont()->setBold(true);
69+
$oCell = $row->nextCell();
70+
$oCell->createTextRun('R1C3')->getFont()->setBold(true);
6871

6972
foreach ($row->getCells() as $cell) {
7073
$cell->getBorders()->getTop()->setLineWidth(4)
@@ -78,23 +81,34 @@
7881
$row->getFill()->setFillType(Fill::FILL_SOLID)
7982
->setStartColor(new Color('FFE06B20'))
8083
->setEndColor(new Color('FFE06B20'));
81-
$row->nextCell()->createTextRun('R2C1');
82-
$row->getCell()->getActiveParagraph()->getAlignment()
84+
$oCell = $row->nextCell();
85+
$oCell->createTextRun('R2C1');
86+
$oCell->getActiveParagraph()->getAlignment()
8387
->setMarginLeft(30)
8488
->setTextDirection(\PhpOffice\PhpPresentation\Style\Alignment::TEXT_DIRECTION_VERTICAL_270);
85-
$row->nextCell()->createTextRun('R2C2');
86-
$row->nextCell()->createTextRun('R2C3');
89+
$oCell = $row->nextCell();
90+
$oCell->createTextRun('R2C2');
91+
$oCell->getActiveParagraph()->getAlignment()
92+
->setMarginBottom(10)
93+
->setMarginTop(20)
94+
->setMarginRight(30)
95+
->setMarginLeft(40);
96+
$oCell = $row->nextCell();
97+
$oCell->createTextRun('R2C3');
8798

8899
// Add row
89100
echo date('H:i:s') . ' Add row'.EOL;
90101
$row = $shape->createRow();
91102
$row->getFill()->setFillType(Fill::FILL_SOLID)
92103
->setStartColor(new Color('FFE06B20'))
93104
->setEndColor(new Color('FFE06B20'));
94-
$row->nextCell()->createTextRun('R3C1');
95-
$row->getCell()->getActiveParagraph()->getAlignment()->setMarginLeft(40);
96-
$row->nextCell()->createTextRun('R3C2');
97-
$row->nextCell()->createTextRun('R3C3');
105+
$oCell = $row->nextCell();
106+
$oCell->createTextRun('R3C1');
107+
$oCell->getActiveParagraph()->getAlignment()->setMarginLeft(40);
108+
$oCell = $row->nextCell();
109+
$oCell->createTextRun('R3C2');
110+
$oCell = $row->nextCell();
111+
$oCell->createTextRun('R3C3');
98112

99113
// Add row
100114
echo date('H:i:s') . ' Add row'.EOL;

samples/Sample_05_Chart.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function fnSlide_Bar(PhpPresentation $objPHPPresentation) {
8282
// Create a bar chart (that should be inserted in a shape)
8383
echo date('H:i:s') . ' Create a bar chart (that should be inserted in a chart shape)'.EOL;
8484
$barChart = new Bar();
85+
$barChart->setGapWidthPercent(158);
8586
$series1 = new Series('2009', $series1Data);
8687
$series1->setShowSeriesName(true);
8788
$series1->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4F81BD'));

src/PhpPresentation/Shape/Chart/Axis.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ class Axis implements ComparableInterface
100100
*/
101101
protected $outline;
102102

103+
/**
104+
* @var boolean
105+
*/
106+
protected $isVisible = true;
107+
103108
/**
104109
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
105110
*
@@ -380,10 +385,32 @@ public function getHashIndex()
380385
* while doing a write of a workbook and when changes are not allowed.
381386
*
382387
* @param string $value Hash index
388+
* @return $this
383389
*/
384390
public function setHashIndex($value)
385391
{
386392
$this->hashIndex = $value;
387393
return $this;
388394
}
395+
396+
/**
397+
* Axis is hidden ?
398+
* @return boolean
399+
*/
400+
public function isVisible()
401+
{
402+
return $this->isVisible;
403+
}
404+
405+
/**
406+
* Hide an axis
407+
*
408+
* @param boolean $value delete
409+
* @return $this
410+
*/
411+
public function setIsVisible($value)
412+
{
413+
$this->isVisible = (bool)$value;
414+
return $this;
415+
}
389416
}

src/PhpPresentation/Shape/Chart/Type/AbstractTypeBar.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ class AbstractTypeBar extends AbstractType
4848
protected $barGrouping = self::GROUPING_CLUSTERED;
4949

5050

51+
/**
52+
* Space between bar or columns clusters
53+
*
54+
* @var int
55+
*/
56+
protected $gapWidthPercent = 150;
57+
58+
5159
/**
5260
* Set bar orientation
5361
*
@@ -91,6 +99,30 @@ public function getBarGrouping()
9199
{
92100
return $this->barGrouping;
93101
}
102+
103+
/**
104+
* @return int
105+
*/
106+
public function getGapWidthPercent()
107+
{
108+
return $this->gapWidthPercent;
109+
}
110+
111+
/**
112+
* @param int $gapWidthPercent
113+
* @return $this
114+
*/
115+
public function setGapWidthPercent($gapWidthPercent)
116+
{
117+
if ($gapWidthPercent < 0) {
118+
$gapWidthPercent = 0;
119+
}
120+
if ($gapWidthPercent > 500) {
121+
$gapWidthPercent = 500;
122+
}
123+
$this->gapWidthPercent = $gapWidthPercent;
124+
return $this;
125+
}
94126

95127
/**
96128
* Get hash code

src/PhpPresentation/Writer/AbstractWriter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ protected function allDrawings()
9696
// Get an array of all drawings
9797
$aDrawings = array();
9898

99-
// Loop trough PhpPresentation
100-
foreach ($this->getPhpPresentation()->getAllSlides() as $oSlide) {
99+
// Loop through PhpPresentation
100+
foreach (array_merge($this->getPhpPresentation()->getAllSlides(), $this->getPhpPresentation()->getAllMasterSlides()) as $oSlide) {
101101
$arrayReturn = $this->iterateCollection($oSlide->getShapeCollection()->getIterator());
102102
$aDrawings = array_merge($aDrawings, $arrayReturn);
103103
}
104+
104105
return $aDrawings;
105106
}
106107

src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function writeColor(XMLWriter $objWriter, Color $color, $alpha = null)
130130

131131
// a:alpha
132132
$objWriter->startElement('a:alpha');
133-
$objWriter->writeAttribute('val', $alpha * 1000);
133+
$objWriter->writeAttribute('val', $alpha . '%');
134134
$objWriter->endElement();
135135

136136
$objWriter->endElement();
@@ -202,13 +202,13 @@ protected function writeGradientFill(XMLWriter $objWriter, Fill $pFill)
202202
$objWriter->startElement('a:gsLst');
203203
// a:gs
204204
$objWriter->startElement('a:gs');
205-
$objWriter->writeAttribute('pos', '0');
205+
$objWriter->writeAttribute('pos', '0%');
206206
$this->writeColor($objWriter, $pFill->getStartColor());
207207
$objWriter->endElement();
208208

209209
// a:gs
210210
$objWriter->startElement('a:gs');
211-
$objWriter->writeAttribute('pos', '100000');
211+
$objWriter->writeAttribute('pos', '100%');
212212
$this->writeColor($objWriter, $pFill->getEndColor());
213213
$objWriter->endElement();
214214

src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ protected function writeDrawingRelations(AbstractSlideAlias $pSlideMaster, $objW
108108
$iterator->next();
109109
}
110110
}
111+
112+
return $relId;
111113
}
112114

113115
/**
@@ -451,10 +453,10 @@ protected function writeShapeTable(XMLWriter $objWriter, ShapeTable $shape, $sha
451453
}
452454

453455
// Margins
454-
$objWriter->writeAttribute('marL', $firstParagraphAlignment->getMarginLeft());
455-
$objWriter->writeAttribute('marR', $firstParagraphAlignment->getMarginRight());
456-
$objWriter->writeAttribute('marT', $firstParagraphAlignment->getMarginTop());
457-
$objWriter->writeAttribute('marB', $firstParagraphAlignment->getMarginBottom());
456+
$objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginLeft()));
457+
$objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginRight()));
458+
$objWriter->writeAttribute('marT', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginTop()));
459+
$objWriter->writeAttribute('marB', CommonDrawing::pixelsToEmu($firstParagraphAlignment->getMarginBottom()));
458460

459461
// Determine borders
460462
$borderLeft = $currentCell->getBorders()->getLeft();
@@ -521,7 +523,7 @@ protected function writeParagraphs(XMLWriter $objWriter, $paragraphs, $bIsPlaceh
521523

522524
$objWriter->startElement('a:lnSpc');
523525
$objWriter->startElement('a:spcPct');
524-
$objWriter->writeAttribute('val', $paragraph->getLineSpacing() * 1000);
526+
$objWriter->writeAttribute('val', $paragraph->getLineSpacing() . "%");
525527
$objWriter->endElement();
526528
$objWriter->endElement();
527529

0 commit comments

Comments
 (0)