@@ -106,7 +106,7 @@ public function addText($text, $fontStyle = null, $paragraphStyle = null, $eleme
106
106
$ elementClass = substr (get_class ($ this ), 0 , strrpos (get_class ($ this ), '\\' )) . '\\' . $ elementName ;
107
107
108
108
// Reset paragraph style for footnote and textrun. They have their own
109
- if (in_array ($ this ->container , array ('textrun ' , 'footnote ' , 'endnote ' ))) {
109
+ if (in_array ($ this ->container , array ('textrun ' , 'footnote ' , 'endnote ' , ' listitemrun ' ))) {
110
110
$ paragraphStyle = null ;
111
111
}
112
112
@@ -205,6 +205,26 @@ public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = n
205
205
return $ element ;
206
206
}
207
207
208
+ /**
209
+ * Add listitemrun element
210
+ *
211
+ * @param int $depth
212
+ * @param mixed $fontStyle
213
+ * @param mixed $listStyle
214
+ * @param mixed $paragraphStyle
215
+ * @return \PhpOffice\PhpWord\Element\ListItemRun
216
+ */
217
+ public function addListItemRun ($ depth = 0 , $ fontStyle = null , $ listStyle = null , $ paragraphStyle = null )
218
+ {
219
+ $ this ->checkValidity ('ListItemRun ' );
220
+
221
+ $ element = new ListItemRun ($ depth , $ fontStyle , $ listStyle , $ paragraphStyle );
222
+ $ element ->setDocPart ($ this ->getDocPart (), $ this ->getDocPartId ());
223
+ $ this ->addElement ($ element );
224
+
225
+ return $ element ;
226
+ }
227
+
208
228
/**
209
229
* Add table element
210
230
*
@@ -345,7 +365,7 @@ public function addTextBox($style = null)
345
365
private function checkValidity ($ method )
346
366
{
347
367
// Valid containers for each element
348
- $ allContainers = array ('section ' , 'header ' , 'footer ' , 'cell ' , 'textrun ' , 'footnote ' , 'endnote ' , 'textbox ' );
368
+ $ allContainers = array ('section ' , 'header ' , 'footer ' , 'cell ' , 'textrun ' , 'footnote ' , 'endnote ' , 'textbox ' , ' listitemrun ' );
349
369
$ validContainers = array (
350
370
'Text ' => $ allContainers ,
351
371
'Link ' => $ allContainers ,
@@ -354,6 +374,7 @@ private function checkValidity($method)
354
374
'Object ' => $ allContainers ,
355
375
'TextRun ' => array ('section ' , 'header ' , 'footer ' , 'cell ' , 'textbox ' ),
356
376
'ListItem ' => array ('section ' , 'header ' , 'footer ' , 'cell ' , 'textbox ' ),
377
+ 'ListItemRun ' => array ('section ' , 'header ' , 'footer ' , 'cell ' , 'textbox ' ),
357
378
'Table ' => array ('section ' , 'header ' , 'footer ' , 'textbox ' ),
358
379
'CheckBox ' => array ('section ' , 'header ' , 'footer ' , 'cell ' ),
359
380
'TextBox ' => array ('section ' , 'header ' , 'footer ' , 'cell ' ),
@@ -395,7 +416,7 @@ private function checkValidity($method)
395
416
*/
396
417
private function checkElementDocPart ()
397
418
{
398
- $ inOtherPart = in_array ($ this ->container , array ('cell ' , 'textrun ' , 'textbox ' ));
419
+ $ inOtherPart = in_array ($ this ->container , array ('cell ' , 'textrun ' , 'textbox ' , ' listitemrun ' ));
399
420
$ docPart = $ inOtherPart ? $ this ->getDocPart () : $ this ->container ;
400
421
$ docPartId = $ inOtherPart ? $ this ->getDocPartId () : $ this ->sectionId ;
401
422
$ inHeaderFooter = ($ docPart == 'header ' || $ docPart == 'footer ' );
0 commit comments