Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Chart | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
write | |
100.00% |
29 / 29 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | /** |
3 | * This file is part of PHPWord - A pure PHP library for reading and writing |
4 | * word processing documents. |
5 | * |
6 | * PHPWord is free software distributed under the terms of the GNU Lesser |
7 | * General Public License version 3 as published by the Free Software Foundation. |
8 | * |
9 | * For the full copyright and license information, please read the LICENSE |
10 | * file that was distributed with this source code. For the full list of |
11 | * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
12 | * |
13 | * @see https://github.com/PHPOffice/PHPWord |
14 | * |
15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16 | */ |
17 | |
18 | namespace PhpOffice\PhpWord\Writer\Word2007\Element; |
19 | |
20 | use PhpOffice\PhpWord\Element\Chart as ChartElement; |
21 | |
22 | /** |
23 | * Chart element writer. |
24 | * |
25 | * @since 0.12.0 |
26 | */ |
27 | class Chart extends AbstractElement |
28 | { |
29 | /** |
30 | * Write element. |
31 | */ |
32 | public function write(): void |
33 | { |
34 | $xmlWriter = $this->getXmlWriter(); |
35 | $element = $this->getElement(); |
36 | if (!$element instanceof ChartElement) { |
37 | return; |
38 | } |
39 | |
40 | $rId = $element->getRelationId(); |
41 | $style = $element->getStyle(); |
42 | |
43 | if (!$this->withoutP) { |
44 | $xmlWriter->startElement('w:p'); |
45 | } |
46 | $this->writeCommentRangeStart(); |
47 | |
48 | $xmlWriter->startElement('w:r'); |
49 | $xmlWriter->startElement('w:drawing'); |
50 | $xmlWriter->startElement('wp:inline'); |
51 | |
52 | // EMU |
53 | $xmlWriter->writeElementBlock('wp:extent', ['cx' => $style->getWidth(), 'cy' => $style->getHeight()]); |
54 | $xmlWriter->writeElementBlock('wp:docPr', ['id' => $rId, 'name' => "Chart{$rId}"]); |
55 | |
56 | $xmlWriter->startElement('a:graphic'); |
57 | $xmlWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); |
58 | $xmlWriter->startElement('a:graphicData'); |
59 | $xmlWriter->writeAttribute('uri', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); |
60 | |
61 | $xmlWriter->startElement('c:chart'); |
62 | $xmlWriter->writeAttribute('r:id', "rId{$rId}"); |
63 | $xmlWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); |
64 | $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); |
65 | $xmlWriter->endElement(); // c:chart |
66 | |
67 | $xmlWriter->endElement(); // a:graphicData |
68 | $xmlWriter->endElement(); // a:graphic |
69 | |
70 | $xmlWriter->endElement(); // wp:inline |
71 | $xmlWriter->endElement(); // w:drawing |
72 | $xmlWriter->endElement(); // w:r |
73 | |
74 | $this->endElementP(); // w:p |
75 | } |
76 | } |