summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-07-13 18:02:29 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-07-13 18:34:36 +0200
commitd0a7a60cfa1a34ec7218656489b7463cd9eb1aad (patch)
tree9136aa054c6870af62bece05dbb06684aadaf385
parent303df30fe93044c36c993e84170f70ec4b3d4d48 (diff)
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
-rw-r--r--sw/qa/extras/rtfimport/data/fdo80905.rtf12
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx10
-rw-r--r--sw/source/core/unocore/unofield.cxx4
3 files changed, 24 insertions, 2 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo80905.rtf b/sw/qa/extras/rtfimport/data/fdo80905.rtf
new file mode 100644
index 000000000000..c088fe0e727d
--- /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 0adabdc3ac55..76de5bbdc766 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 a05c41f56c00..b524eccea702 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;