tdf#148214 RTF import: avoid fake paragraph for \page when possible
commit3c610336a58f644525d5e4d2566c35eee6f7a618
authorMiklos Vajna <vmiklos@collabora.com>
Thu, 8 Sep 2022 18:14:27 +0000 (8 20:14 +0200)
committerMiklos Vajna <vmiklos@collabora.com>
Fri, 9 Sep 2022 06:18:28 +0000 (9 08:18 +0200)
tree64a2731aeb72475fcb40247260cc6124a6dd112b
parent5f86f491701dc9f6f52129cf87644167e95ab40a
tdf#148214 RTF import: avoid fake paragraph for \page when possible

The bugdoc has 2 pages, an explicit page break between them and the
first page has enough content that an additional fake paragraph at the
end would lead to a 3rd, unwanted page.

The fake paragraph was introduced in commit
7b58fc3dafc789aa55fff5ffef6ab83c3aa8b6e0 (fdo#48104 fix RTF import of
\page in inner groups, 2012-04-02), because dmapper ignores more than 1
page breaks in a paragraph.

Fix the problem by only inserting the fake paragraph in case the "page
break before" paragraph property would have no effect (very first
paragraph in the document) or we already sent characters (para props are
lazy-sent on the first character). This keeps existing cases working,
but avoids the unwanted fake paragraph in the bugdoc.

I suspect the root cause is that dmapper doesn't handle multiple page
breaks in a paragraph -- once that's fixed, this parBreak() call can be
completely removed.

Adjusted tests:

- testImportHeaderFooter: this asserted the presence of fake paragraphs,
  which are now gone in the easy case, so this change is an improvement

- testTdf133437: no visual difference before/after, probably the test
  intent was just "make sure this page has several shapes", the exact
  number isn't that interesting

Change-Id: Idd2b8a70b4122eb08d9d305018d384dc0bbb276a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139704
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
sw/qa/extras/rtfexport/rtfexport5.cxx
sw/qa/extras/rtfimport/rtfimport.cxx
writerfilter/CppunitTest_writerfilter_rtftok.mk
writerfilter/qa/cppunittests/rtftok/data/page.rtf [new file with mode: 0644]
writerfilter/qa/cppunittests/rtftok/rtfdispatchsymbol.cxx [new file with mode: 0644]
writerfilter/source/rtftok/rtfdispatchsymbol.cxx