From 8e8827a2d092810394c819c536d48b74080abce8 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Wed, 5 Feb 2014 16:53:10 +0100 Subject: fdo#69652 Default(Date|Time) is a UNO struct now MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: Caolán McNamara --- forms/source/component/EditBase.cxx | 46 +++++++++++++++++++++++++++++++++---- 1 file 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 #include "frm_resource.hxx" #include "frm_resource.hrc" +#include +#include +#include +#include //......................................................................... 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& _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& _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& _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& _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( -- cgit v1.2.3