summaryrefslogtreecommitdiffstats
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-12-08 15:19:06 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-12-09 08:10:40 +0100
commit07b0cde32a7eebce996b8c32aa58545e4ec15003 (patch)
tree53ff7c9317281e6ba7ee227d4a850989935fa746 /writerfilter
parentRTF filter: handle user-defined document properties of type bool (diff)
downloadcore-07b0cde32a7eebce996b8c32aa58545e4ec15003.tar.gz
core-07b0cde32a7eebce996b8c32aa58545e4ec15003.zip
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 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdispatchvalue.cxx3
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx25
2 files changed, 28 insertions, 0 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index eaa845ebc787..0cefa0114505 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -1403,6 +1403,9 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case 30:
m_aStates.top().aPropType = cppu::UnoType<OUString>::get();
break;
+ case 64:
+ m_aStates.top().aPropType = cppu::UnoType<util::DateTime>::get();
+ break;
}
}
break;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 80859bfd1541..09c84a0d9eb3 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -51,6 +51,29 @@
using namespace com::sun::star;
+namespace
+{
+/// Returns an util::DateTime from a 'YYYY. MM. DD.' string.
+util::DateTime getDateTimeFromUserProp(const OUString& rString)
+{
+ util::DateTime aRet;
+ sal_Int32 nLen = rString.getLength();
+ if (nLen >= 4)
+ {
+ aRet.Year = rString.copy(0, 4).toInt32();
+
+ if (nLen >= 8 && rString.copy(4, 2) == ". ")
+ {
+ aRet.Month = rString.copy(6, 2).toInt32();
+
+ if (nLen >= 12 && rString.copy(8, 2) == ". ")
+ aRet.Day = rString.copy(10, 2).toInt32();
+ }
+ }
+ return aRet;
+}
+} // anonymous namespace
+
namespace writerfilter
{
namespace rtftok
@@ -2687,6 +2710,8 @@ RTFError RTFDocumentImpl::popState()
aAny = uno::makeAny(aStaticVal.toInt32());
else if (m_aStates.top().aPropType == cppu::UnoType<bool>::get())
aAny = uno::makeAny(aStaticVal.toBoolean());
+ else if (m_aStates.top().aPropType == cppu::UnoType<util::DateTime>::get())
+ aAny = uno::makeAny(getDateTimeFromUserProp(aStaticVal));
xPropertyContainer->addProperty(rKey, beans::PropertyAttribute::REMOVABLE, aAny);
}