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 <jluth@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.stahl@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 0000000..5461327
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf158826_extraCR.rtf
@@ -0,0 +1,23 @@
{\rtf1
\landscape\paperh5953\paperw8391\margl720\margr720\margt432\margb1728\gutter0\ltrsect
\pagebb
\intbl
\pvpg\phpg
\posx720\posy432
\dxfrtext187\dfrmtxtx187\dfrmtxty0
\wraparound\aspalpha\aspnum
\faauto\adjustright
\rin0\lin0\absnoovrlp1\pararsid5332093\yts39
\shp
a \cell b{\cell }
\clwWidth6300\clshdrawnil \cellx6295
\clwWidth4500\clshdrawnil \cellx10795\row
}
diff --git a/sw/qa/extras/rtfexport/rtfexport8.cxx b/sw/qa/extras/rtfexport/rtfexport8.cxx
index 97968ca..0f01f4f 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 23d8f5d..49e82d3 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;