sw/qa/extras/ooxmlimport/data/tdf107784.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx     |   17 +++++++++++++++++
 sw/source/core/fields/fldbas.cxx             |    2 +-
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 417d993b8b8a86c019758ee0850e4b42967e2afa
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Sep 24 11:14:43 2019 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Sep 24 12:52:54 2019 +0200

    tdf#107784: DOCX Import: Show citation's title in fields
    
    Regression from 06f7d1a96eef5aa69d4872ff6d96eb5085296d09
    The problem is ConditionalExpandAuthIdentifier method uses
    AUTH_FIELD_IDENTIFIER while we want to use AUTH_FIELD_TITLE
    for citations, as we do in DomainMapper_Impl::SetFieldResult
    
    Change-Id: I30dcceba79dda3532ce10732e43303233d2ee441
    Reviewed-on: https://gerrit.libreoffice.org/79441
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlimport/data/tdf107784.docx 
b/sw/qa/extras/ooxmlimport/data/tdf107784.docx
new file mode 100644
index 000000000000..2dc868246ac0
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf107784.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index f90d894b0f1e..f5c85890e3b2 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -685,6 +685,23 @@ DECLARE_OOXMLIMPORT_TEST(testTdf105975formula, 
"tdf105975.docx")
     CPPUNIT_ASSERT_EQUAL(OUString("25"), 
xEnumerationAccess->getPresentation(false).trim());
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf107784, "tdf107784.docx")
+{
+    // Make sure the field displays the citation's title and not the identifier
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> 
xFieldsAccess(xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
+
+    if( !xFields->hasMoreElements() ) {
+        CPPUNIT_ASSERT(false);
+        return;
+    }
+
+    uno::Reference<text::XTextField> 
xEnumerationAccess(xFields->nextElement(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("Bibliography entry"), 
xEnumerationAccess->getPresentation(true).trim());
+    CPPUNIT_ASSERT_EQUAL(OUString("(Smith, 1950)"), 
xEnumerationAccess->getPresentation(false).trim());
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf115883, "tdf115883.docx")
 {
     // Import failed due to an unhandled exception when getting the Surround
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index c46e5bfd3824..0d8894141506 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -418,7 +418,7 @@ SwField::ExpandField(bool const bCached, SwRootFrame 
const*const pLayout) const
             if (GetTypeId() == SwFieldTypesEnum::Authority)
             {
                 const SwAuthorityField* pAuthorityField = static_cast<const 
SwAuthorityField*>(this);
-                m_Cache = 
pAuthorityField->ConditionalExpandAuthIdentifier(pLayout);
+                m_Cache = pAuthorityField->ExpandCitation(AUTH_FIELD_TITLE, 
pLayout);
             }
             else
                 m_Cache = ExpandImpl(pLayout);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to