summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-10-30 16:02:35 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-10-30 22:02:15 +0100
commit97f9af714ea1c46e498fa99f7ca34fc1708d38a6 (patch)
tree9513e5f25d034d39b41c5efe663e003c41a55a78 /sw
parent07d78b38fb9f62d533bf76f9d061134dc862438c (diff)
Related: tdf#125038 DOCX import: fix unexpected linebreak inside IF condition
Writer body text is expected to only contain the result of the field. So in case both the field command and the field result contains a linebreak, we need to make sure that linebreaks are ignored in the field command for field types where the Writer field implementation expects a single string. With this, the number of paragraphs in the bugdoc is now correct. Change-Id: I42f208d6943750ba2e8f88b52c373f6ca9cb2b71 Reviewed-on: https://gerrit.libreoffice.org/81786 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf125038b.docxbin0 -> 12649 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx17
2 files changed, 17 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf125038b.docx b/sw/qa/extras/ooxmlexport/data/tdf125038b.docx
new file mode 100644
index 000000000000..3aa189daded8
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf125038b.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 6dd91d44960a..82237bffa368 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -49,6 +49,23 @@ DECLARE_OOXMLIMPORT_TEST(testTdf125038, "tdf125038.docx")
CPPUNIT_ASSERT_EQUAL(OUString("phone: \t1234567890"), aActual);
}
+DECLARE_OOXMLIMPORT_TEST(testTdf125038b, "tdf125038b.docx")
+{
+ // Load a document with an IF field, where the IF field command contains a paragraph break.
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParagraphAccess(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParagraphs = xParagraphAccess->createEnumeration();
+ CPPUNIT_ASSERT(xParagraphs->hasMoreElements());
+ xParagraphs->nextElement();
+ CPPUNIT_ASSERT(xParagraphs->hasMoreElements());
+ xParagraphs->nextElement();
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expression: !xParagraphs->hasMoreElements()
+ // i.e. the document had 3 paragraphs, while only 2 was expected.
+ CPPUNIT_ASSERT(!xParagraphs->hasMoreElements());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */