@@ -106,7 +106,7 @@ public function addText($text, $fontStyle = null, $paragraphStyle = null, $eleme
106106 $ elementClass = substr (get_class ($ this ), 0 , strrpos (get_class ($ this ), '\\' )) . '\\' . $ elementName ;
107107
108108 // 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 ' ))) {
110110 $ paragraphStyle = null ;
111111 }
112112
@@ -205,6 +205,26 @@ public function addListItem($text, $depth = 0, $fontStyle = null, $listStyle = n
205205 return $ element ;
206206 }
207207
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+
208228 /**
209229 * Add table element
210230 *
@@ -345,7 +365,7 @@ public function addTextBox($style = null)
345365 private function checkValidity ($ method )
346366 {
347367 // 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 ' );
349369 $ validContainers = array (
350370 'Text ' => $ allContainers ,
351371 'Link ' => $ allContainers ,
@@ -354,6 +374,7 @@ private function checkValidity($method)
354374 'Object ' => $ allContainers ,
355375 'TextRun ' => array ('section ' , 'header ' , 'footer ' , 'cell ' , 'textbox ' ),
356376 'ListItem ' => array ('section ' , 'header ' , 'footer ' , 'cell ' , 'textbox ' ),
377+ 'ListItemRun ' => array ('section ' , 'header ' , 'footer ' , 'cell ' , 'textbox ' ),
357378 'Table ' => array ('section ' , 'header ' , 'footer ' , 'textbox ' ),
358379 'CheckBox ' => array ('section ' , 'header ' , 'footer ' , 'cell ' ),
359380 'TextBox ' => array ('section ' , 'header ' , 'footer ' , 'cell ' ),
@@ -395,7 +416,7 @@ private function checkValidity($method)
395416 */
396417 private function checkElementDocPart ()
397418 {
398- $ inOtherPart = in_array ($ this ->container , array ('cell ' , 'textrun ' , 'textbox ' ));
419+ $ inOtherPart = in_array ($ this ->container , array ('cell ' , 'textrun ' , 'textbox ' , ' listitemrun ' ));
399420 $ docPart = $ inOtherPart ? $ this ->getDocPart () : $ this ->container ;
400421 $ docPartId = $ inOtherPart ? $ this ->getDocPartId () : $ this ->sectionId ;
401422 $ inHeaderFooter = ($ docPart == 'header ' || $ docPart == 'footer ' );
0 commit comments