summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2019-11-17 20:07:45 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2019-11-18 21:26:38 +0100
commitfeff6668d8e978f37b37fe043858297eb3b4a2d4 (patch)
treea2088e588f3d461b2aafe5fe76f697d9a71c96b7 /sw/qa
parent543a0658f961f24db6804b90c5389aee15ba2ce4 (diff)
Extend DOCX input field export test for round-trip
This expands the test from tdf#125103 to include more use cases and validate the import of the exported document (tdf#128460). Change-Id: Ifb8615b6b90931996becb8cb44d846eb30956971 Reviewed-on: https://gerrit.libreoffice.org/83038 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/ooxmlexport/data/textinput.odtbin10085 -> 9544 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx67
2 files changed, 63 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/textinput.odt b/sw/qa/extras/ooxmlexport/data/textinput.odt
index 04b8d054c354..3a5da684a0a0 100644
--- a/sw/qa/extras/ooxmlexport/data/textinput.odt
+++ b/sw/qa/extras/ooxmlexport/data/textinput.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 0d9cd773ef9a..e59df2a5ca53 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -465,10 +465,69 @@ DECLARE_OOXMLEXPORT_TEST(testTextInput, "textinput.odt")
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
- // Ensure we have a formfield
- assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[3]/w:instrText", " FILLIN \"\"");
- // and it's content is not gone
- assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[5]/w:t", "SomeText");
+
+ // test the exported DOCX
+
+ // no hint, empty
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[3]/w:instrText", " FILLIN \"\"");
+ assertXPathChildren(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[5]", 1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[5]/w:rPr", 1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[6]/w:fldChar", "fldCharType", "end");
+
+ // no hint, content
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[3]/w:instrText", " FILLIN \"\"");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[5]/w:t", "content without hint");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[6]/w:fldChar", "fldCharType", "end");
+
+ // hint, empty
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[3]/w:instrText", " FILLIN \"hint empty\"");
+ assertXPathChildren(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[5]", 1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[5]/w:rPr", 1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[6]/w:fldChar", "fldCharType", "end");
+
+ // hint, content
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[4]/w:r[3]/w:instrText", " FILLIN \"hint content\"");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[4]/w:r[5]/w:t", "content with hint");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:r[6]/w:fldChar", "fldCharType", "end");
+
+ // test the imported DOCX
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+ CPPUNIT_ASSERT(xFields->hasMoreElements());
+ int nElements = 0;
+
+ do
+ {
+ uno::Any aField = xFields->nextElement();
+ uno::Reference<lang::XServiceInfo> xServiceInfo(aField, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.textfield.Input"));
+ uno::Reference<beans::XPropertySet> xPropertySet(aField, uno::UNO_QUERY);
+ uno::Reference<text::XTextContent> xText(aField, uno::UNO_QUERY);
+
+ // why is the enumeration not in the same order then the fields in the document?
+ // it seems to be stable and the navigation in the GUI is actually correct.
+ OUString sContent, sHint;
+ switch (nElements)
+ {
+ case 1:
+ sContent = "content with hint";
+ sHint = "hint content";
+ break;
+ case 2:
+ sHint = "hint empty";
+ break;
+ case 3:
+ sContent = "content without hint";
+ break;
+ }
+ CPPUNIT_ASSERT_EQUAL(uno::makeAny(sContent), xPropertySet->getPropertyValue("Content"));
+ CPPUNIT_ASSERT_EQUAL(sContent, xText->getAnchor()->getString());
+ CPPUNIT_ASSERT_EQUAL(uno::makeAny(sHint), xPropertySet->getPropertyValue("Hint"));
+ nElements++;
+ }
+ while (xFields->hasMoreElements());
+ CPPUNIT_ASSERT_EQUAL(4, nElements);
}
DECLARE_OOXMLIMPORT_TEST(testTdf123460, "tdf123460.docx")