sw/qa/extras/rtfimport/data/fdo80905.rtf | 12 ++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 10 ++++++++++ sw/source/core/unocore/unofield.cxx | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-)
New commits: commit d0a7a60cfa1a34ec7218656489b7463cd9eb1aad Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sun Jul 13 18:02:29 2014 +0200 fdo#80905 SwXTextFieldMasters::hasByName(): sync with SwXFieldMaster Normally a mail merge field has a name like "css.text.fieldmaster.DataBase.<datasource name>.<table name>.<column name>", however this isn't enforced: just "css.text.fieldmaster.DataBase.TEST" is also accepted (even if its semantics are ~undefined). If SwXFieldMaster::setPropertyValue() allows setting such a field master name, then SwXTextFieldMasters::hasByName() should not ignore such field masters that have no dot in their name ("TEST") or use "Database", not "DataBase", otherwise (sane) client code in writerfilter ends up with hasByName() returning false, but setPropertyValue() throwing an exception, because the field master does have such a name. This fixes DOCX/RTF import of multiple mail merge fields with the same field command. Change-Id: I498eabace25f8e466b3504ba13fa3060d4ba22da diff --git a/sw/qa/extras/rtfimport/data/fdo80905.rtf b/sw/qa/extras/rtfimport/data/fdo80905.rtf new file mode 100644 index 0000000..c088fe0 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo80905.rtf @@ -0,0 +1,12 @@ +{\rtf1 +\pard\plain +{\field +{\*\fldinst MERGEFIELD TEST \\* Upper \\* MERGEFORMAT} +{\fldrslt \'abTEST\'bb} +} +{\field +{\*\fldinst MERGEFIELD TEST \\* Upper \\* MERGEFORMAT} +{\fldrslt \'abTEST\'bb} +} +\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 0adabdc..76de5bb 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1774,6 +1774,16 @@ DECLARE_RTFIMPORT_TEST(testFdo73241, "fdo73241.rtf") CPPUNIT_ASSERT_EQUAL(1, getPages()); } +DECLARE_RTFIMPORT_TEST(testFdo80905, "fdo80905.rtf") +{ + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + xFields->nextElement(); + // The problem was that there was only one field in the document, but there should be true. + CPPUNIT_ASSERT_EQUAL(true, static_cast<bool>(xFields->hasMoreElements())); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index a05c41f..b524ecc 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -2673,11 +2673,11 @@ static sal_uInt16 lcl_GetIdByName( OUString& rName, OUString& rTypeName ) if( sUIName != sFldTypName ) rName = comphelper::string::setToken(rName, 1, '.', sUIName); } - else if (rTypeName == "DataBase") + else if (rTypeName.equalsIgnoreAsciiCase("DataBase")) { rName = rName.copy(RTL_CONSTASCII_LENGTH("DataBase.")); const sal_Int32 nDotCount = comphelper::string::getTokenCount(rName, '.'); - if( 2 <= nDotCount ) + if( 1 <= nDotCount ) { // #i51815# rName = "DataBase." + rName; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits