sw/qa/extras/ooxmlexport/data/tdf124986.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport12.cxx | 22 ++++++++++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 8 ++++++-- 3 files changed, 28 insertions(+), 2 deletions(-)
New commits: commit 701b5cfe9d908b346e95054b565d05747775ae79 Author: brinzing <oliver.brinz...@gmx.de> AuthorDate: Fri Nov 1 16:36:31 2019 +0100 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Tue Dec 10 00:25:28 2019 +0100 tdf#124986: docx: remove trailing quotation marks and spaces from set fields Reviewed-on: https://gerrit.libreoffice.org/81892 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport14.cxx Change-Id: I6390344b72b0148cff8e0ed5150d7abfc9490a2a Reviewed-on: https://gerrit.libreoffice.org/84793 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sw/qa/extras/ooxmlexport/data/tdf124986.docx b/sw/qa/extras/ooxmlexport/data/tdf124986.docx new file mode 100755 index 000000000000..e5bb8f4966b8 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf124986.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx index d7d41b1d1e36..fc79b451ce39 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -771,6 +771,28 @@ DECLARE_OOXMLEXPORT_TEST(testTdf105444, "tdf105444.docx") assertXPath(pXmlComm, "/w:comments/w:comment/w:p", 1); } +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); + } + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index ecb73bb038f4..2506a9609206 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3149,9 +3149,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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits