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

Mike Kaganski mike.kaganski at collabora.com
Tue Jun 27 09:29:59 UTC 2017


 sw/qa/extras/ooxmlimport/data/tdf108806.docx          |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx              |   10 ++++++++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    9 +++++++--
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 6124490c1e486d648d75cd1c3f7f4e793fb1d1c0
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Tue Jun 27 07:50:12 2017 +0300

    tdf#108806: convert CRLF into space in OOXML text
    
    Change-Id: I8e2e108a705ecdb55c096a589d83d51c48b0b83c
    Reviewed-on: https://gerrit.libreoffice.org/39286
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/qa/extras/ooxmlimport/data/tdf108806.docx b/sw/qa/extras/ooxmlimport/data/tdf108806.docx
new file mode 100644
index 000000000000..007b10ae6f96
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf108806.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 673a2b5861cc..a5f7cf21cd96 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1291,6 +1291,16 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108408, "tdf108408.docx")
     CPPUNIT_ASSERT_EQUAL(double(20), getProperty<double>(xRun, "CharHeight"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf108806, "tdf108806.docx")
+{
+    // tdf#108806:The CRLF in the text contents of XML must be converted to single spaces.
+    CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
+    uno::Reference< text::XTextRange > paragraph = getParagraph(1);
+    CPPUNIT_ASSERT_EQUAL(
+        OUString("First part of a line (before CRLF). Second part of the same line (after CRLF)."),
+        paragraph->getString());
+}
+
 DECLARE_OOXMLIMPORT_TEST(testVmlAdjustments, "vml-adjustments.docx")
 {
     uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 48f51b4df512..e1b61a69411b 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -608,9 +608,14 @@ void OOXMLFastContextHandler::endTxbxContent()
 void OOXMLFastContextHandler::text(const OUString & sText)
 {
     if (isForwardEvents())
+    {
+        // tdf#108806: CRLFs in XML were converted to \n before this point.
+        // These must be converted to spaces before further processing.
+        OUString sNormalizedText = sText.replaceAll("\n", " ");
         mpStream->utext(reinterpret_cast < const sal_uInt8 * >
-                        (sText.getStr()),
-                        sText.getLength());
+                        (sNormalizedText.getStr()),
+                        sNormalizedText.getLength());
+    }
 }
 
 void OOXMLFastContextHandler::positionOffset(const OUString& rText)


More information about the Libreoffice-commits mailing list