PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

RTF Writer: Border - Improved and Prepared for Future Implementations

Open rasamassen opened this issue 5 months ago • 2 comments

Description

RTF BorderWriter now detects the border type with the $type variable (each type of border has a different initial tag that must be set), implements setStyle and, for sections and paragraphs, setSpace.

RTF BorderWriter is prepared for future improvements to the RTF TableWriter, which currently doesn't use BorderWriter to write its borders.

RTF BorderWriter is prepared for future improvements to the elements FontStyle and RowStyle to allow borders there as well.

Documentation will be updated after this pull and pull #2831 are approved (as that pull created numerous documentation files, including borders.md).

Checklist:

  • [x] My CI is :green_circle:
  • [x] I have covered by unit tests my new code (check build/coverage for coverage report)
  • [x] I have updated the documentation to describe the changes
  • [x] I have updated the changelog

rasamassen avatar Oct 06 '25 02:10 rasamassen

Coverage Status

coverage: 96.763% (+0.006%) from 96.757% when pulling ac5c42290d28b2458b2abf4f8f3f180d13eb5b75 on rasamassen:border into 0ab0b4940bc52c7183e82ab2fd55324607037a73 on PHPOffice:master.

coveralls avatar Oct 06 '25 03:10 coveralls

Paragraph border colors need a little more attention. In Writer/RTF/Part/Header around line 470:

        if ($style instanceof Numbering) {
            $this->registerList($this->listTable, $style, $defaultFont);
        }

You need to add:

        if ($style instanceof Paragraph) {
            $this->registerBorderColor($style);
        }

That's pretty straightforward. The unexpected part is in Writer/Rtf/Element/AbstractElement. Around line 150:

$styleWriter = new ParagraphStyleWriter($this->paragraphStyle);

Add:

$styleWriter->setParentWriter($this->parentWriter);

oleibman avatar Nov 24 '25 05:11 oleibman