2323use PhpOffice \PhpWord \Style ;
2424use PhpOffice \PhpWord \Style \Font ;
2525use PhpOffice \PhpWord \Style \Table ;
26+ use PhpOffice \PhpWord \Style \Numbering ;
2627
2728/**
2829 * RTF header part writer.
@@ -53,6 +54,13 @@ class Header extends AbstractPart
5354 */
5455 private $ colorTable = [];
5556
57+ /**
58+ * List table.
59+ *
60+ * @var array
61+ */
62+ private $ listTable = [];
63+
5664 /**
5765 * Get font table.
5866 *
@@ -73,21 +81,32 @@ public function getColorTable()
7381 return $ this ->colorTable ;
7482 }
7583
84+ /**
85+ * Get list table.
86+ *
87+ * @return array
88+ */
89+ public function getListTable ()
90+ {
91+ return $ this ->listTable ;
92+ }
93+
7694 /**
7795 * Write part.
7896 *
7997 * @return string
8098 */
8199 public function write ()
82100 {
83- $ this ->registerFont ();
101+ $ this ->registerHeader ();
84102
85103 $ content = '' ;
86104
87105 $ content .= $ this ->writeCharset ();
88106 $ content .= $ this ->writeDefaults ();
89107 $ content .= $ this ->writeFontTable ();
90108 $ content .= $ this ->writeColorTable ();
109+ $ content .= $ this ->writeListTable ();
91110 $ content .= $ this ->writeGenerator ();
92111 $ content .= PHP_EOL ;
93112
@@ -166,6 +185,18 @@ private function writeColorTable()
166185 return $ content ;
167186 }
168187
188+ /**
189+ * Write list table.
190+ *
191+ * @return string
192+ */
193+ private function writeListTable ()
194+ {
195+ $ content = '' ;
196+
197+ return $ content ;
198+ }
199+
169200 /**
170201 * Write.
171202 *
@@ -182,17 +213,17 @@ private function writeGenerator()
182213 }
183214
184215 /**
185- * Register all fonts and colors in both named and inline styles to appropriate header table.
216+ * Register all fonts, colors, and lists in both named and inline styles to appropriate header table.
186217 */
187- private function registerFont (): void
218+ private function registerHeader (): void
188219 {
189220 $ phpWord = $ this ->getParentWriter ()->getPhpWord ();
190221 $ this ->fontTable [] = Settings::getDefaultFontName ();
191222
192223 // Search named styles
193224 $ styles = Style::getStyles ();
194225 foreach ($ styles as $ style ) {
195- $ this ->registerFontItems ($ style );
226+ $ this ->registerHeaderItems ($ style );
196227 }
197228
198229 // Search inline styles
@@ -203,7 +234,7 @@ private function registerFont(): void
203234 foreach ($ elements as $ element ) {
204235 if (method_exists ($ element , 'getFontStyle ' )) {
205236 $ style = $ element ->getFontStyle ();
206- $ this ->registerFontItems ($ style );
237+ $ this ->registerHeaderItems ($ style );
207238 }
208239 }
209240 }
@@ -225,11 +256,11 @@ private function registerBorderColor($style): void
225256 }
226257
227258 /**
228- * Register fonts and colors .
259+ * Register fonts, colors, and lists .
229260 *
230261 * @param Style\AbstractStyle $style
231262 */
232- private function registerFontItems ($ style ): void
263+ private function registerHeaderItems ($ style ): void
233264 {
234265 $ defaultFont = Settings::getDefaultFontName ();
235266 $ defaultColor = Settings::DEFAULT_FONT_COLOR ;
@@ -247,6 +278,9 @@ private function registerFontItems($style): void
247278 $ this ->registerTableItem ($ this ->colorTable , $ style ->getBorderLeftColor (), $ defaultColor );
248279 $ this ->registerTableItem ($ this ->colorTable , $ style ->getBorderBottomColor (), $ defaultColor );
249280 }
281+ if ($ style instanceof Numbering) {
282+ $ this ->registerList ($ this ->listTable , $ style );
283+ }
250284 }
251285
252286 /**
@@ -262,4 +296,15 @@ private function registerTableItem(&$table, $value, $default = null): void
262296 $ table [] = $ value ;
263297 }
264298 }
299+
300+ /**
301+ * Register lists and fonts within lists.
302+ *
303+ * @param array &$table
304+ * @param Style\Numbering $style
305+ */
306+ private function registerList (&$ table , $ style ): void
307+ {
308+ $ table [] = [];
309+ }
265310}
0 commit comments