diff --git a/docs/changes/1.x/1.5.0.md b/docs/changes/1.x/1.5.0.md index b96865bada..f582c281eb 100644 --- a/docs/changes/1.x/1.5.0.md +++ b/docs/changes/1.x/1.5.0.md @@ -7,6 +7,7 @@ ### Bug fixes - Set writeAttribute return type by [@radarhere](https://github.com/radarhere) fixing [#2204](https://github.com/PHPOffice/PHPWord/issues/2204) in [#2776](https://github.com/PHPOffice/PHPWord/pull/2776) +- Writer RTF: Support for type 'bar' and leaders in Tab by [@rasamassen](https://github.com/rasamassen) in [#2815](https://github.com/PHPOffice/PHPWord/pull/2815) ### Miscellaneous @@ -16,4 +17,4 @@ ### BC Breaks -### Notes \ No newline at end of file +### Notes diff --git a/src/PhpWord/Writer/RTF/Style/Tab.php b/src/PhpWord/Writer/RTF/Style/Tab.php index 95e1f10a5c..9fcc036297 100644 --- a/src/PhpWord/Writer/RTF/Style/Tab.php +++ b/src/PhpWord/Writer/RTF/Style/Tab.php @@ -38,12 +38,24 @@ public function write() \PhpOffice\PhpWord\Style\Tab::TAB_STOP_RIGHT => '\tqr', \PhpOffice\PhpWord\Style\Tab::TAB_STOP_CENTER => '\tqc', \PhpOffice\PhpWord\Style\Tab::TAB_STOP_DECIMAL => '\tqdec', + \PhpOffice\PhpWord\Style\Tab::TAB_LEADER_DOT => '\tldot', + \PhpOffice\PhpWord\Style\Tab::TAB_LEADER_HYPHEN => '\tlhyph', + \PhpOffice\PhpWord\Style\Tab::TAB_LEADER_UNDERSCORE => '\tlul', + \PhpOffice\PhpWord\Style\Tab::TAB_LEADER_HEAVY => '\tlth', + \PhpOffice\PhpWord\Style\Tab::TAB_LEADER_MIDDLEDOT => '\tlmdot', ]; $content = ''; if (isset($tabs[$style->getType()])) { $content .= $tabs[$style->getType()]; } - $content .= '\tx' . round($style->getPosition()); + if (isset($tabs[$style->getLeader()])) { + $content .= $tabs[$style->getLeader()]; + } + if ($style->getType() == \PhpOffice\PhpWord\Style\Tab::TAB_STOP_BAR) { + $content .= '\tb' . round($style->getPosition()); + } else { + $content .= '\tx' . round($style->getPosition()); + } return $content; }