summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJean-Sebastien Bevilacqua <realitix@gmail.com>2017-02-16 10:16:50 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-03-28 07:05:30 +0000
commit4d5ce76d894d2335b551f8c2b29437e2049894f0 (patch)
tree152ac7f5dabfc7f7cb1df385dac8ed63a3afa1d1 /sw
parentb3549aacabffad3c4c66d901938d59e4789eef22 (diff)
tdf#105975 Add Set field parsing (docx) in LibreOffice Writer
Introduction ------------ In MSWord, you can create a variable with `SET` field and then reference it later in a formula. When you save your file as `docx`, this `SET` field is registered in you file. In its current state, LibreOffice can't parse the `SET` field in `docx` file. Context of this fix ------------------- This fix is entirely located in the `DomainMapper_Impl.cxx` file because it's where the parsing is done. How this fix works ------------------ First, we add `SET` support by adding it to the `aFields[]` variable. Next, to handle the `SET` constant, we add a condition (swith case) in `DomainMapper_Impl::CloseFieldCommand()` to call `handleFieldSet`. Finally, `handleFieldSet` works like `handleFieldAsk` with small differences. Note ---- I have renamed `lcl_ExctractAskVariableAndHint` to `lcl_ExctractVariableAndHint` because this function is used for both `ASK` and `SET` fields. Change-Id: I2bf948e26e8506ac151d1d0bc8556721bbe0392b Reviewed-on: https://gerrit.libreoffice.org/34333 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx2
-rw-r--r--sw/qa/extras/ooxmlimport/data/105975.docxbin0 -> 12783 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx8
3 files changed, 9 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index ec8b13621001..d473a13f73e2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -432,7 +432,7 @@ DECLARE_OOXMLEXPORT_TEST(testFDO76163 , "fdo76163.docx")
if (!pXmlDoc)
return;
//docx file after RT is getting corrupted.
- assertXPath ( pXmlDoc, "/w:document/w:body/w:p[2]/w:hyperlink/w:r[11]/w:fldChar", "fldCharType", "end" );
+ assertXPath ( pXmlDoc, "/w:document/w:body/w:p[2]/w:hyperlink/w:r[10]/w:fldChar", "fldCharType", "end" );
}
DECLARE_OOXMLEXPORT_TEST(testFDO78659, "fdo78659.docx")
diff --git a/sw/qa/extras/ooxmlimport/data/105975.docx b/sw/qa/extras/ooxmlimport/data/105975.docx
new file mode 100644
index 000000000000..b902aa168a9a
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/105975.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 77880b935b96..87c71b8afb6b 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -699,6 +699,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf105143, "tdf105143.docx")
CPPUNIT_ASSERT_EQUAL(OUString("6674"), aTop);
}
+DECLARE_OOXMLIMPORT_TEST(testTdf105975, "105975.docx")
+{
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xMasters(xTextFieldsSupplier->getTextFieldMasters());
+ // Make sure we have a variable named TEST_VAR.
+ CPPUNIT_ASSERT(xMasters->hasByName("com.sun.star.text.FieldMaster.SetExpression.TEST_VAR"));
+}
+
DECLARE_OOXMLIMPORT_TEST(testfdo76583, "fdo76583.docx")
{
// The problem was that the floating table was imported as a non-floating one.