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

Luke Deller luke at deller.id.au
Mon Mar 5 09:27:09 UTC 2018


 sw/qa/extras/ooxmlexport/data/tdf107035.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx   |   24 ++++++++++++++++++++++++
 sw/source/core/unocore/unotext.cxx           |    4 ++++
 3 files changed, 28 insertions(+)

New commits:
commit 18cbb8fe699131a234355e1d00fa917fede6ac46
Author: Luke Deller <luke at deller.id.au>
Date:   Mon Mar 5 00:14:28 2018 +1100

    tdf#107035 Fix field character style DOCX import
    
    Reinstate a call to DontExpandFormat which was removed from
    appendTextContent in commit 232ad2f2588beff50cb5c1f3b689c581ba317583
    
    This ensures that direct character formatting which ended immediately
    before the insertion point will not be expanded to cover the inserted
    content.
    
    Change-Id: Ie5fa6b5c5acee4f885f9e67535e98801af23661a
    Reviewed-on: https://gerrit.libreoffice.org/50729
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf107035.docx b/sw/qa/extras/ooxmlexport/data/tdf107035.docx
new file mode 100644
index 000000000000..a8ab045b61c9
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf107035.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 4960c87bd9d0..ebc3d81d9f4a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -263,6 +263,30 @@ DECLARE_OOXMLEXPORT_TEST(testTdf113258, "tdf113258.docx")
                          getProperty<sal_Int32>(xShape->getStart(), "ParaTopMargin"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf107035, "tdf107035.docx")
+{
+    // Select the second run containing the page number field
+    auto xPgNumRun = getRun(getParagraph(1), 2, "1");
+
+    // Check that the page number field colour is set to "automatic".
+    sal_Int32 nPgNumColour = getProperty<sal_Int32>(xPgNumRun, "CharColor");
+#if 0
+    // TODO Enable this once tdf#116179 is fixed
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), nPgNumColour);
+
+#else
+    // Meanwhile just check that the page number field colour is different
+    // from the green text before it:
+
+    // Select the first run containing the green text
+    auto xTextRun = getRun(getParagraph(1), 1);
+
+    // Check that the page number field colour is different from the green text
+    CPPUNIT_ASSERT(getProperty<sal_Int32>(xTextRun, "CharColor") != nPgNumColour);
+#endif
+
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index db3d78c9c382..6d01370e5d19 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -528,6 +528,10 @@ SwXText::insertTextContent(
         aIllegal.Message = "first parameter invalid";
         throw aIllegal;
     }
+    // Any direct formatting ending at the insert position (xRange) should not
+    // be expanded to cover the inserted content (xContent)
+    GetDoc()->DontExpandFormat( *aPam.Start() );
+
     // first test if the range is at the right position, then call
     // xContent->attach
     const SwStartNode* pOwnStartNode = GetStartNode();


More information about the Libreoffice-commits mailing list