sw/qa/extras/ooxmlimport/data/tdf107784.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 17 +++++++++++++++++ sw/source/core/fields/authfld.cxx | 9 ++++++++- 3 files changed, 25 insertions(+), 1 deletion(-)
New commits: commit 420c306394ff781fb361f1fb12b5b993a67dd36b Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Sep 24 21:22:30 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Oct 10 10:48:39 2019 +0200 tdf#107784: DOCX Import: Show citation's title in fields (2nd take) Regression from 06f7d1a96eef5aa69d4872ff6d96eb5085296d09 The problem as I see it is that LibreOffice uses the identifier plus optionals prefix and suffix to display the bibliographic references. On the other hand, MSO displays the title for references starting with CITATION. So do the same MSO does, when working with CITATION refs We already add CITATION when we export to ooxml. See case SwFieldIds::TableOfAuthorities in AttributeOutputBase::TextField Change-Id: I144f27f711926658c8b6f89e69f0ddeeb7e7890c Reviewed-on: https://gerrit.libreoffice.org/79477 Tested-by: Jenkins Reviewed-by: Xisco FaulĂ <xiscofa...@libreoffice.org> (cherry picked from commit c02b5cf6472ccb45a916369db493a40ed3e21d60) Reviewed-on: https://gerrit.libreoffice.org/79545 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 b49583b3b4d0..4ee66606b7a6 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -687,6 +687,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/authfld.cxx b/sw/source/core/fields/authfld.cxx index 7d86f12541a0..c84b44d0a7d1 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -505,7 +505,14 @@ OUString SwAuthorityField::ConditionalExpandAuthIdentifier( { //TODO: Expand to: identifier, number sequence, ... if(m_xAuthEntry) - sRet += m_xAuthEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER); + { + OUString sIdentifier(m_xAuthEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER)); + // tdf#107784 Use title if it's a ooxml citation + if (sIdentifier.trim().startsWith("CITATION")) + return m_xAuthEntry->GetAuthorField(AUTH_FIELD_TITLE); + else + sRet += sIdentifier; + } } if(pAuthType->GetSuffix()) sRet += OUStringLiteral1(pAuthType->GetSuffix()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits