Kaydet (Commit) 51c400dc authored tarafından Miklos Vajna's avatar Miklos Vajna

RTF filter: handle user-defined document properties of type double

This was the last unhandled type.

Change-Id: Ife9b93ac81ddab9409c6790228eec03e92920e01
üst 07b0cde3
...@@ -18,5 +18,8 @@ ...@@ -18,5 +18,8 @@
{\propname d} {\propname d}
\proptype64 \proptype64
{\staticval 2016. 01. 30.} {\staticval 2016. 01. 30.}
{\propname pi}
\proptype5
{\staticval 3.14}
} }
} }
...@@ -1020,6 +1020,9 @@ DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf") ...@@ -1020,6 +1020,9 @@ DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2016), aDate.Year); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2016), aDate.Year);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), aDate.Month); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(1), aDate.Month);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(30), aDate.Day); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(30), aDate.Day);
// Test real number.
CPPUNIT_ASSERT_EQUAL(3.14, getProperty<double>(xUserDefinedProperties, "pi"));
} }
DECLARE_RTFEXPORT_TEST(testTdf65642, "tdf65642.rtf") DECLARE_RTFEXPORT_TEST(testTdf65642, "tdf65642.rtf")
......
...@@ -538,8 +538,19 @@ void RtfExport::WriteUserProps() ...@@ -538,8 +538,19 @@ void RtfExport::WriteUserProps()
} }
else if (aAny >>= fValue) else if (aAny >>= fValue)
{ {
WriteUserPropType(3); aValue = OUString::number(fValue);
WriteUserPropValue(OUString::number(fValue)); if (aValue.indexOf('.') == -1)
{
// Integer.
WriteUserPropType(3);
WriteUserPropValue(aValue);
}
else
{
// Real number.
WriteUserPropType(5);
WriteUserPropValue(aValue);
}
} }
else if (aAny >>= aDate) else if (aAny >>= aDate)
{ {
......
...@@ -1397,6 +1397,9 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) ...@@ -1397,6 +1397,9 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case 3: case 3:
m_aStates.top().aPropType = cppu::UnoType<sal_Int32>::get(); m_aStates.top().aPropType = cppu::UnoType<sal_Int32>::get();
break; break;
case 5:
m_aStates.top().aPropType = cppu::UnoType<double>::get();
break;
case 11: case 11:
m_aStates.top().aPropType = cppu::UnoType<bool>::get(); m_aStates.top().aPropType = cppu::UnoType<bool>::get();
break; break;
......
...@@ -2712,6 +2712,8 @@ RTFError RTFDocumentImpl::popState() ...@@ -2712,6 +2712,8 @@ RTFError RTFDocumentImpl::popState()
aAny = uno::makeAny(aStaticVal.toBoolean()); aAny = uno::makeAny(aStaticVal.toBoolean());
else if (m_aStates.top().aPropType == cppu::UnoType<util::DateTime>::get()) else if (m_aStates.top().aPropType == cppu::UnoType<util::DateTime>::get())
aAny = uno::makeAny(getDateTimeFromUserProp(aStaticVal)); aAny = uno::makeAny(getDateTimeFromUserProp(aStaticVal));
else if (m_aStates.top().aPropType == cppu::UnoType<double>::get())
aAny = uno::makeAny(aStaticVal.toDouble());
xPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aAny); xPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aAny);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment