Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
96.55% |
28 / 29 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
TextBox | |
96.55% |
28 / 29 |
|
0.00% |
0 / 1 |
4 | |
0.00% |
0 / 1 |
write | |
96.55% |
28 / 29 |
|
0.00% |
0 / 1 |
4 |
1 | <?php |
2 | |
3 | /** |
4 | * This file is part of PHPWord - A pure PHP library for reading and writing |
5 | * word processing documents. |
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 | * For the full copyright and license information, please read the LICENSE |
9 | * file that was distributed with this source code. For the full list of |
10 | * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
11 | * |
12 | * @see https://github.com/PHPOffice/PHPWord |
13 | * |
14 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
15 | */ |
16 | |
17 | namespace PhpOffice\PhpWord\Writer\Word2007\Element; |
18 | |
19 | use PhpOffice\PhpWord\Writer\Word2007\Style\TextBox as TextBoxStyleWriter; |
20 | |
21 | /** |
22 | * TextBox element writer. |
23 | * |
24 | * @since 0.11.0 |
25 | */ |
26 | class TextBox extends Image |
27 | { |
28 | /** |
29 | * Write element. |
30 | */ |
31 | public function write(): void |
32 | { |
33 | $xmlWriter = $this->getXmlWriter(); |
34 | $element = $this->getElement(); |
35 | if (!$element instanceof \PhpOffice\PhpWord\Element\TextBox) { |
36 | return; |
37 | } |
38 | $style = $element->getStyle(); |
39 | $styleWriter = new TextBoxStyleWriter($xmlWriter, $style); |
40 | |
41 | if (!$this->withoutP) { |
42 | $xmlWriter->startElement('w:p'); |
43 | $styleWriter->writeAlignment(); |
44 | } |
45 | $this->writeCommentRangeStart(); |
46 | |
47 | $xmlWriter->startElement('w:r'); |
48 | $xmlWriter->startElement('w:pict'); |
49 | $xmlWriter->startElement('v:shape'); |
50 | $xmlWriter->writeAttribute('type', '#_x0000_t0202'); |
51 | |
52 | if ($style->getBgColor()) { |
53 | $xmlWriter->writeAttribute('fillcolor', $style->getBgColor()); |
54 | } |
55 | |
56 | $styleWriter->write(); |
57 | $styleWriter->writeBorder(); |
58 | |
59 | $xmlWriter->startElement('v:textbox'); |
60 | $styleWriter->writeInnerMargin(); |
61 | |
62 | // TextBox content, serving as a container |
63 | $xmlWriter->startElement('w:txbxContent'); |
64 | $containerWriter = new Container($xmlWriter, $element); |
65 | $containerWriter->write(); |
66 | $xmlWriter->endElement(); // w:txbxContent |
67 | |
68 | $xmlWriter->endElement(); // v: textbox |
69 | |
70 | $xmlWriter->endElement(); // v:shape |
71 | $xmlWriter->endElement(); // w:pict |
72 | $xmlWriter->endElement(); // w:r |
73 | |
74 | $this->endElementP(); |
75 | } |
76 | } |