Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
23 / 23 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ListItem | |
100.00% |
23 / 23 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
write | |
100.00% |
23 / 23 |
|
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 | use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; |
22 | |
23 | /** |
24 | * ListItem element writer. |
25 | * |
26 | * @since 0.10.0 |
27 | */ |
28 | class ListItem extends AbstractElement |
29 | { |
30 | /** |
31 | * Write list item element. |
32 | */ |
33 | public function write(): void |
34 | { |
35 | $xmlWriter = $this->getXmlWriter(); |
36 | $element = $this->getElement(); |
37 | if (!$element instanceof \PhpOffice\PhpWord\Element\ListItem) { |
38 | return; |
39 | } |
40 | |
41 | $textObject = $element->getTextObject(); |
42 | |
43 | $styleWriter = new ParagraphStyleWriter($xmlWriter, $textObject->getParagraphStyle()); |
44 | $styleWriter->setWithoutPPR(true); |
45 | $styleWriter->setIsInline(true); |
46 | |
47 | $xmlWriter->startElement('w:p'); |
48 | |
49 | $xmlWriter->startElement('w:pPr'); |
50 | $styleWriter->write(); |
51 | |
52 | $xmlWriter->startElement('w:numPr'); |
53 | $xmlWriter->startElement('w:ilvl'); |
54 | $xmlWriter->writeAttribute('w:val', $element->getDepth()); |
55 | $xmlWriter->endElement(); // w:ilvl |
56 | $xmlWriter->startElement('w:numId'); |
57 | $xmlWriter->writeAttribute('w:val', $element->getStyle()->getNumId()); |
58 | $xmlWriter->endElement(); // w:numId |
59 | $xmlWriter->endElement(); // w:numPr |
60 | |
61 | $xmlWriter->endElement(); // w:pPr |
62 | |
63 | $elementWriter = new Text($xmlWriter, $textObject, true); |
64 | $elementWriter->write(); |
65 | |
66 | $xmlWriter->endElement(); // w:p |
67 | } |
68 | } |