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_ENTRYLISTHELPER_HXX 29*cdf0e10cSrcweir #define FORMS_ENTRYLISTHELPER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir /** === begin UNO includes === **/ 32*cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntrySink.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/util/XRefreshable.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntryListener.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 36*cdf0e10cSrcweir /** === end UNO includes === **/ 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 39*cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir //......................................................................... 42*cdf0e10cSrcweir namespace frm 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir //......................................................................... 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir class OControlModel; 47*cdf0e10cSrcweir class ControlModelLock; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir //===================================================================== 50*cdf0e10cSrcweir //= OEntryListHelper 51*cdf0e10cSrcweir //===================================================================== 52*cdf0e10cSrcweir typedef ::cppu::ImplHelper3 < ::com::sun::star::form::binding::XListEntrySink 53*cdf0e10cSrcweir , ::com::sun::star::form::binding::XListEntryListener 54*cdf0e10cSrcweir , ::com::sun::star::util::XRefreshable 55*cdf0e10cSrcweir > OEntryListHelper_BASE; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir class OEntryListHelper : public OEntryListHelper_BASE 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir private: 60*cdf0e10cSrcweir OControlModel& m_rControlModel; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource > 63*cdf0e10cSrcweir m_xListSource; /// our external list source 64*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > 65*cdf0e10cSrcweir m_aStringItems; /// "overridden" StringItemList property value 66*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper 67*cdf0e10cSrcweir m_aRefreshListeners; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir protected: 71*cdf0e10cSrcweir OEntryListHelper( OControlModel& _rControlModel ); 72*cdf0e10cSrcweir OEntryListHelper( const OEntryListHelper& _rSource, OControlModel& _rControlModel ); 73*cdf0e10cSrcweir virtual ~OEntryListHelper( ); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir /// returns the current string item list 76*cdf0e10cSrcweir inline const ::com::sun::star::uno::Sequence< ::rtl::OUString >& 77*cdf0e10cSrcweir getStringItemList() const { return m_aStringItems; } 78*cdf0e10cSrcweir inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& 79*cdf0e10cSrcweir getExternalListEntrySource() const { return m_xListSource; } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir /// determines whether we actually have an external list source 82*cdf0e10cSrcweir inline bool hasExternalListSource( ) const { return m_xListSource.is(); } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir /** handling the XEventListener::disposing call for the case where 85*cdf0e10cSrcweir our list source is being disposed 86*cdf0e10cSrcweir @return 87*cdf0e10cSrcweir <TRUE/> if and only if the disposed object was our list source, and so the 88*cdf0e10cSrcweir event was handled 89*cdf0e10cSrcweir */ 90*cdf0e10cSrcweir bool handleDisposing( const ::com::sun::star::lang::EventObject& _rEvent ); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir /** to be called by derived classes' instances when they're being disposed 93*cdf0e10cSrcweir */ 94*cdf0e10cSrcweir void disposing( ); 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir // prevent method hiding 97*cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException) = 0; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir /** helper for implementing convertFastPropertyValue( StringItemList ) 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir <p>The signature of this method and the return type have the same semantics 102*cdf0e10cSrcweir as convertFastPropertyValue.</p> 103*cdf0e10cSrcweir */ 104*cdf0e10cSrcweir sal_Bool convertNewListSourceProperty( 105*cdf0e10cSrcweir ::com::sun::star::uno::Any& _rConvertedValue, 106*cdf0e10cSrcweir ::com::sun::star::uno::Any& _rOldValue, 107*cdf0e10cSrcweir const ::com::sun::star::uno::Any& _rValue 108*cdf0e10cSrcweir ) 109*cdf0e10cSrcweir SAL_THROW( ( ::com::sun::star::lang::IllegalArgumentException ) ); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir /** helper for implementing setFastPropertyValueNoBroadcast 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir <p>Will internally call stringItemListChanged after the new item list 114*cdf0e10cSrcweir has been set.</p> 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir @precond 117*cdf0e10cSrcweir not to be called when we have an external list source 118*cdf0e10cSrcweir @see hasExternalListSource 119*cdf0e10cSrcweir */ 120*cdf0e10cSrcweir void setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ControlModelLock& _rInstanceLock ); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir /** announces that the list of entries has changed. 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir <p>Derived classes have to override this. Most probably, they'll set the new 125*cdf0e10cSrcweir as model property.</p> 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir @pure 128*cdf0e10cSrcweir @see getStringItemList 129*cdf0e10cSrcweir */ 130*cdf0e10cSrcweir virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) = 0; 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir /** called whenever a connection to a new external list source has been established 133*cdf0e10cSrcweir */ 134*cdf0e10cSrcweir virtual void connectedExternalListSource( ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir /** called whenever a connection to a new external list source has been revoked 137*cdf0e10cSrcweir */ 138*cdf0e10cSrcweir virtual void disconnectedExternalListSource( ); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir /** called when XRefreshable::refresh has been called, and we do *not* have an external 141*cdf0e10cSrcweir list source 142*cdf0e10cSrcweir */ 143*cdf0e10cSrcweir virtual void refreshInternalEntryList() = 0; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir private: 146*cdf0e10cSrcweir // XListEntrySink 147*cdf0e10cSrcweir virtual void SAL_CALL setListEntrySource( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource ) throw (::com::sun::star::uno::RuntimeException); 148*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource > SAL_CALL getListEntrySource( ) throw (::com::sun::star::uno::RuntimeException); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir // XListEntryListener 151*cdf0e10cSrcweir virtual void SAL_CALL entryChanged( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException); 152*cdf0e10cSrcweir virtual void SAL_CALL entryRangeInserted( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException); 153*cdf0e10cSrcweir virtual void SAL_CALL entryRangeRemoved( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException); 154*cdf0e10cSrcweir virtual void SAL_CALL allEntriesChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir // XRefreshable 157*cdf0e10cSrcweir virtual void SAL_CALL refresh() throw(::com::sun::star::uno::RuntimeException); 158*cdf0e10cSrcweir virtual void SAL_CALL addRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); 159*cdf0e10cSrcweir virtual void SAL_CALL removeRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException); 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir private: 162*cdf0e10cSrcweir /** disconnects from the active external list source, if present 163*cdf0e10cSrcweir @see connectExternalListSource 164*cdf0e10cSrcweir */ 165*cdf0e10cSrcweir void disconnectExternalListSource( ); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir /** connects to a new external list source 168*cdf0e10cSrcweir @param _rxSource 169*cdf0e10cSrcweir the new list source. Must not be <NULL/> 170*cdf0e10cSrcweir @see disconnectExternalListSource 171*cdf0e10cSrcweir */ 172*cdf0e10cSrcweir void connectExternalListSource( 173*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource, 174*cdf0e10cSrcweir ControlModelLock& _rInstanceLock 175*cdf0e10cSrcweir ); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir /** refreshes our list entries 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir In case we have an external list source, its used to obtain the new entries, and then 180*cdf0e10cSrcweir stringItemListChanged is called to give the derived class the possibility to 181*cdf0e10cSrcweir react on this. 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir In case we do not have an external list source, refreshInternalEntryList is called. 184*cdf0e10cSrcweir */ 185*cdf0e10cSrcweir void impl_lock_refreshList( ControlModelLock& _rInstanceLock ); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir private: 188*cdf0e10cSrcweir OEntryListHelper(); // never implemented 189*cdf0e10cSrcweir OEntryListHelper( const OEntryListHelper& ); // never implemented 190*cdf0e10cSrcweir OEntryListHelper& operator=( const OEntryListHelper& ); // never implemented 191*cdf0e10cSrcweir }; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir //......................................................................... 194*cdf0e10cSrcweir } // namespace frm 195*cdf0e10cSrcweir //......................................................................... 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir #endif // FORMS_ENTRYLISTHELPER_HXX 199