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