Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
93.75% covered (success)
93.75%
15 / 16
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
TextBox
93.75% covered (success)
93.75%
15 / 16
0.00% covered (danger)
0.00%
0 / 1
2.00
0.00% covered (danger)
0.00%
0 / 1
 write
93.75% covered (success)
93.75%
15 / 16
0.00% covered (danger)
0.00%
0 / 1
2.00
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 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
19namespace PhpOffice\PhpWord\Writer\ODText\Element;
20
21use PhpOffice\PhpWord\Element\TextBox as TextBoxElement;
22use PhpOffice\PhpWord\Writer\ODText\Style\Graphic;
23
24/**
25 * ODF text box element writer.
26 */
27class TextBox extends AbstractElement
28{
29    public function write(): void
30    {
31        $element = $this->getElement();
32        if (!$element instanceof TextBoxElement) {
33            return;
34        }
35
36        $xmlWriter = $this->getXmlWriter();
37        $style = $element->getStyle();
38        $xmlWriter->startElement('draw:frame');
39        $xmlWriter->writeAttribute('draw:style-name', $style->getStyleName());
40        $xmlWriter->writeAttribute('draw:name', $element->getElementId());
41        $xmlWriter->writeAttribute('text:anchor-type', 'as-char');
42        Graphic::writeFrameProperties($xmlWriter, $style);
43        $xmlWriter->startElement('draw:text-box');
44        $container = new Container($xmlWriter, $element);
45        $container->setPart($this->getPart());
46        $container->write();
47        $xmlWriter->endElement();
48        $xmlWriter->endElement();
49    }
50}