fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / UnoControls / inc / multiplexer.hxx
blob0c706479c0525072e2213a9a5894b38835052681
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/KeyEvent.hpp>
26 #include <com/sun/star/awt/KeyModifier.hpp>
27 #include <com/sun/star/awt/XMouseMotionListener.hpp>
28 #include <com/sun/star/awt/FocusEvent.hpp>
29 #include <com/sun/star/awt/XWindowListener.hpp>
30 #include <com/sun/star/awt/XActivateListener.hpp>
31 #include <com/sun/star/awt/MouseEvent.hpp>
32 #include <com/sun/star/awt/XTopWindowListener.hpp>
33 #include <com/sun/star/awt/PaintEvent.hpp>
34 #include <com/sun/star/awt/InputEvent.hpp>
35 #include <com/sun/star/awt/KeyGroup.hpp>
36 #include <com/sun/star/awt/Key.hpp>
37 #include <com/sun/star/awt/WindowEvent.hpp>
38 #include <com/sun/star/awt/XMouseListener.hpp>
39 #include <com/sun/star/awt/KeyFunction.hpp>
40 #include <com/sun/star/awt/FocusChangeReason.hpp>
41 #include <com/sun/star/awt/MouseButton.hpp>
42 #include <com/sun/star/awt/XFocusListener.hpp>
43 #include <com/sun/star/awt/XTopWindow.hpp>
44 #include <com/sun/star/awt/XWindow.hpp>
45 #include <com/sun/star/awt/PosSize.hpp>
46 #include <cppuhelper/weak.hxx>
47 #include <cppuhelper/weakref.hxx>
48 #include <cppuhelper/interfacecontainer.hxx>
50 // "namespaces"
52 namespace unocontrols{
54 // class
56 class OMRCListenerMultiplexerHelper : public ::com::sun::star::awt::XFocusListener
57 , public ::com::sun::star::awt::XWindowListener
58 , public ::com::sun::star::awt::XKeyListener
59 , public ::com::sun::star::awt::XMouseListener
60 , public ::com::sun::star::awt::XMouseMotionListener
61 , public ::com::sun::star::awt::XPaintListener
62 , public ::com::sun::star::awt::XTopWindowListener
63 , public ::cppu::OWeakObject
66 // public methods
68 public:
70 // construct/destruct
72 /**_______________________________________________________________________________________________________
73 @short constructor
74 @descr Create a Multiplexer of XWindowEvents.
75 @param rControl The control. All listeners think that this is the original broadcaster.
76 @param rPeer The peer from which the original events are dispatched. Null is allowed.
79 OMRCListenerMultiplexerHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xControl ,
80 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer );
82 /**_______________________________________________________________________________________________________
83 @short copy-constructor
84 @descr
85 @param rCopyInstance C++-Reference to instance to make copy from.
88 OMRCListenerMultiplexerHelper( const OMRCListenerMultiplexerHelper& aCopyInstance );
90 /**_______________________________________________________________________________________________________
91 @short destructor
94 virtual ~OMRCListenerMultiplexerHelper();
96 // XInterface
98 /**_______________________________________________________________________________________________________
99 @short give answer, if interface is supported
100 @descr The interfaces are searched by type.
102 @seealso XInterface
104 @param "rType" is the type of searched interface.
106 @return Any information about found interface
108 @onerror A RuntimeException is thrown.
111 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
112 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
114 /**_______________________________________________________________________________________________________
115 @short increment refcount
116 @seealso XInterface
117 @seealso release()
118 @onerror A RuntimeException is thrown.
121 virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
123 /**_______________________________________________________________________________________________________
124 @short decrement refcount
125 @seealso XInterface
126 @seealso acquire()
127 @onerror A RuntimeException is thrown.
130 virtual void SAL_CALL release() throw() SAL_OVERRIDE;
132 // operator
134 /**_______________________________________________________________________________________________________
137 operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() const { return ((OWeakObject*)this);}
139 /**_______________________________________________________________________________________________________
142 OMRCListenerMultiplexerHelper& operator= ( const OMRCListenerMultiplexerHelper& aCopyInstance );
144 // container methods
146 /**_______________________________________________________________________________________________________
147 @short Remove all listeners from the previous set peer and add the needed listeners to rPeer.
148 @param rPeer The peer from which the original events are dispatched. Null is allowed.
151 void setPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer );
153 /**_______________________________________________________________________________________________________
154 @short Remove all listeners and send a disposing message.
157 void disposeAndClear();
159 /**_______________________________________________________________________________________________________
160 @short Add the specified listener to the source.
163 void advise( const ::com::sun::star::uno::Type& aType ,
164 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xListener );
166 /**_______________________________________________________________________________________________________
167 @short Remove the specified listener from the source.
170 void unadvise( const ::com::sun::star::uno::Type& aType ,
171 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xListener );
173 // XEventListener
175 /**_______________________________________________________________________________________________________
178 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& aSource)
179 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
181 // XFocusListener
183 /**_______________________________________________________________________________________________________
186 virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& aEvent )
187 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
189 /**_______________________________________________________________________________________________________
192 virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& aEvent )
193 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
195 // XWindowListener
197 /**_______________________________________________________________________________________________________
200 virtual void SAL_CALL windowResized(const ::com::sun::star::awt::WindowEvent& aEvent )
201 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
203 /**_______________________________________________________________________________________________________
206 virtual void SAL_CALL windowMoved(const ::com::sun::star::awt::WindowEvent& aEvent )
207 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
209 /**_______________________________________________________________________________________________________
212 virtual void SAL_CALL windowShown(const ::com::sun::star::lang::EventObject& aEvent )
213 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
215 /**_______________________________________________________________________________________________________
218 virtual void SAL_CALL windowHidden(const ::com::sun::star::lang::EventObject& aEvent )
219 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
221 // XKeyListener
223 /**_______________________________________________________________________________________________________
226 virtual void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& aEvent )
227 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
229 /**_______________________________________________________________________________________________________
232 virtual void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& aEvent )
233 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
235 // XMouseListener
237 /**_______________________________________________________________________________________________________
240 virtual void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& aEvent )
241 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
243 /**_______________________________________________________________________________________________________
246 virtual void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& aEvent )
247 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
249 /**_______________________________________________________________________________________________________
252 virtual void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& aEvent )
253 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
255 /**_______________________________________________________________________________________________________
258 virtual void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& aEvent )
259 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
261 // XMouseMotionListener
263 /**_______________________________________________________________________________________________________
266 virtual void SAL_CALL mouseDragged(const ::com::sun::star::awt::MouseEvent& aEvent )
267 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
269 /**_______________________________________________________________________________________________________
272 virtual void SAL_CALL mouseMoved(const ::com::sun::star::awt::MouseEvent& aEvent )
273 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
275 // XPaintListener
277 /**_______________________________________________________________________________________________________
280 virtual void SAL_CALL windowPaint(const ::com::sun::star::awt::PaintEvent& aEvent )
281 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
283 // XTopWindowListener
285 /**_______________________________________________________________________________________________________
288 virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& aEvent )
289 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
291 /**_______________________________________________________________________________________________________
294 virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& aEvent )
295 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
297 /**_______________________________________________________________________________________________________
300 virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& aEvent )
301 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
303 /**_______________________________________________________________________________________________________
306 virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& aEvent )
307 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
309 /**_______________________________________________________________________________________________________
312 virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& aEvent )
313 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
315 /**_______________________________________________________________________________________________________
318 virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& aEvent )
319 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
321 /**_______________________________________________________________________________________________________
324 virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& aEvent )
325 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
327 // protected methods
329 protected:
331 /**_______________________________________________________________________________________________________
332 @short Remove the listener from the peer.
333 @param xPeer The peer from which the listener is removed.
334 @param rType The listener type, which specify the type of the listener.
337 void impl_adviseToPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer ,
338 const ::com::sun::star::uno::Type& aType );
340 /**_______________________________________________________________________________________________________
341 @short Add the listener to the peer.
342 @param xPeer The peer to which the listener is added.
343 @param rType The listener type, which specify the type of the listener.
346 void impl_unadviseFromPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer ,
347 const ::com::sun::star::uno::Type& aType );
349 // private variables
351 private:
353 ::osl::Mutex m_aMutex;
354 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xPeer; /// The source of the events. Normally this is the peer object.
355 ::com::sun::star::uno::WeakReference< ::com::sun::star::awt::XWindow > m_xControl;
356 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerHolder;
358 }; // class OMRCListenerMultiplexerHelper
360 } // namespace unocontrols
362 #endif // INCLUDED_UNOCONTROLS_INC_MULTIPLEXER_HXX
364 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */