[Libreoffice-commits] core.git: sw/qa sw/source
Xisco Fauli (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 25 11:59:01 UTC 2019
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 c02b5cf6472ccb45a916369db493a40ed3e21d60
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Sep 24 21:22:30 2019 +0200
Commit: Xisco FaulĂ <xiscofauli at libreoffice.org>
CommitDate: Wed Sep 25 13:58:15 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Ă <xiscofauli at libreoffice.org>
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/authfld.cxx b/sw/source/core/fields/authfld.cxx
index 8c91051135f9..f6215b8cff9b 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());
More information about the Libreoffice-commits
mailing list