@@ -477,10 +477,51 @@ protected function _writeTextStyle(PHPWord_Shared_XMLWriter $objWriter = null, P
477
477
478
478
/**
479
479
* Write text break
480
+ *
481
+ * @param PHPWord_Shared_XMLWriter $objWriter
482
+ * @param PHPWord_Section_TextBreak $element
480
483
*/
481
- protected function _writeTextBreak (PHPWord_Shared_XMLWriter $ objWriter = null )
484
+ protected function _writeTextBreak ($ objWriter, $ element = null )
482
485
{
483
- $ objWriter ->writeElement ('w:p ' , null );
486
+ $ hasStyle = false ;
487
+ if (!is_null ($ element )) {
488
+ $ fontStyle = $ element ->getFontStyle ();
489
+ $ sfIsObject = ($ fontStyle instanceof PHPWord_Style_Font) ? true : false ;
490
+ $ paragraphStyle = $ element ->getParagraphStyle ();
491
+ $ spIsObject = ($ paragraphStyle instanceof PHPWord_Style_Paragraph) ? true : false ;
492
+ $ hasStyle = !is_null ($ fontStyle ) || !is_null ($ paragraphStyle );
493
+ }
494
+ if ($ hasStyle ) {
495
+ // Paragraph style
496
+ $ objWriter ->startElement ('w:p ' );
497
+ if ($ spIsObject ) {
498
+ $ this ->_writeParagraphStyle ($ objWriter , $ paragraphStyle );
499
+ } elseif (!$ spIsObject && !is_null ($ paragraphStyle )) {
500
+ $ objWriter ->startElement ('w:pPr ' );
501
+ $ objWriter ->startElement ('w:pStyle ' );
502
+ $ objWriter ->writeAttribute ('w:val ' , $ paragraphStyle );
503
+ $ objWriter ->endElement (); // w:pStyle
504
+ $ objWriter ->endElement (); // w:pPr
505
+ }
506
+ // Font style
507
+ if (!is_null ($ fontStyle )) {
508
+ $ objWriter ->startElement ('w:pPr ' );
509
+ if ($ sfIsObject ) {
510
+ $ this ->_writeTextStyle ($ objWriter , $ fontStyle );
511
+ } elseif (!$ sfIsObject && !is_null ($ fontStyle )) {
512
+ $ objWriter ->startElement ('w:rPr ' );
513
+ $ objWriter ->startElement ('w:rStyle ' );
514
+ $ objWriter ->writeAttribute ('w:val ' , $ fontStyle );
515
+ $ objWriter ->endElement (); // w:rStyle
516
+ $ objWriter ->endElement (); // w:rPr
517
+ }
518
+ $ objWriter ->endElement (); // w:pPr
519
+ }
520
+ $ objWriter ->endElement (); // w:p
521
+ } else {
522
+ // Null element. No paragraph nor font style
523
+ $ objWriter ->writeElement ('w:p ' , null );
524
+ }
484
525
}
485
526
486
527
/**
@@ -570,7 +611,7 @@ protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo
570
611
} elseif ($ element instanceof PHPWord_Section_Link) {
571
612
$ this ->_writeLink ($ objWriter , $ element );
572
613
} elseif ($ element instanceof PHPWord_Section_TextBreak) {
573
- $ this ->_writeTextBreak ($ objWriter );
614
+ $ this ->_writeTextBreak ($ objWriter, $ element );
574
615
} elseif ($ element instanceof PHPWord_Section_ListItem) {
575
616
$ this ->_writeListItem ($ objWriter , $ element );
576
617
} elseif ($ element instanceof PHPWord_Section_Image ||
0 commit comments