use more OInterfaceContainerHelper3 in toolkit

Change-Id: I3861a254d660662cbf575e9669cbacba36634856
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126855
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2021-12-15 11:43:32 +00:00
parent 6ce377a649
commit b2aa646ef0
9 changed files with 44 additions and 53 deletions

View File

@@ -357,9 +357,9 @@ namespace frm
m_aText = sText;
TextEvent aEvt;
aEvt.Source = *this;
::comphelper::OInterfaceIteratorHelper2 aIt( m_aTextListeners );
::comphelper::OInterfaceIteratorHelper3 aIt(m_aTextListeners);
while( aIt.hasMoreElements() )
static_cast<XTextListener *>(aIt.next())->textChanged( aEvt );
aIt.next()->textChanged(aEvt);
}
#endif
}
@@ -532,9 +532,9 @@ namespace frm
setText(aNewText);
TextEvent aEvt;
aEvt.Source = *this;
::comphelper::OInterfaceIteratorHelper2 aIt( m_aTextListeners );
::comphelper::OInterfaceIteratorHelper3 aIt(m_aTextListeners);
while( aIt.hasMoreElements() )
static_cast< XTextListener* >( aIt.next() )->textChanged( aEvt );
aIt.next()->textChanged(aEvt);
}
#endif
return true;

View File

@@ -42,8 +42,10 @@
#include <vector>
#include <functional>
namespace comphelper { class OInterfaceContainerHelper2; }
namespace comphelper { template <class ListenerT> class OInterfaceContainerHelper3; }
namespace com::sun::star::accessibility { class XAccessibleContext; }
namespace com::sun::star::awt { class XTopWindowListener; }
namespace com::sun::star::awt { class XVclContainerListener; }
namespace vcl { class Window; }
class VclWindowEvent;
@@ -97,8 +99,8 @@ protected:
bool bWithDefaults = false );
virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds );
::comphelper::OInterfaceContainerHelper2& GetContainerListeners();
::comphelper::OInterfaceContainerHelper2& GetTopWindowListeners();
::comphelper::OInterfaceContainerHelper3<css::awt::XVclContainerListener>& GetContainerListeners();
::comphelper::OInterfaceContainerHelper3<css::awt::XTopWindowListener>& GetTopWindowListeners();
public:
typedef ::std::function<void ()> Callback;

View File

@@ -42,8 +42,9 @@
#include <com/sun/star/awt/tree/XTreeExpansionListener.hpp>
#include <com/sun/star/awt/tree/XTreeEditListener.hpp>
#include <com/sun/star/view/XSelectionChangeListener.hpp>
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/weak.hxx>
#include <comphelper/interfacecontainer2.hxx>
#include <comphelper/interfacecontainer3.hxx>
#include <toolkit/helper/mutexhelper.hxx>
#include <toolkit/helper/macros.hxx>
#include <com/sun/star/awt/grid/XGridSelectionListener.hpp>
@@ -51,9 +52,9 @@
// class ListenerMultiplexerBase
template <class ListenerT>
class UNLESS_MERGELIBS(TOOLKIT_DLLPUBLIC) ListenerMultiplexerBase : public MutexHelper,
public ::comphelper::OInterfaceContainerHelper2,
public ::comphelper::OInterfaceContainerHelper3<ListenerT>,
public css::uno::XInterface
{
private:
@@ -63,16 +64,25 @@ protected:
::cppu::OWeakObject& GetContext() { return mrContext; }
public:
ListenerMultiplexerBase( ::cppu::OWeakObject& rSource );
virtual ~ListenerMultiplexerBase();
ListenerMultiplexerBase( ::cppu::OWeakObject& rSource )
: ::comphelper::OInterfaceContainerHelper3<ListenerT>(GetMutex()), mrContext(rSource)
{
}
virtual ~ListenerMultiplexerBase()
{
}
// css::uno::XInterface
css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
css::uno::Any SAL_CALL queryInterface(const css::uno::Type & rType) override
{
return ::cppu::queryInterface(rType, static_cast<css::uno::XInterface*>(this));
}
void SAL_CALL acquire() noexcept override { mrContext.acquire(); }
void SAL_CALL release() noexcept override { mrContext.release(); }
};
// class EventListenerMultiplexer
DECL_LISTENERMULTIPLEXER_START( EventListenerMultiplexer, css::lang::XEventListener )

View File

@@ -32,7 +32,7 @@ css::uno::Sequence< sal_Int8 > ClassName::getImplementationId() \
#define DECL_LISTENERMULTIPLEXER_START( ClassName, InterfaceName ) \
class ClassName final : public ListenerMultiplexerBase, public InterfaceName \
class ClassName final : public ListenerMultiplexerBase<InterfaceName>, public InterfaceName \
{ \
public: \
ClassName( ::cppu::OWeakObject& rSource ); \
@@ -43,7 +43,7 @@ public: \
#define DECL_LISTENERMULTIPLEXER_START_DLLPUB( ClassName, InterfaceName ) \
class TOOLKIT_DLLPUBLIC ClassName final : public ListenerMultiplexerBase, public InterfaceName \
class TOOLKIT_DLLPUBLIC ClassName final : public ListenerMultiplexerBase<InterfaceName>, public InterfaceName \
{ \
public: \
ClassName( ::cppu::OWeakObject& rSource ); \
@@ -59,7 +59,7 @@ public: \
#define IMPL_LISTENERMULTIPLEXER_BASEMETHODS( ClassName, InterfaceName ) \
ClassName::ClassName( ::cppu::OWeakObject& rSource ) \
: ListenerMultiplexerBase( rSource ) \
: ListenerMultiplexerBase<InterfaceName>(rSource) \
{ \
} \
void SAL_CALL ClassName::acquire() noexcept { ListenerMultiplexerBase::acquire(); } \
@@ -87,11 +87,10 @@ void ClassName::disposing( const css::lang::EventObject& ) \
#define IMPL_TABLISTENERMULTIPLEXER_LISTENERMETHOD_BODY_1PARAM( ClassName, InterfaceName, MethodName, ParamType1 ) \
{ \
ParamType1 aMulti( evt ); \
::comphelper::OInterfaceIteratorHelper2 aIt( *this ); \
::comphelper::OInterfaceIteratorHelper3 aIt(*this); \
while( aIt.hasMoreElements() ) \
{ \
css::uno::Reference< InterfaceName > xListener( \
static_cast< InterfaceName* >( aIt.next() ) ); \
css::uno::Reference<InterfaceName> xListener(aIt.next()); \
try \
{ \
xListener->MethodName( aMulti ); \
@@ -113,11 +112,10 @@ void ClassName::disposing( const css::lang::EventObject& ) \
{ \
EventType aMulti( evt ); \
aMulti.Source = &GetContext(); \
::comphelper::OInterfaceIteratorHelper2 aIt( *this ); \
::comphelper::OInterfaceIteratorHelper3 aIt(*this); \
while( aIt.hasMoreElements() ) \
{ \
css::uno::Reference< InterfaceName > xListener( \
static_cast< InterfaceName* >( aIt.next() ) ); \
css::uno::Reference<InterfaceName> xListener(aIt.next()); \
try \
{ \
xListener->MethodName( aMulti ); \

View File

@@ -47,6 +47,7 @@
#include <cppuhelper/component.hxx>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase2.hxx>
#include <toolkit/helper/listenermultiplexer.hxx>
#include <tools/diagnose_ex.h>
class DbCellControl;

View File

@@ -22,7 +22,7 @@
#include <toolkit/helper/vclunohelper.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <comphelper/interfacecontainer2.hxx>
#include <comphelper/interfacecontainer3.hxx>
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>

View File

@@ -54,7 +54,6 @@
#include <vcl/settings.hxx>
#include <vcl/commandevent.hxx>
#include <comphelper/flagguard.hxx>
#include <comphelper/interfacecontainer2.hxx>
#include <comphelper/interfacecontainer3.hxx>
#include <comphelper/profilezone.hxx>
#include "stylesettings.hxx"
@@ -1349,12 +1348,12 @@ void VCLXWindow::GetPropertyIds( std::vector< sal_uInt16 >& _out_rIds )
return ImplGetPropertyIds( _out_rIds, mpImpl->mbWithDefaultProps );
}
::comphelper::OInterfaceContainerHelper2& VCLXWindow::GetContainerListeners()
::comphelper::OInterfaceContainerHelper3<css::awt::XVclContainerListener>& VCLXWindow::GetContainerListeners()
{
return mpImpl->getContainerListeners();
}
::comphelper::OInterfaceContainerHelper2& VCLXWindow::GetTopWindowListeners()
::comphelper::OInterfaceContainerHelper3<css::awt::XTopWindowListener>& VCLXWindow::GetTopWindowListeners()
{
return mpImpl->getTopWindowListeners();
}

View File

@@ -451,10 +451,10 @@ void UnoTreeControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolk
void SAL_CALL TreeEditListenerMultiplexer::nodeEditing( const Reference< XTreeNode >& Node )
{
::comphelper::OInterfaceIteratorHelper2 aIt( *this );
::comphelper::OInterfaceIteratorHelper3 aIt(*this);
while( aIt.hasMoreElements() )
{
Reference< XTreeEditListener > xListener(static_cast< XTreeEditListener* >( aIt.next() ) );
Reference<XTreeEditListener> xListener(aIt.next());
try
{
xListener->nodeEditing( Node );
@@ -474,10 +474,10 @@ void SAL_CALL TreeEditListenerMultiplexer::nodeEditing( const Reference< XTreeNo
void SAL_CALL TreeEditListenerMultiplexer::nodeEdited( const Reference< XTreeNode >& Node, const OUString& NewText )
{
::comphelper::OInterfaceIteratorHelper2 aIt( *this );
::comphelper::OInterfaceIteratorHelper3 aIt(*this);
while( aIt.hasMoreElements() )
{
Reference< XTreeEditListener > xListener( static_cast< XTreeEditListener* >( aIt.next() ) );
Reference<XTreeEditListener> xListener(aIt.next());
try
{
xListener->nodeEdited( Node, NewText );

View File

@@ -20,25 +20,6 @@
#include <toolkit/helper/listenermultiplexer.hxx>
#include <toolkit/helper/macros.hxx>
#include <com/sun/star/lang/DisposedException.hpp>
#include <cppuhelper/queryinterface.hxx>
// class ListenerMultiplexerBase
ListenerMultiplexerBase::ListenerMultiplexerBase( ::cppu::OWeakObject& rSource )
: ::comphelper::OInterfaceContainerHelper2( GetMutex() ), mrContext( rSource )
{
}
ListenerMultiplexerBase::~ListenerMultiplexerBase()
{
}
// css::uno::XInterface
css::uno::Any ListenerMultiplexerBase::queryInterface( const css::uno::Type & rType )
{
return ::cppu::queryInterface( rType, static_cast< css::uno::XInterface* >(this) );
}
// class EventListenerMultiplexer
@@ -51,6 +32,7 @@ void SAL_CALL EventListenerMultiplexer::acquire() noexcept
{
return ListenerMultiplexerBase::acquire();
}
void SAL_CALL EventListenerMultiplexer::release() noexcept
{
return ListenerMultiplexerBase::release();
@@ -165,11 +147,10 @@ IMPL_TABLISTENERMULTIPLEXER_LISTENERMETHOD_BODY_1PARAM( TabListenerMultiplexer,
void TabListenerMultiplexer::changed( sal_Int32 evt, const css::uno::Sequence< css::beans::NamedValue >& evt2 )
{
sal_Int32 aMulti( evt );
::comphelper::OInterfaceIteratorHelper2 aIt( *this );
::comphelper::OInterfaceIteratorHelper3 aIt(*this);
while( aIt.hasMoreElements() )
{
css::uno::Reference< css::awt::XTabListener > xListener(
static_cast< css::awt::XTabListener* >( aIt.next() ) );
css::uno::Reference<css::awt::XTabListener> xListener(aIt.next());
try
{
xListener->changed( aMulti, evt2 );