diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2014-02-05 16:53:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-02-05 16:31:23 +0000 |
commit | 8e8827a2d092810394c819c536d48b74080abce8 (patch) | |
tree | 00044e75a3ae4c11b9dc7f18e38e360b9c864650 | |
parent | d18a29455ab6297d7b8a0b37dc93062ce94d37f1 (diff) |
fdo#69652 Default(Date|Time) is a UNO struct now
Changed to UNO struct from integer by
fdo#67235 adapt form control code to time nanosecond API change
Change-Id: I5817d44438d70a0da534c03afd22d74a311252f5
Reviewed-on: https://gerrit.libreoffice.org/7881
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | forms/source/component/EditBase.cxx | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/forms/source/component/EditBase.cxx b/forms/source/component/EditBase.cxx index 73de84685ca1..695a724850d1 100644 --- a/forms/source/component/EditBase.cxx +++ b/forms/source/component/EditBase.cxx @@ -26,10 +26,15 @@ #include <cppuhelper/queryinterface.hxx> #include "frm_resource.hxx" #include "frm_resource.hrc" +#include <tools/time.hxx> +#include <tools/date.hxx> +#include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/Date.hpp> //......................................................................... namespace frm { +using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; @@ -42,9 +47,14 @@ using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; -const sal_uInt16 DEFAULT_LONG = 0x0001; -const sal_uInt16 DEFAULT_DOUBLE = 0x0002; -const sal_uInt16 FILTERPROPOSAL = 0x0004; +namespace +{ + const sal_uInt16 DEFAULT_LONG = 0x0001; + const sal_uInt16 DEFAULT_DOUBLE = 0x0002; + const sal_uInt16 FILTERPROPOSAL = 0x0004; + const sal_uInt16 DEFAULT_TIME = 0x0008; + const sal_uInt16 DEFAULT_DATE = 0x0010; +} DBG_NAME( OEditBaseModel ) //------------------------------------------------------------------ @@ -84,7 +94,7 @@ void OEditBaseModel::write(const Reference<XObjectOutputStream>& _rxOutStream) t OBoundControlModel::write(_rxOutStream); // Version - sal_uInt16 nVersionId = 0x0005; + sal_uInt16 nVersionId = 0x0006; DBG_ASSERT((getPersistenceFlags() & ~PF_SPECIAL_FLAGS) == 0, "OEditBaseModel::write : invalid special version flags !"); // please don't use other flags, older versions can't interpret them ! @@ -102,6 +112,10 @@ void OEditBaseModel::write(const Reference<XObjectOutputStream>& _rxOutStream) t nAnyMask |= DEFAULT_LONG; else if (m_aDefault.getValueType().getTypeClass() == TypeClass_DOUBLE) nAnyMask |= DEFAULT_DOUBLE; + else if (m_aDefault.getValueType() == ::getCppuType((const util::Time*)0)) + nAnyMask |= DEFAULT_TIME; + else if (m_aDefault.getValueType() == ::getCppuType((const util::Date*)0)) + nAnyMask |= DEFAULT_DATE; if (m_bFilterProposal) // Don't save a value, because it's boolean nAnyMask |= FILTERPROPOSAL; @@ -113,6 +127,18 @@ void OEditBaseModel::write(const Reference<XObjectOutputStream>& _rxOutStream) t _rxOutStream->writeLong(getINT32(m_aDefault)); else if ((nAnyMask & DEFAULT_DOUBLE) == DEFAULT_DOUBLE) _rxOutStream->writeDouble(getDouble(m_aDefault)); + else if ((nAnyMask & DEFAULT_TIME) == DEFAULT_TIME) + { + util::Time aTime; + OSL_VERIFY(m_aDefault >>= aTime); + _rxOutStream->writeHyper(::Time(aTime).GetTime()); + } + else if ((nAnyMask & DEFAULT_DATE) == DEFAULT_DATE) + { + util::Date aDate; + OSL_VERIFY(m_aDefault >>= aDate); + _rxOutStream->writeLong(::Date(aDate).GetDate()); + } // since version 5 we write the help text writeHelpTextCompatibly(_rxOutStream); @@ -169,6 +195,14 @@ void OEditBaseModel::read(const Reference<XObjectInputStream>& _rxInStream) thro double fValue = _rxInStream->readDouble(); m_aDefault <<= (double)fValue; } + else if ((nAnyMask & DEFAULT_TIME) == DEFAULT_TIME) + { + m_aDefault <<= ::Time(_rxInStream->readHyper()).GetUNOTime(); + } + else if ((nAnyMask & DEFAULT_DATE) == DEFAULT_DATE) + { + m_aDefault <<= ::Date(_rxInStream->readLong()).GetUNODate(); + } if ((nAnyMask & FILTERPROPOSAL) == FILTERPROPOSAL) m_bFilterProposal = sal_True; @@ -281,8 +315,10 @@ sal_Bool OEditBaseModel::convertFastPropertyValue( Any& rConvertedValue, Any& rO bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const double*)0)); break; case PROPERTY_ID_DEFAULT_DATE: + bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const util::Date*)0)); + break; case PROPERTY_ID_DEFAULT_TIME: - bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const sal_Int32*)0)); + bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aDefault, ::getCppuType((const util::Time*)0)); break; default: bModified = OBoundControlModel::convertFastPropertyValue( |