[Libreoffice-commits] core.git: sw/qa writerfilter/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 16 06:57:49 UTC 2021


 sw/qa/extras/rtfexport/data/pgndec.rtf           |    1 +
 sw/qa/extras/rtfexport/rtfexport.cxx             |    5 +++++
 writerfilter/source/rtftok/rtfdispatchsymbol.cxx |    3 +++
 3 files changed, 9 insertions(+)

New commits:
commit fce76110e02409b67ad977ae0077adf55ca58065
Author:     Justin Luth <justin_luth at sil.org>
AuthorDate: Tue Jul 13 10:12:21 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jul 16 08:57:16 2021 +0200

    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 at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

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;


More information about the Libreoffice-commits mailing list