1*2d785d7eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2d785d7eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2d785d7eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2d785d7eSAndrew Rist * distributed with this work for additional information 6*2d785d7eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2d785d7eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2d785d7eSAndrew Rist * "License"); you may not use this file except in compliance 9*2d785d7eSAndrew Rist * with the License. You may obtain a copy of the License at 10*2d785d7eSAndrew Rist * 11*2d785d7eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2d785d7eSAndrew Rist * 13*2d785d7eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2d785d7eSAndrew Rist * software distributed under the License is distributed on an 15*2d785d7eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2d785d7eSAndrew Rist * KIND, either express or implied. See the License for the 17*2d785d7eSAndrew Rist * specific language governing permissions and limitations 18*2d785d7eSAndrew Rist * under the License. 19*2d785d7eSAndrew Rist * 20*2d785d7eSAndrew Rist *************************************************************/ 21*2d785d7eSAndrew Rist 22*2d785d7eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _FORMS_LISTBOX_HXX_ 25cdf0e10cSrcweir #define _FORMS_LISTBOX_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "FormComponent.hxx" 28cdf0e10cSrcweir #include "cachedrowset.hxx" 29cdf0e10cSrcweir #include "errorbroadcaster.hxx" 30cdf0e10cSrcweir #include "entrylisthelper.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir /** === begin UNO includes === **/ 33cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatter.hpp> 34cdf0e10cSrcweir #include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp> 35cdf0e10cSrcweir #include <com/sun/star/form/ListSourceType.hpp> 36cdf0e10cSrcweir #include <com/sun/star/awt/XItemListener.hpp> 37cdf0e10cSrcweir #include <com/sun/star/awt/XFocusListener.hpp> 38cdf0e10cSrcweir #include <com/sun/star/awt/XListBox.hpp> 39cdf0e10cSrcweir #include <com/sun/star/form/XChangeBroadcaster.hpp> 40cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 41cdf0e10cSrcweir /** === end UNO includes === **/ 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <comphelper/asyncnotification.hxx> 44cdf0e10cSrcweir #include <connectivity/FValue.hxx> 45cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 46cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 47cdf0e10cSrcweir #include <vcl/timer.hxx> 48cdf0e10cSrcweir 49cdf0e10cSrcweir #include <vector> 50cdf0e10cSrcweir 51cdf0e10cSrcweir namespace dbtools 52cdf0e10cSrcweir { 53cdf0e10cSrcweir class FormattedColumnValue; 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir //......................................................................... 57cdf0e10cSrcweir namespace frm 58cdf0e10cSrcweir { 59cdf0e10cSrcweir 60cdf0e10cSrcweir //================================================================== 61cdf0e10cSrcweir //= OListBoxModel 62cdf0e10cSrcweir //================================================================== 63cdf0e10cSrcweir typedef ::std::vector< ::connectivity::ORowSetValue > ValueList; 64cdf0e10cSrcweir 65cdf0e10cSrcweir class OListBoxModel :public OBoundControlModel 66cdf0e10cSrcweir ,public OEntryListHelper 67cdf0e10cSrcweir ,public OErrorBroadcaster 68cdf0e10cSrcweir { 69cdf0e10cSrcweir 70cdf0e10cSrcweir CachedRowSet m_aListRowSet; // the row set to fill the list 71cdf0e10cSrcweir ::connectivity::ORowSetValue m_aSaveValue; 72cdf0e10cSrcweir 73cdf0e10cSrcweir // <properties> 74cdf0e10cSrcweir ::com::sun::star::form::ListSourceType m_eListSourceType; // type der list source 75cdf0e10cSrcweir ::com::sun::star::uno::Any m_aBoundColumn; 76cdf0e10cSrcweir ValueList m_aListSourceValues; 77cdf0e10cSrcweir ValueList m_aBoundValues; 78cdf0e10cSrcweir ::com::sun::star::uno::Sequence<sal_Int16> m_aDefaultSelectSeq; // DefaultSelected 79cdf0e10cSrcweir // </properties> 80cdf0e10cSrcweir 81cdf0e10cSrcweir sal_Int16 m_nNULLPos; // position of the NULL value in our list 82cdf0e10cSrcweir sal_Int32 m_nBoundColumnType; 83cdf0e10cSrcweir 84cdf0e10cSrcweir private: 85cdf0e10cSrcweir ::connectivity::ORowSetValue getFirstSelectedValue() const; 86cdf0e10cSrcweir 87cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir public: 90cdf0e10cSrcweir DECLARE_DEFAULT_LEAF_XTOR( OListBoxModel ); 91cdf0e10cSrcweir 92cdf0e10cSrcweir // XServiceInfo 93cdf0e10cSrcweir IMPLEMENTATION_NAME(OListBoxModel); 94cdf0e10cSrcweir virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir 96cdf0e10cSrcweir // UNO Anbindung 97cdf0e10cSrcweir DECLARE_UNO3_AGG_DEFAULTS(OListBoxModel, OBoundControlModel); 98cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); 99cdf0e10cSrcweir 100cdf0e10cSrcweir // OComponentHelper 101cdf0e10cSrcweir virtual void SAL_CALL disposing(); 102cdf0e10cSrcweir 103cdf0e10cSrcweir // OPropertySetHelper 104cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue, sal_Int32 nHandle) const; 105cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) 106cdf0e10cSrcweir throw (::com::sun::star::uno::Exception); 107cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( 108cdf0e10cSrcweir ::com::sun::star::uno::Any& _rConvertedValue, ::com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) 109cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException); 110cdf0e10cSrcweir 111cdf0e10cSrcweir protected: 112cdf0e10cSrcweir // XMultiPropertySet 113cdf0e10cSrcweir virtual void SAL_CALL setPropertyValues(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 114cdf0e10cSrcweir 115cdf0e10cSrcweir // XPersistObject 116cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); 117cdf0e10cSrcweir virtual void SAL_CALL 118cdf0e10cSrcweir write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 119cdf0e10cSrcweir virtual void SAL_CALL 120cdf0e10cSrcweir read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 121cdf0e10cSrcweir 122cdf0e10cSrcweir // OControlModel's property handling 123cdf0e10cSrcweir virtual void describeFixedProperties( 124cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps 125cdf0e10cSrcweir ) const; 126cdf0e10cSrcweir virtual void describeAggregateProperties( 127cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps 128cdf0e10cSrcweir ) const; 129cdf0e10cSrcweir 130cdf0e10cSrcweir // XEventListener 131cdf0e10cSrcweir virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException); 132cdf0e10cSrcweir 133cdf0e10cSrcweir // OPropertyChangeListener 134cdf0e10cSrcweir virtual void _propertyChanged( const ::com::sun::star::beans::PropertyChangeEvent& _rEvt ) throw ( ::com::sun::star::uno::RuntimeException ); 135cdf0e10cSrcweir 136cdf0e10cSrcweir // prevent method hiding 137cdf0e10cSrcweir using OBoundControlModel::getFastPropertyValue; 138cdf0e10cSrcweir using OBoundControlModel::setPropertyValues; 139cdf0e10cSrcweir 140cdf0e10cSrcweir protected: 141cdf0e10cSrcweir // OBoundControlModel overridables 142cdf0e10cSrcweir virtual ::com::sun::star::uno::Any 143cdf0e10cSrcweir translateDbColumnToControlValue( ); 144cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > 145cdf0e10cSrcweir getSupportedBindingTypes(); 146cdf0e10cSrcweir virtual ::com::sun::star::uno::Any 147cdf0e10cSrcweir translateExternalValueToControlValue( const ::com::sun::star::uno::Any& _rExternalValue ) const; 148cdf0e10cSrcweir virtual ::com::sun::star::uno::Any 149cdf0e10cSrcweir translateControlValueToExternalValue( ) const; 150cdf0e10cSrcweir virtual sal_Bool commitControlValueToDbColumn( bool _bPostReset ); 151cdf0e10cSrcweir 152cdf0e10cSrcweir virtual void onConnectedDbColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxForm ); 153cdf0e10cSrcweir virtual void onDisconnectedDbColumn(); 154cdf0e10cSrcweir 155cdf0e10cSrcweir virtual ::com::sun::star::uno::Any 156cdf0e10cSrcweir getDefaultForReset() const; 157cdf0e10cSrcweir virtual void resetNoBroadcast(); 158cdf0e10cSrcweir 159cdf0e10cSrcweir virtual ::com::sun::star::uno::Any 160cdf0e10cSrcweir getCurrentFormComponentValue() const; 161cdf0e10cSrcweir 162cdf0e10cSrcweir // OEntryListHelper overriables 163cdf0e10cSrcweir virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ); 164cdf0e10cSrcweir virtual void connectedExternalListSource( ); 165cdf0e10cSrcweir virtual void disconnectedExternalListSource( ); 166cdf0e10cSrcweir virtual void refreshInternalEntryList(); 167cdf0e10cSrcweir 168cdf0e10cSrcweir protected: 169cdf0e10cSrcweir DECLARE_XCLONEABLE(); 170cdf0e10cSrcweir 171cdf0e10cSrcweir private: 172cdf0e10cSrcweir void loadData( bool _bForce ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir /** refreshes the list boxes list data 175cdf0e10cSrcweir @precond we don't actually have an external list source 176cdf0e10cSrcweir */ 177cdf0e10cSrcweir void impl_refreshDbEntryList( bool _bForce ); 178cdf0e10cSrcweir 179cdf0e10cSrcweir ValueList impl_getValues() const; 180cdf0e10cSrcweir impl_hasBoundComponent() const181cdf0e10cSrcweir bool impl_hasBoundComponent() const { return m_nBoundColumnType != ::com::sun::star::sdbc::DataType::SQLNULL; } 182cdf0e10cSrcweir }; 183cdf0e10cSrcweir 184cdf0e10cSrcweir //================================================================== 185cdf0e10cSrcweir //= OListBoxControl 186cdf0e10cSrcweir //================================================================== 187cdf0e10cSrcweir typedef ::cppu::ImplHelper4 < ::com::sun::star::awt::XFocusListener 188cdf0e10cSrcweir , ::com::sun::star::awt::XItemListener 189cdf0e10cSrcweir , ::com::sun::star::awt::XListBox 190cdf0e10cSrcweir , ::com::sun::star::form::XChangeBroadcaster 191cdf0e10cSrcweir > OListBoxControl_BASE; 192cdf0e10cSrcweir 193cdf0e10cSrcweir class ChangeListeners; 194cdf0e10cSrcweir 195cdf0e10cSrcweir class OListBoxControl :public OBoundControl 196cdf0e10cSrcweir ,public OListBoxControl_BASE 197cdf0e10cSrcweir ,public IEventProcessor 198cdf0e10cSrcweir { 199cdf0e10cSrcweir private: 200cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper m_aChangeListeners; 201cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper m_aItemListeners; 202cdf0e10cSrcweir 203cdf0e10cSrcweir ::com::sun::star::uno::Any m_aCurrentSelection; 204cdf0e10cSrcweir Timer m_aChangeTimer; 205cdf0e10cSrcweir 206cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XListBox > 207cdf0e10cSrcweir m_xAggregateListBox; 208cdf0e10cSrcweir 209cdf0e10cSrcweir ::rtl::Reference< ::comphelper::AsyncEventNotifier > 210cdf0e10cSrcweir m_pItemBroadcaster; 211cdf0e10cSrcweir 212cdf0e10cSrcweir protected: 213cdf0e10cSrcweir // UNO Anbindung 214cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> _getTypes(); 215cdf0e10cSrcweir 216cdf0e10cSrcweir public: 217cdf0e10cSrcweir OListBoxControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); 218cdf0e10cSrcweir virtual ~OListBoxControl(); 219cdf0e10cSrcweir 220cdf0e10cSrcweir // UNO Anbindung 221cdf0e10cSrcweir DECLARE_UNO3_AGG_DEFAULTS(OListBoxControl, OBoundControl); 222cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); 223cdf0e10cSrcweir 224cdf0e10cSrcweir // XServiceInfo 225cdf0e10cSrcweir IMPLEMENTATION_NAME(OListBoxControl); 226cdf0e10cSrcweir virtual StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); 227cdf0e10cSrcweir 228cdf0e10cSrcweir // XChangeBroadcaster 229cdf0e10cSrcweir virtual void SAL_CALL addChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); 230cdf0e10cSrcweir virtual void SAL_CALL removeChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); 231cdf0e10cSrcweir 232cdf0e10cSrcweir // XFocusListener 233cdf0e10cSrcweir virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& _rEvent) throw(::com::sun::star::uno::RuntimeException); 234cdf0e10cSrcweir virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& _rEvent) throw(::com::sun::star::uno::RuntimeException); 235cdf0e10cSrcweir 236cdf0e10cSrcweir // XItemListener 237cdf0e10cSrcweir virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& _rEvent) throw(::com::sun::star::uno::RuntimeException); 238cdf0e10cSrcweir 239cdf0e10cSrcweir // XEventListener 240cdf0e10cSrcweir virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw (::com::sun::star::uno::RuntimeException); 241cdf0e10cSrcweir 242cdf0e10cSrcweir // OComponentHelper 243cdf0e10cSrcweir virtual void SAL_CALL disposing(); 244cdf0e10cSrcweir 245cdf0e10cSrcweir // XListBox 246cdf0e10cSrcweir virtual void SAL_CALL addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException); 247cdf0e10cSrcweir virtual void SAL_CALL removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw (::com::sun::star::uno::RuntimeException); 248cdf0e10cSrcweir virtual void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw (::com::sun::star::uno::RuntimeException); 249cdf0e10cSrcweir virtual void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw (::com::sun::star::uno::RuntimeException); 250cdf0e10cSrcweir virtual void SAL_CALL addItem( const ::rtl::OUString& aItem, ::sal_Int16 nPos ) throw (::com::sun::star::uno::RuntimeException); 251cdf0e10cSrcweir virtual void SAL_CALL addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aItems, ::sal_Int16 nPos ) throw (::com::sun::star::uno::RuntimeException); 252cdf0e10cSrcweir virtual void SAL_CALL removeItems( ::sal_Int16 nPos, ::sal_Int16 nCount ) throw (::com::sun::star::uno::RuntimeException); 253cdf0e10cSrcweir virtual ::sal_Int16 SAL_CALL getItemCount( ) throw (::com::sun::star::uno::RuntimeException); 254cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getItem( ::sal_Int16 nPos ) throw (::com::sun::star::uno::RuntimeException); 255cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getItems( ) throw (::com::sun::star::uno::RuntimeException); 256cdf0e10cSrcweir virtual ::sal_Int16 SAL_CALL getSelectedItemPos( ) throw (::com::sun::star::uno::RuntimeException); 257cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::sal_Int16 > SAL_CALL getSelectedItemsPos( ) throw (::com::sun::star::uno::RuntimeException); 258cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getSelectedItem( ) throw (::com::sun::star::uno::RuntimeException); 259cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSelectedItems( ) throw (::com::sun::star::uno::RuntimeException); 260cdf0e10cSrcweir virtual void SAL_CALL selectItemPos( ::sal_Int16 nPos, ::sal_Bool bSelect ) throw (::com::sun::star::uno::RuntimeException); 261cdf0e10cSrcweir virtual void SAL_CALL selectItemsPos( const ::com::sun::star::uno::Sequence< ::sal_Int16 >& aPositions, ::sal_Bool bSelect ) throw (::com::sun::star::uno::RuntimeException); 262cdf0e10cSrcweir virtual void SAL_CALL selectItem( const ::rtl::OUString& aItem, ::sal_Bool bSelect ) throw (::com::sun::star::uno::RuntimeException); 263cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL isMutipleMode( ) throw (::com::sun::star::uno::RuntimeException); 264cdf0e10cSrcweir virtual void SAL_CALL setMultipleMode( ::sal_Bool bMulti ) throw (::com::sun::star::uno::RuntimeException); 265cdf0e10cSrcweir virtual ::sal_Int16 SAL_CALL getDropDownLineCount( ) throw (::com::sun::star::uno::RuntimeException); 266cdf0e10cSrcweir virtual void SAL_CALL setDropDownLineCount( ::sal_Int16 nLines ) throw (::com::sun::star::uno::RuntimeException); 267cdf0e10cSrcweir virtual void SAL_CALL makeVisible( ::sal_Int16 nEntry ) throw (::com::sun::star::uno::RuntimeException); 268cdf0e10cSrcweir 269cdf0e10cSrcweir protected: 270cdf0e10cSrcweir // IEventProcessor 271cdf0e10cSrcweir virtual void processEvent( const ::comphelper::AnyEvent& _rEvent ); 272cdf0e10cSrcweir 273cdf0e10cSrcweir private: 274cdf0e10cSrcweir DECL_LINK( OnTimeout, void* ); 275cdf0e10cSrcweir }; 276cdf0e10cSrcweir 277cdf0e10cSrcweir //......................................................................... 278cdf0e10cSrcweir } 279cdf0e10cSrcweir //......................................................................... 280cdf0e10cSrcweir 281cdf0e10cSrcweir #endif // _FORMS_LISTBOX_HXX_ 282cdf0e10cSrcweir 283