diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2021-11-12 12:55:33 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2021-11-12 18:00:01 +0100 |
commit | d2fa58b628b3f48c1c8941dbbd9d2faadddeef99 (patch) | |
tree | 3a54393c69d5a44ba2bfbb600887eac59040eed7 /dbaccess | |
parent | 5f8dc0a2e1ff065978881913156b3ba451231793 (diff) |
Replace some macros in dbaccess part 9
Remove IMPLEMENT_LISTENER_MULTIPLEXER_CORE + BEGIN_DECLARE_LISTENER_MULTIPLEXER
+ END_DECLARE_LISTENER_MULTIPLEXER + DECLARE_MULTIPLEXER_BOOL_METHOD + DECLARE_MULTIPLEXER_VOID_METHOD
+ STOP_MULTIPLEXER_LISTENING + START_PROPERTY_MULTIPLEXER_LISTENING + STOP_PROPERTY_MULTIPLEXER_LISTENING
+ START_MULTIPLEXER_LISTENING
Change-Id: I23dfa9d71b8ae84b9c4ff5e55145e8b350a1eeba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125105
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/browser/formadapter.cxx | 117 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbamultiplex.cxx | 201 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/sbamultiplex.hxx | 291 |
3 files changed, 457 insertions, 152 deletions
diff --git a/dbaccess/source/ui/browser/formadapter.cxx b/dbaccess/source/ui/browser/formadapter.cxx index 344b3ff8dd4d..20314106988b 100644 --- a/dbaccess/source/ui/browser/formadapter.cxx +++ b/dbaccess/source/ui/browser/formadapter.cxx @@ -89,13 +89,42 @@ Any SAL_CALL SbaXFormAdapter::queryInterface(const Type& _rType) void SbaXFormAdapter::StopListening() { // log off all our multiplexers - STOP_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, css::form::XLoadable, m_xMainForm); - STOP_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, css::sdbc::XRowSet, m_xMainForm); - STOP_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, css::sdb::XRowSetApproveBroadcaster, m_xMainForm); - STOP_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, css::sdb::XSQLErrorBroadcaster, m_xMainForm); - STOP_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, css::form::XSubmit, m_xMainForm); - STOP_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, css::form::XReset, m_xMainForm); - + if (m_aLoadListeners.getLength()) + { + css::uno::Reference< css::form::XLoadable > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeLoadListener(&m_aLoadListeners); + } + if (m_aRowSetListeners.getLength()) + { + css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeRowSetListener(&m_aRowSetListeners); + } + if (m_aRowSetApproveListeners.getLength()) + { + css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeRowSetApproveListener(&m_aRowSetApproveListeners); + } + if (m_aErrorListeners.getLength()) + { + css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeSQLErrorListener(&m_aErrorListeners); + } + if (m_aSubmitListeners.getLength()) + { + css::uno::Reference< css::form::XSubmit > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeSubmitListener(&m_aSubmitListeners); + } + if (m_aResetListeners.getLength()) + { + css::uno::Reference< css::form::XReset > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeResetListener(&m_aResetListeners); + } if (m_aParameterListeners.getLength()) { Reference< css::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY); @@ -103,8 +132,20 @@ void SbaXFormAdapter::StopListening() xBroadcaster->removeParameterListener(&m_aParameterListeners); } - STOP_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, css::beans::XPropertySet, m_xMainForm); - STOP_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, css::beans::XPropertySet, m_xMainForm); + if (m_aPropertyChangeListeners.getOverallLen()) + { + css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removePropertyChangeListener(OUString(), &m_aPropertyChangeListeners); + } + + if (m_aVetoablePropertyChangeListeners.getOverallLen()) + { + css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeVetoableChangeListener(OUString(), &m_aVetoablePropertyChangeListeners); + } + if (m_aPropertiesChangeListeners.getLength()) { Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY); @@ -121,12 +162,42 @@ void SbaXFormAdapter::StopListening() void SbaXFormAdapter::StartListening() { // log off all our multiplexers - START_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, css::form::XLoadable, m_xMainForm); - START_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, css::sdbc::XRowSet, m_xMainForm); - START_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, css::sdb::XRowSetApproveBroadcaster, m_xMainForm); - START_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, css::sdb::XSQLErrorBroadcaster, m_xMainForm); - START_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, css::form::XSubmit, m_xMainForm); - START_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, css::form::XReset, m_xMainForm); + if (m_aLoadListeners.getLength()) + { + css::uno::Reference< css::form::XLoadable > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addLoadListener(&m_aLoadListeners); + } + if (m_aRowSetListeners.getLength()) + { + css::uno::Reference< css::sdbc::XRowSet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addRowSetListener(&m_aRowSetListeners); + } + if (m_aRowSetApproveListeners.getLength()) + { + css::uno::Reference< css::sdb::XRowSetApproveBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addRowSetApproveListener(&m_aRowSetApproveListeners); + } + if (m_aErrorListeners.getLength()) + { + css::uno::Reference< css::sdb::XSQLErrorBroadcaster > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addSQLErrorListener(&m_aErrorListeners); + } + if (m_aSubmitListeners.getLength()) + { + css::uno::Reference< css::form::XSubmit > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addSubmitListener(&m_aSubmitListeners); + } + if (m_aResetListeners.getLength()) + { + css::uno::Reference< css::form::XReset > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addResetListener(&m_aResetListeners); + } if (m_aParameterListeners.getLength()) { @@ -135,8 +206,20 @@ void SbaXFormAdapter::StartListening() xBroadcaster->addParameterListener(&m_aParameterListeners); } - START_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, css::beans::XPropertySet, m_xMainForm); - START_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, css::beans::XPropertySet, m_xMainForm); + if (m_aPropertyChangeListeners.getOverallLen()) + { + css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addPropertyChangeListener(OUString(), &m_aPropertyChangeListeners); + } + + if (m_aVetoablePropertyChangeListeners.getOverallLen()) + { + css::uno::Reference< css::beans::XPropertySet > xBroadcaster(m_xMainForm, css::uno::UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addVetoableChangeListener(OUString(), &m_aVetoablePropertyChangeListeners); + } + if (m_aPropertiesChangeListeners.getLength()) { Reference< css::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY); diff --git a/dbaccess/source/ui/browser/sbamultiplex.cxx b/dbaccess/source/ui/browser/sbamultiplex.cxx index fcc53ea8702e..9c2e786bb9d8 100644 --- a/dbaccess/source/ui/browser/sbamultiplex.cxx +++ b/dbaccess/source/ui/browser/sbamultiplex.cxx @@ -23,7 +23,27 @@ using namespace dbaui; // the listener multiplexers // XStatusListener -IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXStatusMultiplexer, css::frame::XStatusListener) +SbaXStatusMultiplexer::SbaXStatusMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) + :OSbaWeakSubObject(rSource) + ,OInterfaceContainerHelper2(_rMutex) +{ +} + +css::uno::Any SAL_CALL SbaXStatusMultiplexer::queryInterface(const css::uno::Type& _rType) +{ + css::uno::Any aReturn = OSbaWeakSubObject::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< css::frame::XStatusListener* >(this), + static_cast< css::lang::XEventListener* >(static_cast< css::frame::XStatusListener* >(this)) + ); + + return aReturn; +} +void SAL_CALL SbaXStatusMultiplexer::disposing(const css::lang::EventObject& ) +{ +} + void SAL_CALL SbaXStatusMultiplexer::statusChanged(const css::frame::FeatureStateEvent& e) { @@ -35,7 +55,27 @@ void SAL_CALL SbaXStatusMultiplexer::statusChanged(const css::frame::FeatureStat } // LoadListener -IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXLoadMultiplexer, css::form::XLoadListener) +SbaXLoadMultiplexer::SbaXLoadMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) + :OSbaWeakSubObject(rSource) + ,OInterfaceContainerHelper2(_rMutex) +{ +} + +css::uno::Any SAL_CALL SbaXLoadMultiplexer::queryInterface(const css::uno::Type& _rType) +{ + css::uno::Any aReturn = OSbaWeakSubObject::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< css::form::XLoadListener* >(this), + static_cast< css::lang::XEventListener* >(static_cast< css::form::XLoadListener* >(this)) + ); + + return aReturn; +} +void SAL_CALL SbaXLoadMultiplexer::disposing(const css::lang::EventObject& ) +{ +} + void SAL_CALL SbaXLoadMultiplexer::loaded(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); @@ -82,7 +122,27 @@ void SAL_CALL SbaXLoadMultiplexer::reloaded(const css::lang::EventObject& e) // css::sdbc::XRowSetListener -IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXRowSetMultiplexer, css::sdbc::XRowSetListener) +SbaXRowSetMultiplexer::SbaXRowSetMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) + :OSbaWeakSubObject(rSource) + ,OInterfaceContainerHelper2(_rMutex) +{ +} + +css::uno::Any SAL_CALL SbaXRowSetMultiplexer::queryInterface(const css::uno::Type& _rType) +{ + css::uno::Any aReturn = OSbaWeakSubObject::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< css::sdbc::XRowSetListener* >(this), + static_cast< css::lang::XEventListener* >(static_cast< css::sdbc::XRowSetListener* >(this)) + ); + + return aReturn; +} +void SAL_CALL SbaXRowSetMultiplexer::disposing(const css::lang::EventObject& ) +{ +} + void SAL_CALL SbaXRowSetMultiplexer::cursorMoved(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); @@ -111,7 +171,27 @@ void SAL_CALL SbaXRowSetMultiplexer::rowSetChanged(const css::lang::EventObject& } // css::sdb::XRowSetApproveListener -IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXRowSetApproveMultiplexer, css::sdb::XRowSetApproveListener) +SbaXRowSetApproveMultiplexer::SbaXRowSetApproveMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) + :OSbaWeakSubObject(rSource) + ,OInterfaceContainerHelper2(_rMutex) +{ +} + +css::uno::Any SAL_CALL SbaXRowSetApproveMultiplexer::queryInterface(const css::uno::Type& _rType) +{ + css::uno::Any aReturn = OSbaWeakSubObject::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< css::sdb::XRowSetApproveListener* >(this), + static_cast< css::lang::XEventListener* >(static_cast< css::sdb::XRowSetApproveListener* >(this)) + ); + + return aReturn; +} +void SAL_CALL SbaXRowSetApproveMultiplexer::disposing(const css::lang::EventObject& ) +{ +} + sal_Bool SAL_CALL SbaXRowSetApproveMultiplexer::approveCursorMove(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); @@ -146,7 +226,27 @@ sal_Bool SAL_CALL SbaXRowSetApproveMultiplexer::approveRowSetChange(const css::l } // css::sdb::XSQLErrorListener -IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXSQLErrorMultiplexer, css::sdb::XSQLErrorListener) +SbaXSQLErrorMultiplexer::SbaXSQLErrorMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) + :OSbaWeakSubObject(rSource) + ,OInterfaceContainerHelper2(_rMutex) +{ +} + +css::uno::Any SAL_CALL SbaXSQLErrorMultiplexer::queryInterface(const css::uno::Type& _rType) +{ + css::uno::Any aReturn = OSbaWeakSubObject::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< css::sdb::XSQLErrorListener* >(this), + static_cast< css::lang::XEventListener* >(static_cast< css::sdb::XSQLErrorListener* >(this)) + ); + + return aReturn; +} +void SAL_CALL SbaXSQLErrorMultiplexer::disposing(const css::lang::EventObject& ) +{ +} + void SAL_CALL SbaXSQLErrorMultiplexer::errorOccured(const css::sdb::SQLErrorEvent& e) { css::sdb::SQLErrorEvent aMulti(e); @@ -157,7 +257,27 @@ void SAL_CALL SbaXSQLErrorMultiplexer::errorOccured(const css::sdb::SQLErrorEven } // css::form::XDatabaseParameterListener -IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXParameterMultiplexer, css::form::XDatabaseParameterListener) +SbaXParameterMultiplexer::SbaXParameterMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) + :OSbaWeakSubObject(rSource) + ,OInterfaceContainerHelper2(_rMutex) +{ +} + +css::uno::Any SAL_CALL SbaXParameterMultiplexer::queryInterface(const css::uno::Type& _rType) +{ + css::uno::Any aReturn = OSbaWeakSubObject::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< css::form::XDatabaseParameterListener* >(this), + static_cast< css::lang::XEventListener* >(static_cast< css::form::XDatabaseParameterListener* >(this)) + ); + + return aReturn; +} +void SAL_CALL SbaXParameterMultiplexer::disposing(const css::lang::EventObject& ) +{ +} + sal_Bool SAL_CALL SbaXParameterMultiplexer::approveParameter(const css::form::DatabaseParameterEvent& e) { css::form::DatabaseParameterEvent aMulti(e); @@ -170,7 +290,29 @@ sal_Bool SAL_CALL SbaXParameterMultiplexer::approveParameter(const css::form::Da } // css::form::XSubmitListener -IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXSubmitMultiplexer, css::form::XSubmitListener) +SbaXSubmitMultiplexer::SbaXSubmitMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) + :OSbaWeakSubObject(rSource) + ,OInterfaceContainerHelper2(_rMutex) +{ +} + +css::uno::Any SAL_CALL SbaXSubmitMultiplexer::queryInterface(const css::uno::Type& _rType) +{ + css::uno::Any aReturn = OSbaWeakSubObject::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< css::form::XSubmitListener* >(this), + static_cast< css::lang::XEventListener* >(static_cast< css::form::XSubmitListener* >(this)) + ); + + return aReturn; +} +void SAL_CALL SbaXSubmitMultiplexer::disposing(const css::lang::EventObject& ) +{ +} + + + sal_Bool SAL_CALL SbaXSubmitMultiplexer::approveSubmit(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); @@ -183,7 +325,28 @@ sal_Bool SAL_CALL SbaXSubmitMultiplexer::approveSubmit(const css::lang::EventObj } // css::form::XResetListener -IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXResetMultiplexer, css::form::XResetListener) +SbaXResetMultiplexer::SbaXResetMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) + :OSbaWeakSubObject(rSource) + ,OInterfaceContainerHelper2(_rMutex) +{ +} + +css::uno::Any SAL_CALL SbaXResetMultiplexer::queryInterface(const css::uno::Type& _rType) +{ + css::uno::Any aReturn = OSbaWeakSubObject::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< css::form::XResetListener* >(this), + static_cast< css::lang::XEventListener* >(static_cast< css::form::XResetListener* >(this)) + ); + + return aReturn; +} +void SAL_CALL SbaXResetMultiplexer::disposing(const css::lang::EventObject& ) +{ +} + + sal_Bool SAL_CALL SbaXResetMultiplexer::approveReset(const css::lang::EventObject& e) { css::lang::EventObject aMulti(e); @@ -353,7 +516,27 @@ void SbaXVetoableChangeMultiplexer::Notify(::comphelper::OInterfaceContainerHelp } // css::beans::XPropertiesChangeListener -IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXPropertiesChangeMultiplexer, css::beans::XPropertiesChangeListener); +SbaXPropertiesChangeMultiplexer::SbaXPropertiesChangeMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) + :OSbaWeakSubObject(rSource) + ,OInterfaceContainerHelper2(_rMutex) +{ +} + +css::uno::Any SAL_CALL SbaXPropertiesChangeMultiplexer::queryInterface(const css::uno::Type& _rType) +{ + css::uno::Any aReturn = OSbaWeakSubObject::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ::cppu::queryInterface(_rType, + static_cast< css::beans::XPropertiesChangeListener* >(this), + static_cast< css::lang::XEventListener* >(static_cast< css::beans::XPropertiesChangeListener* >(this)) + ); + + return aReturn; +} +void SAL_CALL SbaXPropertiesChangeMultiplexer::disposing(const css::lang::EventObject& ) +{ +} + void SbaXPropertiesChangeMultiplexer::propertiesChange(const css::uno::Sequence< css::beans::PropertyChangeEvent>& aEvts) { // the SbaXPropertiesChangeMultiplexer doesn't care about the property names a listener logs on for, it simply diff --git a/dbaccess/source/ui/inc/sbamultiplex.hxx b/dbaccess/source/ui/inc/sbamultiplex.hxx index 286fa3c8bfc7..1ad6152b0df5 100644 --- a/dbaccess/source/ui/inc/sbamultiplex.hxx +++ b/dbaccess/source/ui/inc/sbamultiplex.hxx @@ -51,149 +51,174 @@ namespace dbaui virtual void SAL_CALL release() noexcept override { m_rParent.release(); } }; - // declaration of a listener multiplexer class - #define BEGIN_DECLARE_LISTENER_MULTIPLEXER(classname, listenerclass) \ - class classname \ - :public OSbaWeakSubObject \ - ,public listenerclass \ - ,public ::comphelper::OInterfaceContainerHelper2 \ - { \ - public: \ - classname( ::cppu::OWeakObject& rSource, \ - ::osl::Mutex& rMutex); \ - DECLARE_UNO3_DEFAULTS(classname, OSbaWeakSubObject) \ - virtual css::uno::Any SAL_CALL queryInterface( \ - const css::uno::Type& _rType) override; \ - \ - /* css::lang::XEventListener */ \ - virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; \ - - #define DECLARE_MULTIPLEXER_VOID_METHOD(methodname, eventtype) \ - virtual void SAL_CALL methodname(const eventtype& e) override; \ - - #define DECLARE_MULTIPLEXER_BOOL_METHOD(methodname, eventtype) \ - virtual sal_Bool SAL_CALL methodname(const eventtype& e) override; \ - - #define END_DECLARE_LISTENER_MULTIPLEXER() \ - /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ \ - using OSbaWeakSubObject::operator new; \ - using OSbaWeakSubObject::operator delete; \ - }; \ - - // implementation of a listener multiplexer class - - #define IMPLEMENT_LISTENER_MULTIPLEXER_CORE(classname, listenerclass) \ - \ - classname::classname(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) \ - :OSbaWeakSubObject(rSource) \ - ,OInterfaceContainerHelper2(_rMutex) \ - { \ - } \ - \ - css::uno::Any SAL_CALL classname::queryInterface( \ - const css::uno::Type& _rType) \ - { \ - css::uno::Any aReturn = \ - OSbaWeakSubObject::queryInterface(_rType); \ - if (!aReturn.hasValue()) \ - aReturn = ::cppu::queryInterface(_rType, \ - static_cast< listenerclass* >(this), \ - static_cast< css::lang::XEventListener* >(static_cast< listenerclass* >(this)) \ - ); \ - \ - return aReturn; \ - } \ - void SAL_CALL classname::disposing(const css::lang::EventObject& )\ - { \ - } \ - - - #define STOP_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, broadcasterclass, broadcaster) \ - if (multiplexer.getLength()) \ - { \ - css::uno::Reference< broadcasterclass > xBroadcaster(broadcaster, css::uno::UNO_QUERY); \ - if (xBroadcaster.is()) \ - xBroadcaster->remove##listenerdesc(&multiplexer); \ - } \ - - #define START_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, broadcasterclass, broadcaster) \ - if (multiplexer.getLength()) \ - { \ - css::uno::Reference< broadcasterclass > xBroadcaster(broadcaster, css::uno::UNO_QUERY); \ - if (xBroadcaster.is()) \ - xBroadcaster->add##listenerdesc(&multiplexer); \ - } \ - - #define STOP_PROPERTY_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, broadcasterclass, broadcaster) \ - if (multiplexer.getOverallLen()) \ - { \ - css::uno::Reference< broadcasterclass > xBroadcaster(broadcaster, css::uno::UNO_QUERY); \ - if (xBroadcaster.is()) \ - xBroadcaster->remove##listenerdesc(OUString(), &multiplexer); \ - } \ - - #define START_PROPERTY_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, broadcasterclass, broadcaster) \ - if (multiplexer.getOverallLen()) \ - { \ - css::uno::Reference< broadcasterclass > xBroadcaster(broadcaster, css::uno::UNO_QUERY); \ - if (xBroadcaster.is()) \ - xBroadcaster->add##listenerdesc(OUString(), &multiplexer); \ - } \ - // some listener multiplexers // css::frame::XStatusListener - BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXStatusMultiplexer, css::frame::XStatusListener) - DECLARE_MULTIPLEXER_VOID_METHOD(statusChanged, css::frame::FeatureStateEvent) + class SbaXStatusMultiplexer + :public OSbaWeakSubObject + ,public css::frame::XStatusListener + ,public ::comphelper::OInterfaceContainerHelper2 + { + public: + SbaXStatusMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex); + DECLARE_UNO3_DEFAULTS(SbaXStatusMultiplexer, OSbaWeakSubObject) + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; + + /* css::lang::XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& e) override; private: css::frame::FeatureStateEvent m_aLastKnownStatus; - public: \ + public: const css::frame::FeatureStateEvent& getLastEvent( ) const { return m_aLastKnownStatus; } - END_DECLARE_LISTENER_MULTIPLEXER() + /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ + using OSbaWeakSubObject::operator new; + using OSbaWeakSubObject::operator delete; + }; // css::form::XLoadListener - BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXLoadMultiplexer, css::form::XLoadListener) - DECLARE_MULTIPLEXER_VOID_METHOD(loaded, css::lang::EventObject) - DECLARE_MULTIPLEXER_VOID_METHOD(unloaded, css::lang::EventObject) - DECLARE_MULTIPLEXER_VOID_METHOD(unloading, css::lang::EventObject) - DECLARE_MULTIPLEXER_VOID_METHOD(reloading, css::lang::EventObject) - DECLARE_MULTIPLEXER_VOID_METHOD(reloaded, css::lang::EventObject) - END_DECLARE_LISTENER_MULTIPLEXER() + class SbaXLoadMultiplexer + :public OSbaWeakSubObject + ,public css::form::XLoadListener + ,public ::comphelper::OInterfaceContainerHelper2 + { + public: + SbaXLoadMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex); + DECLARE_UNO3_DEFAULTS(SbaXLoadMultiplexer, OSbaWeakSubObject) + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; + + /* css::lang::XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + virtual void SAL_CALL loaded(const css::lang::EventObject& e) override; + virtual void SAL_CALL unloaded(const css::lang::EventObject& e) override; + virtual void SAL_CALL unloading(const css::lang::EventObject& e) override; + virtual void SAL_CALL reloading(const css::lang::EventObject& e) override; + virtual void SAL_CALL reloaded(const css::lang::EventObject& e) override; + /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ + using OSbaWeakSubObject::operator new; + using OSbaWeakSubObject::operator delete; + }; // css::form::XDatabaseParameterListener - BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXParameterMultiplexer, css::form::XDatabaseParameterListener) - DECLARE_MULTIPLEXER_BOOL_METHOD(approveParameter, css::form::DatabaseParameterEvent) - END_DECLARE_LISTENER_MULTIPLEXER() + class SbaXParameterMultiplexer + :public OSbaWeakSubObject + ,public css::form::XDatabaseParameterListener + ,public ::comphelper::OInterfaceContainerHelper2 + { + public: + SbaXParameterMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex); + DECLARE_UNO3_DEFAULTS(SbaXParameterMultiplexer, OSbaWeakSubObject) + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; + + /* css::lang::XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + virtual sal_Bool SAL_CALL approveParameter(const css::form::DatabaseParameterEvent& e) override; + /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ + using OSbaWeakSubObject::operator new; + using OSbaWeakSubObject::operator delete; + }; // css::form::XSubmitListener - BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXSubmitMultiplexer, css::form::XSubmitListener) - DECLARE_MULTIPLEXER_BOOL_METHOD(approveSubmit, css::lang::EventObject) - END_DECLARE_LISTENER_MULTIPLEXER() + class SbaXSubmitMultiplexer + :public OSbaWeakSubObject + ,public css::form::XSubmitListener + ,public ::comphelper::OInterfaceContainerHelper2 + { + public: + SbaXSubmitMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex); + DECLARE_UNO3_DEFAULTS(SbaXSubmitMultiplexer, OSbaWeakSubObject) + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; + + /* css::lang::XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + virtual sal_Bool SAL_CALL approveSubmit(const css::lang::EventObject& e) override; + /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ + using OSbaWeakSubObject::operator new; + using OSbaWeakSubObject::operator delete; + }; // css::form::XResetListener - BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXResetMultiplexer, css::form::XResetListener) - DECLARE_MULTIPLEXER_BOOL_METHOD(approveReset, css::lang::EventObject) - DECLARE_MULTIPLEXER_VOID_METHOD(resetted, css::lang::EventObject) - END_DECLARE_LISTENER_MULTIPLEXER() + class SbaXResetMultiplexer + :public OSbaWeakSubObject + ,public css::form::XResetListener + ,public ::comphelper::OInterfaceContainerHelper2 + { + public: + SbaXResetMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex); + DECLARE_UNO3_DEFAULTS(SbaXResetMultiplexer, OSbaWeakSubObject) + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; + + /* css::lang::XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + virtual sal_Bool SAL_CALL approveReset(const css::lang::EventObject& e) override; + virtual void SAL_CALL resetted(const css::lang::EventObject& e) override; + /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ + using OSbaWeakSubObject::operator new; + using OSbaWeakSubObject::operator delete; + }; // css::sdbc::XRowSetListener - BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXRowSetMultiplexer, css::sdbc::XRowSetListener) - DECLARE_MULTIPLEXER_VOID_METHOD(cursorMoved, css::lang::EventObject) - DECLARE_MULTIPLEXER_VOID_METHOD(rowChanged, css::lang::EventObject) - DECLARE_MULTIPLEXER_VOID_METHOD(rowSetChanged, css::lang::EventObject) - END_DECLARE_LISTENER_MULTIPLEXER() + class SbaXRowSetMultiplexer + :public OSbaWeakSubObject + ,public css::sdbc::XRowSetListener + ,public ::comphelper::OInterfaceContainerHelper2 + { + public: + SbaXRowSetMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex); + DECLARE_UNO3_DEFAULTS(SbaXRowSetMultiplexer, OSbaWeakSubObject) + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; + + /* css::lang::XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + virtual void SAL_CALL cursorMoved(const css::lang::EventObject& e) override; + virtual void SAL_CALL rowChanged(const css::lang::EventObject& e) override; + virtual void SAL_CALL rowSetChanged(const css::lang::EventObject& e) override; + /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ + using OSbaWeakSubObject::operator new; + using OSbaWeakSubObject::operator delete; + }; // css::sdb::XRowSetApproveListener - BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXRowSetApproveMultiplexer, css::sdb::XRowSetApproveListener) - DECLARE_MULTIPLEXER_BOOL_METHOD(approveCursorMove, css::lang::EventObject) - DECLARE_MULTIPLEXER_BOOL_METHOD(approveRowChange, css::sdb::RowChangeEvent) - DECLARE_MULTIPLEXER_BOOL_METHOD(approveRowSetChange, css::lang::EventObject) - END_DECLARE_LISTENER_MULTIPLEXER() + class SbaXRowSetApproveMultiplexer + :public OSbaWeakSubObject + ,public css::sdb::XRowSetApproveListener + ,public ::comphelper::OInterfaceContainerHelper2 + { + public: + SbaXRowSetApproveMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex); + DECLARE_UNO3_DEFAULTS(SbaXRowSetApproveMultiplexer, OSbaWeakSubObject) + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; + + /* css::lang::XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + virtual sal_Bool SAL_CALL approveCursorMove(const css::lang::EventObject& e) override; + virtual sal_Bool SAL_CALL approveRowChange(const css::sdb::RowChangeEvent& e) override; + virtual sal_Bool SAL_CALL approveRowSetChange(const css::lang::EventObject& e) override; + /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ + using OSbaWeakSubObject::operator new; + using OSbaWeakSubObject::operator delete; + }; // css::sdb::XSQLErrorListener - BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXSQLErrorMultiplexer, css::sdb::XSQLErrorListener) - DECLARE_MULTIPLEXER_VOID_METHOD(errorOccured, css::sdb::SQLErrorEvent) - END_DECLARE_LISTENER_MULTIPLEXER() + class SbaXSQLErrorMultiplexer + :public OSbaWeakSubObject + ,public css::sdb::XSQLErrorListener + ,public ::comphelper::OInterfaceContainerHelper2 + { + public: + SbaXSQLErrorMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex); + DECLARE_UNO3_DEFAULTS(SbaXSQLErrorMultiplexer, OSbaWeakSubObject) + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; + + /* css::lang::XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + virtual void SAL_CALL errorOccured(const css::sdb::SQLErrorEvent& e) override; + /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ + using OSbaWeakSubObject::operator new; + using OSbaWeakSubObject::operator delete; + }; // css::beans::XPropertyChangeListener class SbaXPropertyChangeMultiplexer final @@ -260,9 +285,23 @@ namespace dbaui }; // css::beans::XPropertiesChangeListener - BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXPropertiesChangeMultiplexer, css::beans::XPropertiesChangeListener) - DECLARE_MULTIPLEXER_VOID_METHOD(propertiesChange, css::uno::Sequence< css::beans::PropertyChangeEvent >) - END_DECLARE_LISTENER_MULTIPLEXER() + class SbaXPropertiesChangeMultiplexer + :public OSbaWeakSubObject + ,public css::beans::XPropertiesChangeListener + ,public ::comphelper::OInterfaceContainerHelper2 + { + public: + SbaXPropertiesChangeMultiplexer(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex); + DECLARE_UNO3_DEFAULTS(SbaXPropertiesChangeMultiplexer, OSbaWeakSubObject) + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override; + + /* css::lang::XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + virtual void SAL_CALL propertiesChange(const css::uno::Sequence< css::beans::PropertyChangeEvent >& e) override; + /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper2 have these memory operators */ + using OSbaWeakSubObject::operator new; + using OSbaWeakSubObject::operator delete; + }; // the SbaXPropertiesChangeMultiplexer doesn't care about the property names a listener logs on for, it simply // forwards _all_ changes to _all_ listeners } |