From a2c54dc208278afca127c049f069b48b2a35710e Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Mon, 22 Apr 2013 17:34:50 +0200 Subject: ListBox: take care of validation (use binding value when appropriate) Change-Id: I7c2ab0e42a82baa39e1b48124cc8cf58bfa126d5 --- forms/source/component/ListBox.cxx | 15 +++++++++++++-- forms/source/component/ListBox.hxx | 2 ++ forms/source/inc/FormComponent.hxx | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'forms') diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 18421abf8dfa..2ea90a99dacf 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -1513,6 +1513,13 @@ namespace frm return aReturn; } + //------------------------------------------------------------------------------ + Any OListBoxModel::translateControlValueToValidatableValue( ) const + { + OSL_PRECOND( hasValidator(), "OListBoxModel::translateControlValueToValidatableValue: no validator, so why should I?" ); + return getCurrentFormComponentValue(); + } + //-------------------------------------------------------------------- Any OListBoxModel::getCurrentSingleValue() const { @@ -1552,8 +1559,12 @@ namespace frm //-------------------------------------------------------------------- Any OListBoxModel::getCurrentFormComponentValue() const { - if ( hasValidator() ) - return OBoundControlModel::getCurrentFormComponentValue(); + { + Reference< com::sun::star::form::validation::XValidator > vtor (const_cast(this)->getValidator()); + Reference< XValueBinding > extBinding (const_cast(this)->getValueBinding()); + if ( vtor.is() && vtor == extBinding ) + return translateControlValueToExternalValue(); + } Any aCurrentValue; diff --git a/forms/source/component/ListBox.hxx b/forms/source/component/ListBox.hxx index 7b77883d6b0a..fe60540bd8b9 100644 --- a/forms/source/component/ListBox.hxx +++ b/forms/source/component/ListBox.hxx @@ -186,6 +186,8 @@ protected: translateExternalValueToControlValue( const ::com::sun::star::uno::Any& _rExternalValue ) const; virtual ::com::sun::star::uno::Any translateControlValueToExternalValue( ) const; + virtual ::com::sun::star::uno::Any + translateControlValueToValidatableValue( ) const; virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset ); virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ); diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx index 69cb0922db17..85ddf90a2d0f 100644 --- a/forms/source/inc/FormComponent.hxx +++ b/forms/source/inc/FormComponent.hxx @@ -1081,7 +1081,7 @@ public: virtual void SAL_CALL reloading( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL reloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException); -private: +protected: // XBindableValue virtual void SAL_CALL setValueBinding( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding ) throw (::com::sun::star::form::binding::IncompatibleTypesException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding > SAL_CALL getValueBinding( ) throw (::com::sun::star::uno::RuntimeException); -- cgit