Bump for 3.6-28
[LibreOffice.git] / UnoControls / inc / multiplexer.hxx
blobde455361e75c3b281fb5cb0eaac7b64436c4d838
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #ifndef _UNOCONTROLS_MULTIPLEXER_HXX
30 #define _UNOCONTROLS_MULTIPLEXER_HXX
32 //____________________________________________________________________________________________________________
33 // includes of other projects
34 //____________________________________________________________________________________________________________
36 #include <com/sun/star/awt/XKeyListener.hpp>
37 #include <com/sun/star/awt/XPaintListener.hpp>
38 #include <com/sun/star/awt/KeyEvent.hpp>
39 #include <com/sun/star/awt/KeyModifier.hpp>
40 #include <com/sun/star/awt/XMouseMotionListener.hpp>
41 #include <com/sun/star/awt/FocusEvent.hpp>
42 #include <com/sun/star/awt/XWindowListener.hpp>
43 #include <com/sun/star/awt/XActivateListener.hpp>
44 #include <com/sun/star/awt/MouseEvent.hpp>
45 #include <com/sun/star/awt/XTopWindowListener.hpp>
46 #include <com/sun/star/awt/PaintEvent.hpp>
47 #include <com/sun/star/awt/InputEvent.hpp>
48 #include <com/sun/star/awt/KeyGroup.hpp>
49 #include <com/sun/star/awt/Key.hpp>
50 #include <com/sun/star/awt/WindowEvent.hpp>
51 #include <com/sun/star/awt/XMouseListener.hpp>
52 #include <com/sun/star/awt/KeyFunction.hpp>
53 #include <com/sun/star/awt/FocusChangeReason.hpp>
54 #include <com/sun/star/awt/MouseButton.hpp>
55 #include <com/sun/star/awt/XFocusListener.hpp>
56 #include <com/sun/star/awt/XTopWindow.hpp>
57 #include <com/sun/star/awt/XWindow.hpp>
58 #include <com/sun/star/awt/PosSize.hpp>
59 #include <cppuhelper/weak.hxx>
60 #include <cppuhelper/interfacecontainer.hxx>
61 //____________________________________________________________________________________________________________
62 // includes of my own project
63 //____________________________________________________________________________________________________________
65 //____________________________________________________________________________________________________________
66 // "namespaces"
67 //____________________________________________________________________________________________________________
69 namespace unocontrols{
71 //____________________________________________________________________________________________________________
72 // class
73 //____________________________________________________________________________________________________________
75 class OMRCListenerMultiplexerHelper : public ::com::sun::star::awt::XFocusListener
76 , public ::com::sun::star::awt::XWindowListener
77 , public ::com::sun::star::awt::XKeyListener
78 , public ::com::sun::star::awt::XMouseListener
79 , public ::com::sun::star::awt::XMouseMotionListener
80 , public ::com::sun::star::awt::XPaintListener
81 , public ::com::sun::star::awt::XTopWindowListener
82 , public ::cppu::OWeakObject
85 //____________________________________________________________________________________________________________
86 // public methods
87 //____________________________________________________________________________________________________________
89 public:
91 //________________________________________________________________________________________________________
92 // construct/destruct
93 //________________________________________________________________________________________________________
95 /**_______________________________________________________________________________________________________
96 @short constructor
97 @descr Create a Multiplexer of XWindowEvents.
99 @seealso -
101 @param rControl The control. All listeners think that this is the original broadcaster.
102 @param rPeer The peer from which the original events are dispatched. Null is allowed.
104 @return -
106 @onerror -
109 OMRCListenerMultiplexerHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xControl ,
110 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer );
112 /**_______________________________________________________________________________________________________
113 @short copy-constructor
114 @descr
116 @seealso -
118 @param rCopyInstance C++-Reference to instance to make copy from.
120 @return -
122 @onerror -
125 OMRCListenerMultiplexerHelper( const OMRCListenerMultiplexerHelper& aCopyInstance );
127 /**_______________________________________________________________________________________________________
128 @short destructor
129 @descr -
131 @seealso -
133 @param -
135 @return -
137 @onerror -
140 ~OMRCListenerMultiplexerHelper();
142 //________________________________________________________________________________________________________
143 // XInterface
144 //________________________________________________________________________________________________________
146 /**_______________________________________________________________________________________________________
147 @short give answer, if interface is supported
148 @descr The interfaces are searched by type.
150 @seealso XInterface
152 @param "rType" is the type of searched interface.
154 @return Any information about found interface
156 @onerror A RuntimeException is thrown.
159 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
160 throw( ::com::sun::star::uno::RuntimeException );
162 /**_______________________________________________________________________________________________________
163 @short increment refcount
164 @descr -
166 @seealso XInterface
167 @seealso release()
169 @param -
171 @return -
173 @onerror A RuntimeException is thrown.
176 virtual void SAL_CALL acquire() throw();
178 /**_______________________________________________________________________________________________________
179 @short decrement refcount
180 @descr -
182 @seealso XInterface
183 @seealso acquire()
185 @param -
187 @return -
189 @onerror A RuntimeException is thrown.
192 virtual void SAL_CALL release() throw();
194 //________________________________________________________________________________________________________
195 // operator
196 //________________________________________________________________________________________________________
198 /**_______________________________________________________________________________________________________
199 @short -
200 @descr -
202 @seealso -
204 @param -
206 @return -
208 @onerror -
211 operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() const;
213 /**_______________________________________________________________________________________________________
214 @short -
215 @descr -
217 @seealso -
219 @param -
221 @return -
223 @onerror -
226 OMRCListenerMultiplexerHelper& operator= ( const OMRCListenerMultiplexerHelper& aCopyInstance );
228 //________________________________________________________________________________________________________
229 // container methods
230 //________________________________________________________________________________________________________
232 /**_______________________________________________________________________________________________________
233 @short Remove all listeners from the previous set peer and add the needed listeners to rPeer.
234 @descr -
236 @seealso -
238 @param rPeer The peer from which the original events are dispatched. Null is allowed.
240 @return -
242 @onerror -
245 void setPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer );
247 /**_______________________________________________________________________________________________________
248 @short Remove all listeners and send a disposing message.
249 @descr -
251 @seealso -
253 @param -
255 @return -
257 @onerror -
260 void disposeAndClear();
262 /**_______________________________________________________________________________________________________
263 @short Add the specified listener to the source.
264 @descr -
266 @seealso -
268 @param -
270 @return -
272 @onerror -
275 void advise( const ::com::sun::star::uno::Type& aType ,
276 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xListener );
278 /**_______________________________________________________________________________________________________
279 @short Remove the specified listener from the source.
280 @descr -
282 @seealso -
284 @param -
286 @return -
288 @onerror -
291 void unadvise( const ::com::sun::star::uno::Type& aType ,
292 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xListener );
294 //________________________________________________________________________________________________________
295 // XEventListener
296 //________________________________________________________________________________________________________
298 /**_______________________________________________________________________________________________________
299 @short -
300 @descr -
302 @seealso -
303 @seealso -
305 @param -
307 @return -
309 @onerror -
312 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& aSource)
313 throw( ::com::sun::star::uno::RuntimeException ) ;
315 //________________________________________________________________________________________________________
316 // XFocusListener
317 //________________________________________________________________________________________________________
319 /**_______________________________________________________________________________________________________
320 @short -
321 @descr -
323 @seealso -
324 @seealso -
326 @param -
328 @return -
330 @onerror -
333 virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& aEvent )
334 throw( ::com::sun::star::uno::RuntimeException ) ;
336 /**_______________________________________________________________________________________________________
337 @short -
338 @descr -
340 @seealso -
341 @seealso -
343 @param -
345 @return -
347 @onerror -
350 virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& aEvent )
351 throw( ::com::sun::star::uno::RuntimeException ) ;
353 //________________________________________________________________________________________________________
354 // XWindowListener
355 //________________________________________________________________________________________________________
357 /**_______________________________________________________________________________________________________
358 @short -
359 @descr -
361 @seealso -
362 @seealso -
364 @param -
366 @return -
368 @onerror -
371 virtual void SAL_CALL windowResized(const ::com::sun::star::awt::WindowEvent& aEvent )
372 throw( ::com::sun::star::uno::RuntimeException ) ;
374 /**_______________________________________________________________________________________________________
375 @short -
376 @descr -
378 @seealso -
379 @seealso -
381 @param -
383 @return -
385 @onerror -
388 virtual void SAL_CALL windowMoved(const ::com::sun::star::awt::WindowEvent& aEvent )
389 throw( ::com::sun::star::uno::RuntimeException ) ;
391 /**_______________________________________________________________________________________________________
392 @short -
393 @descr -
395 @seealso -
396 @seealso -
398 @param -
400 @return -
402 @onerror -
405 virtual void SAL_CALL windowShown(const ::com::sun::star::lang::EventObject& aEvent )
406 throw( ::com::sun::star::uno::RuntimeException ) ;
408 /**_______________________________________________________________________________________________________
409 @short -
410 @descr -
412 @seealso -
413 @seealso -
415 @param -
417 @return -
419 @onerror -
422 virtual void SAL_CALL windowHidden(const ::com::sun::star::lang::EventObject& aEvent )
423 throw( ::com::sun::star::uno::RuntimeException ) ;
425 //________________________________________________________________________________________________________
426 // XKeyListener
427 //________________________________________________________________________________________________________
429 /**_______________________________________________________________________________________________________
430 @short -
431 @descr -
433 @seealso -
434 @seealso -
436 @param -
438 @return -
440 @onerror -
443 virtual void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& aEvent )
444 throw( ::com::sun::star::uno::RuntimeException ) ;
446 /**_______________________________________________________________________________________________________
447 @short -
448 @descr -
450 @seealso -
451 @seealso -
453 @param -
455 @return -
457 @onerror -
460 virtual void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& aEvent )
461 throw( ::com::sun::star::uno::RuntimeException ) ;
463 //________________________________________________________________________________________________________
464 // XMouseListener
465 //________________________________________________________________________________________________________
467 /**_______________________________________________________________________________________________________
468 @short -
469 @descr -
471 @seealso -
472 @seealso -
474 @param -
476 @return -
478 @onerror -
481 virtual void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& aEvent )
482 throw( ::com::sun::star::uno::RuntimeException ) ;
484 /**_______________________________________________________________________________________________________
485 @short -
486 @descr -
488 @seealso -
489 @seealso -
491 @param -
493 @return -
495 @onerror -
498 virtual void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& aEvent )
499 throw( ::com::sun::star::uno::RuntimeException ) ;
501 /**_______________________________________________________________________________________________________
502 @short -
503 @descr -
505 @seealso -
506 @seealso -
508 @param -
510 @return -
512 @onerror -
515 virtual void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& aEvent )
516 throw( ::com::sun::star::uno::RuntimeException ) ;
518 /**_______________________________________________________________________________________________________
519 @short -
520 @descr -
522 @seealso -
523 @seealso -
525 @param -
527 @return -
529 @onerror -
532 virtual void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& aEvent )
533 throw( ::com::sun::star::uno::RuntimeException ) ;
535 //________________________________________________________________________________________________________
536 // XMouseMotionListener
537 //________________________________________________________________________________________________________
539 /**_______________________________________________________________________________________________________
540 @short -
541 @descr -
543 @seealso -
544 @seealso -
546 @param -
548 @return -
550 @onerror -
553 virtual void SAL_CALL mouseDragged(const ::com::sun::star::awt::MouseEvent& aEvent )
554 throw( ::com::sun::star::uno::RuntimeException ) ;
556 /**_______________________________________________________________________________________________________
557 @short -
558 @descr -
560 @seealso -
561 @seealso -
563 @param -
565 @return -
567 @onerror -
570 virtual void SAL_CALL mouseMoved(const ::com::sun::star::awt::MouseEvent& aEvent )
571 throw( ::com::sun::star::uno::RuntimeException ) ;
573 //________________________________________________________________________________________________________
574 // XPaintListener
575 //________________________________________________________________________________________________________
577 /**_______________________________________________________________________________________________________
578 @short -
579 @descr -
581 @seealso -
582 @seealso -
584 @param -
586 @return -
588 @onerror -
591 virtual void SAL_CALL windowPaint(const ::com::sun::star::awt::PaintEvent& aEvent )
592 throw( ::com::sun::star::uno::RuntimeException ) ;
594 //________________________________________________________________________________________________________
595 // XTopWindowListener
596 //________________________________________________________________________________________________________
598 /**_______________________________________________________________________________________________________
599 @short -
600 @descr -
602 @seealso -
603 @seealso -
605 @param -
607 @return -
609 @onerror -
612 virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& aEvent )
613 throw( ::com::sun::star::uno::RuntimeException ) ;
615 /**_______________________________________________________________________________________________________
616 @short -
617 @descr -
619 @seealso -
620 @seealso -
622 @param -
624 @return -
626 @onerror -
629 virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& aEvent )
630 throw( ::com::sun::star::uno::RuntimeException ) ;
632 /**_______________________________________________________________________________________________________
633 @short -
634 @descr -
636 @seealso -
637 @seealso -
639 @param -
641 @return -
643 @onerror -
646 virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& aEvent )
647 throw( ::com::sun::star::uno::RuntimeException ) ;
649 /**_______________________________________________________________________________________________________
650 @short -
651 @descr -
653 @seealso -
654 @seealso -
656 @param -
658 @return -
660 @onerror -
663 virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& aEvent )
664 throw( ::com::sun::star::uno::RuntimeException ) ;
666 /**_______________________________________________________________________________________________________
667 @short -
668 @descr -
670 @seealso -
671 @seealso -
673 @param -
675 @return -
677 @onerror -
680 virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& aEvent )
681 throw( ::com::sun::star::uno::RuntimeException ) ;
683 /**_______________________________________________________________________________________________________
684 @short -
685 @descr -
687 @seealso -
688 @seealso -
690 @param -
692 @return -
694 @onerror -
697 virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& aEvent )
698 throw( ::com::sun::star::uno::RuntimeException ) ;
700 /**_______________________________________________________________________________________________________
701 @short -
702 @descr -
704 @seealso -
705 @seealso -
707 @param -
709 @return -
711 @onerror -
714 virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& aEvent )
715 throw( ::com::sun::star::uno::RuntimeException ) ;
717 //____________________________________________________________________________________________________________
718 // protected methods
719 //____________________________________________________________________________________________________________
721 protected:
723 /**_______________________________________________________________________________________________________
724 @short Remove the listener from the peer.
725 @descr -
727 @seealso -
729 @param xPeer The peer from which the listener is removed.
730 @param rType The listener type, which specify the type of the listener.
732 @return -
734 @onerror -
737 void impl_adviseToPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer ,
738 const ::com::sun::star::uno::Type& aType );
740 /**_______________________________________________________________________________________________________
741 @short Add the listener to the peer.
742 @descr -
744 @seealso -
746 @param xPeer The peer to which the listener is added.
747 @param rType The listener type, which specify the type of the listener.
749 @return -
751 @onerror -
754 void impl_unadviseFromPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer ,
755 const ::com::sun::star::uno::Type& aType );
757 //____________________________________________________________________________________________________________
758 // private variables
759 //____________________________________________________________________________________________________________
761 private:
763 ::osl::Mutex m_aMutex ;
764 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xPeer ; /// The source of the events. Normally this is the peer object.
765 ::com::sun::star::uno::WeakReference< ::com::sun::star::awt::XWindow > m_xControl ;
766 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerHolder ;
768 }; // class OMRCListenerMultiplexerHelper
770 } // namespace unocontrols
772 #endif // ifndef _UNOCONTROLS_MULTIPLEXER_HXX
774 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */