diff options
author | brinzing <oliver.brinzing@gmx.de> | 2019-11-01 16:36:31 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-11-11 09:54:50 +0100 |
commit | fea5c10e222b10d83e0081dc1d1b2e678689d250 (patch) | |
tree | 257d63df6dc508092353728c80652a4d4eef0902 | |
parent | e4bf92ae344e0db16177de7fc9eed432339d8705 (diff) |
tdf#124986: docx: remove trailing quotation marks and spaces from set fields
Change-Id: I6390344b72b0148cff8e0ed5150d7abfc9490a2a
Reviewed-on: https://gerrit.libreoffice.org/81892
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/tdf124986.docx | bin | 0 -> 12108 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 21 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 8 |
3 files changed, 27 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf124986.docx b/sw/qa/extras/ooxmlexport/data/tdf124986.docx Binary files differnew file mode 100755 index 000000000000..e5bb8f4966b8 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf124986.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 12950c8451a7..98ee2ab45c48 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -67,6 +67,27 @@ DECLARE_OOXMLIMPORT_TEST(testTdf125038, "tdf125038.docx") CPPUNIT_ASSERT_EQUAL(OUString("phone: \t1234567890"), aActual); } +DECLARE_OOXMLIMPORT_TEST(testTdf124986, "tdf124986.docx") +{ + // Load a document with SET fields, where the SET fields contain leading/trailing quotation marks and spaces. + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + + while (xFields->hasMoreElements()) + { + uno::Reference<lang::XServiceInfo> xServiceInfo(xFields->nextElement(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xServiceInfo, uno::UNO_QUERY); + OUString aValue; + if (xServiceInfo->supportsService("com.sun.star.text.TextField.SetExpression")) + { + xPropertySet->getPropertyValue("Content") >>= aValue; + CPPUNIT_ASSERT_EQUAL(OUString("demo"), aValue); + } + } +} + DECLARE_OOXMLIMPORT_TEST(testTdf125038b, "tdf125038b.docx") { // Load a document with an IF field, where the IF field command contains a paragraph break. diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 732099649ae4..19f3e67aee73 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3650,9 +3650,13 @@ void DomainMapper_Impl::handleFieldSet sVariable = lcl_ExctractVariableAndHint(pContext->GetCommand(), sHint); // remove surrounding "" if exists - if( sHint.getLength() >= 2 && sHint.startsWith("\"") ) + if(sHint.getLength() >= 2) { - sHint = sHint.trim().copy(1, sHint.getLength() - 2); + OUString sTmp = sHint.trim(); + if (sTmp.startsWith("\"") && sTmp.endsWith("\"")) + { + sHint = sTmp.copy(1, sTmp.getLength() - 2); + } } // determine field master name |