diff options
author | Justin Luth <justin_luth@sil.org> | 2021-07-13 10:12:21 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-07-16 08:57:16 +0200 |
commit | fce76110e02409b67ad977ae0077adf55ca58065 (patch) | |
tree | 5521e452155e26543b8469a2111e80521e2c63b8 | |
parent | b42fe2e2653775743d20f02356a73aa8e3c2696a (diff) |
tdf#82111 rtf import: ensure CR before section break
In other places, there were caveats for applying a CR
when inserting instead of importing, or when in a header,
but none of those seem to apply in this case.
A section cannot occur in a table, and anytime a
section occurs, it ought to finish off the paragraph.
So a simple clause seems good enough here.
There were basically two different existing unit tests
that match this condition, and neither of them
were currently mis-handled. I safely adapted one of them
to imitate the error condition I was addressing.
Change-Id: Ie8ccd3978276bf10321e0bf80141572f40102874
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118819
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/qa/extras/rtfexport/data/pgndec.rtf | 1 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchsymbol.cxx | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfexport/data/pgndec.rtf b/sw/qa/extras/rtfexport/data/pgndec.rtf index 7f38c69101b8..bc53633e7a66 100644 --- a/sw/qa/extras/rtfexport/data/pgndec.rtf +++ b/sw/qa/extras/rtfexport/data/pgndec.rtf @@ -1,5 +1,6 @@ {\rtf1 \pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 +\par {\field\fldedit {\*\fldinst { PAGE \\* MERGEFORMAT } diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 714aa8f468b1..326c63a3cbae 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -1223,6 +1223,11 @@ DECLARE_RTFEXPORT_TEST(testPgndec, "pgndec.rtf") CPPUNIT_ASSERT_EQUAL( style::NumberingType::ARABIC, getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType")); + + // tdf#82111 ensure a pargraph exists before a section break. + // This was only two paragraphs, and both page number fields were in one para on page 2 ("11"). + getParagraph(2, "1"); + CPPUNIT_ASSERT_EQUAL(3, getParagraphs()); } DECLARE_RTFEXPORT_TEST(testTdf98806, "tdf98806.rtf") diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx index 88d303c0b2c1..df02f36fc18a 100644 --- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx +++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx @@ -133,6 +133,9 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) break; case RTFKeyword::SECT: { + if (m_bNeedCr) + dispatchSymbol(RTFKeyword::PAR); + m_bHadSect = true; if (m_bIgnoreNextContSectBreak) m_bIgnoreNextContSectBreak = false; |