summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlimport
diff options
context:
space:
mode:
authorJean-Sebastien Bevilacqua <realitix@gmail.com>2017-02-16 10:54:33 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-03-30 17:39:00 +0000
commitc568eb7d3bb4584867f0a1f0a7965f73097f009b (patch)
treeea7e6fb1e0d77369a90bc69dd8756f589bb352e4 /sw/qa/extras/ooxmlimport
parent53c2507bf97867011fd2bfbbac6c86b7fc494338 (diff)
tdf#105975 Add Formula field parsing (docx) in SWriter
Introduction ------------ In MSWord, you can create a formula field (starting with =). When you save your file as `docx`, this `FORMULA` field is registered in you file (a field starting with `=`). In its current state, LibreOffice can't parse the `FORMULA` 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 `FORMULA` support by adding it to the `aFields[]` variable. Next, to handle the `FORMULA` constant, we add a condition (swith case) in `DomainMapper_Impl::CloseFieldCommand()` to call `handleFieldFormula`. Note ---- In function `lcl_ExtractToken`, if command starts with `=`, it's a `FORMULA` field. Change-Id: If7d25de5413aa3133b22523d8a3f34ab6961adfc Reviewed-on: https://gerrit.libreoffice.org/34334 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw/qa/extras/ooxmlimport')
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf105975.docxbin0 -> 12754 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx17
2 files changed, 17 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf105975.docx b/sw/qa/extras/ooxmlimport/data/tdf105975.docx
new file mode 100644
index 000000000000..f9407df8889d
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf105975.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 7fb3871f32ed..208ed6370e7b 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -722,6 +722,23 @@ DECLARE_OOXMLIMPORT_TEST(testfdo76583, "fdo76583.docx")
lcl_countTextFrames( mxComponent, 1 );
}
+DECLARE_OOXMLIMPORT_TEST(testTdf105975formula, "tdf105975.docx")
+{
+ // Make sure the field contains a formula with 10 + 15
+ uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+
+ if( !xFields->hasMoreElements() ) {
+ CPPUNIT_ASSERT(false);
+ return;
+ }
+
+ uno::Reference<text::XTextField> xEnumerationAccess(xFields->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("10+15"), xEnumerationAccess->getPresentation(true).trim());
+ CPPUNIT_ASSERT_EQUAL(OUString("25"), xEnumerationAccess->getPresentation(false).trim());
+}
+
DECLARE_OOXMLIMPORT_TEST(testTdf75573, "tdf75573_page1frame.docx")
{
// the problem was that the frame was discarded