bump product version to 4.1.6.2
[LibreOffice.git] / UnoControls / inc / multiplexer.hxx
blob9d1fdba51e636392ebd5c07014b9d8f2224873e9
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 _UNOCONTROLS_MULTIPLEXER_HXX
21 #define _UNOCONTROLS_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/interfacecontainer.hxx>
49 //____________________________________________________________________________________________________________
50 // "namespaces"
51 //____________________________________________________________________________________________________________
53 namespace unocontrols{
55 //____________________________________________________________________________________________________________
56 // class
57 //____________________________________________________________________________________________________________
59 class OMRCListenerMultiplexerHelper : public ::com::sun::star::awt::XFocusListener
60 , public ::com::sun::star::awt::XWindowListener
61 , public ::com::sun::star::awt::XKeyListener
62 , public ::com::sun::star::awt::XMouseListener
63 , public ::com::sun::star::awt::XMouseMotionListener
64 , public ::com::sun::star::awt::XPaintListener
65 , public ::com::sun::star::awt::XTopWindowListener
66 , public ::cppu::OWeakObject
69 //____________________________________________________________________________________________________________
70 // public methods
71 //____________________________________________________________________________________________________________
73 public:
75 //________________________________________________________________________________________________________
76 // construct/destruct
77 //________________________________________________________________________________________________________
79 /**_______________________________________________________________________________________________________
80 @short constructor
81 @descr Create a Multiplexer of XWindowEvents.
83 @seealso -
85 @param rControl The control. All listeners think that this is the original broadcaster.
86 @param rPeer The peer from which the original events are dispatched. Null is allowed.
88 @return -
90 @onerror -
93 OMRCListenerMultiplexerHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xControl ,
94 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer );
96 /**_______________________________________________________________________________________________________
97 @short copy-constructor
98 @descr
100 @seealso -
102 @param rCopyInstance C++-Reference to instance to make copy from.
104 @return -
106 @onerror -
109 OMRCListenerMultiplexerHelper( const OMRCListenerMultiplexerHelper& aCopyInstance );
111 /**_______________________________________________________________________________________________________
112 @short destructor
113 @descr -
115 @seealso -
117 @param -
119 @return -
121 @onerror -
124 ~OMRCListenerMultiplexerHelper();
126 //________________________________________________________________________________________________________
127 // XInterface
128 //________________________________________________________________________________________________________
130 /**_______________________________________________________________________________________________________
131 @short give answer, if interface is supported
132 @descr The interfaces are searched by type.
134 @seealso XInterface
136 @param "rType" is the type of searched interface.
138 @return Any information about found interface
140 @onerror A RuntimeException is thrown.
143 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
144 throw( ::com::sun::star::uno::RuntimeException );
146 /**_______________________________________________________________________________________________________
147 @short increment refcount
148 @descr -
150 @seealso XInterface
151 @seealso release()
153 @param -
155 @return -
157 @onerror A RuntimeException is thrown.
160 virtual void SAL_CALL acquire() throw();
162 /**_______________________________________________________________________________________________________
163 @short decrement refcount
164 @descr -
166 @seealso XInterface
167 @seealso acquire()
169 @param -
171 @return -
173 @onerror A RuntimeException is thrown.
176 virtual void SAL_CALL release() throw();
178 //________________________________________________________________________________________________________
179 // operator
180 //________________________________________________________________________________________________________
182 /**_______________________________________________________________________________________________________
183 @short -
184 @descr -
186 @seealso -
188 @param -
190 @return -
192 @onerror -
195 operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() const;
197 /**_______________________________________________________________________________________________________
198 @short -
199 @descr -
201 @seealso -
203 @param -
205 @return -
207 @onerror -
210 OMRCListenerMultiplexerHelper& operator= ( const OMRCListenerMultiplexerHelper& aCopyInstance );
212 //________________________________________________________________________________________________________
213 // container methods
214 //________________________________________________________________________________________________________
216 /**_______________________________________________________________________________________________________
217 @short Remove all listeners from the previous set peer and add the needed listeners to rPeer.
218 @descr -
220 @seealso -
222 @param rPeer The peer from which the original events are dispatched. Null is allowed.
224 @return -
226 @onerror -
229 void setPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer );
231 /**_______________________________________________________________________________________________________
232 @short Remove all listeners and send a disposing message.
233 @descr -
235 @seealso -
237 @param -
239 @return -
241 @onerror -
244 void disposeAndClear();
246 /**_______________________________________________________________________________________________________
247 @short Add the specified listener to the source.
248 @descr -
250 @seealso -
252 @param -
254 @return -
256 @onerror -
259 void advise( const ::com::sun::star::uno::Type& aType ,
260 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xListener );
262 /**_______________________________________________________________________________________________________
263 @short Remove the specified listener from the source.
264 @descr -
266 @seealso -
268 @param -
270 @return -
272 @onerror -
275 void unadvise( const ::com::sun::star::uno::Type& aType ,
276 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xListener );
278 //________________________________________________________________________________________________________
279 // XEventListener
280 //________________________________________________________________________________________________________
282 /**_______________________________________________________________________________________________________
283 @short -
284 @descr -
286 @seealso -
287 @seealso -
289 @param -
291 @return -
293 @onerror -
296 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& aSource)
297 throw( ::com::sun::star::uno::RuntimeException ) ;
299 //________________________________________________________________________________________________________
300 // XFocusListener
301 //________________________________________________________________________________________________________
303 /**_______________________________________________________________________________________________________
304 @short -
305 @descr -
307 @seealso -
308 @seealso -
310 @param -
312 @return -
314 @onerror -
317 virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& aEvent )
318 throw( ::com::sun::star::uno::RuntimeException ) ;
320 /**_______________________________________________________________________________________________________
321 @short -
322 @descr -
324 @seealso -
325 @seealso -
327 @param -
329 @return -
331 @onerror -
334 virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& aEvent )
335 throw( ::com::sun::star::uno::RuntimeException ) ;
337 //________________________________________________________________________________________________________
338 // XWindowListener
339 //________________________________________________________________________________________________________
341 /**_______________________________________________________________________________________________________
342 @short -
343 @descr -
345 @seealso -
346 @seealso -
348 @param -
350 @return -
352 @onerror -
355 virtual void SAL_CALL windowResized(const ::com::sun::star::awt::WindowEvent& aEvent )
356 throw( ::com::sun::star::uno::RuntimeException ) ;
358 /**_______________________________________________________________________________________________________
359 @short -
360 @descr -
362 @seealso -
363 @seealso -
365 @param -
367 @return -
369 @onerror -
372 virtual void SAL_CALL windowMoved(const ::com::sun::star::awt::WindowEvent& aEvent )
373 throw( ::com::sun::star::uno::RuntimeException ) ;
375 /**_______________________________________________________________________________________________________
376 @short -
377 @descr -
379 @seealso -
380 @seealso -
382 @param -
384 @return -
386 @onerror -
389 virtual void SAL_CALL windowShown(const ::com::sun::star::lang::EventObject& aEvent )
390 throw( ::com::sun::star::uno::RuntimeException ) ;
392 /**_______________________________________________________________________________________________________
393 @short -
394 @descr -
396 @seealso -
397 @seealso -
399 @param -
401 @return -
403 @onerror -
406 virtual void SAL_CALL windowHidden(const ::com::sun::star::lang::EventObject& aEvent )
407 throw( ::com::sun::star::uno::RuntimeException ) ;
409 //________________________________________________________________________________________________________
410 // XKeyListener
411 //________________________________________________________________________________________________________
413 /**_______________________________________________________________________________________________________
414 @short -
415 @descr -
417 @seealso -
418 @seealso -
420 @param -
422 @return -
424 @onerror -
427 virtual void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& aEvent )
428 throw( ::com::sun::star::uno::RuntimeException ) ;
430 /**_______________________________________________________________________________________________________
431 @short -
432 @descr -
434 @seealso -
435 @seealso -
437 @param -
439 @return -
441 @onerror -
444 virtual void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& aEvent )
445 throw( ::com::sun::star::uno::RuntimeException ) ;
447 //________________________________________________________________________________________________________
448 // XMouseListener
449 //________________________________________________________________________________________________________
451 /**_______________________________________________________________________________________________________
452 @short -
453 @descr -
455 @seealso -
456 @seealso -
458 @param -
460 @return -
462 @onerror -
465 virtual void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& aEvent )
466 throw( ::com::sun::star::uno::RuntimeException ) ;
468 /**_______________________________________________________________________________________________________
469 @short -
470 @descr -
472 @seealso -
473 @seealso -
475 @param -
477 @return -
479 @onerror -
482 virtual void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& aEvent )
483 throw( ::com::sun::star::uno::RuntimeException ) ;
485 /**_______________________________________________________________________________________________________
486 @short -
487 @descr -
489 @seealso -
490 @seealso -
492 @param -
494 @return -
496 @onerror -
499 virtual void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& aEvent )
500 throw( ::com::sun::star::uno::RuntimeException ) ;
502 /**_______________________________________________________________________________________________________
503 @short -
504 @descr -
506 @seealso -
507 @seealso -
509 @param -
511 @return -
513 @onerror -
516 virtual void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& aEvent )
517 throw( ::com::sun::star::uno::RuntimeException ) ;
519 //________________________________________________________________________________________________________
520 // XMouseMotionListener
521 //________________________________________________________________________________________________________
523 /**_______________________________________________________________________________________________________
524 @short -
525 @descr -
527 @seealso -
528 @seealso -
530 @param -
532 @return -
534 @onerror -
537 virtual void SAL_CALL mouseDragged(const ::com::sun::star::awt::MouseEvent& aEvent )
538 throw( ::com::sun::star::uno::RuntimeException ) ;
540 /**_______________________________________________________________________________________________________
541 @short -
542 @descr -
544 @seealso -
545 @seealso -
547 @param -
549 @return -
551 @onerror -
554 virtual void SAL_CALL mouseMoved(const ::com::sun::star::awt::MouseEvent& aEvent )
555 throw( ::com::sun::star::uno::RuntimeException ) ;
557 //________________________________________________________________________________________________________
558 // XPaintListener
559 //________________________________________________________________________________________________________
561 /**_______________________________________________________________________________________________________
562 @short -
563 @descr -
565 @seealso -
566 @seealso -
568 @param -
570 @return -
572 @onerror -
575 virtual void SAL_CALL windowPaint(const ::com::sun::star::awt::PaintEvent& aEvent )
576 throw( ::com::sun::star::uno::RuntimeException ) ;
578 //________________________________________________________________________________________________________
579 // XTopWindowListener
580 //________________________________________________________________________________________________________
582 /**_______________________________________________________________________________________________________
583 @short -
584 @descr -
586 @seealso -
587 @seealso -
589 @param -
591 @return -
593 @onerror -
596 virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& aEvent )
597 throw( ::com::sun::star::uno::RuntimeException ) ;
599 /**_______________________________________________________________________________________________________
600 @short -
601 @descr -
603 @seealso -
604 @seealso -
606 @param -
608 @return -
610 @onerror -
613 virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& aEvent )
614 throw( ::com::sun::star::uno::RuntimeException ) ;
616 /**_______________________________________________________________________________________________________
617 @short -
618 @descr -
620 @seealso -
621 @seealso -
623 @param -
625 @return -
627 @onerror -
630 virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& aEvent )
631 throw( ::com::sun::star::uno::RuntimeException ) ;
633 /**_______________________________________________________________________________________________________
634 @short -
635 @descr -
637 @seealso -
638 @seealso -
640 @param -
642 @return -
644 @onerror -
647 virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& aEvent )
648 throw( ::com::sun::star::uno::RuntimeException ) ;
650 /**_______________________________________________________________________________________________________
651 @short -
652 @descr -
654 @seealso -
655 @seealso -
657 @param -
659 @return -
661 @onerror -
664 virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& aEvent )
665 throw( ::com::sun::star::uno::RuntimeException ) ;
667 /**_______________________________________________________________________________________________________
668 @short -
669 @descr -
671 @seealso -
672 @seealso -
674 @param -
676 @return -
678 @onerror -
681 virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& aEvent )
682 throw( ::com::sun::star::uno::RuntimeException ) ;
684 /**_______________________________________________________________________________________________________
685 @short -
686 @descr -
688 @seealso -
689 @seealso -
691 @param -
693 @return -
695 @onerror -
698 virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& aEvent )
699 throw( ::com::sun::star::uno::RuntimeException ) ;
701 //____________________________________________________________________________________________________________
702 // protected methods
703 //____________________________________________________________________________________________________________
705 protected:
707 /**_______________________________________________________________________________________________________
708 @short Remove the listener from the peer.
709 @descr -
711 @seealso -
713 @param xPeer The peer from which the listener is removed.
714 @param rType The listener type, which specify the type of the listener.
716 @return -
718 @onerror -
721 void impl_adviseToPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer ,
722 const ::com::sun::star::uno::Type& aType );
724 /**_______________________________________________________________________________________________________
725 @short Add the listener to the peer.
726 @descr -
728 @seealso -
730 @param xPeer The peer to which the listener is added.
731 @param rType The listener type, which specify the type of the listener.
733 @return -
735 @onerror -
738 void impl_unadviseFromPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& xPeer ,
739 const ::com::sun::star::uno::Type& aType );
741 //____________________________________________________________________________________________________________
742 // private variables
743 //____________________________________________________________________________________________________________
745 private:
747 ::osl::Mutex m_aMutex ;
748 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xPeer ; /// The source of the events. Normally this is the peer object.
749 ::com::sun::star::uno::WeakReference< ::com::sun::star::awt::XWindow > m_xControl ;
750 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerHolder ;
752 }; // class OMRCListenerMultiplexerHelper
754 } // namespace unocontrols
756 #endif // ifndef _UNOCONTROLS_MULTIPLEXER_HXX
758 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */