update dev300-m58
[ooovba.git] / forms / source / component / entrylisthelper.hxx
blobb4bfffddc1b9ffdd4e05c02fdfe9b8858a026b56
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: entrylisthelper.hxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef FORMS_ENTRYLISTHELPER_HXX
32 #define FORMS_ENTRYLISTHELPER_HXX
34 /** === begin UNO includes === **/
35 #include <com/sun/star/form/binding/XListEntrySink.hpp>
36 #include <com/sun/star/util/XRefreshable.hpp>
37 #include <com/sun/star/form/binding/XListEntryListener.hpp>
38 #include <com/sun/star/lang/IllegalArgumentException.hpp>
39 /** === end UNO includes === **/
41 #include <cppuhelper/implbase3.hxx>
42 #include <cppuhelper/interfacecontainer.hxx>
44 //.........................................................................
45 namespace frm
47 //.........................................................................
49 class OControlModel;
50 class ControlModelLock;
52 //=====================================================================
53 //= OEntryListHelper
54 //=====================================================================
55 typedef ::cppu::ImplHelper3 < ::com::sun::star::form::binding::XListEntrySink
56 , ::com::sun::star::form::binding::XListEntryListener
57 , ::com::sun::star::util::XRefreshable
58 > OEntryListHelper_BASE;
60 class OEntryListHelper : public OEntryListHelper_BASE
62 private:
63 OControlModel& m_rControlModel;
65 ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
66 m_xListSource; /// our external list source
67 ::com::sun::star::uno::Sequence< ::rtl::OUString >
68 m_aStringItems; /// "overridden" StringItemList property value
69 ::cppu::OInterfaceContainerHelper
70 m_aRefreshListeners;
73 protected:
74 OEntryListHelper( OControlModel& _rControlModel );
75 OEntryListHelper( const OEntryListHelper& _rSource, OControlModel& _rControlModel );
76 virtual ~OEntryListHelper( );
78 /// returns the current string item list
79 inline const ::com::sun::star::uno::Sequence< ::rtl::OUString >&
80 getStringItemList() const { return m_aStringItems; }
81 inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >&
82 getExternalListEntrySource() const { return m_xListSource; }
84 /// determines whether we actually have an external list source
85 inline bool hasExternalListSource( ) const { return m_xListSource.is(); }
87 /** handling the XEventListener::disposing call for the case where
88 our list source is being disposed
89 @return
90 <TRUE/> if and only if the disposed object was our list source, and so the
91 event was handled
93 bool handleDisposing( const ::com::sun::star::lang::EventObject& _rEvent );
95 /** to be called by derived classes' instances when they're being disposed
97 void disposing( );
99 // prevent method hiding
100 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException) = 0;
102 /** helper for implementing convertFastPropertyValue( StringItemList )
104 <p>The signature of this method and the return type have the same semantics
105 as convertFastPropertyValue.</p>
107 sal_Bool convertNewListSourceProperty(
108 ::com::sun::star::uno::Any& _rConvertedValue,
109 ::com::sun::star::uno::Any& _rOldValue,
110 const ::com::sun::star::uno::Any& _rValue
112 SAL_THROW( ( ::com::sun::star::lang::IllegalArgumentException ) );
114 /** helper for implementing setFastPropertyValueNoBroadcast
116 <p>Will internally call stringItemListChanged after the new item list
117 has been set.</p>
119 @precond
120 not to be called when we have an external list source
121 @see hasExternalListSource
123 void setNewStringItemList( const ::com::sun::star::uno::Any& _rValue, ControlModelLock& _rInstanceLock );
125 /** announces that the list of entries has changed.
127 <p>Derived classes have to override this. Most probably, they'll set the new
128 as model property.</p>
130 @pure
131 @see getStringItemList
133 virtual void stringItemListChanged( ControlModelLock& _rInstanceLock ) = 0;
135 /** called whenever a connection to a new external list source has been established
137 virtual void connectedExternalListSource( );
139 /** called whenever a connection to a new external list source has been revoked
141 virtual void disconnectedExternalListSource( );
143 /** called when XRefreshable::refresh has been called, and we do *not* have an external
144 list source
146 virtual void refreshInternalEntryList() = 0;
148 private:
149 // XListEntrySink
150 virtual void SAL_CALL setListEntrySource( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource ) throw (::com::sun::star::uno::RuntimeException);
151 virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource > SAL_CALL getListEntrySource( ) throw (::com::sun::star::uno::RuntimeException);
153 // XListEntryListener
154 virtual void SAL_CALL entryChanged( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
155 virtual void SAL_CALL entryRangeInserted( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
156 virtual void SAL_CALL entryRangeRemoved( const ::com::sun::star::form::binding::ListEntryEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
157 virtual void SAL_CALL allEntriesChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
159 // XRefreshable
160 virtual void SAL_CALL refresh() throw(::com::sun::star::uno::RuntimeException);
161 virtual void SAL_CALL addRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException);
162 virtual void SAL_CALL removeRefreshListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener>& _rxListener) throw(::com::sun::star::uno::RuntimeException);
164 private:
165 /** disconnects from the active external list source, if present
166 @see connectExternalListSource
168 void disconnectExternalListSource( );
170 /** connects to a new external list source
171 @param _rxSource
172 the new list source. Must not be <NULL/>
173 @see disconnectExternalListSource
175 void connectExternalListSource(
176 const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource,
177 ControlModelLock& _rInstanceLock
180 /** refreshes our list entries
182 In case we have an external list source, its used to obtain the new entries, and then
183 stringItemListChanged is called to give the derived class the possibility to
184 react on this.
186 In case we do not have an external list source, refreshInternalEntryList is called.
188 void impl_lock_refreshList( ControlModelLock& _rInstanceLock );
190 private:
191 OEntryListHelper(); // never implemented
192 OEntryListHelper( const OEntryListHelper& ); // never implemented
193 OEntryListHelper& operator=( const OEntryListHelper& ); // never implemented
196 //.........................................................................
197 } // namespace frm
198 //.........................................................................
201 #endif // FORMS_ENTRYLISTHELPER_HXX