From 8ee69b0ba13f74d1515fac71df92947eb6328ab1 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Sun, 4 Aug 2013 01:14:22 +0200 Subject: fdo#67235 adapt form control code to time nanosecond API change, step 3 Change-Id: I4899c89ee5b2a54c9c05b531ab284365f1558e3d Reviewed-on: https://gerrit.libreoffice.org/5270 Tested-by: Lionel Elie Mamane Reviewed-by: Lionel Elie Mamane --- forms/source/component/Date.cxx | 36 ++++++------------------------------ forms/source/component/Time.cxx | 39 +++++---------------------------------- 2 files changed, 11 insertions(+), 64 deletions(-) (limited to 'forms') diff --git a/forms/source/component/Date.cxx b/forms/source/component/Date.cxx index 47f6ea35213c..b5edf236ef14 100644 --- a/forms/source/component/Date.cxx +++ b/forms/source/component/Date.cxx @@ -105,7 +105,7 @@ ODateModel::ODateModel(const Reference& _rxFactory) try { if ( m_xAggregateSet.is() ) - m_xAggregateSet->setPropertyValue( PROPERTY_DATEMIN, makeAny( (sal_Int32)( ::Date( 1, 1, 1800 ).GetDate() ) ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_DATEMIN, makeAny(util::Date(1, 1, 1800)) ); } catch( const Exception& ) { @@ -170,7 +170,7 @@ OUString SAL_CALL ODateModel::getServiceName() throw ( ::com::sun::star::uno::Ru void ODateModel::describeFixedProperties( Sequence< Property >& _rProps ) const { BEGIN_DESCRIBE_PROPERTIES( 4, OEditBaseModel ) - DECL_PROP3(DEFAULT_DATE, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID); + DECL_PROP3(DEFAULT_DATE, util::Date, BOUND, MAYBEDEFAULT, MAYBEVOID); DECL_PROP1(TABINDEX, sal_Int16, BOUND); DECL_PROP1(FORMATKEY, sal_Int32, TRANSIENT); DECL_IFACE_PROP2(FORMATSSUPPLIER, XNumberFormatsSupplier, READONLY, TRANSIENT); @@ -275,45 +275,22 @@ sal_Bool ODateModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) return sal_True; } -//------------------------------------------------------------------------------ -void ODateModel::impl_translateControlValueToUNODate( Any& _rUNOValue ) const -{ - _rUNOValue = getControlValue(); - if ( _rUNOValue.hasValue() ) - { - sal_Int32 nDate = 0; - OSL_VERIFY( _rUNOValue >>= nDate ); - _rUNOValue <<= DBTypeConversion::toDate( nDate ); - } -} - //------------------------------------------------------------------------------ Any ODateModel::translateControlValueToExternalValue( ) const { - Any aExternalValue; - impl_translateControlValueToUNODate( aExternalValue ); - return aExternalValue; + return getControlValue(); } //------------------------------------------------------------------------------ Any ODateModel::translateExternalValueToControlValue( const Any& _rExternalValue ) const { - Any aControlValue; - if ( _rExternalValue.hasValue() ) - { - util::Date aDate; - OSL_VERIFY( _rExternalValue >>= aDate ); - aControlValue <<= DBTypeConversion::toINT32( aDate ); - } - return aControlValue; + return _rExternalValue; } //------------------------------------------------------------------------------ Any ODateModel::translateControlValueToValidatableValue( ) const { - Any aValidatableValue; - impl_translateControlValueToUNODate( aValidatableValue ); - return aValidatableValue; + return getControlValue(); } //------------------------------------------------------------------------------ @@ -323,8 +300,7 @@ Any ODateModel::translateDbColumnToControlValue() if (m_xColumn->wasNull()) m_aSaveValue.clear(); else - // the aggregated set expects an Int32 as value ... - m_aSaveValue <<= DBTypeConversion::toINT32(aDate); + m_aSaveValue <<= aDate; return m_aSaveValue; } diff --git a/forms/source/component/Time.cxx b/forms/source/component/Time.cxx index db81946d45a4..73e668b94070 100644 --- a/forms/source/component/Time.cxx +++ b/forms/source/component/Time.cxx @@ -167,7 +167,7 @@ OUString SAL_CALL OTimeModel::getServiceName() throw ( ::com::sun::star::uno::Ru void OTimeModel::describeFixedProperties( Sequence< Property >& _rProps ) const { BEGIN_DESCRIBE_PROPERTIES( 4, OEditBaseModel ) - DECL_PROP3(DEFAULT_TIME, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID); + DECL_PROP3(DEFAULT_TIME, util::Time, BOUND, MAYBEDEFAULT, MAYBEVOID); DECL_PROP1(TABINDEX, sal_Int16, BOUND); DECL_PROP1(FORMATKEY, sal_Int32, TRANSIENT); DECL_IFACE_PROP2(FORMATSSUPPLIER, XNumberFormatsSupplier, READONLY, TRANSIENT); @@ -273,49 +273,22 @@ sal_Bool OTimeModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) return sal_True; } -//------------------------------------------------------------------------------ -void OTimeModel::impl_translateControlValueToUNOTime( Any& _rUNOValue ) const -{ - _rUNOValue = getControlValue(); - if ( _rUNOValue.hasValue() ) - { - sal_Int64 nTime = 0; - OSL_VERIFY( _rUNOValue >>= nTime ); - if ( nTime == ::Time( 99, 99, 99 ).GetTime() ) - // "invalid time" in VCL is different from "invalid time" in UNO - _rUNOValue.clear(); - else - _rUNOValue <<= DBTypeConversion::toTime( nTime ); - } -} - //------------------------------------------------------------------------------ Any OTimeModel::translateControlValueToExternalValue( ) const { - Any aExternalValue; - impl_translateControlValueToUNOTime( aExternalValue ); - return aExternalValue; + return getControlValue(); } //------------------------------------------------------------------------------ Any OTimeModel::translateExternalValueToControlValue( const Any& _rExternalValue ) const { - Any aControlValue; - if ( _rExternalValue.hasValue() ) - { - util::Time aTime; - OSL_VERIFY( _rExternalValue >>= aTime ); - aControlValue <<= DBTypeConversion::toINT64( aTime ); - } - return aControlValue; + return _rExternalValue; } //------------------------------------------------------------------------------ Any OTimeModel::translateControlValueToValidatableValue( ) const { - Any aValidatableValue; - impl_translateControlValueToUNOTime( aValidatableValue ); - return aValidatableValue; + return getControlValue(); } //------------------------------------------------------------------------------ @@ -325,9 +298,7 @@ Any OTimeModel::translateDbColumnToControlValue() if ( m_xColumn->wasNull() ) m_aSaveValue.clear(); else - // TODO FIXME: "the aggregated set expects an Int32 as value ..." - // need to fix it for int64 - m_aSaveValue <<= DBTypeConversion::toINT64( aTime ); + m_aSaveValue <<= aTime; return m_aSaveValue; } -- cgit v1.2.3