[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - 2 commits - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Apr 26 14:19:48 UTC 2018


 sw/qa/extras/rtfexport/data/tdf116841.rtf        |   16 ++++++++++++++++
 sw/qa/extras/rtfexport/rtfexport2.cxx            |    3 ++-
 sw/qa/extras/rtfexport/rtfexport3.cxx            |    8 ++++++++
 sw/qa/extras/rtfimport/data/tdf117246.rtf        |   11 +++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx             |    6 ++++++
 writerfilter/source/dmapper/NumberingManager.cxx |    5 +++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx   |    9 +++++++++
 7 files changed, 57 insertions(+), 1 deletion(-)

New commits:
commit fc1ee8a8473beadbf5d364e059bba6c8006562af
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 26 12:03:12 2018 +0200

    tdf#117246 RTF import: don't loose page breaks inside nested groups
    
    Regression from e3f254ab8211fbab7541cde2100a35c875b0c240 (RTF import:
    fix spurious page breaks at doc end (related: rhbz#1065629),
    2014-02-27), the problem was that now we update the parser state to
    remember the next section break should set the break type of the current
    section to "next page", but this state should be remembered once the RTF
    group ends ("}" character), otherwise \page will be represented with a
    continuous break, i.e. lost.
    
    (cherry picked from commit 4a93b46e4652e73ed3460e4c66999d94e50db4b7)
    
    Change-Id: I69a8413f45e17e11d6d676c7bfd13ca7560b4d43
    Reviewed-on: https://gerrit.libreoffice.org/53506
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/rtfimport/data/tdf117246.rtf b/sw/qa/extras/rtfimport/data/tdf117246.rtf
new file mode 100644
index 000000000000..a6fc7cf94426
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf117246.rtf
@@ -0,0 +1,11 @@
+{\rtf1
+\sbknone\pard\plain
+{Page 1}
+{\par }
+{\page }
+{Page 2}
+{\par }
+{\page }
+{Page 3}
+{\par }
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 254e203398e3..b3ca9eeedd25 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -138,6 +138,12 @@ DECLARE_RTFIMPORT_TEST(testN695479, "n695479.rtf")
     CPPUNIT_ASSERT(bDrawFound);
 }
 
+DECLARE_RTFIMPORT_TEST(testTdf117246, "tdf117246.rtf")
+{
+    // This was 2, all but the last \page was lost.
+    CPPUNIT_ASSERT_EQUAL(3, getPages());
+}
+
 DECLARE_RTFIMPORT_TEST(testTdf108943, "tdf108943.rtf")
 {
     uno::Reference<beans::XPropertySet> xPropertySet(
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index b3bc922dd437..b23c01af91ff 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3333,6 +3333,15 @@ RTFError RTFDocumentImpl::popState()
         // don't do it again in the outer state later.
         m_aStates.top().nTableRowWidthAfter = 0;
 
+    if (m_nResetBreakOnSectBreak != RTF_invalid && !m_aStates.empty())
+    {
+        // Section break type created for \page still has an effect in the
+        // outer state as well.
+        RTFValue::Pointer_t pType = aState.aSectionSprms.find(NS_ooxml::LN_EG_SectPrContents_type);
+        if (pType)
+            m_aStates.top().aSectionSprms.set(NS_ooxml::LN_EG_SectPrContents_type, pType);
+    }
+
     return RTFError::OK;
 }
 
commit 03b987372b680a8ecfac61d976c69f7443acba11
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Apr 23 22:09:23 2018 +0200

    tdf#116841 RTF import: fix default value of left para margin from numbering
    
    The left mragin value is usually spelled out in RTF and DOCX, but this
    bugdoc used the WW6 RTF markup to declare the numbering rules and there
    the margin value was missing.
    
    This also allows me to partially revert the changes to testTdf106953
    from commit 56a695fddb915bcba13b088b5b2b4e0841d4acbc (tdf#112211 RTF
    import: fix unwanted direct formatting for left indents, 2017-09-26).
    
    (cherry picked from commit 810364653b8e5ef8578ae7c9fc2e3b9196e7cdc4)
    
    Conflicts:
            sw/qa/extras/rtfexport/rtfexport3.cxx
    
    Change-Id: I9902f2f9ada4080cb4d873624ae9824342c6ee77
    Reviewed-on: https://gerrit.libreoffice.org/53433
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/rtfexport/data/tdf116841.rtf b/sw/qa/extras/rtfexport/data/tdf116841.rtf
new file mode 100644
index 000000000000..75ff4878d7ab
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf116841.rtf
@@ -0,0 +1,16 @@
+{\rtf1\ansi\ansicpg1252\deff0\deflang1034
+{\fonttbl
+{\f0\fnil\fcharset0\fprq0\fttruetype Times New Roman;}
+{\f1\fnil\fcharset0\fprq0\fttruetype Arial;}
+{\f2\fnil\fcharset0\fprq0\fttruetype Courier New;}
+}
+\kerning0\cf0\viewkind1\paperw11905\paperh16837\margl1440\margr1440\widowctl
+\sectd\sbknone\colsx360\headery0\footery0
+\pard
+{\*\pn\pnql\pnstart0\pnlvlblt
+{\pntxtb\bullet}
+}
+\fi-431\li720
+{\f0\fs24\lang1033
+This is item one}
+\par\pard}
diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx
index 802ff33f89c1..6331b33e8e62 100644
--- a/sw/qa/extras/rtfexport/rtfexport2.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport2.cxx
@@ -1089,10 +1089,11 @@ DECLARE_RTFEXPORT_TEST(testN825305, "n825305.rtf")
 
 DECLARE_RTFEXPORT_TEST(testTdf106953, "tdf106953.rtf")
 {
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270),
+                         getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
     auto xRules = getProperty<uno::Reference<container::XIndexAccess>>(
         getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
     comphelper::SequenceAsHashMap aRule(xRules->getByIndex(0));
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), aRule["IndentAt"].get<sal_Int32>());
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aRule["FirstLineIndent"].get<sal_Int32>());
 }
 
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 0c63f23972e0..beaf63faf020 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -68,6 +68,14 @@ DECLARE_RTFEXPORT_TEST(testTdf104035, "tdf104035.rtf")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(450)), aTabStops[0].Position);
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf116841, "tdf116841.rtf")
+{
+    // This was 0, left margin was ignored as we assumed the default is already
+    // fine for us.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270),
+                         getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 108ce7f5c2ce..878e949e4976 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -315,6 +315,11 @@ uno::Sequence<beans::PropertyValue> ListLevel::GetLevelProperties(bool bDefaults
         else if (rReadId == PROP_FIRST_LINE_INDENT && bDefaults)
             // Writer default is -360 twips, Word default seems to be 0.
             aNumberingProperties.emplace_back("FirstLineIndent", 0, uno::makeAny(static_cast<sal_Int32>(0)), beans::PropertyState_DIRECT_VALUE);
+        else if (rReadId == PROP_INDENT_AT && bDefaults)
+            // Writer default is 720 twips, Word default seems to be 0.
+            aNumberingProperties.emplace_back("IndentAt", 0,
+                                              uno::makeAny(static_cast<sal_Int32>(0)),
+                                              beans::PropertyState_DIRECT_VALUE);
     }
 
     boost::optional<PropertyMap::Property> aPropFont = getProperty(PROP_CHAR_FONT_NAME);


More information about the Libreoffice-commits mailing list