diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-12-08 14:33:41 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-12-09 07:08:12 +0000 |
commit | 547de17fcb654e560a60d683c33482feeee84358 (patch) | |
tree | e5d3a414a4b8d647fd7adeb0ef925bfb19c1b274 | |
parent | 73131fc3806ce2a7da61c93590e467e5b044c341 (diff) |
RTF filter: handle user-defined document properties of type bool
Next to number and string.
Change-Id: I76f78197412606f00559c1c2790b7c70117ef1c1
Reviewed-on: https://gerrit.libreoffice.org/31767
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/rtfexport/data/custom-doc-props.rtf | 6 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.cxx | 20 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.hxx | 2 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchvalue.cxx | 3 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 2 |
6 files changed, 32 insertions, 5 deletions
diff --git a/sw/qa/extras/rtfexport/data/custom-doc-props.rtf b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf index 3e6eee854f8c..e774659bbf56 100644 --- a/sw/qa/extras/rtfexport/data/custom-doc-props.rtf +++ b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf @@ -9,5 +9,11 @@ {\propname n} \proptype3 {\staticval 42} +{\propname by} +\proptype11 +{\staticval 1} +{\propname bn} +\proptype11 +{\staticval 0} } } diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 2420cb0d06c5..27ca1af122b3 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -1010,6 +1010,10 @@ DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf") 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")); + // Test boolean "yes". + CPPUNIT_ASSERT(getProperty<bool>(xUserDefinedProperties, "by")); + // Test boolean "no". + CPPUNIT_ASSERT(!getProperty<bool>(xUserDefinedProperties, "bn")); } DECLARE_RTFEXPORT_TEST(testTdf65642, "tdf65642.rtf") diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index bcc8fcefede4..e0fef9bace43 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -469,6 +469,12 @@ void RtfExport::WriteInfo() Strm().WriteChar('}'); } +void RtfExport::WriteUserPropType(int nType) +{ + Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE); + OutULong(nType); +} + void RtfExport::WriteUserPropValue(const OUString& rValue) { Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_STATICVAL " "); @@ -517,17 +523,21 @@ void RtfExport::WriteUserProps() // Property value. OUString aValue; double fValue; + bool bValue; uno::Any aAny = xPropertySet->getPropertyValue(rProperty.Name); - if (aAny >>= aValue) + if (aAny >>= bValue) + { + WriteUserPropType(11); + WriteUserPropValue(OUString::number(static_cast<int>(bValue))); + } + else if (aAny >>= aValue) { - Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE); - OutULong(30); + WriteUserPropType(30); WriteUserPropValue(aValue); } else if (aAny >>= fValue) { - Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PROPTYPE); - OutULong(3); + WriteUserPropType(3); WriteUserPropValue(OUString::number(fValue)); } } diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx index a399f47964ba..72a0a5bc45f4 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 type. + void WriteUserPropType(int nType); /// Writes a single user property value. void WriteUserPropValue(const OUString& rValue); /// Writes the userprops group: user defined document properties. diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index dc49e6484ef6..eaa845ebc787 100644 --- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx +++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx @@ -1397,6 +1397,9 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) case 3: m_aStates.top().aPropType = cppu::UnoType<sal_Int32>::get(); break; + case 11: + m_aStates.top().aPropType = cppu::UnoType<bool>::get(); + break; case 30: m_aStates.top().aPropType = cppu::UnoType<OUString>::get(); break; diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index c92e3a9fd4a8..80859bfd1541 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2685,6 +2685,8 @@ RTFError RTFDocumentImpl::popState() aAny = uno::makeAny(aStaticVal); else if (m_aStates.top().aPropType == cppu::UnoType<sal_Int32>::get()) aAny = uno::makeAny(aStaticVal.toInt32()); + else if (m_aStates.top().aPropType == cppu::UnoType<bool>::get()) + aAny = uno::makeAny(aStaticVal.toBoolean()); xPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aAny); } |