20#ifndef INCLUDED_TOOLKIT_HELPER_MACROS_HXX
21#define INCLUDED_TOOLKIT_HELPER_MACROS_HXX
24#include <osl/diagnose.h>
27#define IMPL_IMPLEMENTATION_ID( ClassName ) \
28css::uno::Sequence< sal_Int8 > ClassName::getImplementationId() \
30 return css::uno::Sequence<sal_Int8>(); \
34#define DECL_LISTENERMULTIPLEXER_START( ClassName, InterfaceName ) \
35class ClassName final : public ListenerMultiplexerBase<InterfaceName>, public InterfaceName \
38 ClassName( ::cppu::OWeakObject& rSource ); \
39 css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; \
40 void SAL_CALL acquire() noexcept override; \
41 void SAL_CALL release() noexcept override; \
42 void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
45#define DECL_LISTENERMULTIPLEXER_START_DLLPUB( ClassName, InterfaceName ) \
46class TOOLKIT_DLLPUBLIC ClassName final : public ListenerMultiplexerBase<InterfaceName>, public InterfaceName \
49 ClassName( ::cppu::OWeakObject& rSource ); \
50 css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; \
51 void SAL_CALL acquire() noexcept override; \
52 void SAL_CALL release() noexcept override; \
53 void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
56#define DECL_LISTENERMULTIPLEXER_END \
60#define IMPL_LISTENERMULTIPLEXER_BASEMETHODS( ClassName, InterfaceName ) \
61ClassName::ClassName( ::cppu::OWeakObject& rSource ) \
62 : ListenerMultiplexerBase<InterfaceName>(rSource) \
65void SAL_CALL ClassName::acquire() noexcept { ListenerMultiplexerBase::acquire(); } \
66void SAL_CALL ClassName::release() noexcept { ListenerMultiplexerBase::release(); } \
67css::uno::Any ClassName::queryInterface( const css::uno::Type & rType ) \
69 css::uno::Any aRet = ::cppu::queryInterface( rType, \
70 (static_cast< css::lang::XEventListener* >(this)), \
71 (static_cast< InterfaceName* >(this)) ); \
72 return (aRet.hasValue() ? aRet : ListenerMultiplexerBase::queryInterface( rType )); \
74void ClassName::disposing( const css::lang::EventObject& ) \
79#if OSL_DEBUG_LEVEL > 0
80 #define DISPLAY_EXCEPTION( ClassName, MethodName ) \
81 css::uno::Any ex( cppu::getCaughtException() ); \
82 SAL_WARN( "toolkit", #ClassName "::" #MethodName ": caught an exception! " << exceptionToString(ex));
84 #define DISPLAY_EXCEPTION( ClassName, MethodName )
87#define IMPL_TABLISTENERMULTIPLEXER_LISTENERMETHOD_BODY_1PARAM( ClassName, InterfaceName, MethodName, ParamType1 ) \
89 ParamType1 aMulti( evt ); \
90 std::unique_lock g(m_aMutex); \
91 ::comphelper::OInterfaceIteratorHelper4 aIt(g, maListeners); \
93 while( aIt.hasMoreElements() ) \
95 css::uno::Reference<InterfaceName> xListener(aIt.next()); \
98 xListener->MethodName( aMulti ); \
100 catch(const css::lang::DisposedException& e) \
102 OSL_ENSURE( e.Context.is(), "caught DisposedException with empty Context field" ); \
103 if ( e.Context == xListener || !e.Context.is() ) \
105 std::unique_lock g2(m_aMutex); \
109 catch(const css::uno::RuntimeException&) \
111 DISPLAY_EXCEPTION( ClassName, MethodName ) \
116#define IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_BODY( ClassName, InterfaceName, MethodName, EventType ) \
118 EventType aMulti( evt ); \
119 aMulti.Source = &GetContext(); \
120 std::unique_lock g(m_aMutex); \
121 ::comphelper::OInterfaceIteratorHelper4 aIt(g, maListeners); \
123 while( aIt.hasMoreElements() ) \
125 css::uno::Reference<InterfaceName> xListener(aIt.next()); \
128 xListener->MethodName( aMulti ); \
130 catch(const css::lang::DisposedException& e) \
132 OSL_ENSURE( e.Context.is(), "caught DisposedException with empty Context field" ); \
133 if ( e.Context == xListener || !e.Context.is() ) \
135 std::unique_lock g2(m_aMutex); \
139 catch(const css::uno::RuntimeException&) \
141 DISPLAY_EXCEPTION( ClassName, MethodName ) \
146#define IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_EXCEPTION( ClassName, InterfaceName, MethodName, EventType, Exception ) \
147void ClassName::MethodName( const EventType& evt ) \
148IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_BODY( ClassName, InterfaceName, MethodName, EventType )
150#define IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( ClassName, InterfaceName, MethodName, EventType ) \
151void ClassName::MethodName( const EventType& evt ) \
152IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_BODY( ClassName, InterfaceName, MethodName, EventType )
154#define DECLIMPL_SERVICEINFO_DERIVED( ImplName, BaseClass, ServiceName ) \
155 OUString SAL_CALL getImplementationName( ) override { return "stardiv.Toolkit." #ImplName; } \
156 css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override \
158 css::uno::Sequence< OUString > aNames = BaseClass::getSupportedServiceNames( ); \
159 aNames.realloc( aNames.getLength() + 1 ); \
160 aNames.getArray()[ aNames.getLength() - 1 ] = ServiceName; \