1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <toolkit/helper/listenermultiplexer.hxx>
21 #include <toolkit/helper/macros.hxx>
22 #include <com/sun/star/lang/DisposedException.hpp>
24 // class EventListenerMultiplexer
26 EventListenerMultiplexer::EventListenerMultiplexer( ::cppu::OWeakObject
& rSource
)
27 : ListenerMultiplexerBase( rSource
)
31 void SAL_CALL
EventListenerMultiplexer::acquire() noexcept
33 return ListenerMultiplexerBase::acquire();
36 void SAL_CALL
EventListenerMultiplexer::release() noexcept
38 return ListenerMultiplexerBase::release();
41 // css::uno::XInterface
42 css::uno::Any
EventListenerMultiplexer::queryInterface( const css::uno::Type
& rType
)
44 css::uno::Any aRet
= ::cppu::queryInterface( rType
,
45 static_cast< css::lang::XEventListener
* >(this) );
46 return (aRet
.hasValue() ? aRet
: ListenerMultiplexerBase::queryInterface( rType
));
49 // css::lang::XEventListener
50 void EventListenerMultiplexer::disposing( const css::lang::EventObject
& )
55 // class FocusListenerMultiplexer
57 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( FocusListenerMultiplexer
, css::awt::XFocusListener
)
58 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( FocusListenerMultiplexer
, css::awt::XFocusListener
, focusGained
, css::awt::FocusEvent
)
59 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( FocusListenerMultiplexer
, css::awt::XFocusListener
, focusLost
, css::awt::FocusEvent
)
62 // class WindowListenerMultiplexer
64 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( WindowListenerMultiplexer
, css::awt::XWindowListener
)
65 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( WindowListenerMultiplexer
, css::awt::XWindowListener
, windowResized
, css::awt::WindowEvent
)
66 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( WindowListenerMultiplexer
, css::awt::XWindowListener
, windowMoved
, css::awt::WindowEvent
)
67 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( WindowListenerMultiplexer
, css::awt::XWindowListener
, windowShown
, css::lang::EventObject
)
68 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( WindowListenerMultiplexer
, css::awt::XWindowListener
, windowHidden
, css::lang::EventObject
)
71 // class VclContainerListenerMultiplexer
73 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( VclContainerListenerMultiplexer
, css::awt::XVclContainerListener
)
74 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( VclContainerListenerMultiplexer
, css::awt::XVclContainerListener
, windowAdded
, css::awt::VclContainerEvent
)
75 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( VclContainerListenerMultiplexer
, css::awt::XVclContainerListener
, windowRemoved
, css::awt::VclContainerEvent
)
78 // class KeyListenerMultiplexer
80 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( KeyListenerMultiplexer
, css::awt::XKeyListener
)
81 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( KeyListenerMultiplexer
, css::awt::XKeyListener
, keyPressed
, css::awt::KeyEvent
)
82 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( KeyListenerMultiplexer
, css::awt::XKeyListener
, keyReleased
, css::awt::KeyEvent
)
85 // class MouseListenerMultiplexer
87 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( MouseListenerMultiplexer
, css::awt::XMouseListener
)
88 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MouseListenerMultiplexer
, css::awt::XMouseListener
, mousePressed
, css::awt::MouseEvent
)
89 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MouseListenerMultiplexer
, css::awt::XMouseListener
, mouseReleased
, css::awt::MouseEvent
)
90 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MouseListenerMultiplexer
, css::awt::XMouseListener
, mouseEntered
, css::awt::MouseEvent
)
91 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MouseListenerMultiplexer
, css::awt::XMouseListener
, mouseExited
, css::awt::MouseEvent
)
94 // class MouseMotionListenerMultiplexer
96 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( MouseMotionListenerMultiplexer
, css::awt::XMouseMotionListener
)
97 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MouseMotionListenerMultiplexer
, css::awt::XMouseMotionListener
, mouseDragged
, css::awt::MouseEvent
)
98 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MouseMotionListenerMultiplexer
, css::awt::XMouseMotionListener
, mouseMoved
, css::awt::MouseEvent
)
101 // class PaintListenerMultiplexer
103 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( PaintListenerMultiplexer
, css::awt::XPaintListener
)
104 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( PaintListenerMultiplexer
, css::awt::XPaintListener
, windowPaint
, css::awt::PaintEvent
)
107 // class TopWindowListenerMultiplexer
109 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TopWindowListenerMultiplexer
, css::awt::XTopWindowListener
)
110 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TopWindowListenerMultiplexer
, css::awt::XTopWindowListener
, windowOpened
, css::lang::EventObject
)
111 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TopWindowListenerMultiplexer
, css::awt::XTopWindowListener
, windowClosing
, css::lang::EventObject
)
112 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TopWindowListenerMultiplexer
, css::awt::XTopWindowListener
, windowClosed
, css::lang::EventObject
)
113 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TopWindowListenerMultiplexer
, css::awt::XTopWindowListener
, windowMinimized
, css::lang::EventObject
)
114 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TopWindowListenerMultiplexer
, css::awt::XTopWindowListener
, windowNormalized
, css::lang::EventObject
)
115 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TopWindowListenerMultiplexer
, css::awt::XTopWindowListener
, windowActivated
, css::lang::EventObject
)
116 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TopWindowListenerMultiplexer
, css::awt::XTopWindowListener
, windowDeactivated
, css::lang::EventObject
)
119 // class TextListenerMultiplexer
121 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TextListenerMultiplexer
, css::awt::XTextListener
)
122 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TextListenerMultiplexer
, css::awt::XTextListener
, textChanged
, css::awt::TextEvent
)
125 // class ActionListenerMultiplexer
127 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( ActionListenerMultiplexer
, css::awt::XActionListener
)
128 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( ActionListenerMultiplexer
, css::awt::XActionListener
, actionPerformed
, css::awt::ActionEvent
)
131 // class ItemListenerMultiplexer
133 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( ItemListenerMultiplexer
, css::awt::XItemListener
)
134 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( ItemListenerMultiplexer
, css::awt::XItemListener
, itemStateChanged
, css::awt::ItemEvent
)
137 // class TabListenerMultiplexer
139 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TabListenerMultiplexer
, css::awt::XTabListener
)
141 void TabListenerMultiplexer::inserted( sal_Int32 evt
)
142 IMPL_TABLISTENERMULTIPLEXER_LISTENERMETHOD_BODY_1PARAM( TabListenerMultiplexer
, css::awt::XTabListener
, inserted
, ::sal_Int32
)
144 void TabListenerMultiplexer::removed( sal_Int32 evt
)
145 IMPL_TABLISTENERMULTIPLEXER_LISTENERMETHOD_BODY_1PARAM( TabListenerMultiplexer
, css::awt::XTabListener
, removed
, ::sal_Int32
)
147 void TabListenerMultiplexer::changed( sal_Int32 evt
, const css::uno::Sequence
< css::beans::NamedValue
>& evt2
)
149 sal_Int32
aMulti( evt
);
150 std::unique_lock
g(m_aMutex
);
151 ::comphelper::OInterfaceIteratorHelper4
aIt(g
, maListeners
);
153 while( aIt
.hasMoreElements() )
155 css::uno::Reference
<css::awt::XTabListener
> xListener(aIt
.next());
158 xListener
->changed( aMulti
, evt2
);
160 catch(const css::lang::DisposedException
& e
)
162 OSL_ENSURE( e
.Context
.is(), "caught DisposedException with empty Context field" );
163 if ( e
.Context
== xListener
|| !e
.Context
.is() )
165 std::unique_lock
g2(m_aMutex
);
169 catch(const css::uno::RuntimeException
&)
171 DISPLAY_EXCEPTION( TabListenerMultiplexer
, changed
)
177 void TabListenerMultiplexer::activated( sal_Int32 evt
)
178 IMPL_TABLISTENERMULTIPLEXER_LISTENERMETHOD_BODY_1PARAM( TabListenerMultiplexer
, css::awt::XTabListener
, activated
, ::sal_Int32
)
180 void TabListenerMultiplexer::deactivated( sal_Int32 evt
)
181 IMPL_TABLISTENERMULTIPLEXER_LISTENERMETHOD_BODY_1PARAM( TabListenerMultiplexer
, css::awt::XTabListener
, deactivated
, ::sal_Int32
)
184 // class ContainerListenerMultiplexer
186 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( ContainerListenerMultiplexer
, css::container::XContainerListener
)
187 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( ContainerListenerMultiplexer
, css::container::XContainerListener
, elementInserted
, css::container::ContainerEvent
)
188 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( ContainerListenerMultiplexer
, css::container::XContainerListener
, elementRemoved
, css::container::ContainerEvent
)
189 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( ContainerListenerMultiplexer
, css::container::XContainerListener
, elementReplaced
, css::container::ContainerEvent
)
192 // class SpinListenerMultiplexer
194 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( SpinListenerMultiplexer
, css::awt::XSpinListener
)
195 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SpinListenerMultiplexer
, css::awt::XSpinListener
, up
, css::awt::SpinEvent
)
196 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SpinListenerMultiplexer
, css::awt::XSpinListener
, down
, css::awt::SpinEvent
)
197 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SpinListenerMultiplexer
, css::awt::XSpinListener
, first
, css::awt::SpinEvent
)
198 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SpinListenerMultiplexer
, css::awt::XSpinListener
, last
, css::awt::SpinEvent
)
201 // class AdjustmentListenerMultiplexer
203 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( AdjustmentListenerMultiplexer
, css::awt::XAdjustmentListener
)
204 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( AdjustmentListenerMultiplexer
, css::awt::XAdjustmentListener
, adjustmentValueChanged
, css::awt::AdjustmentEvent
)
207 // class MenuListenerMultiplexer
209 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( MenuListenerMultiplexer
, css::awt::XMenuListener
)
210 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MenuListenerMultiplexer
, css::awt::XMenuListener
, itemHighlighted
, css::awt::MenuEvent
)
211 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MenuListenerMultiplexer
, css::awt::XMenuListener
, itemSelected
, css::awt::MenuEvent
)
212 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MenuListenerMultiplexer
, css::awt::XMenuListener
, itemActivated
, css::awt::MenuEvent
)
213 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( MenuListenerMultiplexer
, css::awt::XMenuListener
, itemDeactivated
, css::awt::MenuEvent
)
216 // class TreeSelectionListenerMultiplexer
218 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TreeSelectionListenerMultiplexer
, css::view::XSelectionChangeListener
)
219 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TreeSelectionListenerMultiplexer
, css::view::XSelectionChangeListener
, selectionChanged
, css::lang::EventObject
)
222 // class TreeSelectionListenerMultiplexer
224 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TreeExpansionListenerMultiplexer
, css::awt::tree::XTreeExpansionListener
)
225 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TreeExpansionListenerMultiplexer
, css::awt::tree::XTreeExpansionListener
, requestChildNodes
, css::awt::tree::TreeExpansionEvent
)
226 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_EXCEPTION( TreeExpansionListenerMultiplexer
, css::awt::tree::XTreeExpansionListener
, treeExpanding
, css::awt::tree::TreeExpansionEvent
, css::awt::tree::ExpandVetoException
)
227 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_EXCEPTION( TreeExpansionListenerMultiplexer
, css::awt::tree::XTreeExpansionListener
, treeCollapsing
, css::awt::tree::TreeExpansionEvent
, css::awt::tree::ExpandVetoException
)
228 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TreeExpansionListenerMultiplexer
, css::awt::tree::XTreeExpansionListener
, treeExpanded
, css::awt::tree::TreeExpansionEvent
)
229 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TreeExpansionListenerMultiplexer
, css::awt::tree::XTreeExpansionListener
, treeCollapsed
, css::awt::tree::TreeExpansionEvent
)
232 // class TreeEditListenerMultiplexer
234 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TreeEditListenerMultiplexer
, css::awt::tree::XTreeEditListener
)
237 // class SelectionListenerMultiplexer
239 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( SelectionListenerMultiplexer
, css::awt::grid::XGridSelectionListener
)
240 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SelectionListenerMultiplexer
, css::awt::grid::XGridSelectionListener
, selectionChanged
, css::awt::grid::GridSelectionEvent
)
243 // class SelectionListenerMultiplexer
245 IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TabPageListenerMultiplexer
, css::awt::tab::XTabPageContainerListener
)
246 IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TabPageListenerMultiplexer
, css::awt::tab::XTabPageContainerListener
, tabPageActivated
, css::awt::tab::TabPageActivatedEvent
)
247 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */