update dev300-m58
[ooovba.git] / UnoControls / inc / multiplexer.hxx
bloba9d2c5760c80c755ed422556b82adf9ac50575e4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: multiplexer.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _UNOCONTROLS_MULTIPLEXER_HXX
32 #define _UNOCONTROLS_MULTIPLEXER_HXX
34 //____________________________________________________________________________________________________________
35 // includes of other projects
36 //____________________________________________________________________________________________________________
38 #include <com/sun/star/awt/XKeyListener.hpp>
39 #include <com/sun/star/awt/XPaintListener.hpp>
40 #include <com/sun/star/awt/KeyEvent.hpp>
41 #include <com/sun/star/awt/KeyModifier.hpp>
42 #include <com/sun/star/awt/XMouseMotionListener.hpp>
43 #include <com/sun/star/awt/FocusEvent.hpp>
44 #include <com/sun/star/awt/XWindowListener.hpp>
45 #include <com/sun/star/awt/XActivateListener.hpp>
46 #include <com/sun/star/awt/MouseEvent.hpp>
47 #include <com/sun/star/awt/XTopWindowListener.hpp>
48 #include <com/sun/star/awt/PaintEvent.hpp>
49 #include <com/sun/star/awt/InputEvent.hpp>
50 #include <com/sun/star/awt/KeyGroup.hpp>
51 #include <com/sun/star/awt/Key.hpp>
52 #include <com/sun/star/awt/WindowEvent.hpp>
53 #include <com/sun/star/awt/XMouseListener.hpp>
54 #include <com/sun/star/awt/KeyFunction.hpp>
55 #include <com/sun/star/awt/FocusChangeReason.hpp>
56 #include <com/sun/star/awt/MouseButton.hpp>
57 #include <com/sun/star/awt/XFocusListener.hpp>
58 #include <com/sun/star/awt/XTopWindow.hpp>
59 #include <com/sun/star/awt/XWindow.hpp>
60 #include <com/sun/star/awt/PosSize.hpp>
61 #include <cppuhelper/weak.hxx>
62 #include <cppuhelper/interfacecontainer.hxx>
63 //____________________________________________________________________________________________________________
64 // includes of my own project
65 //____________________________________________________________________________________________________________
67 //____________________________________________________________________________________________________________
68 // "namespaces"
69 //____________________________________________________________________________________________________________
71 namespace unocontrols{
73 #define UNO3_OWEAKOBJECT ::cppu::OWeakObject
74 #define UNO3_XWINDOW ::com::sun::star::awt::XWindow
75 #define UNO3_REFERENCE ::com::sun::star::uno::Reference
76 #define UNO3_WEAKREFERENCE ::com::sun::star::uno::WeakReference
77 #define UNO3_MUTEX ::osl::Mutex
78 #define UNO3_XWINDOWLISTENER ::com::sun::star::awt::XWindowListener
79 #define UNO3_XKEYLISTENER ::com::sun::star::awt::XKeyListener
80 #define UNO3_XMOUSELISTENER ::com::sun::star::awt::XMouseListener
81 #define UNO3_XMOUSEMOTIONLISTENER ::com::sun::star::awt::XMouseMotionListener
82 #define UNO3_XPAINTLISTENER ::com::sun::star::awt::XPaintListener
83 #define UNO3_XTOPWINDOWLISTENER ::com::sun::star::awt::XTopWindowListener
84 #define UNO3_XFOCUSLISTENER ::com::sun::star::awt::XFocusListener
85 #define UNO3_ANY ::com::sun::star::uno::Any
86 #define UNO3_TYPE ::com::sun::star::uno::Type
87 #define UNO3_RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException
88 #define UNO3_XINTERFACE ::com::sun::star::uno::XInterface
89 #define UNO3_EVENTOBJECT ::com::sun::star::lang::EventObject
90 #define UNO3_FOCUSEVENT ::com::sun::star::awt::FocusEvent
91 #define UNO3_WINDOWEVENT ::com::sun::star::awt::WindowEvent
92 #define UNO3_KEYEVENT ::com::sun::star::awt::KeyEvent
93 #define UNO3_MOUSEEVENT ::com::sun::star::awt::MouseEvent
94 #define UNO3_PAINTEVENT ::com::sun::star::awt::PaintEvent
95 #define UNO3_OMULTITYPEINTERFACECONTAINERHELPER ::cppu::OMultiTypeInterfaceContainerHelper
97 //____________________________________________________________________________________________________________
98 // class
99 //____________________________________________________________________________________________________________
101 class OMRCListenerMultiplexerHelper : public UNO3_XFOCUSLISTENER
102 , public UNO3_XWINDOWLISTENER
103 , public UNO3_XKEYLISTENER
104 , public UNO3_XMOUSELISTENER
105 , public UNO3_XMOUSEMOTIONLISTENER
106 , public UNO3_XPAINTLISTENER
107 , public UNO3_XTOPWINDOWLISTENER
108 , public UNO3_OWEAKOBJECT
111 //____________________________________________________________________________________________________________
112 // public methods
113 //____________________________________________________________________________________________________________
115 public:
117 //________________________________________________________________________________________________________
118 // construct/destruct
119 //________________________________________________________________________________________________________
121 /**_______________________________________________________________________________________________________
122 @short constructor
123 @descr Create a Multiplexer of XWindowEvents.
125 @seealso -
127 @param rControl The control. All listeners think that this is the original broadcaster.
128 @param rPeer The peer from which the original events are dispatched. Null is allowed.
130 @return -
132 @onerror -
135 OMRCListenerMultiplexerHelper( const UNO3_REFERENCE< UNO3_XWINDOW >& xControl ,
136 const UNO3_REFERENCE< UNO3_XWINDOW >& xPeer );
138 /**_______________________________________________________________________________________________________
139 @short copy-constructor
140 @descr
142 @seealso -
144 @param rCopyInstance C++-Reference to instance to make copy from.
146 @return -
148 @onerror -
151 OMRCListenerMultiplexerHelper( const OMRCListenerMultiplexerHelper& aCopyInstance );
153 /**_______________________________________________________________________________________________________
154 @short destructor
155 @descr -
157 @seealso -
159 @param -
161 @return -
163 @onerror -
166 ~OMRCListenerMultiplexerHelper();
168 //________________________________________________________________________________________________________
169 // XInterface
170 //________________________________________________________________________________________________________
172 /**_______________________________________________________________________________________________________
173 @short give answer, if interface is supported
174 @descr The interfaces are searched by type.
176 @seealso XInterface
178 @param "rType" is the type of searched interface.
180 @return Any information about found interface
182 @onerror A RuntimeException is thrown.
185 virtual UNO3_ANY SAL_CALL queryInterface( const UNO3_TYPE& aType ) throw( UNO3_RUNTIMEEXCEPTION );
187 /**_______________________________________________________________________________________________________
188 @short increment refcount
189 @descr -
191 @seealso XInterface
192 @seealso release()
194 @param -
196 @return -
198 @onerror A RuntimeException is thrown.
201 virtual void SAL_CALL acquire() throw();
203 /**_______________________________________________________________________________________________________
204 @short decrement refcount
205 @descr -
207 @seealso XInterface
208 @seealso acquire()
210 @param -
212 @return -
214 @onerror A RuntimeException is thrown.
217 virtual void SAL_CALL release() throw();
219 //________________________________________________________________________________________________________
220 // operator
221 //________________________________________________________________________________________________________
223 /**_______________________________________________________________________________________________________
224 @short -
225 @descr -
227 @seealso -
229 @param -
231 @return -
233 @onerror -
236 operator UNO3_REFERENCE< UNO3_XINTERFACE >() const;
238 /**_______________________________________________________________________________________________________
239 @short -
240 @descr -
242 @seealso -
244 @param -
246 @return -
248 @onerror -
251 OMRCListenerMultiplexerHelper& operator= ( const OMRCListenerMultiplexerHelper& aCopyInstance );
253 //________________________________________________________________________________________________________
254 // container methods
255 //________________________________________________________________________________________________________
257 /**_______________________________________________________________________________________________________
258 @short Remove all listeners from the previous set peer and add the needed listeners to rPeer.
259 @descr -
261 @seealso -
263 @param rPeer The peer from which the original events are dispatched. Null is allowed.
265 @return -
267 @onerror -
270 void setPeer( const UNO3_REFERENCE< UNO3_XWINDOW >& xPeer );
272 /**_______________________________________________________________________________________________________
273 @short Remove all listeners and send a disposing message.
274 @descr -
276 @seealso -
278 @param -
280 @return -
282 @onerror -
285 void disposeAndClear();
287 /**_______________________________________________________________________________________________________
288 @short Add the specified listener to the source.
289 @descr -
291 @seealso -
293 @param -
295 @return -
297 @onerror -
300 void advise( const UNO3_TYPE& aType ,
301 const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener );
303 /**_______________________________________________________________________________________________________
304 @short Remove the specified listener from the source.
305 @descr -
307 @seealso -
309 @param -
311 @return -
313 @onerror -
316 void unadvise( const UNO3_TYPE& aType ,
317 const UNO3_REFERENCE< UNO3_XINTERFACE >& xListener );
319 //________________________________________________________________________________________________________
320 // XEventListener
321 //________________________________________________________________________________________________________
323 /**_______________________________________________________________________________________________________
324 @short -
325 @descr -
327 @seealso -
328 @seealso -
330 @param -
332 @return -
334 @onerror -
337 virtual void SAL_CALL disposing(const UNO3_EVENTOBJECT& aSource) throw( UNO3_RUNTIMEEXCEPTION ) ;
339 //________________________________________________________________________________________________________
340 // XFocusListener
341 //________________________________________________________________________________________________________
343 /**_______________________________________________________________________________________________________
344 @short -
345 @descr -
347 @seealso -
348 @seealso -
350 @param -
352 @return -
354 @onerror -
357 virtual void SAL_CALL focusGained(const UNO3_FOCUSEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
359 /**_______________________________________________________________________________________________________
360 @short -
361 @descr -
363 @seealso -
364 @seealso -
366 @param -
368 @return -
370 @onerror -
373 virtual void SAL_CALL focusLost(const UNO3_FOCUSEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
375 //________________________________________________________________________________________________________
376 // XWindowListener
377 //________________________________________________________________________________________________________
379 /**_______________________________________________________________________________________________________
380 @short -
381 @descr -
383 @seealso -
384 @seealso -
386 @param -
388 @return -
390 @onerror -
393 virtual void SAL_CALL windowResized(const UNO3_WINDOWEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
395 /**_______________________________________________________________________________________________________
396 @short -
397 @descr -
399 @seealso -
400 @seealso -
402 @param -
404 @return -
406 @onerror -
409 virtual void SAL_CALL windowMoved(const UNO3_WINDOWEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
411 /**_______________________________________________________________________________________________________
412 @short -
413 @descr -
415 @seealso -
416 @seealso -
418 @param -
420 @return -
422 @onerror -
425 virtual void SAL_CALL windowShown(const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
427 /**_______________________________________________________________________________________________________
428 @short -
429 @descr -
431 @seealso -
432 @seealso -
434 @param -
436 @return -
438 @onerror -
441 virtual void SAL_CALL windowHidden(const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
443 //________________________________________________________________________________________________________
444 // XKeyListener
445 //________________________________________________________________________________________________________
447 /**_______________________________________________________________________________________________________
448 @short -
449 @descr -
451 @seealso -
452 @seealso -
454 @param -
456 @return -
458 @onerror -
461 virtual void SAL_CALL keyPressed( const UNO3_KEYEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
463 /**_______________________________________________________________________________________________________
464 @short -
465 @descr -
467 @seealso -
468 @seealso -
470 @param -
472 @return -
474 @onerror -
477 virtual void SAL_CALL keyReleased( const UNO3_KEYEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
479 //________________________________________________________________________________________________________
480 // XMouseListener
481 //________________________________________________________________________________________________________
483 /**_______________________________________________________________________________________________________
484 @short -
485 @descr -
487 @seealso -
488 @seealso -
490 @param -
492 @return -
494 @onerror -
497 virtual void SAL_CALL mousePressed(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
499 /**_______________________________________________________________________________________________________
500 @short -
501 @descr -
503 @seealso -
504 @seealso -
506 @param -
508 @return -
510 @onerror -
513 virtual void SAL_CALL mouseReleased(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
515 /**_______________________________________________________________________________________________________
516 @short -
517 @descr -
519 @seealso -
520 @seealso -
522 @param -
524 @return -
526 @onerror -
529 virtual void SAL_CALL mouseEntered(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
531 /**_______________________________________________________________________________________________________
532 @short -
533 @descr -
535 @seealso -
536 @seealso -
538 @param -
540 @return -
542 @onerror -
545 virtual void SAL_CALL mouseExited(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
547 //________________________________________________________________________________________________________
548 // XMouseMotionListener
549 //________________________________________________________________________________________________________
551 /**_______________________________________________________________________________________________________
552 @short -
553 @descr -
555 @seealso -
556 @seealso -
558 @param -
560 @return -
562 @onerror -
565 virtual void SAL_CALL mouseDragged(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
567 /**_______________________________________________________________________________________________________
568 @short -
569 @descr -
571 @seealso -
572 @seealso -
574 @param -
576 @return -
578 @onerror -
581 virtual void SAL_CALL mouseMoved(const UNO3_MOUSEEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
583 //________________________________________________________________________________________________________
584 // XPaintListener
585 //________________________________________________________________________________________________________
587 /**_______________________________________________________________________________________________________
588 @short -
589 @descr -
591 @seealso -
592 @seealso -
594 @param -
596 @return -
598 @onerror -
601 virtual void SAL_CALL windowPaint(const UNO3_PAINTEVENT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
603 //________________________________________________________________________________________________________
604 // XTopWindowListener
605 //________________________________________________________________________________________________________
607 /**_______________________________________________________________________________________________________
608 @short -
609 @descr -
611 @seealso -
612 @seealso -
614 @param -
616 @return -
618 @onerror -
621 virtual void SAL_CALL windowOpened( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
623 /**_______________________________________________________________________________________________________
624 @short -
625 @descr -
627 @seealso -
628 @seealso -
630 @param -
632 @return -
634 @onerror -
637 virtual void SAL_CALL windowClosing( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
639 /**_______________________________________________________________________________________________________
640 @short -
641 @descr -
643 @seealso -
644 @seealso -
646 @param -
648 @return -
650 @onerror -
653 virtual void SAL_CALL windowClosed( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
655 /**_______________________________________________________________________________________________________
656 @short -
657 @descr -
659 @seealso -
660 @seealso -
662 @param -
664 @return -
666 @onerror -
669 virtual void SAL_CALL windowMinimized( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
671 /**_______________________________________________________________________________________________________
672 @short -
673 @descr -
675 @seealso -
676 @seealso -
678 @param -
680 @return -
682 @onerror -
685 virtual void SAL_CALL windowNormalized( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
687 /**_______________________________________________________________________________________________________
688 @short -
689 @descr -
691 @seealso -
692 @seealso -
694 @param -
696 @return -
698 @onerror -
701 virtual void SAL_CALL windowActivated( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
703 /**_______________________________________________________________________________________________________
704 @short -
705 @descr -
707 @seealso -
708 @seealso -
710 @param -
712 @return -
714 @onerror -
717 virtual void SAL_CALL windowDeactivated( const UNO3_EVENTOBJECT& aEvent ) throw( UNO3_RUNTIMEEXCEPTION ) ;
719 //____________________________________________________________________________________________________________
720 // protected methods
721 //____________________________________________________________________________________________________________
723 protected:
725 /**_______________________________________________________________________________________________________
726 @short Remove the listener from the peer.
727 @descr -
729 @seealso -
731 @param xPeer The peer from which the listener is removed.
732 @param rType The listener type, which specify the type of the listener.
734 @return -
736 @onerror -
739 void impl_adviseToPeer( const UNO3_REFERENCE< UNO3_XWINDOW >& xPeer ,
740 const UNO3_TYPE& aType );
742 /**_______________________________________________________________________________________________________
743 @short Add the listener to the peer.
744 @descr -
746 @seealso -
748 @param xPeer The peer to which the listener is added.
749 @param rType The listener type, which specify the type of the listener.
751 @return -
753 @onerror -
756 void impl_unadviseFromPeer( const UNO3_REFERENCE< UNO3_XWINDOW >& xPeer ,
757 const UNO3_TYPE& aType );
759 //____________________________________________________________________________________________________________
760 // private variables
761 //____________________________________________________________________________________________________________
763 private:
765 UNO3_MUTEX m_aMutex ;
766 UNO3_REFERENCE< UNO3_XWINDOW > m_xPeer ; /// The source of the events. Normally this is the peer object.
767 UNO3_WEAKREFERENCE< UNO3_XWINDOW > m_xControl ;
768 UNO3_OMULTITYPEINTERFACECONTAINERHELPER m_aListenerHolder ;
770 }; // class OMRCListenerMultiplexerHelper
772 } // namespace unocontrols
774 #endif // ifndef _UNOCONTROLS_MULTIPLEXER_HXX