diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-12-08 15:19:06 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-12-09 08:10:40 +0100 |
commit | 07b0cde32a7eebce996b8c32aa58545e4ec15003 (patch) | |
tree | 53ff7c9317281e6ba7ee227d4a850989935fa746 /sw | |
parent | 547de17fcb654e560a60d683c33482feeee84358 (diff) |
RTF filter: handle user-defined document properties of type date
The date format is undefined by the RTF spec, but Word seems to work
with 'YYYY. MM. DD.'.
Change-Id: I79a10984963851c86cba92892eab13cec1e37072
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 | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.cxx | 17 |
3 files changed, 26 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfexport/data/custom-doc-props.rtf b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf index e774659bbf56..361631d6ab3b 100644 --- a/sw/qa/extras/rtfexport/data/custom-doc-props.rtf +++ b/sw/qa/extras/rtfexport/data/custom-doc-props.rtf @@ -15,5 +15,8 @@ {\propname bn} \proptype11 {\staticval 0} +{\propname d} +\proptype64 +{\staticval 2016. 01. 30.} } } diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 27ca1af122b3..fa544ac7628f 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -1014,6 +1014,12 @@ DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf") CPPUNIT_ASSERT(getProperty<bool>(xUserDefinedProperties, "by")); // Test boolean "no". CPPUNIT_ASSERT(!getProperty<bool>(xUserDefinedProperties, "bn")); + + // Test roundtrip of date in general, and year/month/day in particular. + util::DateTime aDate = getProperty<util::DateTime>(xUserDefinedProperties, "d"); + 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>(30), aDate.Day); } DECLARE_RTFEXPORT_TEST(testTdf65642, "tdf65642.rtf") diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index e0fef9bace43..dd3490b69c40 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -524,6 +524,7 @@ void RtfExport::WriteUserProps() OUString aValue; double fValue; bool bValue; + util::DateTime aDate; uno::Any aAny = xPropertySet->getPropertyValue(rProperty.Name); if (aAny >>= bValue) { @@ -540,6 +541,22 @@ void RtfExport::WriteUserProps() WriteUserPropType(3); WriteUserPropValue(OUString::number(fValue)); } + else if (aAny >>= aDate) + { + WriteUserPropType(64); + // Format is 'YYYY. MM. DD.'. + aValue += OUString::number(aDate.Year); + aValue += ". "; + if (aDate.Month < 10) + aValue += "0"; + aValue += OUString::number(aDate.Month); + aValue += ". "; + if (aDate.Day < 10) + aValue += "0"; + aValue += OUString::number(aDate.Day); + aValue += "."; + WriteUserPropValue(aValue); + } } } |