summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-08-23 09:09:57 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-08-23 13:20:32 +0200
commit5b518ab051cc04e672ceb01da42b06625a1a4ce9 (patch)
tree69402bec04d6d9620e406cf677adbcd3a2be458a /sw/qa
parentd239bf6d79e93f650a4241fcd2da0cb77c9cb95b (diff)
tdf#111964: only trim XML whitespace
OUString::trim() uses rtl_uString_newTrim, which relies upon rtl_ImplIsWhitespace. The latter treats as whitespaces not only characters with values less than or equal to 32, but also Unicode General Punctuation area Space and some Control characters. Thus, using OUString::trim() is incorrect when the goal is to trim XML whitespace, which is defined as one of 0x09, 0x0A, 0x0D, 0x20. The comments for OUString::trim() and rtl_uString_newTrim are corrected to describe which characters are considered whitespace. A unit test included. Change-Id: I45a132be923a52dcd5a4c35aeecb53d423b49fec Reviewed-on: https://gerrit.libreoffice.org/41444 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf111964.docxbin0 -> 1481 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx10
2 files changed, 10 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf111964.docx b/sw/qa/extras/ooxmlexport/data/tdf111964.docx
new file mode 100644
index 000000000000..7cb85a1d87df
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf111964.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 0f5e9c6320e5..f9cb088d5068 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -936,6 +936,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf109184, "tdf109184.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xff0000), getProperty<sal_Int32>(xCell3, "BackColor"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf111964, "tdf111964.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ // Unicode spaces that are not XML whitespace must not be trimmed
+ const sal_Unicode sWSReference [] { 0x2002, 0x2002, 0x2002, 0x2002, 0x2002, 0 };
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[4]/w:t", sWSReference);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */