Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
49 / 49 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| CheckBox | |
100.00% |
49 / 49 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| write | |
100.00% |
49 / 49 |
|
100.00% |
1 / 1 |
2 | |||
| 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 | /** |
| 22 | * CheckBox element writer. |
| 23 | * |
| 24 | * @since 0.10.0 |
| 25 | */ |
| 26 | class CheckBox extends Text |
| 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\CheckBox) { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | $this->startElementP(); |
| 40 | |
| 41 | $xmlWriter->startElement('w:r'); |
| 42 | $xmlWriter->startElement('w:fldChar'); |
| 43 | $xmlWriter->writeAttribute('w:fldCharType', 'begin'); |
| 44 | $xmlWriter->startElement('w:ffData'); |
| 45 | $xmlWriter->startElement('w:name'); |
| 46 | $xmlWriter->writeAttribute('w:val', $this->getText($element->getName())); |
| 47 | $xmlWriter->endElement(); //w:name |
| 48 | $xmlWriter->writeAttribute('w:enabled', ''); |
| 49 | $xmlWriter->startElement('w:calcOnExit'); |
| 50 | $xmlWriter->writeAttribute('w:val', '0'); |
| 51 | $xmlWriter->endElement(); //w:calcOnExit |
| 52 | $xmlWriter->startElement('w:checkBox'); |
| 53 | $xmlWriter->writeAttribute('w:sizeAuto', ''); |
| 54 | $xmlWriter->startElement('w:default'); |
| 55 | $xmlWriter->writeAttribute('w:val', 0); |
| 56 | $xmlWriter->endElement(); //w:default |
| 57 | $xmlWriter->endElement(); //w:checkBox |
| 58 | $xmlWriter->endElement(); // w:ffData |
| 59 | $xmlWriter->endElement(); // w:fldChar |
| 60 | $xmlWriter->endElement(); // w:r |
| 61 | |
| 62 | $xmlWriter->startElement('w:r'); |
| 63 | $xmlWriter->startElement('w:instrText'); |
| 64 | $xmlWriter->writeAttribute('xml:space', 'preserve'); |
| 65 | $xmlWriter->text(' FORMCHECKBOX '); |
| 66 | $xmlWriter->endElement(); // w:instrText |
| 67 | $xmlWriter->endElement(); // w:r |
| 68 | $xmlWriter->startElement('w:r'); |
| 69 | $xmlWriter->startElement('w:fldChar'); |
| 70 | $xmlWriter->writeAttribute('w:fldCharType', 'separate'); |
| 71 | $xmlWriter->endElement(); // w:fldChar |
| 72 | $xmlWriter->endElement(); // w:r |
| 73 | $xmlWriter->startElement('w:r'); |
| 74 | $xmlWriter->startElement('w:fldChar'); |
| 75 | $xmlWriter->writeAttribute('w:fldCharType', 'end'); |
| 76 | $xmlWriter->endElement(); // w:fldChar |
| 77 | $xmlWriter->endElement(); // w:r |
| 78 | |
| 79 | $xmlWriter->startElement('w:r'); |
| 80 | |
| 81 | $this->writeFontStyle(); |
| 82 | |
| 83 | $xmlWriter->startElement('w:t'); |
| 84 | $xmlWriter->writeAttribute('xml:space', 'preserve'); |
| 85 | $this->writeText($this->getText($element->getText())); |
| 86 | $xmlWriter->endElement(); // w:t |
| 87 | $xmlWriter->endElement(); // w:r |
| 88 | |
| 89 | $this->endElementP(); // w:p |
| 90 | } |
| 91 | } |