@@ -100,7 +100,7 @@ public function addText($text, $fontStyle = null, $paragraphStyle = null, $eleme
100
100
*/
101
101
public function addTextRun ($ paragraphStyle = null )
102
102
{
103
- $ this ->checkValidity ('Textrun ' );
103
+ $ this ->checkValidity ('TextRun ' );
104
104
105
105
$ element = new TextRun ($ paragraphStyle );
106
106
$ element ->setDocPart ($ this ->getDocPart (), $ this ->getDocPartId ());
@@ -327,10 +327,10 @@ private function checkValidity($method)
327
327
'TextBreak ' => $ allContainers ,
328
328
'Image ' => $ allContainers ,
329
329
'Object ' => $ allContainers ,
330
- 'TextRun ' => array ('section ' , 'header ' , 'footer ' , 'cell ' ),
331
- 'ListItem ' => array ('section ' , 'header ' , 'footer ' , 'cell ' ),
330
+ 'TextRun ' => array ('section ' , 'header ' , 'footer ' , 'cell ' , ' textbox ' ),
331
+ 'ListItem ' => array ('section ' , 'header ' , 'footer ' , 'cell ' , ' textbox ' ),
332
332
'CheckBox ' => array ('section ' , 'header ' , 'footer ' , 'cell ' ),
333
- 'TextBox ' => array ('section ' , 'header ' , 'footer ' ),
333
+ 'TextBox ' => array ('section ' , 'header ' , 'footer ' , ' cell ' ),
334
334
'Footnote ' => array ('section ' , 'textrun ' , 'cell ' ),
335
335
'Endnote ' => array ('section ' , 'textrun ' , 'cell ' ),
336
336
'PreserveText ' => array ('header ' , 'footer ' , 'cell ' ),
@@ -346,7 +346,7 @@ private function checkValidity($method)
346
346
// Check if a method is valid for current container
347
347
if (array_key_exists ($ method , $ validContainers )) {
348
348
if (!in_array ($ this ->container , $ validContainers [$ method ])) {
349
- throw new \BadMethodCallException ();
349
+ throw new \BadMethodCallException (" Cannot put $ method in $ this -> container . " );
350
350
}
351
351
}
352
352
// Check if a method is valid for current container, located in other container
@@ -356,7 +356,7 @@ private function checkValidity($method)
356
356
$ allowedDocParts = $ rules [1 ];
357
357
foreach ($ containers as $ container ) {
358
358
if ($ this ->container == $ container && !in_array ($ this ->getDocPart (), $ allowedDocParts )) {
359
- throw new \BadMethodCallException ();
359
+ throw new \BadMethodCallException (" Cannot put $ method in $ this -> container . " );
360
360
}
361
361
}
362
362
}
@@ -369,11 +369,12 @@ private function checkValidity($method)
369
369
*/
370
370
private function checkElementDocPart ()
371
371
{
372
- $ isCellTextrun = in_array ($ this ->container , array ('cell ' , 'textrun ' , 'textbox ' ));
373
- $ docPart = $ isCellTextrun ? $ this ->getDocPart () : $ this ->container ;
374
- $ docPartId = $ isCellTextrun ? $ this ->getDocPartId () : $ this ->sectionId ;
372
+ $ inOtherPart = in_array ($ this ->container , array ('cell ' , 'textrun ' , 'textbox ' ));
373
+ $ docPart = $ inOtherPart ? $ this ->getDocPart () : $ this ->container ;
374
+ $ docPartId = $ inOtherPart ? $ this ->getDocPartId () : $ this ->sectionId ;
375
375
$ inHeaderFooter = ($ docPart == 'header ' || $ docPart == 'footer ' );
376
376
$ docPartId = $ inHeaderFooter ? $ this ->getDocPartId () : $ docPartId ;
377
+
377
378
return $ inHeaderFooter ? $ docPart . $ docPartId : $ docPart ;
378
379
}
379
380
0 commit comments