Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : *
6 : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : *
8 : * OpenOffice.org - a multi-platform office productivity suite
9 : *
10 : * This file is part of OpenOffice.org.
11 : *
12 : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : * it under the terms of the GNU Lesser General Public License version 3
14 : * only, as published by the Free Software Foundation.
15 : *
16 : * OpenOffice.org is distributed in the hope that it will be useful,
17 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : * GNU Lesser General Public License version 3 for more details
20 : * (a copy is included in the LICENSE file that accompanied this code).
21 : *
22 : * You should have received a copy of the GNU Lesser General Public License
23 : * version 3 along with OpenOffice.org. If not, see
24 : * <http://www.openoffice.org/license.html>
25 : * for a copy of the LGPLv3 License.
26 : *
27 : ************************************************************************/
28 : #ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MULTIPLX_HXX
29 : #define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MULTIPLX_HXX
30 :
31 : #include <com/sun/star/awt/XControl.hpp>
32 : #include <com/sun/star/awt/XKeyListener.hpp>
33 : #include <com/sun/star/awt/XPaintListener.hpp>
34 : #include <com/sun/star/awt/KeyEvent.hpp>
35 : #include <com/sun/star/awt/KeyModifier.hpp>
36 : #include <com/sun/star/awt/XMouseMotionListener.hpp>
37 : #include <com/sun/star/awt/FocusEvent.hpp>
38 : #include <com/sun/star/awt/XWindowListener.hpp>
39 : #include <com/sun/star/awt/XActivateListener.hpp>
40 : #include <com/sun/star/awt/MouseEvent.hpp>
41 : #include <com/sun/star/awt/XTopWindowListener.hpp>
42 : #include <com/sun/star/awt/PaintEvent.hpp>
43 : #include <com/sun/star/awt/InputEvent.hpp>
44 : #include <com/sun/star/awt/KeyGroup.hpp>
45 : #include <com/sun/star/awt/Key.hpp>
46 : #include <com/sun/star/awt/WindowEvent.hpp>
47 : #include <com/sun/star/awt/XMouseListener.hpp>
48 : #include <com/sun/star/awt/KeyFunction.hpp>
49 : #include <com/sun/star/awt/FocusChangeReason.hpp>
50 : #include <com/sun/star/awt/MouseButton.hpp>
51 : #include <com/sun/star/awt/XFocusListener.hpp>
52 : #include <com/sun/star/awt/XTopWindow.hpp>
53 : #include <com/sun/star/awt/XWindow.hpp>
54 : #include <com/sun/star/awt/PosSize.hpp>
55 :
56 : #include <cppuhelper/implbase7.hxx>
57 : #include <cppuhelper/interfacecontainer.hxx>
58 :
59 : using namespace com::sun::star::uno;
60 :
61 0 : struct MRCListenerMultiplexerHelper_Mutex
62 : {
63 : ::osl::Mutex aMutex;
64 : };
65 :
66 0 : class MRCListenerMultiplexerHelper :
67 : public MRCListenerMultiplexerHelper_Mutex,
68 :
69 : public ::cppu::WeakAggImplHelper7<
70 : ::com::sun::star::awt::XFocusListener,
71 : ::com::sun::star::awt::XWindowListener,
72 : ::com::sun::star::awt::XKeyListener,
73 : ::com::sun::star::awt::XMouseListener,
74 : ::com::sun::star::awt::XMouseMotionListener,
75 : ::com::sun::star::awt::XPaintListener,
76 : ::com::sun::star::awt::XTopWindowListener >
77 : {
78 : public:
79 : /**
80 : * Create a Multiplexer of XWindowEvents.
81 : *
82 : * @param rControl The control. All listeners think that this is the original
83 : * broadcaster.
84 : * @param rPeer The peer from which the original events are dispatched. Null is
85 : * allowed.
86 : */
87 : MRCListenerMultiplexerHelper( const Reference< ::com::sun::star::awt::XWindow > & rControl, const Reference< ::com::sun::star::awt::XWindow > & rPeer );
88 :
89 : /**
90 : * Remove all listeners from the previous set peer and add the needed listeners to rPeer.
91 : * @param rPeer The peer from which the original events are dispatched. Null is
92 : * allowed.
93 : */
94 : void setPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer );
95 :
96 : /**
97 : * Remove all listeners and send a disposing message.
98 : */
99 : void disposeAndClear();
100 :
101 : /**
102 : * Add the specified listener to the source.
103 : */
104 : void advise( const Type& type, const Reference< XInterface > & listener);
105 : /**
106 : * Remove the specified listener from the source.
107 : */
108 : void unadvise(const Type& type, const Reference< XInterface > & listener);
109 :
110 : // ::com::sun::star::lang::XEventListener
111 : void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(std::exception) SAL_OVERRIDE;
112 : // ::com::sun::star::awt::XFocusListener
113 : void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw(std::exception) SAL_OVERRIDE;
114 : void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw(std::exception) SAL_OVERRIDE;
115 : // ::com::sun::star::awt::XWindowListener
116 : void SAL_CALL windowResized(const ::com::sun::star::awt::WindowEvent& e) throw(std::exception) SAL_OVERRIDE;
117 : void SAL_CALL windowMoved(const ::com::sun::star::awt::WindowEvent& e) throw(std::exception) SAL_OVERRIDE;
118 : void SAL_CALL windowShown(const ::com::sun::star::lang::EventObject& e) throw(std::exception) SAL_OVERRIDE;
119 : void SAL_CALL windowHidden(const ::com::sun::star::lang::EventObject& e) throw(std::exception) SAL_OVERRIDE;
120 : // ::com::sun::star::awt::XKeyListener
121 : void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ) throw(std::exception) SAL_OVERRIDE;
122 : void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ) throw(std::exception) SAL_OVERRIDE;
123 : // ::com::sun::star::awt::XMouseListener
124 : void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& e) throw(std::exception) SAL_OVERRIDE;
125 : void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& e) throw(std::exception) SAL_OVERRIDE;
126 : void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw(std::exception) SAL_OVERRIDE;
127 : void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw(std::exception) SAL_OVERRIDE;
128 : // ::com::sun::star::awt::XMouseMotionListener
129 : void SAL_CALL mouseDragged(const ::com::sun::star::awt::MouseEvent& e) throw(std::exception) SAL_OVERRIDE;
130 : void SAL_CALL mouseMoved(const ::com::sun::star::awt::MouseEvent& e) throw(std::exception) SAL_OVERRIDE;
131 : // ::com::sun::star::awt::XPaintListener
132 : void SAL_CALL windowPaint(const ::com::sun::star::awt::PaintEvent& e) throw(std::exception) SAL_OVERRIDE;
133 : // ::com::sun::star::awt::XTopWindowListener
134 : void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ) throw(std::exception) SAL_OVERRIDE;
135 : void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& e ) throw(std::exception) SAL_OVERRIDE;
136 : void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& e ) throw(std::exception) SAL_OVERRIDE;
137 : void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw(std::exception) SAL_OVERRIDE;
138 : void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw(std::exception) SAL_OVERRIDE;
139 : void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ) throw(std::exception) SAL_OVERRIDE;
140 : void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw(std::exception) SAL_OVERRIDE;
141 : protected:
142 : /**
143 : * Remove the listener with the uik rUik from the peer rPeer.
144 : * @param rPeer the peer from which the listener is removed.
145 : * @param rUik the listener uik, which specify the type of the listener.
146 : */
147 : void adviseToPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type );
148 : /**
149 : * Add the listener with the uik rUik to the peer rPeer.
150 : * @param rPeer the peer to which the listener is added.
151 : * @param rUik the listener uik, which specify the type of the listener.
152 : */
153 : void unadviseFromPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type );
154 : private:
155 : /** The source of the events. Normally this is the peer object.*/
156 : Reference< ::com::sun::star::awt::XWindow > xPeer;
157 : WeakReference< ::com::sun::star::awt::XControl > xControl;
158 : ::cppu::OMultiTypeInterfaceContainerHelper aListenerHolder;
159 :
160 :
161 : MRCListenerMultiplexerHelper( const MRCListenerMultiplexerHelper & ) SAL_DELETED_FUNCTION;
162 : MRCListenerMultiplexerHelper & operator = ( const MRCListenerMultiplexerHelper & ) SAL_DELETED_FUNCTION;
163 : };
164 :
165 : #endif // INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MULTIPLX_HXX
166 :
167 :
168 :
169 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|