[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Mon Jul 14 04:39:59 PDT 2014
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 a4fd1b2eafcc49486cb6a360d792f779659b68e2
Author: Miklos Vajna <vmiklos at 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.
(cherry picked from commit d0a7a60cfa1a34ec7218656489b7463cd9eb1aad)
Conflicts:
sw/source/core/unocore/unofield.cxx
Change-Id: I498eabace25f8e466b3504ba13fa3060d4ba22da
Reviewed-on: https://gerrit.libreoffice.org/10269
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
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 4fd6941..6f6dede 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1709,6 +1709,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 3043353..56be0c0 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -2674,11 +2674,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."));
sal_uInt16 nDotCount = comphelper::string::getTokenCount(rName, '.');
- if( 2 <= nDotCount )
+ if( 1 <= nDotCount )
{
// #i51815#
rName = "DataBase." + rName;
More information about the Libreoffice-commits
mailing list