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