Completed
Pull Request — develop (#390)
by Franck
07:24
created

ObjectsChart::writeAxisStyle()   C

Complexity

Conditions 9
Paths 64

Size

Total Lines 90
Code Lines 60

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 59
CRAP Score 9.0028

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 90
ccs 59
cts 61
cp 0.9672
rs 5.1827
cc 9
eloc 60
nc 64
nop 1
crap 9.0028

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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