sw/qa/extras/rtfexport/data/custom-doc-props.rtf | 6 ++++++ sw/qa/extras/rtfexport/rtfexport.cxx | 4 ++++ sw/source/filter/ww8/rtfexport.cxx | 20 +++++++++++++++----- sw/source/filter/ww8/rtfexport.hxx | 2 ++ writerfilter/source/rtftok/rtfdispatchvalue.cxx | 3 +++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 2 ++ 6 files changed, 32 insertions(+), 5 deletions(-)
New commits: commit 547de17fcb654e560a60d683c33482feeee84358 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Dec 8 14:33:41 2016 +0100 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 <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/qa/extras/rtfexport/data/custom-doc-props.rtf b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf index 3e6eee8..e774659 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 2420cb0..27ca1af 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 bcc8fce..e0fef9b 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 a399f47..72a0a5b 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 dc49e64..eaa845e 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 c92e3a9..80859bf 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); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits