sw/qa/extras/rtfexport/data/tdf158826_extraCR.rtf | 23 ++++++++++++++++++++++ sw/qa/extras/rtfexport/rtfexport8.cxx | 11 ++++++++++ writerfilter/source/rtftok/rtfdispatchflag.cxx | 4 ++- 3 files changed, 37 insertions(+), 1 deletion(-)
New commits: commit 4399bccc5ee5a3fa69a8818e7ae265c144d33d64 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Wed Dec 27 18:58:33 2023 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Thu Dec 28 22:51:13 2023 +0100 tdf#158826 rtfimport: ignore page break before document starts This avoids a 24.2 exposed bug from my commit 016f779ee6c7f601be3ae19dc57497e63a5bf817 RTF import simply cannot be relied upon to create paragraphs where they need to be. A side effect of fixing frames is that spurious paragraphs can be created, and if a frame starts the document, then an otherwise ignored page break can be attached to the second paragraph and thus become exposed. This seems pretty much like the RTF implementation of what was done for DOC and DOCX for tdf#118711. At least it is related. make CppunitTest_sw_rtfexport8 CPPUNIT_TEST_NAME=testTdf158826_extraCR The following unit tests trigger this code (with no visible change) abi10076.odt tdf121623.rtf tdf129513.rtf tdf131963.docx Change-Id: I21afa826b6f6fbb735591603a0620b8b47de517e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161374 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/rtfexport/data/tdf158826_extraCR.rtf b/sw/qa/extras/rtfexport/data/tdf158826_extraCR.rtf new file mode 100644 index 000000000000..5461327da3ca --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf158826_extraCR.rtf @@ -0,0 +1,23 @@ +{ tf1 +\landscape\paperh5953\paperw8391\margl720\margr720\margt432\margb1728\gutter0\ltrsect + + +\pagebb +\intbl +\pvpg\phpg + +\posx720\posy432 +\dxfrtext187\dfrmtxtx187\dfrmtxty0 +\wraparoundspalphaspnum +aautodjustright + in0\lin0bsnoovrlp1\pararsid5332093\yts39 + + +\shp + + +a +++ +} diff --git a/sw/qa/extras/rtfexport/rtfexport8.cxx b/sw/qa/extras/rtfexport/rtfexport8.cxx index 3023e51dcb21..9848d0573db8 100644 --- a/sw/qa/extras/rtfexport/rtfexport8.cxx +++ b/sw/qa/extras/rtfexport/rtfexport8.cxx @@ -86,6 +86,17 @@ DECLARE_RTFEXPORT_TEST(testTdf158586_lostFrame, "tdf158586_lostFrame.rtf") // CPPUNIT_ASSERT_EQUAL(2, getPages()); } +DECLARE_RTFEXPORT_TEST(testTdf158826_extraCR, "tdf158826_extraCR.rtf") +{ + // Note: this is a hand-minimized sample, and very likely doesn't follow RTF { } rules... + + // The page break defined before the document content should not cause a page break + CPPUNIT_ASSERT_EQUAL(1, getPages()); + + // There is a two-column floating table [that SHOULD be getParagraphOrTable(1)] + uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY_THROW); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx index 72c777aab1fb..753f1c3fbba9 100644 --- a/writerfilter/source/rtftok/rtfdispatchflag.cxx +++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx @@ -520,7 +520,9 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) } break; case RTFKeyword::PAGEBB: - nParam = NS_ooxml::LN_CT_PPrBase_pageBreakBefore; + // ignore a page break that is defined before the document content has even started + if (!m_bFirstRun) + nParam = NS_ooxml::LN_CT_PPrBase_pageBreakBefore; break; default: break;