sw/qa/extras/rtfexport/data/tdf158826_extraCR.rtf | 23 ++++++++++++++++++++++ sw/qa/extras/rtfexport/rtfexport8.cxx | 14 +++++++++++++ writerfilter/source/rtftok/rtfdispatchflag.cxx | 4 ++- 3 files changed, 40 insertions(+), 1 deletion(-)
New commits: commit f2ebcfc09a9d2bac9792b0215f5d97bd990ffcef Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Wed Dec 27 18:58:33 2023 -0500 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Feb 12 17:35:28 2024 +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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161395 (cherry picked from commit 8d37b8e6430715860934ccaec8c0d1b448ac4d8c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163188 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> 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 97968caba437..0f01f4f36193 100644 --- a/sw/qa/extras/rtfexport/rtfexport8.cxx +++ b/sw/qa/extras/rtfexport/rtfexport8.cxx @@ -36,6 +36,8 @@ using namespace css; +namespace +{ class Test : public SwModelTestBase { public: @@ -141,6 +143,18 @@ DECLARE_RTFEXPORT_TEST(testAnnotationPar, "tdf136445-1-min.rtf") .isEmpty()); } +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 + uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY_THROW); +} + +} // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx index 23d8f5d1f59f..49e82d3b9a88 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;