|
18 | 18 |
|
19 | 19 | namespace PhpOffice\PhpWord\Writer\ODText\Style; |
20 | 20 |
|
| 21 | +use PhpOffice\PhpWord\Style\Font as FontStyle; |
| 22 | + |
21 | 23 | /** |
22 | 24 | * Font style writer. |
23 | 25 | * |
@@ -72,9 +74,34 @@ public function write(): void |
72 | 74 | $xmlWriter->writeAttributeIf($style->isItalic(), 'style:font-style-complex', 'italic'); |
73 | 75 |
|
74 | 76 | // Underline |
75 | | - // @todo Various mode of underline |
| 77 | + $underlines = [ |
| 78 | + FontStyle::UNDERLINE_DASH => 'dash', |
| 79 | + FontStyle::UNDERLINE_DASHHEAVY => 'dash', |
| 80 | + FontStyle::UNDERLINE_DASHLONG => 'long-dash', |
| 81 | + FontStyle::UNDERLINE_DASHLONGHEAVY => 'long-dash', |
| 82 | + FontStyle::UNDERLINE_DOUBLE => 'solid', |
| 83 | + FontStyle::UNDERLINE_DOTDASH => 'dot-dash', |
| 84 | + FontStyle::UNDERLINE_DOTDASHHEAVY => 'dot-dash', |
| 85 | + FontStyle::UNDERLINE_DOTDOTDASH => 'dot-dot-dash', |
| 86 | + FontStyle::UNDERLINE_DOTDOTDASHHEAVY => 'dot-dot-dash', |
| 87 | + FontStyle::UNDERLINE_DOTTED => 'dotted', |
| 88 | + FontStyle::UNDERLINE_DOTTEDHEAVY => 'dotted', |
| 89 | + FontStyle::UNDERLINE_HEAVY => 'solid', |
| 90 | + FontStyle::UNDERLINE_SINGLE => 'solid', |
| 91 | + FontStyle::UNDERLINE_WAVY => 'wave', |
| 92 | + FontStyle::UNDERLINE_WAVYDOUBLE => 'wave', |
| 93 | + FontStyle::UNDERLINE_WAVYHEAVY => 'wave', |
| 94 | + FontStyle::UNDERLINE_WORDS => 'solid', |
| 95 | + ]; |
| 96 | + |
76 | 97 | $underline = $style->getUnderline(); |
77 | | - $xmlWriter->writeAttributeIf($underline != 'none', 'style:text-underline-style', 'solid'); |
| 98 | + if (isset($underlines[$underline])) { |
| 99 | + $xmlWriter->writeAttributeIf($underline != 'none', 'style:text-underline-style', $underlines[$underline]); |
| 100 | + $xmlWriter->writeAttributeIf(str_contains(strtolower($underline), 'heavy'), 'style:text-underline-width', 'bold'); |
| 101 | + $xmlWriter->writeAttributeIf(str_contains(strtolower($underline), 'thick'), 'style:text-underline-width', 'bold'); |
| 102 | + $xmlWriter->writeAttributeIf(str_contains(strtolower($underline), 'double'), 'style:text-underline-type', 'double'); |
| 103 | + $xmlWriter->writeAttributeIf(str_contains(strtolower($underline), 'words'), 'style:text-underline-mode', 'skip-white-space'); |
| 104 | + } |
78 | 105 |
|
79 | 106 | // Strikethrough, double strikethrough |
80 | 107 | $xmlWriter->writeAttributeIf($style->isStrikethrough(), 'style:text-line-through-type', 'single'); |
|
0 commit comments