Completed
Push — develop ( f4e000...ba7ca1 )
by Franck
13s
created

ObjectsChart   F

Complexity

Total Complexity 109

Size/Duplication

Total Lines 966
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 20

Test Coverage

Coverage 99.46%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 109
c 1
b 0
f 0
lcom 1
cbo 20
dl 0
loc 966
ccs 552
cts 555
cp 0.9946
rs 1.263

20 Methods

Rating   Name   Duplication   Size   Complexity  
A writeGridline() 0 11 2
A writeGridlineStyle() 0 17 2
A writeChartStyle() 0 15 1
A writeFloor() 0 8 1
A writeFloorStyle() 0 18 1
A render() 0 12 3
C writeContentPart() 0 145 8
B writeAxis() 0 42 3
C writeAxisStyle() 0 88 9
B writeLegend() 0 30 6
A writeLegendStyle() 0 22 2
C writePlotArea() 0 51 7
C writePlotAreaStyle() 0 48 10
C writeSeries() 0 68 15
F writeSeriesStyle() 0 131 22
C writeTable() 0 87 8
A writeTitle() 0 18 2
A writeTitleStyle() 0 20 3
A writeWall() 0 8 1
B writeWallStyle() 0 25 3

How to fix   Complexity   

Complex Class

Complex classes like ObjectsChart often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ObjectsChart, and based on these observations, apply Extract Interface, too.

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 61
    public function render()
54
    {
55 61
        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 61
        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
        // 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
        }
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
        }
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
        }
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
        }
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
        }
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
        }
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
        }
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
            default:
459 24
                $position = 'end';
460 24
                break;
461
        }
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 24
    }
470
471
    /**
472
     * @param Chart $chart
473
     */
474 24
    private function writeLegendStyle(Chart $chart)
475
    {
476
        // style:style
477 24
        $this->xmlContent->startElement('style:style');
478 24
        $this->xmlContent->writeAttribute('style:name', 'styleLegend');
479 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
480
        // style:chart-properties
481 24
        $this->xmlContent->startElement('style:chart-properties');
482 24
        $this->xmlContent->writeAttribute('chart:auto-position', 'true');
483
        // > style:chart-properties
484 24
        $this->xmlContent->endElement();
485
        // style:text-properties
486 24
        $this->xmlContent->startElement('style:text-properties');
487 24
        $this->xmlContent->writeAttribute('fo:color', '#'.$chart->getLegend()->getFont()->getColor()->getRGB());
488 24
        $this->xmlContent->writeAttribute('fo:font-family', $chart->getLegend()->getFont()->getName());
489 24
        $this->xmlContent->writeAttribute('fo:font-size', $chart->getLegend()->getFont()->getSize().'pt');
490 24
        $this->xmlContent->writeAttribute('fo:font-style', $chart->getLegend()->getFont()->isItalic() ? 'italic' : 'normal');
491
        // > style:text-properties
492 24
        $this->xmlContent->endElement();
493
        // > style:style
494 24
        $this->xmlContent->endElement();
495 24
    }
496
497
    /**
498
     * @param Chart $chart
499
     */
500 24
    private function writePlotArea(Chart $chart)
501
    {
502 24
        $chartType = $chart->getPlotArea()->getType();
503
504
        // chart:plot-area
505 24
        $this->xmlContent->startElement('chart:plot-area');
506 24
        $this->xmlContent->writeAttribute('chart:style-name', 'stylePlotArea');
507 24
        if ($chartType instanceof Bar3D || $chartType instanceof Pie3D) {
508 5
            $this->xmlContent->writeAttribute('dr3d:ambient-color', '#cccccc');
509 5
            $this->xmlContent->writeAttribute('dr3d:lighting-mode', 'true');
510
        }
511 24
        if ($chartType instanceof Bar3D || $chartType instanceof Pie3D) {
512
            // dr3d:light
513
            $arrayLight = array(
514 5
                array('#808080', '(0 0 1)', 'false', 'true'),
515
                array('#666666', '(0.2 0.4 1)', 'true', 'false'),
516
                array('#808080', '(0 0 1)', 'false', 'false'),
517
                array('#808080', '(0 0 1)', 'false', 'false'),
518
                array('#808080', '(0 0 1)', 'false', 'false'),
519
                array('#808080', '(0 0 1)', 'false', 'false'),
520
                array('#808080', '(0 0 1)', 'false', 'false'),
521
            );
522 5
            foreach ($arrayLight as $light) {
523 5
                $this->xmlContent->startElement('dr3d:light');
524 5
                $this->xmlContent->writeAttribute('dr3d:diffuse-color', $light[0]);
525 5
                $this->xmlContent->writeAttribute('dr3d:direction', $light[1]);
526 5
                $this->xmlContent->writeAttribute('dr3d:enabled', $light[2]);
527 5
                $this->xmlContent->writeAttribute('dr3d:specular', $light[3]);
528 5
                $this->xmlContent->endElement();
529
            }
530
        }
531
532
        //**** Axis ****
533 24
        $this->writeAxis($chart);
534
535
        //**** Series ****
536 24
        $this->rangeCol = 'B';
537 24
        $this->numSeries = 0;
538 24
        foreach ($chartType->getSeries() as $series) {
539 22
            $this->writeSeries($chart, $series);
540 22
            $this->rangeCol++;
541 22
            $this->numSeries++;
542
        }
543
544
        //**** Wall ****
545 24
        $this->writeWall();
546
        //**** Floor ****
547 24
        $this->writeFloor();
548
        // > chart:plot-area
549 24
        $this->xmlContent->endElement();
550 24
    }
551
552
    /**
553
     * @param Chart $chart
554
     * @link : http://books.evc-cit.info/odbook/ch08.html#chart-plot-area-section
555
     */
556 24
    private function writePlotAreaStyle(Chart $chart)
557
    {
558 24
        $chartType = $chart->getPlotArea()->getType();
559
560
        // style:style
561 24
        $this->xmlContent->startElement('style:style');
562 24
        $this->xmlContent->writeAttribute('style:name', 'stylePlotArea');
563 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
564
        // style:text-properties
565 24
        $this->xmlContent->startElement('style:chart-properties');
566 24
        if ($chartType instanceof Bar3D) {
567 3
            $this->xmlContent->writeAttribute('chart:three-dimensional', 'true');
568 3
            $this->xmlContent->writeAttribute('chart:right-angled-axes', 'true');
569 21
        } elseif ($chartType instanceof Pie3D) {
570 2
            $this->xmlContent->writeAttribute('chart:three-dimensional', 'true');
571 2
            $this->xmlContent->writeAttribute('chart:right-angled-axes', 'true');
572
        }
573 24
        if ($chartType instanceof AbstractTypeBar) {
574 8
            $chartVertical = 'false';
575 8
            if ($chartType->getBarDirection() == AbstractTypeBar::DIRECTION_HORIZONTAL) {
576 2
                $chartVertical = 'true';
577
            }
578 8
            $this->xmlContent->writeAttribute('chart:vertical', $chartVertical);
579 8
            if ($chartType->getBarGrouping() == Bar::GROUPING_CLUSTERED) {
580 6
                $this->xmlContent->writeAttribute('chart:stacked', 'false');
581 6
                $this->xmlContent->writeAttribute('chart:overlap', '0');
582 2
            } elseif ($chartType->getBarGrouping() == Bar::GROUPING_STACKED) {
583 1
                $this->xmlContent->writeAttribute('chart:stacked', 'true');
584 1
                $this->xmlContent->writeAttribute('chart:overlap', '100');
585 1
            } elseif ($chartType->getBarGrouping() == Bar::GROUPING_PERCENTSTACKED) {
586 1
                $this->xmlContent->writeAttribute('chart:stacked', 'true');
587 1
                $this->xmlContent->writeAttribute('chart:overlap', '100');
588 1
                $this->xmlContent->writeAttribute('chart:percentage', 'true');
589
            }
590
        }
591 24
        $labelFormat = 'value';
592 24
        if ($chartType instanceof AbstractTypeBar) {
593 8
            if ($chartType->getBarGrouping() == Bar::GROUPING_PERCENTSTACKED) {
594 1
                $labelFormat = 'percentage';
595
            }
596
        }
597 24
        $this->xmlContent->writeAttribute('chart:data-label-number', $labelFormat);
598
599
        // > style:text-properties
600 24
        $this->xmlContent->endElement();
601
        // > style:style
602 24
        $this->xmlContent->endElement();
603 24
    }
604
605
    /**
606
     * @param Chart $chart
607
     * @param Chart\Series $series
608
     * @throws \Exception
609
     */
610 22
    private function writeSeries(Chart $chart, Chart\Series $series)
611
    {
612 22
        $chartType = $chart->getPlotArea()->getType();
613
614 22
        $numRange = count($series->getValues());
615
        // chart:series
616 22
        $this->xmlContent->startElement('chart:series');
617 22
        $this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$'.$this->rangeCol.'$2:.$'.$this->rangeCol.'$'.($numRange+1));
618 22
        $this->xmlContent->writeAttribute('chart:label-cell-address', 'table-local.$'.$this->rangeCol.'$1');
619 22
        if ($chartType instanceof Area) {
620 1
            $this->xmlContent->writeAttribute('chart:class', 'chart:area');
621 21
        } elseif ($chartType instanceof AbstractTypeBar) {
622 7
            $this->xmlContent->writeAttribute('chart:class', 'chart:bar');
623 14
        } elseif ($chartType instanceof Line) {
624 6
            $this->xmlContent->writeAttribute('chart:class', 'chart:line');
625 8
        } elseif ($chartType instanceof AbstractTypePie) {
626 5
            $this->xmlContent->writeAttribute('chart:class', 'chart:circle');
627 3
        } elseif ($chartType instanceof Scatter) {
628 3
            $this->xmlContent->writeAttribute('chart:class', 'chart:scatter');
629
        }
630 22
        $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries);
631 22
        if ($chartType instanceof Area || $chartType instanceof AbstractTypeBar || $chartType instanceof Line || $chartType instanceof Scatter) {
632 17
            $dataPointFills = $series->getDataPointFills();
633
634 17
            $incRepeat = $numRange;
635 17
            if (!empty($dataPointFills)) {
636 4
                $inc = 0;
637 4
                $incRepeat = 0;
638 4
                $newFill = new Fill();
639
                do {
640 4
                    if ($series->getDataPointFill($inc)->getHashCode() != $newFill->getHashCode()) {
641
                        // chart:data-point
642 4
                        $this->xmlContent->startElement('chart:data-point');
643 4
                        $this->xmlContent->writeAttribute('chart:repeated', $incRepeat);
644
                        // > chart:data-point
645 4
                        $this->xmlContent->endElement();
646 4
                        $incRepeat = 0;
647
648
                        // chart:data-point
649 4
                        $this->xmlContent->startElement('chart:data-point');
650 4
                        $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries.'_'.$inc);
651
                        // > chart:data-point
652 4
                        $this->xmlContent->endElement();
653
                    }
654 4
                    $inc++;
655 4
                    $incRepeat++;
656 4
                } while ($inc < $numRange);
657 4
                $incRepeat--;
658
            }
659
            // chart:data-point
660 17
            $this->xmlContent->startElement('chart:data-point');
661 17
            $this->xmlContent->writeAttribute('chart:repeated', $incRepeat);
662
            // > chart:data-point
663 17
            $this->xmlContent->endElement();
664 5
        } elseif ($chartType instanceof AbstractTypePie) {
665 5
            $count = count($series->getDataPointFills());
666 5
            for ($inc = 0; $inc < $count; $inc++) {
667
                // chart:data-point
668 3
                $this->xmlContent->startElement('chart:data-point');
669 3
                $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries.'_'.$inc);
670
                // > chart:data-point
671 3
                $this->xmlContent->endElement();
672
            }
673
        }
674
675
        // > chart:series
676 22
        $this->xmlContent->endElement();
677 22
    }
678
679
    /**
680
     * @param Chart $chart
681
     * @param Chart\Series $series
682
     */
683 22
    private function writeSeriesStyle(Chart $chart, Chart\Series $series)
684
    {
685 22
        $chartType = $chart->getPlotArea()->getType();
686
687
        // style:style
688 22
        $this->xmlContent->startElement('style:style');
689 22
        $this->xmlContent->writeAttribute('style:name', 'styleSeries'.$this->numSeries);
690 22
        $this->xmlContent->writeAttribute('style:family', 'chart');
691
        // style:chart-properties
692 22
        $this->xmlContent->startElement('style:chart-properties');
693 22
        if ($series->hasShowValue()) {
694 22
            if ($series->hasShowPercentage()) {
695 1
                $this->xmlContent->writeAttribute('chart:data-label-number', 'value-and-percentage');
696
            } else {
697 22
                $this->xmlContent->writeAttribute('chart:data-label-number', 'value');
698
            }
699
        } else {
700 1
            if ($series->hasShowPercentage()) {
701 1
                $this->xmlContent->writeAttribute('chart:data-label-number', 'percentage');
702
            }
703
        }
704 22
        if ($series->hasShowCategoryName()) {
705 1
            $this->xmlContent->writeAttribute('chart:data-label-text', 'true');
706
        }
707 22
        $this->xmlContent->writeAttribute('chart:label-position', 'center');
708 22
        if ($chartType instanceof AbstractTypePie) {
709 5
            $this->xmlContent->writeAttribute('chart:pie-offset', $chartType->getExplosion());
710
        }
711 22
        if ($chartType instanceof Line || $chartType instanceof Scatter) {
712 9
            $oMarker = $series->getMarker();
713
            /**
714
             * @link : http://www.datypic.com/sc/odf/a-chart_symbol-type.html
715
             */
716 9
            $this->xmlContent->writeAttributeIf($oMarker->getSymbol() == Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'none');
717
            /**
718
             * @link : http://www.datypic.com/sc/odf/a-chart_symbol-name.html
719
             */
720 9
            $this->xmlContent->writeAttributeIf($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'named-symbol');
721 9
            if ($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE) {
722 2
                switch ($oMarker->getSymbol()) {
723 2
                    case Chart\Marker::SYMBOL_DASH:
724 2
                        $symbolName = 'horizontal-bar';
725 2
                        break;
726 2
                    case Chart\Marker::SYMBOL_DOT:
727 2
                        $symbolName = 'circle';
728 2
                        break;
729 2
                    case Chart\Marker::SYMBOL_TRIANGLE:
730 2
                        $symbolName = 'arrow-up';
731 2
                        break;
732
                    default:
733 2
                        $symbolName = $oMarker->getSymbol();
734 2
                        break;
735
                }
736 2
                $this->xmlContent->writeAttribute('chart:symbol-name', $symbolName);
737 2
                $symbolSize = number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', '');
738 2
                $this->xmlContent->writeAttribute('chart:symbol-width', $symbolSize.'cm');
739 2
                $this->xmlContent->writeAttribute('chart:symbol-height', $symbolSize.'cm');
740
            }
741
        }
742
743 22
        $separator = $series->getSeparator();
744 22
        if (!empty($separator)) {
745
            // style:chart-properties/chart:label-separator
746 1
            $this->xmlContent->startElement('chart:label-separator');
747 1
            if ($separator == PHP_EOL) {
748
                $this->xmlContent->writeRaw('<text:p><text:line-break /></text:p>');
749
            } else {
750 1
                $this->xmlContent->writeElement('text:p', $separator);
751
            }
752 1
            $this->xmlContent->endElement();
753
        }
754
755
        // > style:chart-properties
756 22
        $this->xmlContent->endElement();
757
        // style:graphic-properties
758 22
        $this->xmlContent->startElement('style:graphic-properties');
759 22
        if ($chartType instanceof Line || $chartType instanceof Scatter) {
760 9
            $outlineWidth = '';
761 9
            $outlineColor = '';
762
763 9
            $oOutline = $series->getOutline();
764 9
            if ($oOutline instanceof Outline) {
765 2
                $outlineWidth = $oOutline->getWidth();
766 2
                if (!empty($outlineWidth)) {
767 2
                    $outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', '');
768
                }
769 2
                $outlineColor = $oOutline->getFill()->getStartColor()->getRGB();
770
            }
771 9
            if (empty($outlineWidth)) {
772 9
                $outlineWidth = '0.079';
773
            }
774 9
            if (empty($outlineColor)) {
775 9
                $outlineColor = '4a7ebb';
776
            }
777 9
            $this->xmlContent->writeAttribute('svg:stroke-width', $outlineWidth.'cm');
778 9
            $this->xmlContent->writeAttribute('svg:stroke-color', '#'.$outlineColor);
779
        } else {
780 13
            $this->xmlContent->writeAttribute('draw:stroke', 'none');
781 13
            if (!($chartType instanceof Area)) {
782 12
                $this->xmlContent->writeAttribute('draw:fill', $series->getFill()->getFillType());
783
            }
784
        }
785 22
        $this->xmlContent->writeAttribute('draw:fill-color', '#'.$series->getFill()->getStartColor()->getRGB());
786
        // > style:graphic-properties
787 22
        $this->xmlContent->endElement();
788
        // style:text-properties
789 22
        $this->xmlContent->startElement('style:text-properties');
790 22
        $this->xmlContent->writeAttribute('fo:color', '#'.$series->getFont()->getColor()->getRGB());
791 22
        $this->xmlContent->writeAttribute('fo:font-family', $series->getFont()->getName());
792 22
        $this->xmlContent->writeAttribute('fo:font-size', $series->getFont()->getSize().'pt');
793
        // > style:text-properties
794 22
        $this->xmlContent->endElement();
795
796
        // > style:style
797 22
        $this->xmlContent->endElement();
798
799 22
        foreach ($series->getDataPointFills() as $idx => $oFill) {
800
            // style:style
801 7
            $this->xmlContent->startElement('style:style');
802 7
            $this->xmlContent->writeAttribute('style:name', 'styleSeries'.$this->numSeries.'_'.$idx);
803 7
            $this->xmlContent->writeAttribute('style:family', 'chart');
804
            // style:graphic-properties
805 7
            $this->xmlContent->startElement('style:graphic-properties');
806 7
            $this->xmlContent->writeAttribute('draw:fill', $oFill->getFillType());
807 7
            $this->xmlContent->writeAttribute('draw:fill-color', '#'.$oFill->getStartColor()->getRGB());
808
            // > style:graphic-properties
809 7
            $this->xmlContent->endElement();
810
            // > style:style
811 7
            $this->xmlContent->endElement();
812
        }
813 22
    }
814
815
    /**
816
     */
817 24
    private function writeTable()
818
    {
819
        // table:table
820 24
        $this->xmlContent->startElement('table:table');
821 24
        $this->xmlContent->writeAttribute('table:name', 'table-local');
822
823
        // table:table-header-columns
824 24
        $this->xmlContent->startElement('table:table-header-columns');
825
        // table:table-column
826 24
        $this->xmlContent->startElement('table:table-column');
827
        // > table:table-column
828 24
        $this->xmlContent->endElement();
829
        // > table:table-header-columns
830 24
        $this->xmlContent->endElement();
831
832
        // table:table-columns
833 24
        $this->xmlContent->startElement('table:table-columns');
834
        // table:table-column
835 24
        $this->xmlContent->startElement('table:table-column');
836 24
        if (!empty($this->arrayData)) {
837 22
            $rowFirst = reset($this->arrayData);
838 22
            $this->xmlContent->writeAttribute('table:number-columns-repeated', count($rowFirst) - 1);
839
        }
840
        // > table:table-column
841 24
        $this->xmlContent->endElement();
842
        // > table:table-columns
843 24
        $this->xmlContent->endElement();
844
845
        // table:table-header-rows
846 24
        $this->xmlContent->startElement('table:table-header-rows');
847
        // table:table-row
848 24
        $this->xmlContent->startElement('table:table-row');
849 24
        if (!empty($this->arrayData)) {
850 22
            $rowFirst = reset($this->arrayData);
851 22
            foreach ($rowFirst as $key => $cell) {
852
                // table:table-cell
853 22
                $this->xmlContent->startElement('table:table-cell');
854 22
                if (isset($this->arrayTitle[$key - 1])) {
855 22
                    $this->xmlContent->writeAttribute('office:value-type', 'string');
856
                }
857
                // text:p
858 22
                $this->xmlContent->startElement('text:p');
859 22
                if (isset($this->arrayTitle[$key - 1])) {
860 22
                    $this->xmlContent->text($this->arrayTitle[$key - 1]);
861
                }
862
                // > text:p
863 22
                $this->xmlContent->endElement();
864
                // > table:table-cell
865 22
                $this->xmlContent->endElement();
866
            }
867
        }
868
        // > table:table-row
869 24
        $this->xmlContent->endElement();
870
        // > table:table-header-rows
871 24
        $this->xmlContent->endElement();
872
873
        // table:table-rows
874 24
        $this->xmlContent->startElement('table:table-rows');
875
876 24
        foreach ($this->arrayData as $row) {
877
            // table:table-row
878 22
            $this->xmlContent->startElement('table:table-row');
879 22
            foreach ($row as $cell) {
880
                // table:table-cell
881 22
                $this->xmlContent->startElement('table:table-cell');
882
883 22
                $cellNumeric = is_numeric($cell);
884 22
                $this->xmlContent->writeAttributeIf(!$cellNumeric, 'office:value-type', 'string');
885 22
                $this->xmlContent->writeAttributeIf($cellNumeric, 'office:value-type', 'float');
886 22
                $this->xmlContent->writeAttributeIf($cellNumeric, 'office:value', $cell);
887
                // text:p
888 22
                $this->xmlContent->startElement('text:p');
889 22
                $this->xmlContent->text($cell);
890
                // > text:p
891 22
                $this->xmlContent->endElement();
892
                // > table:table-cell
893 22
                $this->xmlContent->endElement();
894
            }
895
            // > table:table-row
896 22
            $this->xmlContent->endElement();
897
        }
898
899
        // > table:table-rows
900 24
        $this->xmlContent->endElement();
901
        // > table:table
902 24
        $this->xmlContent->endElement();
903 24
    }
904
905
    /**
906
     * @param Title $oTitle
907
     */
908 24
    private function writeTitle(Title $oTitle)
909
    {
910 24
        if (!$oTitle->isVisible()) {
911 1
            return;
912
        }
913
        // chart:title
914 24
        $this->xmlContent->startElement('chart:title');
915 24
        $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetX()), 3) . 'cm');
916 24
        $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetY()), 3) . 'cm');
917 24
        $this->xmlContent->writeAttribute('chart:style-name', 'styleTitle');
918
        // > text:p
919 24
        $this->xmlContent->startElement('text:p');
920 24
        $this->xmlContent->text($oTitle->getText());
921
        // > text:p
922 24
        $this->xmlContent->endElement();
923
        // > chart:title
924 24
        $this->xmlContent->endElement();
925 24
    }
926
927
    /**
928
     * @param Title $oTitle
929
     */
930 24
    private function writeTitleStyle(Title $oTitle)
931
    {
932 24
        if (!$oTitle->isVisible()) {
933 1
            return;
934
        }
935
        // style:style
936 24
        $this->xmlContent->startElement('style:style');
937 24
        $this->xmlContent->writeAttribute('style:name', 'styleTitle');
938 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
939
        // style:text-properties
940 24
        $this->xmlContent->startElement('style:text-properties');
941 24
        $this->xmlContent->writeAttribute('fo:color', '#'.$oTitle->getFont()->getColor()->getRGB());
942 24
        $this->xmlContent->writeAttribute('fo:font-family', $oTitle->getFont()->getName());
943 24
        $this->xmlContent->writeAttribute('fo:font-size', $oTitle->getFont()->getSize().'pt');
944 24
        $this->xmlContent->writeAttribute('fo:font-style', $oTitle->getFont()->isItalic() ? 'italic' : 'normal');
945
        // > style:text-properties
946 24
        $this->xmlContent->endElement();
947
        // > style:style
948 24
        $this->xmlContent->endElement();
949 24
    }
950
951 24
    private function writeWall()
952
    {
953
        // chart:wall
954 24
        $this->xmlContent->startElement('chart:wall');
955 24
        $this->xmlContent->writeAttribute('chart:style-name', 'styleWall');
956
        // > chart:wall
957 24
        $this->xmlContent->endElement();
958 24
    }
959
960
    /**
961
     * @param Chart $chart
962
     */
963 24
    private function writeWallStyle(Chart $chart)
964
    {
965 24
        $chartType = $chart->getPlotArea()->getType();
966
967
        // style:style
968 24
        $this->xmlContent->startElement('style:style');
969 24
        $this->xmlContent->writeAttribute('style:name', 'styleWall');
970 24
        $this->xmlContent->writeAttribute('style:family', 'chart');
971
        // style:chart-properties
972 24
        $this->xmlContent->startElement('style:graphic-properties');
973
        //@todo : Permit edit color and size border of wall
974 24
        if ($chartType instanceof Line || $chartType instanceof Scatter) {
975 10
            $this->xmlContent->writeAttribute('draw:fill', 'solid');
976 10
            $this->xmlContent->writeAttribute('draw:fill-color', '#FFFFFF');
977
        } else {
978 14
            $this->xmlContent->writeAttribute('draw:fill', 'none');
979 14
            $this->xmlContent->writeAttribute('draw:stroke', 'solid');
980 14
            $this->xmlContent->writeAttribute('svg:stroke-width', '0.026cm');
981 14
            $this->xmlContent->writeAttribute('svg:stroke-color', '#878787');
982
        }
983
        // > style:chart-properties
984 24
        $this->xmlContent->endElement();
985
        // > style:style
986 24
        $this->xmlContent->endElement();
987 24
    }
988
}
989