22#include <osl/diagnose.h>
25#include <com/sun/star/awt/XWindow.hpp>
26#include <com/sun/star/awt/XTopWindow.hpp>
28using namespace ::
cppu;
38#define MULTIPLEX( INTERFACE, METHOD, EVENTTYP, EVENT ) \
41 comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerHolder.getContainer( cppu::UnoType<INTERFACE>::get() ); \
45 comphelper::OInterfaceIteratorHelper2 aIterator( *pContainer ); \
46 EVENTTYP aLocalEvent = EVENT; \
49 aLocalEvent.Source = m_xControl; \
51 if( !aLocalEvent.Source ) \
53 if( !aIterator.hasMoreElements() ) \
55 INTERFACE * pListener = static_cast<INTERFACE *>(aIterator.next()); \
58 pListener->METHOD( aLocalEvent ); \
60 catch(const RuntimeException& ) \
68 const Reference< XWindow >& xPeer )
80 , XMouseMotionListener()
82 , XTopWindowListener()
83 , OWeakObject(aCopyInstance)
101 Any aReturn ( ::cppu::queryInterface( rType ,
102 static_cast< XWindowListener*
> (
this ) ,
103 static_cast< XKeyListener*
> (
this ) ,
104 static_cast< XFocusListener*
> (
this ) ,
105 static_cast< XMouseListener*
> (
this ) ,
106 static_cast< XMouseMotionListener*
> (
this ) ,
107 static_cast< XPaintListener*
> (
this ) ,
108 static_cast< XTopWindowListener*
> (
this ) ,
109 static_cast< XTopWindowListener*
> (
this )
114 if ( aReturn.hasValue() )
122 return OWeakObject::queryInterface( rType );
134 OWeakObject::acquire();
145 OWeakObject::release();
161 for(
const auto& rContainedType : aContainedTypes )
170 for(
const auto& rContainedType : aContainedTypes )
187 const Reference< XInterface >& xListener )
203 const Reference< XInterface >& xListener )
386 xPeer->addWindowListener(
this );
388 xPeer->addKeyListener(
this );
390 xPeer->addFocusListener(
this );
392 xPeer->addMouseListener(
this );
394 xPeer->addMouseMotionListener(
this );
396 xPeer->addPaintListener(
this );
399 Reference< XTopWindow > xTop( xPeer, UNO_QUERY );
401 xTop->addTopWindowListener(
this );
405 OSL_FAIL(
"unknown listener" );
416 xPeer->removeWindowListener(
this );
418 xPeer->removeKeyListener(
this );
420 xPeer->removeFocusListener(
this );
422 xPeer->removeMouseListener(
this );
424 xPeer->removeMouseMotionListener(
this );
426 xPeer->removePaintListener(
this );
429 Reference< XTopWindow > xTop( xPeer, UNO_QUERY );
431 xTop->removeTopWindowListener(
this );
435 OSL_FAIL(
"unknown listener" );
sal_Int32 removeInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
sal_Int32 addInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &r)
void disposeAndClear(const css::lang::EventObject &rEvt)
std::vector< css::uno::Type > getContainedTypes() const
void unadvise(const css::uno::Type &aType, const css::uno::Reference< css::uno::XInterface > &xListener)
Remove the specified listener from the source.
void impl_adviseToPeer(const css::uno::Reference< css::awt::XWindow > &xPeer, const css::uno::Type &aType)
Remove the listener from the peer.
css::uno::WeakReference< css::awt::XWindow > m_xControl
The source of the events. Normally this is the peer object.
virtual void SAL_CALL windowMoved(const css::awt::WindowEvent &aEvent) override
virtual void SAL_CALL windowDeactivated(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL windowActivated(const css::lang::EventObject &aEvent) override
css::uno::Reference< css::awt::XWindow > m_xPeer
virtual ~OMRCListenerMultiplexerHelper() override
virtual void SAL_CALL mouseMoved(const css::awt::MouseEvent &aEvent) override
virtual void SAL_CALL windowHidden(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL windowPaint(const css::awt::PaintEvent &aEvent) override
void disposeAndClear()
Remove all listeners and send a disposing message.
comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerHolder
virtual void SAL_CALL mouseDragged(const css::awt::MouseEvent &aEvent) override
virtual void SAL_CALL windowNormalized(const css::lang::EventObject &aEvent) override
void advise(const css::uno::Type &aType, const css::uno::Reference< css::uno::XInterface > &xListener)
Add the specified listener to the source.
virtual void SAL_CALL windowClosing(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL mouseExited(const css::awt::MouseEvent &aEvent) override
virtual void SAL_CALL focusGained(const css::awt::FocusEvent &aEvent) override
virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent &aEvent) override
virtual void SAL_CALL focusLost(const css::awt::FocusEvent &aEvent) override
void impl_unadviseFromPeer(const css::uno::Reference< css::awt::XWindow > &xPeer, const css::uno::Type &aType)
Add the listener to the peer.
OMRCListenerMultiplexerHelper(const css::uno::Reference< css::awt::XWindow > &xControl, const css::uno::Reference< css::awt::XWindow > &xPeer)
constructor @descr Create a Multiplexer of XWindowEvents.
virtual void SAL_CALL keyReleased(const css::awt::KeyEvent &aEvent) override
virtual void SAL_CALL windowResized(const css::awt::WindowEvent &aEvent) override
virtual void SAL_CALL acquire() noexcept override
increment refcount @seealso XInterface @seealso release() @onerror A RuntimeException is thrown.
virtual void SAL_CALL keyPressed(const css::awt::KeyEvent &aEvent) override
virtual void SAL_CALL windowMinimized(const css::lang::EventObject &aEvent) override
void setPeer(const css::uno::Reference< css::awt::XWindow > &xPeer)
Remove all listeners from the previous set peer and add the needed listeners to rPeer.
virtual void SAL_CALL disposing(const css::lang::EventObject &aSource) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
give answer, if interface is supported @descr The interfaces are searched by type.
virtual void SAL_CALL windowClosed(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL windowShown(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent &aEvent) override
virtual void SAL_CALL windowOpened(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL release() noexcept override
decrement refcount @seealso XInterface @seealso acquire() @onerror A RuntimeException is thrown.
virtual void SAL_CALL mousePressed(const css::awt::MouseEvent &aEvent) override
#define MULTIPLEX(INTERFACE, METHOD, EVENTTYP, EVENT)