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 <vcl/vclevent.hxx>
21 #include <vcl/window.hxx>
22 #include <vcl/menu.hxx>
24 #include <vcleventlisteners.hxx>
26 using ::com::sun::star::uno::Reference
;
27 using ::com::sun::star::accessibility::XAccessible
;
30 VclAccessibleEvent::VclAccessibleEvent( VclEventId n
, const Reference
<XAccessible
>& rxAccessible
) :
32 mxAccessible(rxAccessible
)
36 VclAccessibleEvent::~VclAccessibleEvent()
41 void VclEventListeners::Call( VclSimpleEvent
& rEvent
) const
43 if ( m_aListeners
.empty() )
46 // Copy the list, because this can be destroyed when calling a Link...
47 std::vector
<Link
<VclSimpleEvent
&,void>> aCopy( m_aListeners
);
48 std::vector
<Link
<VclSimpleEvent
&,void>>::iterator
aIter( aCopy
.begin() );
49 std::vector
<Link
<VclSimpleEvent
&,void>>::const_iterator
aEnd( aCopy
.end() );
50 if (VclWindowEvent
* pWindowEvent
= dynamic_cast<VclWindowEvent
*>(&rEvent
))
52 VclPtr
<vcl::Window
> xWin(pWindowEvent
->GetWindow());
53 while ( aIter
!= aEnd
&& xWin
&& ! xWin
->IsDisposed() )
55 Link
<VclSimpleEvent
&,void> &rLink
= *aIter
;
56 // check this hasn't been removed in some re-enterancy scenario fdo#47368
57 if( std::find(m_aListeners
.begin(), m_aListeners
.end(), rLink
) != m_aListeners
.end() )
64 while ( aIter
!= aEnd
)
66 Link
<VclSimpleEvent
&,void> &rLink
= *aIter
;
67 if( std::find(m_aListeners
.begin(), m_aListeners
.end(), rLink
) != m_aListeners
.end() )
74 void VclEventListeners::addListener( const Link
<VclSimpleEvent
&,void>& rListener
)
76 m_aListeners
.push_back( rListener
);
79 void VclEventListeners::removeListener( const Link
<VclSimpleEvent
&,void>& rListener
)
81 m_aListeners
.erase( std::remove(m_aListeners
.begin(), m_aListeners
.end(), rListener
), m_aListeners
.end() );
84 VclWindowEvent::VclWindowEvent( vcl::Window
* pWin
, VclEventId n
, void* pDat
) : VclSimpleEvent(n
)
86 pWindow
= pWin
; pData
= pDat
;
89 VclWindowEvent::~VclWindowEvent() {}
91 VclMenuEvent::VclMenuEvent( Menu
* pM
, VclEventId n
, sal_uInt16 nPos
)
92 : VclSimpleEvent(n
), pMenu(pM
), mnPos(nPos
)
95 VclMenuEvent::~VclMenuEvent()
98 Menu
* VclMenuEvent::GetMenu() const
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */