Completed
Pull Request — develop (#402)
by Franck
08:56
created

ObjectsChart::writeLegend()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 32
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 27
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 32
ccs 27
cts 27
cp 1
rs 8.439
cc 6
eloc 25
nc 6
nop 1
crap 6
1
<?php
2
3
namespace PhpOffice\PhpPresentation\Writer\ODPresentation;
4
5
use PhpOffice\Common\Adapter\Zip\ZipInterface;
6
use PhpOffice\Common\Drawing as CommonDrawing;
7
use PhpOffice\Common\Text;
8
use PhpOffice\Common\XMLWriter;
9
use PhpOffice\PhpPresentation\Shape\Chart;
10
use PhpOffice\PhpPresentation\Shape\Chart\Title;
11
use PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypeBar;
12
use PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractTypePie;
13
use PhpOffice\PhpPresentation\Shape\Chart\Type\Area;
14
use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar;
15
use PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D;
16
use PhpOffice\PhpPresentation\Shape\Chart\Type\Doughnut;
17
use PhpOffice\PhpPresentation\Shape\Chart\Type\Line;
18
use PhpOffice\PhpPresentation\Shape\Chart\Type\Pie3D;
19
use PhpOffice\PhpPresentation\Shape\Chart\Type\Scatter;
20
use PhpOffice\PhpPresentation\Style\Fill;
21
use PhpOffice\PhpPresentation\Style\Outline;
22
23
class ObjectsChart extends AbstractDecoratorWriter
24
{
25
    /**
26
     * @var XMLWriter
27
     */
28
    protected $xmlContent;
29
    /**
30
     * @var mixed
31
     */
32
    protected $arrayData;
33
    /**
34
     * @var mixed
35
     */
36
    protected $arrayTitle;
37
    /**
38
     * @var integer
39
     */
40
    protected $numData;
41
    /**
42
     * @var integer
43
     */
44
    protected $numSeries;
45
    /**
46
     * @var string
47
     */
48
    protected $rangeCol;
49
50
    /**
51
     * @return ZipInterface
52
     */
53 60
    public function render()
54
    {
55 60
        foreach ($this->getArrayChart() as $keyChart => $shapeChart) {
56 24
            $content = $this->writeContentPart($shapeChart);
57
58 24
            if (!empty($content)) {
59 24
                $this->getZip()->addFromString('Object '.$keyChart.'/content.xml', $content);
60 24
            }
61 60
        }
62
63 60
        return $this->getZip();
64
    }
65
66
    /**
67
     * @param Chart $chart
68
     * @return string
69
     * @throws \Exception
70
     */
71 24
    protected function writeContentPart(Chart $chart)
72
    {
73 24
        $this->xmlContent = new XMLWriter(XMLWriter::STORAGE_MEMORY);
74
75 24
        $chartType = $chart->getPlotArea()->getType();
76
77
        // Data
78 24
        $this->arrayData = array();
79 24
        $this->arrayTitle = array();
80 24
        $this->numData = 0;
81 24
        foreach ($chartType->getSeries() as $series) {
82 22
            $inc = 0;
83 22
            $this->arrayTitle[] = $series->getTitle();
84 22
            foreach ($series->getValues() as $key => $value) {
85 22
                if (!isset($this->arrayData[$inc])) {
86 22
                    $this->arrayData[$inc] = array();
87 22
                }
88 22
                if (empty($this->arrayData[$inc])) {
89 22
                    $this->arrayData[$inc][] = $key;
90 22
                }
91 22
                $this->arrayData[$inc][] = $value;
92 22
                $inc++;
93 22
            }
94 22
            if ($inc > $this->numData) {
95 22
                $this->numData = $inc;
96 22
            }
97 24
        }
98
99
        // office:document-content
100 24
        $this->xmlContent->startElement('office:document-content');
101 24
        $this->xmlContent->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
102 24
        $this->xmlContent->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
103 24
        $this->xmlContent->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
104 24
        $this->xmlContent->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
105 24
        $this->xmlContent->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
106 24
        $this->xmlContent->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
107 24
        $this->xmlContent->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
108 24
        $this->xmlContent->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
109 24
        $this->xmlContent->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
110 24
        $this->xmlContent->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
111 24
        $this->xmlContent->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
112 24
        $this->xmlContent->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
113 24
        $this->xmlContent->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
114 24
        $this->xmlContent->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
115 24
        $this->xmlContent->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
116 24
        $this->xmlContent->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
117 24
        $this->xmlContent->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
118 24
        $this->xmlContent->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
119 24
        $this->xmlContent->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
120 24
        $this->xmlContent->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
121 24
        $this->xmlContent->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
122 24
        $this->xmlContent->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
123 24
        $this->xmlContent->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
124 24
        $this->xmlContent->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
125 24
        $this->xmlContent->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
126 24
        $this->xmlContent->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
127 24
        $this->xmlContent->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
128 24
        $this->xmlContent->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
129 24
        $this->xmlContent->writeAttribute('xmlns:chartooo', 'http://openoffice.org/2010/chart');
130 24
        $this->xmlContent->writeAttribute('xmlns:drawooo', 'http://openoffice.org/2010/draw');
131 24
        $this->xmlContent->writeAttribute('xmlns:calcext', 'urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0');
132 24
        $this->xmlContent->writeAttribute('xmlns:loext', 'urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0');
133 24
        $this->xmlContent->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
134 24
        $this->xmlContent->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0');
135 24
        $this->xmlContent->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
136 24
        $this->xmlContent->writeAttribute('office:version', '1.2');
137
138
        // office:automatic-styles
139 24
        $this->xmlContent->startElement('office:automatic-styles');
140
141
        // Chart
142 24
        $this->writeChartStyle($chart);
143
144
        // Axis
145 24
        $this->writeAxisStyle($chart);
146
147
        // Series
148 24
        $this->numSeries = 0;
149 24
        foreach ($chartType->getSeries() as $series) {
150 22
            $this->writeSeriesStyle($chart, $series);
151
152 22
            $this->numSeries++;
153 24
        }
154
155
        // Floor
156 24
        $this->writeFloorStyle();
157
158
        // Legend
159 24
        $this->writeLegendStyle($chart);
160
161
        // PlotArea
162 24
        $this->writePlotAreaStyle($chart);
163
164
        // Title
165 24
        $this->writeTitleStyle($chart->getTitle());
166
167
        // Wall
168 24
        $this->writeWallStyle($chart);
169
170
        // > office:automatic-styles
171 24
        $this->xmlContent->endElement();
172
173
        // office:body
174 24
        $this->xmlContent->startElement('office:body');
175
        // office:chart
176 24
        $this->xmlContent->startElement('office:chart');
177
        // office:chart
178 24
        $this->xmlContent->startElement('chart:chart');
179 24
        $this->xmlContent->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getWidth()), 3) . 'cm');
180 24
        $this->xmlContent->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getHeight()), 3) . 'cm');
181 24
        $this->xmlContent->writeAttribute('xlink:href', '.');
182 24
        $this->xmlContent->writeAttribute('xlink:type', 'simple');
183 24
        $this->xmlContent->writeAttribute('chart:style-name', 'styleChart');
184 24
        $this->xmlContent->writeAttributeIf($chartType instanceof Area, 'chart:class', 'chart:area');
185 24
        $this->xmlContent->writeAttributeIf($chartType instanceof AbstractTypeBar, 'chart:class', 'chart:bar');
186 24
        if (!($chartType instanceof Doughnut)) {
187 23
            $this->xmlContent->writeAttributeIf($chartType instanceof AbstractTypePie, 'chart:class', 'chart:circle');
188 23
        }
189 24
        $this->xmlContent->writeAttributeIf($chartType instanceof Doughnut, 'chart:class', 'chart:ring');
190 24
        $this->xmlContent->writeAttributeIf($chartType instanceof Line, 'chart:class', 'chart:line');
191 24
        $this->xmlContent->writeAttributeIf($chartType instanceof Scatter, 'chart:class', 'chart:scatter');
192
193
        //**** Title ****
194 24
        $this->writeTitle($chart->getTitle());
195
196
        //**** Legend ****
197 24
        $this->writeLegend($chart);
198
199
        //**** Plotarea ****
200 24
        $this->writePlotArea($chart);
201
202
        //**** Table ****
203 24
        $this->writeTable();
204
205
        // > chart:chart
206 24
        $this->xmlContent->endElement();
207
        // > office:chart
208 24
        $this->xmlContent->endElement();
209
        // > office:body
210 24
        $this->xmlContent->endElement();
211
        // > office:document-content
212 24
        $this->xmlContent->endElement();
213
214 24
        return $this->xmlContent->getData();
215
    }
216
217
    /**
218
     * @param Chart $chart
219
     */
220 24
    private function writeAxis(Chart $chart)
221
    {
222 24
        $chartType = $chart->getPlotArea()->getType();
223
224
        // chart:axis
225 24
        $this->xmlContent->startElement('chart:axis');
226 24
        $this->xmlContent->writeAttribute('chart:dimension', 'x');
227 24
        $this->xmlContent->writeAttribute('chart:name', 'primary-x');
228 24
        $this->xmlContent->writeAttribute('chartooo:axis-type', 'text');
229 24
        $this->xmlContent->writeAttribute('chart:style-name', 'styleAxisX');
230
        // chart:axis > chart:categories
231 24
        $this->xmlContent->startElement('chart:categories');
232 24
        $this->xmlContent->writeAttribute('table:cell-range-address', 'table-local.$A$2:.$A$'.($this->numData+1));
233 24
        $this->xmlContent->endElement();
234
        // chart:axis > chart:grid
235 24
        $this->writeGridline($chart->getPlotArea()->getAxisX()->getMajorGridlines(), 'styleAxisXGridlinesMajor', 'major');
236
        // chart:axis > chart:grid
237 24
        $this->writeGridline($chart->getPlotArea()->getAxisX()->getMinorGridlines(), 'styleAxisXGridlinesMinor', 'minor');
238
        // ##chart:axis
239 24
        $this->xmlContent->endElement();
240
241
        // chart:axis
242 24
        $this->xmlContent->startElement('chart:axis');
243 24
        $this->xmlContent->writeAttribute('chart:dimension', 'y');
244 24
        $this->xmlContent->writeAttribute('chart:name', 'primary-y');
245 24
        $this->xmlContent->writeAttribute('chart:style-name', 'styleAxisY');
246
        // chart:axis > chart:grid
247 24
        $this->writeGridline($chart->getPlotArea()->getAxisY()->getMajorGridlines(), 'styleAxisYGridlinesMajor', 'major');
248
        // chart:axis > chart:grid
249 24
        $this->writeGridline($chart->getPlotArea()->getAxisY()->getMinorGridlines(), 'styleAxisYGridlinesMinor', 'minor');
250
        // ##chart:axis
251 24
        $this->xmlContent->endElement();
252
253 24
        if ($chartType instanceof Bar3D || $chartType instanceof Pie3D) {
254
            // chart:axis
255 5
            $this->xmlContent->startElement('chart:axis');
256 5
            $this->xmlContent->writeAttribute('chart:dimension', 'z');
257 5
            $this->xmlContent->writeAttribute('chart:name', 'primary-z');
258
            // > chart:axis
259 5
            $this->xmlContent->endElement();
260 5
        }
261 24
    }
262
263 24
    protected function writeGridline($oGridlines, $styleName, $chartClass)
264
    {
265 24
        if (!($oGridlines instanceof Chart\Gridlines)) {
266 24
            return ;
267
        }
268
269 1
        $this->xmlContent->startElement('chart:grid');
270 1
        $this->xmlContent->writeAttribute('chart:style-name', $styleName);
271 1
        $this->xmlContent->writeAttribute('chart:class', $chartClass);
272 1
        $this->xmlContent->endElement();
273 1
    }
274
275
    /**
276
     * @param Chart $chart
277
     * @todo Set function in \PhpPresentation\Shape\Chart\Axis for defining width and color of the axis
278
     */
279 24
    protected function writeAxisStyle(Chart $chart)
280
    {
281 24
        $chartType = $chart->getPlotArea()->getType();
282
283
        // AxisX
284
        // style:style
285 24
        $this->xmlContent->startElement('style:style');
286 24
        $this->xmlContent->writeAttribute('style:name', 'styleAxisX');
287 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
288
        // style:style > style:chart-properties
289 24
        $this->xmlContent->startElement('style:chart-properties');
290 24
        $this->xmlContent->writeAttribute('chart:display-label', 'true');
291 24
        $this->xmlContent->writeAttribute('chart:tick-marks-major-inner', 'false');
292 24
        $this->xmlContent->writeAttribute('chart:tick-marks-major-outer', 'false');
293 24
        if ($chartType instanceof AbstractTypePie) {
294 5
            $this->xmlContent->writeAttribute('chart:reverse-direction', 'true');
295 5
        }
296 24
        if ($chart->getPlotArea()->getAxisX()->getMinBounds() != null) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $chart->getPlotArea()->getAxisX()->getMinBounds() of type integer|null against null; this is ambiguous if the integer can be zero. Consider using a strict comparison !== instead.
Loading history...
297 1
            $this->xmlContent->writeAttribute('chart:minimum', $chart->getPlotArea()->getAxisX()->getMinBounds());
298 1
        }
299 24
        if ($chart->getPlotArea()->getAxisX()->getMaxBounds() != null) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $chart->getPlotArea()->getAxisX()->getMaxBounds() of type integer|null against null; this is ambiguous if the integer can be zero. Consider using a strict comparison !== instead.
Loading history...
300 1
            $this->xmlContent->writeAttribute('chart:maximum', $chart->getPlotArea()->getAxisX()->getMaxBounds());
301 1
        }
302 24
        $this->xmlContent->endElement();
303
        // style:style > style:text-properties
304 24
        $oFont = $chart->getPlotArea()->getAxisX()->getFont();
305 24
        $this->xmlContent->startElement('style:text-properties');
306 24
        $this->xmlContent->writeAttribute('fo:color', '#'.$oFont->getColor()->getRGB());
307 24
        $this->xmlContent->writeAttribute('fo:font-family', $oFont->getName());
308 24
        $this->xmlContent->writeAttribute('fo:font-size', $oFont->getSize().'pt');
309 24
        $this->xmlContent->writeAttribute('fo:font-style', $oFont->isItalic() ? 'italic' : 'normal');
310 24
        $this->xmlContent->endElement();
311
        // style:style > style:graphic-properties
312 24
        $this->xmlContent->startElement('style:graphic-properties');
313 24
        $this->xmlContent->writeAttribute('svg:stroke-width', '0.026cm');
314 24
        $this->xmlContent->writeAttribute('svg:stroke-color', '#878787');
315 24
        $this->xmlContent->endElement();
316
        // ##style:style
317 24
        $this->xmlContent->endElement();
318
319
        // AxisX GridLines Major
320 24
        $this->writeGridlineStyle($chart->getPlotArea()->getAxisX()->getMajorGridlines(), 'styleAxisXGridlinesMajor');
321
322
        // AxisX GridLines Minor
323 24
        $this->writeGridlineStyle($chart->getPlotArea()->getAxisX()->getMinorGridlines(), 'styleAxisXGridlinesMinor');
324
325
        // AxisY
326
        // style:style
327 24
        $this->xmlContent->startElement('style:style');
328 24
        $this->xmlContent->writeAttribute('style:name', 'styleAxisY');
329 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
330
        // style:style > style:chart-properties
331 24
        $this->xmlContent->startElement('style:chart-properties');
332 24
        $this->xmlContent->writeAttribute('chart:display-label', 'true');
333 24
        $this->xmlContent->writeAttribute('chart:tick-marks-major-inner', 'false');
334 24
        $this->xmlContent->writeAttribute('chart:tick-marks-major-outer', 'false');
335 24
        if ($chartType instanceof AbstractTypePie) {
336 5
            $this->xmlContent->writeAttribute('chart:reverse-direction', 'true');
337 5
        }
338 24
        if ($chart->getPlotArea()->getAxisY()->getMinBounds() != null) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $chart->getPlotArea()->getAxisY()->getMinBounds() of type integer|null against null; this is ambiguous if the integer can be zero. Consider using a strict comparison !== instead.
Loading history...
339
            $this->xmlContent->writeAttribute('chart:minimum', $chart->getPlotArea()->getAxisY()->getMinBounds());
340
        }
341 24
        if ($chart->getPlotArea()->getAxisY()->getMaxBounds() != null) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $chart->getPlotArea()->getAxisY()->getMaxBounds() of type integer|null against null; this is ambiguous if the integer can be zero. Consider using a strict comparison !== instead.
Loading history...
342
            $this->xmlContent->writeAttribute('chart:maximum', $chart->getPlotArea()->getAxisY()->getMaxBounds());
343
        }
344 24
        $this->xmlContent->endElement();
345
        // style:style > style:text-properties
346 24
        $oFont = $chart->getPlotArea()->getAxisY()->getFont();
347 24
        $this->xmlContent->startElement('style:text-properties');
348 24
        $this->xmlContent->writeAttribute('fo:color', '#'.$oFont->getColor()->getRGB());
349 24
        $this->xmlContent->writeAttribute('fo:font-family', $oFont->getName());
350 24
        $this->xmlContent->writeAttribute('fo:font-size', $oFont->getSize().'pt');
351 24
        $this->xmlContent->writeAttribute('fo:font-style', $oFont->isItalic() ? 'italic' : 'normal');
352 24
        $this->xmlContent->endElement();
353
        // style:graphic-properties
354 24
        $this->xmlContent->startElement('style:graphic-properties');
355 24
        $this->xmlContent->writeAttribute('svg:stroke-width', '0.026cm');
356 24
        $this->xmlContent->writeAttribute('svg:stroke-color', '#878787');
357 24
        $this->xmlContent->endElement();
358
        // ## style:style
359 24
        $this->xmlContent->endElement();
360
361
        // AxisY GridLines Major
362 24
        $this->writeGridlineStyle($chart->getPlotArea()->getAxisY()->getMajorGridlines(), 'styleAxisYGridlinesMajor');
363
364
        // AxisY GridLines Minor
365 24
        $this->writeGridlineStyle($chart->getPlotArea()->getAxisY()->getMinorGridlines(), 'styleAxisYGridlinesMinor');
366 24
    }
367
368
    /**
369
     * @param Chart\Gridlines $oGridlines
370
     * @param string $styleName
371
     */
372 24
    protected function writeGridlineStyle($oGridlines, $styleName)
373
    {
374 24
        if (!($oGridlines instanceof Chart\Gridlines)) {
375 24
            return;
376
        }
377
        // style:style
378 1
        $this->xmlContent->startElement('style:style');
379 1
        $this->xmlContent->writeAttribute('style:name', $styleName);
380 1
        $this->xmlContent->writeAttribute('style:family', 'chart');
381
        // style:style > style:graphic-properties
382 1
        $this->xmlContent->startElement('style:graphic-properties');
383 1
        $this->xmlContent->writeAttribute('svg:stroke-width', number_format(CommonDrawing::pointsToCentimeters($oGridlines->getOutline()->getWidth()), 2, '.', '').'cm');
384 1
        $this->xmlContent->writeAttribute('svg:stroke-color', '#'.$oGridlines->getOutline()->getFill()->getStartColor()->getRGB());
385 1
        $this->xmlContent->endElement();
386
        // ##style:style
387 1
        $this->xmlContent->endElement();
388 1
    }
389
390
    /**
391
     * @param Chart $chart
392
     */
393 24
    private function writeChartStyle(Chart $chart)
394
    {
395
        // style:style
396 24
        $this->xmlContent->startElement('style:style');
397 24
        $this->xmlContent->writeAttribute('style:name', 'styleChart');
398 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
399
        // style:graphic-properties
400 24
        $this->xmlContent->startElement('style:graphic-properties');
401 24
        $this->xmlContent->writeAttribute('draw:stroke', $chart->getFill()->getFillType());
402 24
        $this->xmlContent->writeAttribute('draw:fill-color', '#'.$chart->getFill()->getStartColor()->getRGB());
403
        // > style:graphic-properties
404 24
        $this->xmlContent->endElement();
405
        // > style:style
406 24
        $this->xmlContent->endElement();
407 24
    }
408
409 24
    private function writeFloor()
410
    {
411
        // chart:floor
412 24
        $this->xmlContent->startElement('chart:floor');
413 24
        $this->xmlContent->writeAttribute('chart:style-name', 'styleFloor');
414
        // > chart:floor
415 24
        $this->xmlContent->endElement();
416 24
    }
417
418 24
    private function writeFloorStyle()
419
    {
420
        // style:style
421 24
        $this->xmlContent->startElement('style:style');
422 24
        $this->xmlContent->writeAttribute('style:name', 'styleFloor');
423 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
424
        // style:chart-properties
425 24
        $this->xmlContent->startElement('style:graphic-properties');
426 24
        $this->xmlContent->writeAttribute('draw:fill', 'none');
427
        //@todo : Permit edit color and size border of floor
428 24
        $this->xmlContent->writeAttribute('draw:stroke', 'solid');
429 24
        $this->xmlContent->writeAttribute('svg:stroke-width', '0.026cm');
430 24
        $this->xmlContent->writeAttribute('svg:stroke-color', '#878787');
431
        // > style:chart-properties
432 24
        $this->xmlContent->endElement();
433
        // > style:style
434 24
        $this->xmlContent->endElement();
435 24
    }
436
437
    /**
438
     * @param Chart $chart
439
     */
440 24
    private function writeLegend(Chart $chart)
441
    {
442
        // chart:legend
443 24
        $this->xmlContent->startElement('chart:legend');
444 24
        switch ($chart->getLegend()->getPosition()) {
445 24
            case Chart\Legend::POSITION_BOTTOM:
446 1
                $position = 'bottom';
447 1
                break;
448 24
            case Chart\Legend::POSITION_LEFT:
449 1
                $position = 'start';
450 1
                break;
451 24
            case Chart\Legend::POSITION_TOP:
452 1
                $position = 'top';
453 1
                break;
454 24
            case Chart\Legend::POSITION_TOPRIGHT:
455 1
                $position = 'top-end';
456 1
                break;
457 24
            case Chart\Legend::POSITION_RIGHT:
458 24
            default:
459 24
                $position = 'end';
460 24
                break;
461 24
        }
462 24
        $this->xmlContent->writeAttribute('chart:legend-position', $position);
463 24
        $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getLegend()->getOffsetX()), 3) . 'cm');
464 24
        $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getLegend()->getOffsetY()), 3) . 'cm');
465 24
        $this->xmlContent->writeAttribute('style:legend-expansion', 'high');
466 24
        $this->xmlContent->writeAttribute('chart:style-name', 'styleLegend');
467
        // > chart:legend
468 24
        $this->xmlContent->endElement();
469
470
471 24
    }
472
473
    /**
474
     * @param Chart $chart
475
     */
476 24
    private function writeLegendStyle(Chart $chart)
477
    {
478
        // style:style
479 24
        $this->xmlContent->startElement('style:style');
480 24
        $this->xmlContent->writeAttribute('style:name', 'styleLegend');
481 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
482
        // style:chart-properties
483 24
        $this->xmlContent->startElement('style:chart-properties');
484 24
        $this->xmlContent->writeAttribute('chart:auto-position', 'true');
485
        // > style:chart-properties
486 24
        $this->xmlContent->endElement();
487
        // style:text-properties
488 24
        $this->xmlContent->startElement('style:text-properties');
489 24
        $this->xmlContent->writeAttribute('fo:color', '#'.$chart->getLegend()->getFont()->getColor()->getRGB());
490 24
        $this->xmlContent->writeAttribute('fo:font-family', $chart->getLegend()->getFont()->getName());
491 24
        $this->xmlContent->writeAttribute('fo:font-size', $chart->getLegend()->getFont()->getSize().'pt');
492 24
        $this->xmlContent->writeAttribute('fo:font-style', $chart->getLegend()->getFont()->isItalic() ? 'italic' : 'normal');
493
        // > style:text-properties
494 24
        $this->xmlContent->endElement();
495
        // > style:style
496 24
        $this->xmlContent->endElement();
497 24
    }
498
499
    /**
500
     * @param Chart $chart
501
     */
502 24
    private function writePlotArea(Chart $chart)
503
    {
504 24
        $chartType = $chart->getPlotArea()->getType();
505
506
        // chart:plot-area
507 24
        $this->xmlContent->startElement('chart:plot-area');
508 24
        $this->xmlContent->writeAttribute('chart:style-name', 'stylePlotArea');
509 24
        if ($chartType instanceof Bar3D || $chartType instanceof Pie3D) {
510 5
            $this->xmlContent->writeAttribute('dr3d:ambient-color', '#cccccc');
511 5
            $this->xmlContent->writeAttribute('dr3d:lighting-mode', 'true');
512 5
        }
513 24
        if ($chartType instanceof Bar3D || $chartType instanceof Pie3D) {
514
            // dr3d:light
515
            $arrayLight = array(
516 5
                array('#808080', '(0 0 1)', 'false', 'true'),
517 5
                array('#666666', '(0.2 0.4 1)', 'true', 'false'),
518 5
                array('#808080', '(0 0 1)', 'false', 'false'),
519 5
                array('#808080', '(0 0 1)', 'false', 'false'),
520 5
                array('#808080', '(0 0 1)', 'false', 'false'),
521 5
                array('#808080', '(0 0 1)', 'false', 'false'),
522 5
                array('#808080', '(0 0 1)', 'false', 'false'),
523 5
            );
524 5
            foreach ($arrayLight as $light) {
525 5
                $this->xmlContent->startElement('dr3d:light');
526 5
                $this->xmlContent->writeAttribute('dr3d:diffuse-color', $light[0]);
527 5
                $this->xmlContent->writeAttribute('dr3d:direction', $light[1]);
528 5
                $this->xmlContent->writeAttribute('dr3d:enabled', $light[2]);
529 5
                $this->xmlContent->writeAttribute('dr3d:specular', $light[3]);
530 5
                $this->xmlContent->endElement();
531 5
            }
532 5
        }
533
534
        //**** Axis ****
535 24
        $this->writeAxis($chart);
536
537
        //**** Series ****
538 24
        $this->rangeCol = 'B';
539 24
        $this->numSeries = 0;
540 24
        foreach ($chartType->getSeries() as $series) {
541 22
            $this->writeSeries($chart, $series);
542 22
            $this->rangeCol++;
543 22
            $this->numSeries++;
544 24
        }
545
546
        //**** Wall ****
547 24
        $this->writeWall();
548
        //**** Floor ****
549 24
        $this->writeFloor();
550
        // > chart:plot-area
551 24
        $this->xmlContent->endElement();
552 24
    }
553
554
    /**
555
     * @param Chart $chart
556
     * @link : http://books.evc-cit.info/odbook/ch08.html#chart-plot-area-section
557
     */
558 24
    private function writePlotAreaStyle(Chart $chart)
559
    {
560 24
        $chartType = $chart->getPlotArea()->getType();
561
562
        // style:style
563 24
        $this->xmlContent->startElement('style:style');
564 24
        $this->xmlContent->writeAttribute('style:name', 'stylePlotArea');
565 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
566
        // style:text-properties
567 24
        $this->xmlContent->startElement('style:chart-properties');
568 24
        if ($chartType instanceof Bar3D) {
569 3
            $this->xmlContent->writeAttribute('chart:three-dimensional', 'true');
570 3
            $this->xmlContent->writeAttribute('chart:right-angled-axes', 'true');
571 24
        } elseif ($chartType instanceof Pie3D) {
572 2
            $this->xmlContent->writeAttribute('chart:three-dimensional', 'true');
573 2
            $this->xmlContent->writeAttribute('chart:right-angled-axes', 'true');
574 2
        }
575 24
        if ($chartType instanceof AbstractTypeBar) {
576 8
            $chartVertical = 'false';
577 8
            if ($chartType->getBarDirection() == AbstractTypeBar::DIRECTION_HORIZONTAL) {
578 2
                $chartVertical = 'true';
579 2
            }
580 8
            $this->xmlContent->writeAttribute('chart:vertical', $chartVertical);
581 8
            if ($chartType->getBarGrouping() == Bar::GROUPING_CLUSTERED) {
582 6
                $this->xmlContent->writeAttribute('chart:stacked', 'false');
583 6
                $this->xmlContent->writeAttribute('chart:overlap', '0');
584 8
            } elseif ($chartType->getBarGrouping() == Bar::GROUPING_STACKED) {
585 1
                $this->xmlContent->writeAttribute('chart:stacked', 'true');
586 1
                $this->xmlContent->writeAttribute('chart:overlap', '100');
587 2
            } elseif ($chartType->getBarGrouping() == Bar::GROUPING_PERCENTSTACKED) {
588 1
                $this->xmlContent->writeAttribute('chart:stacked', 'true');
589 1
                $this->xmlContent->writeAttribute('chart:overlap', '100');
590 1
                $this->xmlContent->writeAttribute('chart:percentage', 'true');
591 1
            }
592 8
        }
593 24
        $labelFormat = 'value';
594 24
        if ($chartType instanceof AbstractTypeBar) {
595 8
            if ($chartType->getBarGrouping() == Bar::GROUPING_PERCENTSTACKED) {
596 1
                $labelFormat = 'percentage';
597 1
            }
598 8
        }
599 24
        $this->xmlContent->writeAttribute('chart:data-label-number', $labelFormat);
600
601
        // > style:text-properties
602 24
        $this->xmlContent->endElement();
603
        // > style:style
604 24
        $this->xmlContent->endElement();
605 24
    }
606
607
    /**
608
     * @param Chart $chart
609
     * @param Chart\Series $series
610
     * @throws \Exception
611
     */
612 22
    private function writeSeries(Chart $chart, Chart\Series $series)
613
    {
614 22
        $chartType = $chart->getPlotArea()->getType();
615
616 22
        $numRange = count($series->getValues());
617
        // chart:series
618 22
        $this->xmlContent->startElement('chart:series');
619 22
        $this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$'.$this->rangeCol.'$2:.$'.$this->rangeCol.'$'.($numRange+1));
620 22
        $this->xmlContent->writeAttribute('chart:label-cell-address', 'table-local.$'.$this->rangeCol.'$1');
621 22
        if ($chartType instanceof Area) {
622 1
            $this->xmlContent->writeAttribute('chart:class', 'chart:area');
623 22
        } elseif ($chartType instanceof AbstractTypeBar) {
624 7
            $this->xmlContent->writeAttribute('chart:class', 'chart:bar');
625 21
        } elseif ($chartType instanceof Line) {
626 6
            $this->xmlContent->writeAttribute('chart:class', 'chart:line');
627 14
        } elseif ($chartType instanceof AbstractTypePie) {
628 5
            $this->xmlContent->writeAttribute('chart:class', 'chart:circle');
629 8
        } elseif ($chartType instanceof Scatter) {
630 3
            $this->xmlContent->writeAttribute('chart:class', 'chart:scatter');
631 3
        }
632 22
        $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries);
633 22
        if ($chartType instanceof Area || $chartType instanceof AbstractTypeBar || $chartType instanceof Line || $chartType instanceof Scatter) {
634 17
            $dataPointFills = $series->getDataPointFills();
635
636 17
            $incRepeat = $numRange;
637 17
            if (!empty($dataPointFills)) {
638 4
                $inc = 0;
639 4
                $incRepeat = 0;
640 4
                $newFill = new Fill();
641
                do {
642 4
                    if ($series->getDataPointFill($inc)->getHashCode() != $newFill->getHashCode()) {
643
                        // chart:data-point
644 4
                        $this->xmlContent->startElement('chart:data-point');
645 4
                        $this->xmlContent->writeAttribute('chart:repeated', $incRepeat);
646
                        // > chart:data-point
647 4
                        $this->xmlContent->endElement();
648 4
                        $incRepeat = 0;
649
650
                        // chart:data-point
651 4
                        $this->xmlContent->startElement('chart:data-point');
652 4
                        $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries.'_'.$inc);
653
                        // > chart:data-point
654 4
                        $this->xmlContent->endElement();
655 4
                    }
656 4
                    $inc++;
657 4
                    $incRepeat++;
658 4
                } while ($inc < $numRange);
659 4
                $incRepeat--;
660 4
            }
661
            // chart:data-point
662 17
            $this->xmlContent->startElement('chart:data-point');
663 17
            $this->xmlContent->writeAttribute('chart:repeated', $incRepeat);
664
            // > chart:data-point
665 17
            $this->xmlContent->endElement();
666 22
        } elseif ($chartType instanceof AbstractTypePie) {
667 5
            $count = count($series->getDataPointFills());
668 5
            for ($inc = 0; $inc < $count; $inc++) {
669
                // chart:data-point
670 3
                $this->xmlContent->startElement('chart:data-point');
671 3
                $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries.'_'.$inc);
672
                // > chart:data-point
673 3
                $this->xmlContent->endElement();
674 3
            }
675 5
        }
676
677
        // > chart:series
678 22
        $this->xmlContent->endElement();
679 22
    }
680
681
    /**
682
     * @param Chart $chart
683
     * @param Chart\Series $series
684
     */
685 22
    private function writeSeriesStyle(Chart $chart, Chart\Series $series)
686
    {
687 22
        $chartType = $chart->getPlotArea()->getType();
688
689
        // style:style
690 22
        $this->xmlContent->startElement('style:style');
691 22
        $this->xmlContent->writeAttribute('style:name', 'styleSeries'.$this->numSeries);
692 22
        $this->xmlContent->writeAttribute('style:family', 'chart');
693
        // style:chart-properties
694 22
        $this->xmlContent->startElement('style:chart-properties');
695 22
        if ($series->hasShowValue()) {
696 22
            if ($series->hasShowPercentage()) {
697 1
                $this->xmlContent->writeAttribute('chart:data-label-number', 'value-and-percentage');
698 1
            } else {
699 22
                $this->xmlContent->writeAttribute('chart:data-label-number', 'value');
700
            }
701 22
        } else {
702 1
            if ($series->hasShowPercentage()) {
703 1
                $this->xmlContent->writeAttribute('chart:data-label-number', 'percentage');
704 1
            }
705
        }
706 22
        if ($series->hasShowCategoryName()) {
707 1
            $this->xmlContent->writeAttribute('chart:data-label-text', 'true');
708 1
        }
709 22
        $this->xmlContent->writeAttribute('chart:label-position', 'center');
710 22
        if ($chartType instanceof AbstractTypePie) {
711 5
            $this->xmlContent->writeAttribute('chart:pie-offset', $chartType->getExplosion());
712 5
        }
713 22
        if ($chartType instanceof Line || $chartType instanceof Scatter) {
714 9
            $oMarker = $series->getMarker();
715
            /**
716
             * @link : http://www.datypic.com/sc/odf/a-chart_symbol-type.html
717
             */
718 9
            $this->xmlContent->writeAttributeIf($oMarker->getSymbol() == Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'none');
719
            /**
720
             * @link : http://www.datypic.com/sc/odf/a-chart_symbol-name.html
721
             */
722 9
            $this->xmlContent->writeAttributeIf($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'named-symbol');
723 9
            if ($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE) {
724 2
                switch ($oMarker->getSymbol()) {
725 2
                    case Chart\Marker::SYMBOL_DASH:
726 2
                        $symbolName = 'horizontal-bar';
727 2
                        break;
728 2
                    case Chart\Marker::SYMBOL_DOT:
729 2
                        $symbolName = 'circle';
730 2
                        break;
731 2
                    case Chart\Marker::SYMBOL_TRIANGLE:
732 2
                        $symbolName = 'arrow-up';
733 2
                        break;
734 2
                    default:
735 2
                        $symbolName = $oMarker->getSymbol();
736 2
                        break;
737 2
                }
738 2
                $this->xmlContent->writeAttribute('chart:symbol-name', $symbolName);
739 2
                $symbolSize = number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', '');
740 2
                $this->xmlContent->writeAttribute('chart:symbol-width', $symbolSize.'cm');
741 2
                $this->xmlContent->writeAttribute('chart:symbol-height', $symbolSize.'cm');
742 2
            }
743 9
        }
744
745 22
        $separator = $series->getSeparator();
746 22
        if (!empty($separator)) {
747
            // style:chart-properties/chart:label-separator
748 1
            $this->xmlContent->startElement('chart:label-separator');
749 1
            if ($separator == PHP_EOL) {
750
                $this->xmlContent->writeRaw('<text:p><text:line-break /></text:p>');
751
            } else {
752 1
                $this->xmlContent->writeElement('text:p', $separator);
753
            }
754 1
            $this->xmlContent->endElement();
755 1
        }
756
757
        // > style:chart-properties
758 22
        $this->xmlContent->endElement();
759
        // style:graphic-properties
760 22
        $this->xmlContent->startElement('style:graphic-properties');
761 22
        if ($chartType instanceof Line || $chartType instanceof Scatter) {
762 9
            $outlineWidth = '';
763 9
            $outlineColor = '';
764
765 9
            $oOutline = $series->getOutline();
766 9
            if ($oOutline instanceof Outline) {
767 2
                $outlineWidth = $oOutline->getWidth();
768 2
                if (!empty($outlineWidth)) {
769 2
                    $outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', '');
770 2
                }
771 2
                $outlineColor = $oOutline->getFill()->getStartColor()->getRGB();
772 2
            }
773 9
            if (empty($outlineWidth)) {
774 9
                $outlineWidth = '0.079';
775 9
            }
776 9
            if (empty($outlineColor)) {
777 9
                $outlineColor = '4a7ebb';
778 9
            }
779 9
            $this->xmlContent->writeAttribute('svg:stroke-width', $outlineWidth.'cm');
780 9
            $this->xmlContent->writeAttribute('svg:stroke-color', '#'.$outlineColor);
781 9
        } else {
782 13
            $this->xmlContent->writeAttribute('draw:stroke', 'none');
783 13
            if (!($chartType instanceof Area)) {
784 12
                $this->xmlContent->writeAttribute('draw:fill', $series->getFill()->getFillType());
785 12
            }
786
        }
787 22
        $this->xmlContent->writeAttribute('draw:fill-color', '#'.$series->getFill()->getStartColor()->getRGB());
788
        // > style:graphic-properties
789 22
        $this->xmlContent->endElement();
790
        // style:text-properties
791 22
        $this->xmlContent->startElement('style:text-properties');
792 22
        $this->xmlContent->writeAttribute('fo:color', '#'.$series->getFont()->getColor()->getRGB());
793 22
        $this->xmlContent->writeAttribute('fo:font-family', $series->getFont()->getName());
794 22
        $this->xmlContent->writeAttribute('fo:font-size', $series->getFont()->getSize().'pt');
795
        // > style:text-properties
796 22
        $this->xmlContent->endElement();
797
798
        // > style:style
799 22
        $this->xmlContent->endElement();
800
801 22
        foreach ($series->getDataPointFills() as $idx => $oFill) {
802
            // style:style
803 7
            $this->xmlContent->startElement('style:style');
804 7
            $this->xmlContent->writeAttribute('style:name', 'styleSeries'.$this->numSeries.'_'.$idx);
805 7
            $this->xmlContent->writeAttribute('style:family', 'chart');
806
            // style:graphic-properties
807 7
            $this->xmlContent->startElement('style:graphic-properties');
808 7
            $this->xmlContent->writeAttribute('draw:fill', $oFill->getFillType());
809 7
            $this->xmlContent->writeAttribute('draw:fill-color', '#'.$oFill->getStartColor()->getRGB());
810
            // > style:graphic-properties
811 7
            $this->xmlContent->endElement();
812
            // > style:style
813 7
            $this->xmlContent->endElement();
814 22
        }
815 22
    }
816
817
    /**
818
     */
819 24
    private function writeTable()
820
    {
821
        // table:table
822 24
        $this->xmlContent->startElement('table:table');
823 24
        $this->xmlContent->writeAttribute('table:name', 'table-local');
824
825
        // table:table-header-columns
826 24
        $this->xmlContent->startElement('table:table-header-columns');
827
        // table:table-column
828 24
        $this->xmlContent->startElement('table:table-column');
829
        // > table:table-column
830 24
        $this->xmlContent->endElement();
831
        // > table:table-header-columns
832 24
        $this->xmlContent->endElement();
833
834
        // table:table-columns
835 24
        $this->xmlContent->startElement('table:table-columns');
836
        // table:table-column
837 24
        $this->xmlContent->startElement('table:table-column');
838 24
        if (!empty($this->arrayData)) {
839 22
            $rowFirst = reset($this->arrayData);
840 22
            $this->xmlContent->writeAttribute('table:number-columns-repeated', count($rowFirst) - 1);
841 22
        }
842
        // > table:table-column
843 24
        $this->xmlContent->endElement();
844
        // > table:table-columns
845 24
        $this->xmlContent->endElement();
846
847
        // table:table-header-rows
848 24
        $this->xmlContent->startElement('table:table-header-rows');
849
        // table:table-row
850 24
        $this->xmlContent->startElement('table:table-row');
851 24
        if (!empty($this->arrayData)) {
852 22
            $rowFirst = reset($this->arrayData);
853 22
            foreach ($rowFirst as $key => $cell) {
854
                // table:table-cell
855 22
                $this->xmlContent->startElement('table:table-cell');
856 22
                if (isset($this->arrayTitle[$key - 1])) {
857 22
                    $this->xmlContent->writeAttribute('office:value-type', 'string');
858 22
                }
859
                // text:p
860 22
                $this->xmlContent->startElement('text:p');
861 22
                if (isset($this->arrayTitle[$key - 1])) {
862 22
                    $this->xmlContent->text($this->arrayTitle[$key - 1]);
863 22
                }
864
                // > text:p
865 22
                $this->xmlContent->endElement();
866
                // > table:table-cell
867 22
                $this->xmlContent->endElement();
868 22
            }
869 22
        }
870
        // > table:table-row
871 24
        $this->xmlContent->endElement();
872
        // > table:table-header-rows
873 24
        $this->xmlContent->endElement();
874
875
        // table:table-rows
876 24
        $this->xmlContent->startElement('table:table-rows');
877
878 24
        foreach ($this->arrayData as $row) {
879
            // table:table-row
880 22
            $this->xmlContent->startElement('table:table-row');
881 22
            foreach ($row as $cell) {
882
                // table:table-cell
883 22
                $this->xmlContent->startElement('table:table-cell');
884
885 22
                $cellNumeric = is_numeric($cell);
886 22
                $this->xmlContent->writeAttributeIf(!$cellNumeric, 'office:value-type', 'string');
887 22
                $this->xmlContent->writeAttributeIf($cellNumeric, 'office:value-type', 'float');
888 22
                $this->xmlContent->writeAttributeIf($cellNumeric, 'office:value', $cell);
889
                // text:p
890 22
                $this->xmlContent->startElement('text:p');
891 22
                $this->xmlContent->text($cell);
892
                // > text:p
893 22
                $this->xmlContent->endElement();
894
                // > table:table-cell
895 22
                $this->xmlContent->endElement();
896 22
            }
897
            // > table:table-row
898 22
            $this->xmlContent->endElement();
899 24
        }
900
901
        // > table:table-rows
902 24
        $this->xmlContent->endElement();
903
        // > table:table
904 24
        $this->xmlContent->endElement();
905 24
    }
906
907
    /**
908
     * @param Title $oTitle
909
     */
910 24
    private function writeTitle(Title $oTitle)
911
    {
912 24
        if (!$oTitle->isVisible()) {
913 1
            return;
914
        }
915
        // chart:title
916 24
        $this->xmlContent->startElement('chart:title');
917 24
        $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetX()), 3) . 'cm');
918 24
        $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetY()), 3) . 'cm');
919 24
        $this->xmlContent->writeAttribute('chart:style-name', 'styleTitle');
920
        // > text:p
921 24
        $this->xmlContent->startElement('text:p');
922 24
        $this->xmlContent->text($oTitle->getText());
923
        // > text:p
924 24
        $this->xmlContent->endElement();
925
        // > chart:title
926 24
        $this->xmlContent->endElement();
927 24
    }
928
929
    /**
930
     * @param Title $oTitle
931
     */
932 24
    private function writeTitleStyle(Title $oTitle)
933
    {
934 24
        if (!$oTitle->isVisible()) {
935 1
            return;
936
        }
937
        // style:style
938 24
        $this->xmlContent->startElement('style:style');
939 24
        $this->xmlContent->writeAttribute('style:name', 'styleTitle');
940 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
941
        // style:text-properties
942 24
        $this->xmlContent->startElement('style:text-properties');
943 24
        $this->xmlContent->writeAttribute('fo:color', '#'.$oTitle->getFont()->getColor()->getRGB());
944 24
        $this->xmlContent->writeAttribute('fo:font-family', $oTitle->getFont()->getName());
945 24
        $this->xmlContent->writeAttribute('fo:font-size', $oTitle->getFont()->getSize().'pt');
946 24
        $this->xmlContent->writeAttribute('fo:font-style', $oTitle->getFont()->isItalic() ? 'italic' : 'normal');
947
        // > style:text-properties
948 24
        $this->xmlContent->endElement();
949
        // > style:style
950 24
        $this->xmlContent->endElement();
951 24
    }
952
953 24
    private function writeWall()
954
    {
955
        // chart:wall
956 24
        $this->xmlContent->startElement('chart:wall');
957 24
        $this->xmlContent->writeAttribute('chart:style-name', 'styleWall');
958
        // > chart:wall
959 24
        $this->xmlContent->endElement();
960 24
    }
961
962
    /**
963
     * @param Chart $chart
964
     */
965 24
    private function writeWallStyle(Chart $chart)
966
    {
967 24
        $chartType = $chart->getPlotArea()->getType();
968
969
        // style:style
970 24
        $this->xmlContent->startElement('style:style');
971 24
        $this->xmlContent->writeAttribute('style:name', 'styleWall');
972 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
973
        // style:chart-properties
974 24
        $this->xmlContent->startElement('style:graphic-properties');
975
        //@todo : Permit edit color and size border of wall
976 24
        if ($chartType instanceof Line || $chartType instanceof Scatter) {
977 10
            $this->xmlContent->writeAttribute('draw:fill', 'solid');
978 10
            $this->xmlContent->writeAttribute('draw:fill-color', '#FFFFFF');
979 10
        } else {
980 14
            $this->xmlContent->writeAttribute('draw:fill', 'none');
981 14
            $this->xmlContent->writeAttribute('draw:stroke', 'solid');
982 14
            $this->xmlContent->writeAttribute('svg:stroke-width', '0.026cm');
983 14
            $this->xmlContent->writeAttribute('svg:stroke-color', '#878787');
984
        }
985
        // > style:chart-properties
986 24
        $this->xmlContent->endElement();
987
        // > style:style
988 24
        $this->xmlContent->endElement();
989 24
    }
990
}
991