summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-12-08 12:19:27 +0100
committerMichael Stahl <mstahl@redhat.com>2017-02-06 22:54:38 +0000
commit6a537b3c44e79a389a8a8b7c10e53579c7ecf389 (patch)
treece4eb0d0f214f300693426324456d33fa8878fe3
parentbf357ae90811edc101ff13774c2e28a16bb5420d (diff)
tdf#104082 RTF filter: handle user-defined document properties of type number
Previously only strings were handled, which resulted in not being able to open the bugdoc. (cherry picked from commit fc8c4606e0834cd2128a228c2c95fc7c8f9eb7b1) Change-Id: I2452cbabf48bfaa9f1a3044be4b8cbe4aa9dd0d9 Reviewed-on: https://gerrit.libreoffice.org/33952 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--sw/qa/extras/rtfexport/data/custom-doc-props.rtf3
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx2
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx25
-rw-r--r--sw/source/filter/ww8/rtfexport.hxx2
-rw-r--r--writerfilter/source/rtftok/rtfdispatchvalue.cxx3
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx2
6 files changed, 30 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 1c827db63754..18a2a0ef7c04 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 bf5c61cdd335..edf7281984ef 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 81d18c119377..80b4e35b4f5f 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.
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index 9de22b7d447b..1c0ec1bd8401 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -1391,6 +1391,9 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
{
switch (nParam)
{
+ case 3:
+ m_aStates.top().aPropType = cppu::UnoType<sal_Int32>::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 ddede5718c2c..2264493649e8 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2687,6 +2687,8 @@ RTFError RTFDocumentImpl::popState()
uno::Any aAny;
if (m_aStates.top().aPropType == cppu::UnoType<OUString>::get())
aAny = uno::makeAny(aStaticVal);
+ else if (m_aStates.top().aPropType == cppu::UnoType<sal_Int32>::get())
+ aAny = uno::makeAny(aStaticVal.toInt32());
xPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aAny);
}