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