From f5c7e770314826c121fb6a03d56f424d308e1e2f 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 Changed to UNO struct from integer by fdo#67235 adapt form control code to time nanosecond API change Change-Id: I5817d44438d70a0da534c03afd22d74a311252f5 --- forms/source/component/EditBase.cxx | 46 +++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'forms') diff --git a/forms/source/component/EditBase.cxx b/forms/source/component/EditBase.cxx index 5d4aa3138c62..100d355e1d0d 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; +} //------------------------------------------------------------------ OEditBaseModel::OEditBaseModel( const Reference< XComponentContext >& _rxFactory, const OUString& rUnoControlModelName, @@ -80,7 +90,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 ! @@ -98,6 +108,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; @@ -109,6 +123,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); @@ -165,6 +191,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; @@ -277,8 +311,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