Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
25 / 25 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Line | |
100.00% |
25 / 25 |
|
100.00% |
1 / 1 |
5 | |
100.00% |
1 / 1 |
writeStroke | |
100.00% |
25 / 25 |
|
100.00% |
1 / 1 |
5 |
1 | <?php |
2 | /** |
3 | * This file is part of PHPWord - A pure PHP library for reading and writing |
4 | * word processing documents. |
5 | * |
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 | * |
9 | * For the full copyright and license information, please read the LICENSE |
10 | * file that was distributed with this source code. For the full list of |
11 | * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
12 | * |
13 | * @see https://github.com/PHPOffice/PHPWord |
14 | * |
15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16 | */ |
17 | |
18 | namespace PhpOffice\PhpWord\Writer\Word2007\Style; |
19 | |
20 | use PhpOffice\PhpWord\Style\Line as LineStyle; |
21 | |
22 | /** |
23 | * Line style writer. |
24 | */ |
25 | class Line extends Frame |
26 | { |
27 | /** |
28 | * Write Line stroke. |
29 | * |
30 | * @todo Merge with `Stroke` style |
31 | */ |
32 | public function writeStroke(): void |
33 | { |
34 | $xmlWriter = $this->getXmlWriter(); |
35 | $style = $this->getStyle(); |
36 | if (!$style instanceof LineStyle) { |
37 | return; |
38 | } |
39 | |
40 | $dash = $style->getDash(); |
41 | $dashStyles = [ |
42 | LineStyle::DASH_STYLE_DASH => 'dash', |
43 | LineStyle::DASH_STYLE_ROUND_DOT => '1 1', |
44 | LineStyle::DASH_STYLE_SQUARE_DOT => '1 1', |
45 | LineStyle::DASH_STYLE_DASH_DOT => 'dashDot', |
46 | LineStyle::DASH_STYLE_LONG_DASH => 'longDash', |
47 | LineStyle::DASH_STYLE_LONG_DASH_DOT => 'longDashDot', |
48 | LineStyle::DASH_STYLE_LONG_DASH_DOT_DOT => 'longDashDotDot', |
49 | ]; |
50 | |
51 | $xmlWriter->startElement('v:stroke'); |
52 | |
53 | $xmlWriter->writeAttributeIf($style->getWeight() !== null, 'weight', $style->getWeight() . 'pt'); |
54 | $xmlWriter->writeAttributeIf($style->getColor() !== null, 'color', $style->getColor()); |
55 | $xmlWriter->writeAttributeIf($style->getBeginArrow() !== null, 'startarrow', $style->getBeginArrow()); |
56 | $xmlWriter->writeAttributeIf($style->getEndArrow() !== null, 'endarrow', $style->getEndArrow()); |
57 | |
58 | if ($dash !== null) { |
59 | if (isset($dashStyles[$dash])) { |
60 | $xmlWriter->writeAttribute('dashstyle', $dashStyles[$dash]); |
61 | } |
62 | if ($dash == LineStyle::DASH_STYLE_ROUND_DOT) { |
63 | $xmlWriter->writeAttribute('endcap', 'round'); |
64 | } |
65 | } |
66 | |
67 | $xmlWriter->endElement(); //v:stroke |
68 | } |
69 | } |