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 _SBA_MULTIPLEX_HXX
29*cdf0e10cSrcweir #define _SBA_MULTIPLEX_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //#ifndef _SDB_TOOLS_HXX
32*cdf0e10cSrcweir //#include <sdb/tools.hxx>
33*cdf0e10cSrcweir //#endif
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XVETOABLECHANGELISTENER_HPP_
36*cdf0e10cSrcweir #include <com/sun/star/beans/XVetoableChangeListener.hpp>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XUPDATELISTENER_HPP_
39*cdf0e10cSrcweir #include <com/sun/star/form/XUpdateListener.hpp>
40*cdf0e10cSrcweir #endif
41*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XERRORLISTENER_HPP_
42*cdf0e10cSrcweir #include <com/sun/star/form/XErrorListener.hpp>
43*cdf0e10cSrcweir #endif
44*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XRESTORELISTENER_HPP_
45*cdf0e10cSrcweir #include <com/sun/star/form/XRestoreListener.hpp>
46*cdf0e10cSrcweir #endif
47*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XINSERTLISTENER_HPP_
48*cdf0e10cSrcweir #include <com/sun/star/form/XInsertListener.hpp>
49*cdf0e10cSrcweir #endif
50*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XDELETELISTENER_HPP_
51*cdf0e10cSrcweir #include <com/sun/star/form/XDeleteListener.hpp>
52*cdf0e10cSrcweir #endif
53*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XPOSITIONINGLISTENER_HPP_
54*cdf0e10cSrcweir #include <com/sun/star/form/XPositioningListener.hpp>
55*cdf0e10cSrcweir #endif
56*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XDATABASEPARAMETERLISTENER_HPP_
57*cdf0e10cSrcweir #include <com/sun/star/form/XDatabaseParameterListener.hpp>
58*cdf0e10cSrcweir #endif
59*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XLOADLISTENER_HPP_
60*cdf0e10cSrcweir #include <com/sun/star/form/XLoadListener.hpp>
61*cdf0e10cSrcweir #endif
62*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATECHANGELISTENER_HPP_
63*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
64*cdf0e10cSrcweir #endif
65*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTIESCHANGELISTENER_HPP_
66*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertiesChangeListener.hpp>
67*cdf0e10cSrcweir #endif
68*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
69*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp>
70*cdf0e10cSrcweir #endif
71*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XSUBMITLISTENER_HPP_
72*cdf0e10cSrcweir #include <com/sun/star/form/XSubmitListener.hpp>
73*cdf0e10cSrcweir #endif
74*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XRESETLISTENER_HPP_
75*cdf0e10cSrcweir #include <com/sun/star/form/XResetListener.hpp>
76*cdf0e10cSrcweir #endif
77*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XREFRESHLISTENER_HPP_
78*cdf0e10cSrcweir #include <com/sun/star/util/XRefreshListener.hpp>
79*cdf0e10cSrcweir #endif
80*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XSQLERRORLISTENER_HPP_
81*cdf0e10cSrcweir #include <com/sun/star/sdb/XSQLErrorListener.hpp>
82*cdf0e10cSrcweir #endif
83*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XROWSETAPPROVELISTENER_HPP_
84*cdf0e10cSrcweir #include <com/sun/star/sdb/XRowSetApproveListener.hpp>
85*cdf0e10cSrcweir #endif
86*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROWSETLISTENER_HPP_
87*cdf0e10cSrcweir #include <com/sun/star/sdbc/XRowSetListener.hpp>
88*cdf0e10cSrcweir #endif
89*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XSTATUSLISTENER_HPP_
90*cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp>
91*cdf0e10cSrcweir #endif
92*cdf0e10cSrcweir #ifndef _COMPHELPER_STLTYPES_HXX_
93*cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
94*cdf0e10cSrcweir #endif
95*cdf0e10cSrcweir #ifndef _COMPHELPER_UNO3_HXX_
96*cdf0e10cSrcweir #include <comphelper/uno3.hxx>
97*cdf0e10cSrcweir #endif
98*cdf0e10cSrcweir #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
99*cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx>
100*cdf0e10cSrcweir #endif
101*cdf0e10cSrcweir #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
102*cdf0e10cSrcweir #include <cppuhelper/queryinterface.hxx>
103*cdf0e10cSrcweir #endif
104*cdf0e10cSrcweir #ifndef _CPPUHELPER_WEAK_HXX_
105*cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
106*cdf0e10cSrcweir #endif
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir namespace dbaui
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir 	//------------------------------------------------------------------
111*cdf0e10cSrcweir 	// TODO : replace this class if MM provides an WeakSubObject in cppu
112*cdf0e10cSrcweir 	class OSbaWeakSubObject : public ::cppu::OWeakObject
113*cdf0e10cSrcweir 	{
114*cdf0e10cSrcweir 	protected:
115*cdf0e10cSrcweir 		::cppu::OWeakObject&	m_rParent;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	public:
118*cdf0e10cSrcweir 		OSbaWeakSubObject(::cppu::OWeakObject& rParent) : m_rParent(rParent) { }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 		virtual void SAL_CALL acquire() throw() { m_rParent.acquire(); }
121*cdf0e10cSrcweir 		virtual void SAL_CALL release() throw() { m_rParent.release(); }
122*cdf0e10cSrcweir 	};
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	//------------------------------------------------------------------
125*cdf0e10cSrcweir 	// declaration of a listener multiplexer class
126*cdf0e10cSrcweir 	#define BEGIN_DECLARE_LISTENER_MULTIPLEXER(classname, listenerclass)					\
127*cdf0e10cSrcweir 	class classname																			\
128*cdf0e10cSrcweir 			:public OSbaWeakSubObject															\
129*cdf0e10cSrcweir 			,public listenerclass															\
130*cdf0e10cSrcweir 			,public ::cppu::OInterfaceContainerHelper										\
131*cdf0e10cSrcweir 	{																						\
132*cdf0e10cSrcweir 	public:																					\
133*cdf0e10cSrcweir 		classname( ::cppu::OWeakObject& rSource,											\
134*cdf0e10cSrcweir 			::osl::Mutex& rMutex);															\
135*cdf0e10cSrcweir 		DECLARE_UNO3_DEFAULTS(classname, OSbaWeakSubObject);									\
136*cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any	SAL_CALL queryInterface(						\
137*cdf0e10cSrcweir 			const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException); \
138*cdf0e10cSrcweir 																							\
139*cdf0e10cSrcweir 		/* ::com::sun::star::lang::XEventListener */										\
140*cdf0e10cSrcweir 		virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException);	\
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	#define DECLARE_MULTIPLEXER_VOID_METHOD(methodname, eventtype)							\
144*cdf0e10cSrcweir 		virtual void SAL_CALL methodname(const eventtype& e) throw (::com::sun::star::uno::RuntimeException); \
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	#define DECLARE_MULTIPLEXER_BOOL_METHOD(methodname, eventtype)							\
147*cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL methodname(const eventtype& e) throw (::com::sun::star::uno::RuntimeException);	\
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 	#define END_DECLARE_LISTENER_MULTIPLEXER()												\
151*cdf0e10cSrcweir 	/* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper have these memory operators */	\
152*cdf0e10cSrcweir 		void * SAL_CALL operator new( size_t size ) throw() { return OSbaWeakSubObject::operator new(size); }	\
153*cdf0e10cSrcweir 		void SAL_CALL operator delete( void * p ) throw() { OSbaWeakSubObject::operator delete(p); }	\
154*cdf0e10cSrcweir 	};																						\
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 	//------------------------------------------------------------------
157*cdf0e10cSrcweir 	// implementation of a listener multiplexer class
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	#define IMPLEMENT_LISTENER_MULTIPLEXER_CORE(classname, listenerclass)					\
160*cdf0e10cSrcweir 																							\
161*cdf0e10cSrcweir 	/*................................................................*/					\
162*cdf0e10cSrcweir 	classname::classname(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex)				\
163*cdf0e10cSrcweir 			:OSbaWeakSubObject(rSource)														\
164*cdf0e10cSrcweir 			,OInterfaceContainerHelper(_rMutex)												\
165*cdf0e10cSrcweir 	{																						\
166*cdf0e10cSrcweir 	}																						\
167*cdf0e10cSrcweir 																							\
168*cdf0e10cSrcweir 	::com::sun::star::uno::Any	SAL_CALL classname::queryInterface(							\
169*cdf0e10cSrcweir 		const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException) \
170*cdf0e10cSrcweir 	{																						\
171*cdf0e10cSrcweir 		::com::sun::star::uno::Any aReturn = 												\
172*cdf0e10cSrcweir 			OSbaWeakSubObject::queryInterface(_rType);											\
173*cdf0e10cSrcweir 		if (!aReturn.hasValue())															\
174*cdf0e10cSrcweir 			aReturn = ::cppu::queryInterface(_rType,										\
175*cdf0e10cSrcweir 				static_cast< listenerclass* >(this),										\
176*cdf0e10cSrcweir 				static_cast< ::com::sun::star::lang::XEventListener* >(static_cast< listenerclass* >(this))	\
177*cdf0e10cSrcweir 			);																				\
178*cdf0e10cSrcweir 																							\
179*cdf0e10cSrcweir 		return aReturn;																		\
180*cdf0e10cSrcweir 	}																						\
181*cdf0e10cSrcweir 	/*................................................................*/					\
182*cdf0e10cSrcweir 	void SAL_CALL classname::disposing(const ::com::sun::star::lang::EventObject& ) throw(::com::sun::star::uno::RuntimeException)\
183*cdf0e10cSrcweir 	{																						\
184*cdf0e10cSrcweir 	}																						\
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	#define IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(classname, listenerclass, methodname, eventtype)	\
188*cdf0e10cSrcweir 	void SAL_CALL classname::methodname(const eventtype& e) throw (::com::sun::star::uno::RuntimeException)	\
189*cdf0e10cSrcweir 	{																						\
190*cdf0e10cSrcweir 		eventtype aMulti(e);																\
191*cdf0e10cSrcweir 		aMulti.Source = &m_rParent;															\
192*cdf0e10cSrcweir 		::cppu::OInterfaceIteratorHelper aIt(*this);										\
193*cdf0e10cSrcweir 		while (aIt.hasMoreElements())														\
194*cdf0e10cSrcweir 			static_cast< listenerclass*>(aIt.next())->methodname(aMulti);				\
195*cdf0e10cSrcweir 	}																						\
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 	#define IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(classname, listenerclass, methodname, eventtype)	\
198*cdf0e10cSrcweir 	/*................................................................*/					\
199*cdf0e10cSrcweir 	sal_Bool SAL_CALL classname::methodname(const eventtype& e) throw (::com::sun::star::uno::RuntimeException)	\
200*cdf0e10cSrcweir 	{																						\
201*cdf0e10cSrcweir 		eventtype aMulti(e);																\
202*cdf0e10cSrcweir 		aMulti.Source = &m_rParent;															\
203*cdf0e10cSrcweir 		::cppu::OInterfaceIteratorHelper aIt(*this);										\
204*cdf0e10cSrcweir 		sal_Bool bResult = sal_True;														\
205*cdf0e10cSrcweir 		while (bResult && aIt.hasMoreElements())											\
206*cdf0e10cSrcweir 			bResult = static_cast< listenerclass*>(aIt.next())->methodname(aMulti);		\
207*cdf0e10cSrcweir 		return bResult;																		\
208*cdf0e10cSrcweir 	}																						\
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 	//------------------------------------------------------------------
211*cdf0e10cSrcweir 	// helper for classes which do event multiplexing
212*cdf0e10cSrcweir 	#define IMPLEMENT_LISTENER_ADMINISTRATION(classname, listenernamespace, listenerdesc, multiplexer, braodcasterclass, broadcaster) \
213*cdf0e10cSrcweir 	/*................................................................*/					\
214*cdf0e10cSrcweir 	void SAL_CALL classname::add##listenerdesc(const ::com::sun::star::uno::Reference< ::com::sun::star::listenernamespace::X##listenerdesc >& l) throw(::com::sun::star::uno::RuntimeException)\
215*cdf0e10cSrcweir 	{																						\
216*cdf0e10cSrcweir 		multiplexer.addInterface(l);															\
217*cdf0e10cSrcweir 		if (multiplexer.getLength() == 1)													\
218*cdf0e10cSrcweir 		{																					\
219*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY);	\
220*cdf0e10cSrcweir 			if (xBroadcaster.is())															\
221*cdf0e10cSrcweir 				xBroadcaster->add##listenerdesc(&multiplexer);								\
222*cdf0e10cSrcweir 		}																					\
223*cdf0e10cSrcweir 	}																						\
224*cdf0e10cSrcweir 	/*................................................................*/					\
225*cdf0e10cSrcweir 	void SAL_CALL classname::remove##listenerdesc(const ::com::sun::star::uno::Reference< ::com::sun::star::listenernamespace::X##listenerdesc >& l) throw(::com::sun::star::uno::RuntimeException)\
226*cdf0e10cSrcweir 	{																						\
227*cdf0e10cSrcweir 		if (multiplexer.getLength() == 1)													\
228*cdf0e10cSrcweir 		{																					\
229*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY);	\
230*cdf0e10cSrcweir 			if (xBroadcaster.is())															\
231*cdf0e10cSrcweir 				xBroadcaster->remove##listenerdesc(&multiplexer);							\
232*cdf0e10cSrcweir 		}																					\
233*cdf0e10cSrcweir 		multiplexer.removeInterface(l);														\
234*cdf0e10cSrcweir 	}																						\
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 	#define STOP_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, braodcasterclass, broadcaster) \
238*cdf0e10cSrcweir 	if (multiplexer.getLength())															\
239*cdf0e10cSrcweir 	{																					\
240*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY);	\
241*cdf0e10cSrcweir 		if (xBroadcaster.is())															\
242*cdf0e10cSrcweir 			xBroadcaster->remove##listenerdesc(&multiplexer);							\
243*cdf0e10cSrcweir 	}																					\
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 	#define START_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, braodcasterclass, broadcaster) \
246*cdf0e10cSrcweir 	if (multiplexer.getLength())														\
247*cdf0e10cSrcweir 	{																					\
248*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY);	\
249*cdf0e10cSrcweir 		if (xBroadcaster.is())															\
250*cdf0e10cSrcweir 			xBroadcaster->add##listenerdesc(&multiplexer);								\
251*cdf0e10cSrcweir 	}																					\
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 	//------------------------------------------------------------------
256*cdf0e10cSrcweir 	// declaration of property listener multiplexers
257*cdf0e10cSrcweir 	// (with support for specialized and unspecialized property listeners)
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	#define DECLARE_PROPERTY_MULTIPLEXER(classname, listenerclass, methodname, eventtype, exceptions)	\
260*cdf0e10cSrcweir 	class classname																			\
261*cdf0e10cSrcweir 			:public OSbaWeakSubObject															\
262*cdf0e10cSrcweir 			,public listenerclass															\
263*cdf0e10cSrcweir 	{																						\
264*cdf0e10cSrcweir 		typedef ::cppu::OMultiTypeInterfaceContainerHelperVar<								\
265*cdf0e10cSrcweir 				::rtl::OUString, ::comphelper::UStringHash, ::comphelper::UStringEqual >	ListenerContainerMap;	\
266*cdf0e10cSrcweir 		ListenerContainerMap	m_aListeners;												\
267*cdf0e10cSrcweir 																							\
268*cdf0e10cSrcweir 	public:																					\
269*cdf0e10cSrcweir 		classname( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex );					\
270*cdf0e10cSrcweir 		DECLARE_UNO3_DEFAULTS(classname, OSbaWeakSubObject);									\
271*cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any	SAL_CALL queryInterface(						\
272*cdf0e10cSrcweir 			const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException); \
273*cdf0e10cSrcweir 																							\
274*cdf0e10cSrcweir 		/* ::com::sun::star::lang::XEventListener */										\
275*cdf0e10cSrcweir 		virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException);	\
276*cdf0e10cSrcweir 																							\
277*cdf0e10cSrcweir 		virtual void SAL_CALL methodname(const eventtype& e)  throw exceptions;				\
278*cdf0e10cSrcweir 																							\
279*cdf0e10cSrcweir 	public:																					\
280*cdf0e10cSrcweir 		void addInterface(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rListener);	\
281*cdf0e10cSrcweir 		void removeInterface(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rListener);	\
282*cdf0e10cSrcweir 																							\
283*cdf0e10cSrcweir 		void disposeAndClear();																\
284*cdf0e10cSrcweir 																							\
285*cdf0e10cSrcweir 		sal_Int32 getOverallLen() const;													\
286*cdf0e10cSrcweir 																							\
287*cdf0e10cSrcweir 		::cppu::OInterfaceContainerHelper* getContainer(const ::rtl::OUString& rName)		\
288*cdf0e10cSrcweir 			{ return m_aListeners.getContainer(rName); }									\
289*cdf0e10cSrcweir 																							\
290*cdf0e10cSrcweir 	protected:																				\
291*cdf0e10cSrcweir 		void Notify(::cppu::OInterfaceContainerHelper& rListeners, const eventtype& e);		\
292*cdf0e10cSrcweir 	};																						\
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 	//------------------------------------------------------------------
296*cdf0e10cSrcweir 	// implementation of property listener multiplexers
297*cdf0e10cSrcweir 	#define IMPLEMENT_PROPERTY_MULTIPLEXER(classname, listenerclass, methodname, eventtype, exceptions)	\
298*cdf0e10cSrcweir 	/*................................................................*/					\
299*cdf0e10cSrcweir 	classname::classname(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex)				\
300*cdf0e10cSrcweir 			:OSbaWeakSubObject(rSource)														\
301*cdf0e10cSrcweir 			,m_aListeners(rMutex)															\
302*cdf0e10cSrcweir 	{																						\
303*cdf0e10cSrcweir 	}																						\
304*cdf0e10cSrcweir 																							\
305*cdf0e10cSrcweir 	::com::sun::star::uno::Any	SAL_CALL classname::queryInterface(							\
306*cdf0e10cSrcweir 		const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException) \
307*cdf0e10cSrcweir 	{																						\
308*cdf0e10cSrcweir 		::com::sun::star::uno::Any aReturn = 												\
309*cdf0e10cSrcweir 			OSbaWeakSubObject::queryInterface(_rType);											\
310*cdf0e10cSrcweir 		if (!aReturn.hasValue())															\
311*cdf0e10cSrcweir 			aReturn = ::cppu::queryInterface(_rType,										\
312*cdf0e10cSrcweir 				static_cast< listenerclass* >(this),										\
313*cdf0e10cSrcweir 				static_cast< ::com::sun::star::lang::XEventListener* >(static_cast< listenerclass* >(this))	\
314*cdf0e10cSrcweir 			);																				\
315*cdf0e10cSrcweir 																							\
316*cdf0e10cSrcweir 		return aReturn;																		\
317*cdf0e10cSrcweir 	}																						\
318*cdf0e10cSrcweir 	/*................................................................*/					\
319*cdf0e10cSrcweir 	void SAL_CALL classname::disposing(const ::com::sun::star::lang::EventObject& ) throw(::com::sun::star::uno::RuntimeException)\
320*cdf0e10cSrcweir 	{																						\
321*cdf0e10cSrcweir 	}																						\
322*cdf0e10cSrcweir 																							\
323*cdf0e10cSrcweir 	void SAL_CALL classname::methodname(const eventtype& e) throw exceptions				\
324*cdf0e10cSrcweir 	{																						\
325*cdf0e10cSrcweir 		::cppu::OInterfaceContainerHelper* pListeners = m_aListeners.getContainer(e.PropertyName);	\
326*cdf0e10cSrcweir 		if (pListeners)																		\
327*cdf0e10cSrcweir 			Notify(*pListeners, e);															\
328*cdf0e10cSrcweir 																							\
329*cdf0e10cSrcweir 		/* do the notification for the unspecialized listeners, too */						\
330*cdf0e10cSrcweir 		pListeners = m_aListeners.getContainer(::rtl::OUString());							\
331*cdf0e10cSrcweir 		if (pListeners)																		\
332*cdf0e10cSrcweir 			Notify(*pListeners, e);															\
333*cdf0e10cSrcweir 	}																						\
334*cdf0e10cSrcweir 																							\
335*cdf0e10cSrcweir 	void classname::addInterface(const ::rtl::OUString& rName,								\
336*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener)	\
337*cdf0e10cSrcweir 	{																						\
338*cdf0e10cSrcweir 		m_aListeners.addInterface(rName, rListener);										\
339*cdf0e10cSrcweir 	}																						\
340*cdf0e10cSrcweir 																							\
341*cdf0e10cSrcweir 	void classname::removeInterface(const ::rtl::OUString& rName,							\
342*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener)	\
343*cdf0e10cSrcweir 	{																						\
344*cdf0e10cSrcweir 		m_aListeners.removeInterface(rName, rListener);										\
345*cdf0e10cSrcweir 	}																						\
346*cdf0e10cSrcweir 																							\
347*cdf0e10cSrcweir 	void classname::disposeAndClear()														\
348*cdf0e10cSrcweir 	{																						\
349*cdf0e10cSrcweir 		::com::sun::star::lang::EventObject aEvt(m_rParent);								\
350*cdf0e10cSrcweir 		m_aListeners.disposeAndClear(aEvt);																\
351*cdf0e10cSrcweir 	}																						\
352*cdf0e10cSrcweir 																							\
353*cdf0e10cSrcweir 	sal_Int32 classname::getOverallLen() const												\
354*cdf0e10cSrcweir 	{																						\
355*cdf0e10cSrcweir 		sal_Int32 nLen = 0;																	\
356*cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::rtl::OUString > aContained = m_aListeners.getContainedTypes();	\
357*cdf0e10cSrcweir 		const ::rtl::OUString* pContained = aContained.getConstArray();						\
358*cdf0e10cSrcweir 		for (	sal_Int32 i=0; i<aContained.getLength(); ++i, ++pContained)					\
359*cdf0e10cSrcweir 			nLen += m_aListeners.getContainer(*pContained)->getLength();					\
360*cdf0e10cSrcweir 		return nLen;																		\
361*cdf0e10cSrcweir 	}																						\
362*cdf0e10cSrcweir 																							\
363*cdf0e10cSrcweir 	void classname::Notify(::cppu::OInterfaceContainerHelper& rListeners, const eventtype& e)	\
364*cdf0e10cSrcweir 	{																						\
365*cdf0e10cSrcweir 		eventtype aMulti(e);																\
366*cdf0e10cSrcweir 		aMulti.Source = &m_rParent;															\
367*cdf0e10cSrcweir 		::cppu::OInterfaceIteratorHelper aIt(rListeners);									\
368*cdf0e10cSrcweir 		while (aIt.hasMoreElements())														\
369*cdf0e10cSrcweir 			static_cast< listenerclass*>(aIt.next())->methodname(aMulti);				\
370*cdf0e10cSrcweir 	}																						\
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 	//------------------------------------------------------------------
373*cdf0e10cSrcweir 	// helper for classes which do property event multiplexing
374*cdf0e10cSrcweir 	#define IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(classname, listenerdesc, multiplexer, braodcasterclass, broadcaster) \
375*cdf0e10cSrcweir 	/*................................................................*/					\
376*cdf0e10cSrcweir 	void SAL_CALL classname::add##listenerdesc(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::X##listenerdesc >& l ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)\
377*cdf0e10cSrcweir 	{																						\
378*cdf0e10cSrcweir 		multiplexer.addInterface(rName, l);													\
379*cdf0e10cSrcweir 		if (multiplexer.getOverallLen() == 1)												\
380*cdf0e10cSrcweir 		{																					\
381*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY);	\
382*cdf0e10cSrcweir 			if (xBroadcaster.is())															\
383*cdf0e10cSrcweir 				xBroadcaster->add##listenerdesc(::rtl::OUString(), &multiplexer);							\
384*cdf0e10cSrcweir 		}																					\
385*cdf0e10cSrcweir 	}																						\
386*cdf0e10cSrcweir 	/*................................................................*/					\
387*cdf0e10cSrcweir 	void SAL_CALL classname::remove##listenerdesc(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::X##listenerdesc >& l ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)\
388*cdf0e10cSrcweir 	{																						\
389*cdf0e10cSrcweir 		if (multiplexer.getOverallLen() == 1)												\
390*cdf0e10cSrcweir 		{																					\
391*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY);	\
392*cdf0e10cSrcweir 			if (xBroadcaster.is())															\
393*cdf0e10cSrcweir 				xBroadcaster->remove##listenerdesc(::rtl::OUString(), &multiplexer);						\
394*cdf0e10cSrcweir 		}																					\
395*cdf0e10cSrcweir 		multiplexer.removeInterface(rName, l);												\
396*cdf0e10cSrcweir 	}																						\
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir 	#define STOP_PROPERTY_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, braodcasterclass, broadcaster) \
399*cdf0e10cSrcweir 	if (multiplexer.getOverallLen())														\
400*cdf0e10cSrcweir 	{																						\
401*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY);	\
402*cdf0e10cSrcweir 		if (xBroadcaster.is())																\
403*cdf0e10cSrcweir 			xBroadcaster->remove##listenerdesc(::rtl::OUString(), &multiplexer);							\
404*cdf0e10cSrcweir 	}																						\
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 	#define START_PROPERTY_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, braodcasterclass, broadcaster) \
407*cdf0e10cSrcweir 	if (multiplexer.getOverallLen())														\
408*cdf0e10cSrcweir 	{																						\
409*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY);	\
410*cdf0e10cSrcweir 		if (xBroadcaster.is())																\
411*cdf0e10cSrcweir 			xBroadcaster->add##listenerdesc(::rtl::OUString(), &multiplexer);								\
412*cdf0e10cSrcweir 	}																						\
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir 	//==================================================================
417*cdf0e10cSrcweir 	// some listener multiplexers
418*cdf0e10cSrcweir 	//==================================================================
419*cdf0e10cSrcweir 	// ::com::sun::star::frame::XStatusListener
420*cdf0e10cSrcweir 	BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXStatusMultiplexer, ::com::sun::star::frame::XStatusListener)
421*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(statusChanged, ::com::sun::star::frame::FeatureStateEvent)
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir 	private:
424*cdf0e10cSrcweir 		::com::sun::star::frame::FeatureStateEvent	m_aLastKnownStatus;
425*cdf0e10cSrcweir 	public:																					\
426*cdf0e10cSrcweir 		inline ::com::sun::star::frame::FeatureStateEvent getLastEvent( ) const { return m_aLastKnownStatus; }
427*cdf0e10cSrcweir 	END_DECLARE_LISTENER_MULTIPLEXER()
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 	// ::com::sun::star::form::XLoadListener
430*cdf0e10cSrcweir 	BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener)
431*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(loaded, ::com::sun::star::lang::EventObject)
432*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(unloaded, ::com::sun::star::lang::EventObject)
433*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(unloading, ::com::sun::star::lang::EventObject)
434*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(reloading, ::com::sun::star::lang::EventObject)
435*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(reloaded, ::com::sun::star::lang::EventObject)
436*cdf0e10cSrcweir 	END_DECLARE_LISTENER_MULTIPLEXER()
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir 	// ::com::sun::star::form::XDatabaseParameterListener
439*cdf0e10cSrcweir 	BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXParameterMultiplexer, ::com::sun::star::form::XDatabaseParameterListener)
440*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_BOOL_METHOD(approveParameter, ::com::sun::star::form::DatabaseParameterEvent)
441*cdf0e10cSrcweir 	END_DECLARE_LISTENER_MULTIPLEXER()
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir 	// ::com::sun::star::form::XSubmitListener
444*cdf0e10cSrcweir 	BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXSubmitMultiplexer, ::com::sun::star::form::XSubmitListener)
445*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_BOOL_METHOD(approveSubmit, ::com::sun::star::lang::EventObject)
446*cdf0e10cSrcweir 	END_DECLARE_LISTENER_MULTIPLEXER()
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir 	// ::com::sun::star::form::XResetListener
449*cdf0e10cSrcweir 	BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXResetMultiplexer, ::com::sun::star::form::XResetListener)
450*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_BOOL_METHOD(approveReset, ::com::sun::star::lang::EventObject)
451*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(resetted, ::com::sun::star::lang::EventObject)
452*cdf0e10cSrcweir 	END_DECLARE_LISTENER_MULTIPLEXER()
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 	// ::com::sun::star::sdbc::XRowSetListener
455*cdf0e10cSrcweir 	BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener)
456*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(cursorMoved, ::com::sun::star::lang::EventObject)
457*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(rowChanged, ::com::sun::star::lang::EventObject)
458*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(rowSetChanged, ::com::sun::star::lang::EventObject)
459*cdf0e10cSrcweir 	END_DECLARE_LISTENER_MULTIPLEXER()
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir 	// ::com::sun::star::sdb::XRowSetApproveListener
462*cdf0e10cSrcweir 	BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener)
463*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_BOOL_METHOD(approveCursorMove, ::com::sun::star::lang::EventObject)
464*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_BOOL_METHOD(approveRowChange, ::com::sun::star::sdb::RowChangeEvent)
465*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_BOOL_METHOD(approveRowSetChange, ::com::sun::star::lang::EventObject)
466*cdf0e10cSrcweir 	END_DECLARE_LISTENER_MULTIPLEXER()
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir 	// ::com::sun::star::sdb::XSQLErrorListener
469*cdf0e10cSrcweir 	BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXSQLErrorMultiplexer, ::com::sun::star::sdb::XSQLErrorListener)
470*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(errorOccured, ::com::sun::star::sdb::SQLErrorEvent)
471*cdf0e10cSrcweir 	END_DECLARE_LISTENER_MULTIPLEXER()
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	// ::com::sun::star::beans::XPropertyChangeListener
474*cdf0e10cSrcweir 	DECLARE_PROPERTY_MULTIPLEXER(SbaXPropertyChangeMultiplexer, ::com::sun::star::beans::XPropertyChangeListener, propertyChange, ::com::sun::star::beans::PropertyChangeEvent, (::com::sun::star::uno::RuntimeException))
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir 	// ::com::sun::star::beans::XVetoableChangeListener
477*cdf0e10cSrcweir 	DECLARE_PROPERTY_MULTIPLEXER(SbaXVetoableChangeMultiplexer, ::com::sun::star::beans::XVetoableChangeListener, vetoableChange, ::com::sun::star::beans::PropertyChangeEvent, (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException))
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir 	// ::com::sun::star::beans::XPropertiesChangeListener
480*cdf0e10cSrcweir 	BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXPropertiesChangeMultiplexer, ::com::sun::star::beans::XPropertiesChangeListener)
481*cdf0e10cSrcweir 		DECLARE_MULTIPLEXER_VOID_METHOD(propertiesChange, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >)
482*cdf0e10cSrcweir 	END_DECLARE_LISTENER_MULTIPLEXER()
483*cdf0e10cSrcweir 	// the SbaXPropertiesChangeMultiplexer doesn't care about the property names a listener logs on for, it simply
484*cdf0e10cSrcweir 	// forwards _all_ changes to _all_ listeners
485*cdf0e10cSrcweir }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir #endif // _SBA_MULTIPLEXER_HXX
488*cdf0e10cSrcweir 
489