ObjectsChart::writeFloor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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