Skip to content

Commit 3d9d26c

Browse files
authored
Merge pull request #339 from Progi1984/issue218
Features from Fork
2 parents 7db88c5 + ac58bac commit 3d9d26c

File tree

17 files changed

+580
-258
lines changed

17 files changed

+580
-258
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
- PowerPoint97 Reader : Support of Slide Note - @Progi1984 GH-226
1919
- PowerPoint2007 Reader : Support of Shape Table - @Progi1984 GH-240
2020
- PowerPoint2007 Reader : Support of Slide Note - @Progi1984 GH-226
21+
- PowerPoint2007 Reader : Support text direction in Alignment for Table - @Progi1984 GH-218
2122
- PowerPoint2007 Writer : Implement character spacing - @jvanoostrom GH-301
2223
- PowerPoint2007 Writer : Axis Bounds in Chart - @Progi1984 GH-269
23-
- PowerPoint2007 Writer : Implement Legend Key in Series for Chart - @Progi1984 GH-319
24+
- PowerPoint2007 Writer : Implement Legend Key in Series for Chart - @Progi1984 GH-319
25+
- PowerPoint2007 Writer : Support text direction in Alignment for Table - @SeregPie GH-218
26+
- PowerPoint2007 Writer : Support tick mark & unit in Axis for Chart - @Faab GH-218
27+
- PowerPoint2007 Writer : Support separator in Series for Chart - @jphchaput GH-218
2428
- Misc : Added two methods for setting Border & Fill in Legend - @Progi1984 GH-265
2529

2630
## 0.7.0 - 2016-09-12

docs/shapes_chart.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,34 @@ For resetting them, you pass null as parameter to these methods.
4848
$oShape->getPlotArea()->getAxisX()->setMinBounds(0);
4949
$oShape->getPlotArea()->getAxisX()->setMaxBounds(200);
5050
51+
For Axis Y, you can define tick mark with `setMinorTickMark` & `setMajorTickMark` methods.
52+
For resetting them, you pass Axis::TICK_MARK_NONE as parameter to these methods.
53+
54+
.. code-block:: php
55+
56+
use \PhpOffice\PhpPresentation\Shape\Chart\Axis;
57+
58+
$oLine = new Line();
59+
60+
$oShape = $oSlide->createChartShape();
61+
$oShape->getPlotArea()->setType($oLine);
62+
$oShape->getPlotArea()->getAxisY()->setMinorTickMark(Axis::TICK_MARK_NONE);
63+
$oShape->getPlotArea()->getAxisY()->setMajorTickMark(Axis::TICK_MARK_INSIDE);
64+
65+
For Axis Y, you can define unit with `setMinorUnit` & `setMajorUnit` methods.
66+
For resetting them, you pass null as parameter to these methods.
67+
68+
.. code-block:: php
69+
70+
use \PhpOffice\PhpPresentation\Shape\Chart\Axis;
71+
72+
$oLine = new Line();
73+
74+
$oShape = $oSlide->createChartShape();
75+
$oShape->getPlotArea()->setType($oLine);
76+
$oShape->getPlotArea()->getAxisY()->setMinorUnit(null);
77+
$oShape->getPlotArea()->getAxisY()->setMajorUnit(0.05);
78+
5179
Title
5280
^^^^^
5381

@@ -109,6 +137,7 @@ You can define if some informations are displayed.
109137
.. code-block:: php
110138
111139
$oSeries = new Series('Downloads', $seriesData);
140+
$oSeries->setSeparator(';');
112141
$oSeries->setShowCategoryName(true);
113142
$oSeries->setShowLeaderLines(true);
114143
$oSeries->setShowLegendKey(true);

docs/shapes_table.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,25 @@ For defining margins of cell, you can use the `setMargin*` method of a Alignment
6666
->setMarginTop(80);
6767
6868
69+
Define the text direction of a cell
70+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71+
For defining the text direction of cell, you can use the `setTextDirection` method of the `getAlignment` method of a Cell object.
72+
The width is in pixels.
73+
74+
.. code-block:: php
75+
76+
$tableShape = $slide->createTableShape($columns);
77+
$row = $tableShape->createRow();
78+
$cellA1 = $row->nextCell();
79+
$cellA1->getAlignment()->setTextDirection(\PhpOffice\PhpPresentation\Style\Alignment::TEXT_DIRECTION_VERTICAL_270);
80+
81+
6982
Define the width of a cell
7083
~~~~~~~~~~~~~~~~~~~~~~~~~~
7184
The width of cells are defined by the width of cell of the first row.
7285
If not defined, all cells widths are calculated from the width of the shape and the number of columns.
7386

74-
For defining the width of cell, you can use the `setWidth` method of a Cell object.
87+
For defining the width of cell, you can use the `setWidth` method of a Cell object.
7588
The width is in pixels.
7689

7790
.. code-block:: php

phpmd.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<!-- PptSlides needs more coupling (default: 13) -->
2121
<!-- Writer/Office2007/AbstractSlide needs more coupling (default: 13) -->
2222
<properties>
23-
<property name="minimum" value="32" />
23+
<property name="minimum" value="35" />
2424
</properties>
2525
</rule>
2626
<rule ref="rulesets/design.xml/NumberOfChildren">

samples/Sample_04_Table.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@
7979
->setStartColor(new Color('FFE06B20'))
8080
->setEndColor(new Color('FFE06B20'));
8181
$row->nextCell()->createTextRun('R2C1');
82-
$row->getCell()->getActiveParagraph()->getAlignment()->setMarginLeft(30);
82+
$row->getCell()->getActiveParagraph()->getAlignment()
83+
->setMarginLeft(30)
84+
->setTextDirection(\PhpOffice\PhpPresentation\Style\Alignment::TEXT_DIRECTION_VERTICAL_270);
8385
$row->nextCell()->createTextRun('R2C2');
8486
$row->nextCell()->createTextRun('R2C3');
8587

src/PhpPresentation/Reader/PowerPoint2007.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,9 @@ protected function loadShapeTable(XMLReader $document, \DOMElement $node, Abstra
947947
if ($oElementTcPr instanceof \DOMElement) {
948948
$numParagraphs = count($oCell->getParagraphs());
949949
if ($numParagraphs > 0) {
950+
if ($oElementTcPr->hasAttribute('vert')) {
951+
$oCell->getParagraph(0)->getAlignment()->setTextDirection($oElementTcPr->getAttribute('vert'));
952+
}
950953
if ($oElementTcPr->hasAttribute('anchor')) {
951954
$oCell->getParagraph(0)->getAlignment()->setVertical($oElementTcPr->getAttribute('anchor'));
952955
}

src/PhpPresentation/Shape/Chart/Axis.php

Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class Axis implements ComparableInterface
2828
const AXIS_X = 'x';
2929
const AXIS_Y = 'y';
3030

31+
const TICK_MARK_NONE = 'none';
32+
const TICK_MARK_CROSS = 'cross';
33+
const TICK_MARK_INSIDE = 'in';
34+
const TICK_MARK_OUTSIDE = 'out';
35+
3136
/**
3237
* Title
3338
*
@@ -69,6 +74,26 @@ class Axis implements ComparableInterface
6974
*/
7075
protected $maxBounds;
7176

77+
/**
78+
* @var string
79+
*/
80+
protected $minorTickMark = self::TICK_MARK_NONE;
81+
82+
/**
83+
* @var string
84+
*/
85+
protected $majorTickMark = self::TICK_MARK_NONE;
86+
87+
/**
88+
* @var float
89+
*/
90+
protected $minorUnit;
91+
92+
/**
93+
* @var float
94+
*/
95+
protected $majorUnit;
96+
7297
/**
7398
* Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
7499
*
@@ -149,6 +174,42 @@ public function setFormatCode($value = '')
149174
return $this;
150175
}
151176

177+
/**
178+
* @return int|null
179+
*/
180+
public function getMinBounds()
181+
{
182+
return $this->minBounds;
183+
}
184+
185+
/**
186+
* @param int|null $minBounds
187+
* @return Axis
188+
*/
189+
public function setMinBounds($minBounds = null)
190+
{
191+
$this->minBounds = is_null($minBounds) ? null : (int)$minBounds;
192+
return $this;
193+
}
194+
195+
/**
196+
* @return int|null
197+
*/
198+
public function getMaxBounds()
199+
{
200+
return $this->maxBounds;
201+
}
202+
203+
/**
204+
* @param int|null $maxBounds
205+
* @return Axis
206+
*/
207+
public function setMaxBounds($maxBounds = null)
208+
{
209+
$this->maxBounds = is_null($maxBounds) ? null : (int)$maxBounds;
210+
return $this;
211+
}
212+
152213
/**
153214
* @return Gridlines
154215
*/
@@ -186,38 +247,74 @@ public function setMinorGridlines(Gridlines $minorGridlines)
186247
}
187248

188249
/**
189-
* @return int|null
250+
* @return string
190251
*/
191-
public function getMinBounds()
252+
public function getMinorTickMark()
192253
{
193-
return $this->minBounds;
254+
return $this->minorTickMark;
194255
}
195256

196257
/**
197-
* @param int|null $minBounds
258+
* @param string $pTickMark
198259
* @return Axis
199260
*/
200-
public function setMinBounds($minBounds = null)
261+
public function setMinorTickMark($pTickMark = self::TICK_MARK_NONE)
201262
{
202-
$this->minBounds = is_null($minBounds) ? null : (int) $minBounds;
263+
$this->minorTickMark = $pTickMark;
203264
return $this;
204265
}
205266

206267
/**
207-
* @return int|null
268+
* @return string
208269
*/
209-
public function getMaxBounds()
270+
public function getMajorTickMark()
210271
{
211-
return $this->maxBounds;
272+
return $this->majorTickMark;
212273
}
213274

214275
/**
215-
* @param int|null $maxBounds
276+
* @param string $pTickMark
216277
* @return Axis
217278
*/
218-
public function setMaxBounds($maxBounds = null)
279+
public function setMajorTickMark($pTickMark = self::TICK_MARK_NONE)
280+
{
281+
$this->majorTickMark = $pTickMark;
282+
return $this;
283+
}
284+
285+
/**
286+
* @return float
287+
*/
288+
public function getMinorUnit()
289+
{
290+
return $this->minorUnit;
291+
}
292+
293+
/**
294+
* @param float $pUnit
295+
* @return Axis
296+
*/
297+
public function setMinorUnit($pUnit = null)
298+
{
299+
$this->minorUnit = $pUnit;
300+
return $this;
301+
}
302+
303+
/**
304+
* @return float
305+
*/
306+
public function getMajorUnit()
307+
{
308+
return $this->majorUnit;
309+
}
310+
311+
/**
312+
* @param float $pUnit
313+
* @return Axis
314+
*/
315+
public function setMajorUnit($pUnit = null)
219316
{
220-
$this->maxBounds = is_null($maxBounds) ? null : (int) $maxBounds;
317+
$this->majorUnit = $pUnit;
221318
return $this;
222319
}
223320

0 commit comments

Comments
 (0)