From abe8ea175ad9fc282a1e702acb74da5d7c967cbe Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 29 Jan 2016 12:18:49 +0100 Subject: tdf#96175 RTF filter: export \company Change-Id: I590d015aa50350cceef70313498e72474d242789 Reviewed-on: https://gerrit.libreoffice.org/21897 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/qa/extras/rtfexport/data/tdf96175.rtf | 6 ++++++ sw/qa/extras/rtfexport/rtfexport.cxx | 10 ++++++++++ sw/source/filter/ww8/rtfexport.cxx | 15 +++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 sw/qa/extras/rtfexport/data/tdf96175.rtf (limited to 'sw') diff --git a/sw/qa/extras/rtfexport/data/tdf96175.rtf b/sw/qa/extras/rtfexport/data/tdf96175.rtf new file mode 100644 index 000000000000..b125ba67c843 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf96175.rtf @@ -0,0 +1,6 @@ +{\rtf1 +{\info +{\*\company foobar} +} +hello +\par} diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index f39e01345fc7..08250349b44e 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -973,6 +973,16 @@ DECLARE_RTFEXPORT_TEST(testPageBackground, "page-background.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty(xPageStyle, "BackColor")); } +DECLARE_RTFEXPORT_TEST(testTdf96175, "tdf96175.rtf") +{ + // The problem that a user defined property named "Company" was lost on export. + uno::Reference xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties(), uno::UNO_QUERY); + uno::Reference xUserDefinedProperties = xDocumentProperties->getUserDefinedProperties(); + // This resulted in a beans::UnknownPropertyException. + CPPUNIT_ASSERT_EQUAL(OUString("foobar"), getProperty(xUserDefinedProperties, "Company")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 4fed09fa55cd..766d6d4a4823 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -443,6 +443,21 @@ void RtfExport::WriteInfo() if (xDocProps.is()) { + // Handle user-defined properties. + uno::Reference xUserDefinedProperties = xDocProps->getUserDefinedProperties(); + if (xUserDefinedProperties.is()) + { + uno::Reference xPropertySet(xUserDefinedProperties, uno::UNO_QUERY); + uno::Reference xPropertySetInfo = xPropertySet->getPropertySetInfo(); + // Do we have explicit markup in RTF for this property name? + if (xPropertySetInfo->hasPropertyByName("Company")) + { + OUString aValue; + xPropertySet->getPropertyValue("Company") >>= aValue; + OutUnicode(OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_COMPANY, aValue); + } + } + OutUnicode(OOO_STRING_SVTOOLS_RTF_TITLE, xDocProps->getTitle(), true); OutUnicode(OOO_STRING_SVTOOLS_RTF_SUBJECT, xDocProps->getSubject()); -- cgit