summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-09 14:41:10 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-07 17:42:40 +0200
commit40d8e6bfd4917525213339d9ff329c42ea514770 (patch)
tree11c018784cb64f8bc500c1640c5246d5659c39b7 /sw
parent353df704c8123d76fed2a3c5c636154be2451e26 (diff)
RTF export: write user-defined document properties
(cherry picked from commit 2e1a6ba26fd0cb251f831dd2a0f60103ca1342e2) Conflicts: sw/qa/extras/rtfimport/rtfimport.cxx Change-Id: I07dfd626f7d248e264fd1724f6f2bd1241be39d0
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/data/custom-doc-props.rtf (renamed from sw/qa/extras/rtfimport/data/custom-doc-props.rtf)0
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx10
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx10
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx53
-rw-r--r--sw/source/filter/ww8/rtfexport.hxx2
5 files changed, 65 insertions, 10 deletions
diff --git a/sw/qa/extras/rtfimport/data/custom-doc-props.rtf b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf
index b36d864f2969..b36d864f2969 100644
--- a/sw/qa/extras/rtfimport/data/custom-doc-props.rtf
+++ b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 3fced509548f..7cd5df854a89 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1026,6 +1026,16 @@ DECLARE_RTFEXPORT_TEST(testPgndec, "pgndec.rtf")
CPPUNIT_ASSERT_EQUAL(style::NumberingType::ARABIC, getProperty<sal_Int16>(getStyles("PageStyles")->getByName("Converted1"), "NumberingType"));
}
+DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf")
+{
+ // Custom document properties were not improved, this resulted in a beans::UnknownPropertyException.
+ uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
+ uno::Reference<beans::XPropertyContainer> xUserDefinedProperties = xDocumentProperties->getUserDefinedProperties();
+ CPPUNIT_ASSERT_EQUAL(OUString("2016-03-08T10:55:18,531376147"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StartValidity"));
+ CPPUNIT_ASSERT_EQUAL(OUString("None"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StopValidity"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index fcab9f1603ea..5242f85e5609 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2603,16 +2603,6 @@ DECLARE_RTFIMPORT_TEST(testTdf50821, "tdf50821.rtf")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(191), getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
}
-DECLARE_RTFIMPORT_TEST(testCustomDocProps, "custom-doc-props.rtf")
-{
- // Custom document properties were not improved, this resulted in a beans::UnknownPropertyException.
- uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
- uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
- uno::Reference<beans::XPropertyContainer> xUserDefinedProperties = xDocumentProperties->getUserDefinedProperties();
- CPPUNIT_ASSERT_EQUAL(OUString("2016-03-08T10:55:18,531376147"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StartValidity"));
- CPPUNIT_ASSERT_EQUAL(OUString("None"), getProperty<OUString>(xUserDefinedProperties, "urn:bails:IntellectualProperty:Authorization:StopValidity"));
-}
-
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 766d6d4a4823..139a97507d08 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -477,6 +477,58 @@ void RtfExport::WriteInfo()
Strm().WriteChar('}');
}
+void RtfExport::WriteUserProps()
+{
+ Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_USERPROPS);
+
+ SwDocShell* pDocShell(m_pDoc->GetDocShell());
+ uno::Reference<document::XDocumentProperties> xDocProps;
+ if (pDocShell)
+ {
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(pDocShell->GetModel(), uno::UNO_QUERY);
+ xDocProps.set(xDPS->getDocumentProperties());
+ }
+
+ 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::Sequence<beans::Property> aProperties = xPropertySet->getPropertySetInfo()->getProperties();
+
+ for (const beans::Property& rProperty : aProperties)
+ {
+ if (rProperty.Name.startsWith("Company"))
+ // We have explicit markup in RTF for this property.
+ continue;
+
+ // Property name.
+ Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_PROPNAME " ");
+ Strm().WriteCharPtr(msfilter::rtfutil::OutString(rProperty.Name, eDefaultEncoding).getStr());
+ Strm().WriteChar('}');
+
+ // Property value type.
+ OUString aValue;
+ if (xPropertySet->getPropertyValue(rProperty.Name) >>= aValue)
+ {
+ Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE);
+ OutULong(30);
+ }
+
+ // Property value.
+ Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " ");
+ Strm().WriteCharPtr(msfilter::rtfutil::OutString(aValue, eDefaultEncoding).getStr());
+ Strm().WriteChar('}');
+ }
+ }
+
+ }
+
+ Strm().WriteChar('}');
+}
+
void RtfExport::WritePageDescTable()
{
// Write page descriptions (page styles)
@@ -538,6 +590,7 @@ void RtfExport::ExportDocument_Impl()
WriteRevTab();
WriteInfo();
+ WriteUserProps();
// Default TabSize
Strm().WriteCharPtr(m_pAttrOutput->m_aTabStop.makeStringAndClear().getStr()).WriteCharPtr(SAL_NEWLINE_STRING);
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index cdf7b8e825ec..554da4a32651 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -204,6 +204,8 @@ private:
void WriteFootnoteSettings();
void WriteMainText();
void WriteInfo();
+ /// Writes the userprops group: user defined document properties.
+ void WriteUserProps();
/// Writes the writer-specific \pgdsctbl group.
void WritePageDescTable();
/// This is necessary to have the numbering table ready before the main text is being processed.