bump product version to 6.4.0.3
[LibreOffice.git] / UnoControls / inc / multiplexer.hxx
blobdda3013a3600e80fbbf4490a01c05490f488e084
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_UNOCONTROLS_INC_MULTIPLEXER_HXX
21 #define INCLUDED_UNOCONTROLS_INC_MULTIPLEXER_HXX
23 #include <com/sun/star/awt/XKeyListener.hpp>
24 #include <com/sun/star/awt/XPaintListener.hpp>
25 #include <com/sun/star/awt/XMouseMotionListener.hpp>
26 #include <com/sun/star/awt/XWindowListener.hpp>
27 #include <com/sun/star/awt/XTopWindowListener.hpp>
28 #include <com/sun/star/awt/XMouseListener.hpp>
29 #include <com/sun/star/awt/XFocusListener.hpp>
30 #include <cppuhelper/weak.hxx>
31 #include <cppuhelper/weakref.hxx>
32 #include <cppuhelper/interfacecontainer.hxx>
34 namespace com::sun::star::awt { class XWindow; }
35 namespace com::sun::star::awt { struct KeyEvent; }
36 namespace com::sun::star::awt { struct MouseEvent; }
37 namespace com::sun::star::awt { struct PaintEvent; }
38 namespace com::sun::star::awt { struct WindowEvent; }
40 namespace unocontrols {
42 class OMRCListenerMultiplexerHelper : public css::awt::XFocusListener
43 , public css::awt::XWindowListener
44 , public css::awt::XKeyListener
45 , public css::awt::XMouseListener
46 , public css::awt::XMouseMotionListener
47 , public css::awt::XPaintListener
48 , public css::awt::XTopWindowListener
49 , public ::cppu::OWeakObject
51 public:
53 /**
54 @short constructor
55 @descr Create a Multiplexer of XWindowEvents.
56 @param rControl The control. All listeners think that this is the original broadcaster.
57 @param rPeer The peer from which the original events are dispatched. Null is allowed.
60 OMRCListenerMultiplexerHelper( const css::uno::Reference< css::awt::XWindow >& xControl ,
61 const css::uno::Reference< css::awt::XWindow >& xPeer );
63 /**
64 @short copy-constructor
65 @descr
66 @param rCopyInstance C++-Reference to instance to make copy from.
69 OMRCListenerMultiplexerHelper( const OMRCListenerMultiplexerHelper& aCopyInstance );
71 virtual ~OMRCListenerMultiplexerHelper() override;
73 // XInterface
75 /**
76 @short give answer, if interface is supported
77 @descr The interfaces are searched by type.
79 @seealso XInterface
81 @param "rType" is the type of searched interface.
83 @return Any information about found interface
85 @onerror A RuntimeException is thrown.
88 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
90 /**
91 @short increment refcount
92 @seealso XInterface
93 @seealso release()
94 @onerror A RuntimeException is thrown.
97 virtual void SAL_CALL acquire() throw() override;
99 /**
100 @short decrement refcount
101 @seealso XInterface
102 @seealso acquire()
103 @onerror A RuntimeException is thrown.
106 virtual void SAL_CALL release() throw() override;
108 OMRCListenerMultiplexerHelper& operator= ( const OMRCListenerMultiplexerHelper& aCopyInstance );
110 // container methods
113 @short Remove all listeners from the previous set peer and add the needed listeners to rPeer.
114 @param rPeer The peer from which the original events are dispatched. Null is allowed.
117 void setPeer( const css::uno::Reference< css::awt::XWindow >& xPeer );
120 @short Remove all listeners and send a disposing message.
123 void disposeAndClear();
126 @short Add the specified listener to the source.
129 void advise( const css::uno::Type& aType ,
130 const css::uno::Reference< css::uno::XInterface >& xListener );
133 @short Remove the specified listener from the source.
136 void unadvise( const css::uno::Type& aType ,
137 const css::uno::Reference< css::uno::XInterface >& xListener );
139 // XEventListener
141 virtual void SAL_CALL disposing(const css::lang::EventObject& aSource) override;
143 // XFocusListener
145 virtual void SAL_CALL focusGained(const css::awt::FocusEvent& aEvent ) override;
147 virtual void SAL_CALL focusLost(const css::awt::FocusEvent& aEvent ) override;
149 // XWindowListener
151 virtual void SAL_CALL windowResized(const css::awt::WindowEvent& aEvent ) override;
153 virtual void SAL_CALL windowMoved(const css::awt::WindowEvent& aEvent ) override;
155 virtual void SAL_CALL windowShown(const css::lang::EventObject& aEvent ) override;
157 virtual void SAL_CALL windowHidden(const css::lang::EventObject& aEvent ) override;
159 // XKeyListener
161 virtual void SAL_CALL keyPressed( const css::awt::KeyEvent& aEvent ) override;
163 virtual void SAL_CALL keyReleased( const css::awt::KeyEvent& aEvent ) override;
165 // XMouseListener
167 virtual void SAL_CALL mousePressed(const css::awt::MouseEvent& aEvent ) override;
169 virtual void SAL_CALL mouseReleased(const css::awt::MouseEvent& aEvent ) override;
171 virtual void SAL_CALL mouseEntered(const css::awt::MouseEvent& aEvent ) override;
173 virtual void SAL_CALL mouseExited(const css::awt::MouseEvent& aEvent ) override;
175 // XMouseMotionListener
177 virtual void SAL_CALL mouseDragged(const css::awt::MouseEvent& aEvent ) override;
179 virtual void SAL_CALL mouseMoved(const css::awt::MouseEvent& aEvent ) override;
181 // XPaintListener
183 virtual void SAL_CALL windowPaint(const css::awt::PaintEvent& aEvent ) override;
185 // XTopWindowListener
187 virtual void SAL_CALL windowOpened( const css::lang::EventObject& aEvent ) override;
189 virtual void SAL_CALL windowClosing( const css::lang::EventObject& aEvent ) override;
191 virtual void SAL_CALL windowClosed( const css::lang::EventObject& aEvent ) override;
193 virtual void SAL_CALL windowMinimized( const css::lang::EventObject& aEvent ) override;
195 virtual void SAL_CALL windowNormalized( const css::lang::EventObject& aEvent ) override;
197 virtual void SAL_CALL windowActivated( const css::lang::EventObject& aEvent ) override;
199 virtual void SAL_CALL windowDeactivated( const css::lang::EventObject& aEvent ) override;
201 // protected methods
203 protected:
206 @short Remove the listener from the peer.
207 @param xPeer The peer from which the listener is removed.
208 @param rType The listener type, which specify the type of the listener.
211 void impl_adviseToPeer( const css::uno::Reference< css::awt::XWindow >& xPeer ,
212 const css::uno::Type& aType );
215 @short Add the listener to the peer.
216 @param xPeer The peer to which the listener is added.
217 @param rType The listener type, which specify the type of the listener.
220 void impl_unadviseFromPeer( const css::uno::Reference< css::awt::XWindow >& xPeer ,
221 const css::uno::Type& aType );
223 // private variables
225 private:
226 ::osl::Mutex m_aMutex;
227 css::uno::Reference< css::awt::XWindow > m_xPeer; /// The source of the events. Normally this is the peer object.
228 css::uno::WeakReference< css::awt::XWindow > m_xControl;
229 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerHolder;
235 #endif // INCLUDED_UNOCONTROLS_INC_MULTIPLEXER_HXX
237 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */