diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-12-08 12:19:27 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-12-08 13:38:42 +0100 |
commit | fc8c4606e0834cd2128a228c2c95fc7c8f9eb7b1 (patch) | |
tree | 5d0ba9963fc72db9897bd3298d41996f971ee92a /sw | |
parent | a66731982e93cdcc5beaa5b0586a7f12a7fc0ef6 (diff) |
RTF filter: handle user-defined document properties of type number
Previously only strings were handled.
Change-Id: I2452cbabf48bfaa9f1a3044be4b8cbe4aa9dd0d9
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/rtfexport/data/custom-doc-props.rtf | 3 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.cxx | 25 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.hxx | 2 |
4 files changed, 25 insertions, 7 deletions
diff --git a/sw/qa/extras/rtfexport/data/custom-doc-props.rtf b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf index b36d864f2969..3e6eee854f8c 100644 --- a/sw/qa/extras/rtfexport/data/custom-doc-props.rtf +++ b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf @@ -6,5 +6,8 @@ {\propname urn:bails:IntellectualProperty:Authorization:StopValidity} \proptype30 {\staticval None} +{\propname n} +\proptype3 +{\staticval 42} } } diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 37e9ba71a099..2420cb0d06c5 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -1008,6 +1008,8 @@ DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf") 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")); + // Test roundtrip of numbers. This failed as getProperty() did not find "n". + CPPUNIT_ASSERT_EQUAL(42.0, getProperty<double>(xUserDefinedProperties, "n")); } DECLARE_RTFEXPORT_TEST(testTdf65642, "tdf65642.rtf") diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index 5e31a3c3bb63..bcc8fcefede4 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -469,6 +469,13 @@ void RtfExport::WriteInfo() Strm().WriteChar('}'); } +void RtfExport::WriteUserPropValue(const OUString& rValue) +{ + Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " "); + Strm().WriteCharPtr(msfilter::rtfutil::OutString(rValue, m_eDefaultEncoding).getStr()); + Strm().WriteChar('}'); +} + void RtfExport::WriteUserProps() { Strm().WriteChar('{').WriteCharPtr(OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_USERPROPS); @@ -507,18 +514,22 @@ void RtfExport::WriteUserProps() Strm().WriteCharPtr(msfilter::rtfutil::OutString(rProperty.Name, m_eDefaultEncoding).getStr()); Strm().WriteChar('}'); - // Property value type. + // Property value. OUString aValue; - if (xPropertySet->getPropertyValue(rProperty.Name) >>= aValue) + double fValue; + uno::Any aAny = xPropertySet->getPropertyValue(rProperty.Name); + if (aAny >>= aValue) { Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE); OutULong(30); + WriteUserPropValue(aValue); + } + else if (aAny >>= fValue) + { + Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE); + OutULong(3); + WriteUserPropValue(OUString::number(fValue)); } - - // Property value. - Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " "); - Strm().WriteCharPtr(msfilter::rtfutil::OutString(aValue, m_eDefaultEncoding).getStr()); - Strm().WriteChar('}'); } } diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx index 71c55f068550..a399f47964ba 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 a single user property value. + void WriteUserPropValue(const OUString& rValue); /// Writes the userprops group: user defined document properties. void WriteUserProps(); /// Writes the writer-specific \pgdsctbl group. |