summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-01-29 12:18:49 +0100
committerMichael Stahl <mstahl@redhat.com>2016-02-25 12:55:26 +0000
commitc3952d952ba6604af28eb116af5d26f6edda5a37 (patch)
tree334c4b483ec28887b6dfffa346682db9499f90dc /sw
parent31df50f5c985a43772cce0828754bef8085d875a (diff)
tdf#96175 RTF filter: export \company
(cherry picked from commit abe8ea175ad9fc282a1e702acb74da5d7c967cbe) Change-Id: I590d015aa50350cceef70313498e72474d242789 Reviewed-on: https://gerrit.libreoffice.org/22694 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/data/tdf96175.rtf6
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx10
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx15
3 files changed, 31 insertions, 0 deletions
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 56040f898327..b650888cce6b 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -919,6 +919,16 @@ DECLARE_RTFEXPORT_TEST(testPageBackground, "page-background.rtf")
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
}
+DECLARE_RTFEXPORT_TEST(testTdf96175, "tdf96175.rtf")
+{
+ // The problem that a user defined property named "Company" was lost on export.
+ uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertyContainer> xUserDefinedProperties = xDocumentProperties->getUserDefinedProperties();
+ // This resulted in a beans::UnknownPropertyException.
+ CPPUNIT_ASSERT_EQUAL(OUString("foobar"), getProperty<OUString>(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 efbf120ff8ab..594154ba312e 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -446,6 +446,21 @@ void RtfExport::WriteInfo()
if (xDocProps.is())
{
+ // Handle user-defined properties.
+ uno::Reference<beans::XPropertyContainer> xUserDefinedProperties = xDocProps->getUserDefinedProperties();
+ if (xUserDefinedProperties.is())
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(xUserDefinedProperties, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySetInfo> 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());