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>
25 #include "vcleventlisteners.hxx"
27 #include <com/sun/star/accessibility/XAccessible.hpp>
29 using ::com::sun::star::uno::Reference
;
30 using ::com::sun::star::accessibility::XAccessible
;
33 VclAccessibleEvent::VclAccessibleEvent( sal_uLong n
, const Reference
<XAccessible
>& rxAccessible
) :
35 mxAccessible(rxAccessible
)
39 VclAccessibleEvent::~VclAccessibleEvent()
44 void VclEventListeners::Call( VclSimpleEvent
& rEvent
) const
46 if ( m_aListeners
.empty() )
49 // Copy the list, because this can be destroyed when calling a Link...
50 std::vector
<Link
<VclSimpleEvent
&,void>> aCopy( m_aListeners
);
51 std::vector
<Link
<VclSimpleEvent
&,void>>::iterator
aIter( aCopy
.begin() );
52 std::vector
<Link
<VclSimpleEvent
&,void>>::const_iterator
aEnd( aCopy
.end() );
53 if (VclWindowEvent
* pWindowEvent
= dynamic_cast<VclWindowEvent
*>(&rEvent
))
55 VclPtr
<vcl::Window
> xWin(pWindowEvent
->GetWindow());
56 while ( aIter
!= aEnd
&& xWin
&& ! xWin
->IsDisposed() )
58 Link
<VclSimpleEvent
&,void> &rLink
= *aIter
;
59 // check this hasn't been removed in some re-enterancy scenario fdo#47368
60 if( std::find(m_aListeners
.begin(), m_aListeners
.end(), rLink
) != m_aListeners
.end() )
67 while ( aIter
!= aEnd
)
69 Link
<VclSimpleEvent
&,void> &rLink
= *aIter
;
70 if( std::find(m_aListeners
.begin(), m_aListeners
.end(), rLink
) != m_aListeners
.end() )
77 void VclEventListeners::addListener( const Link
<VclSimpleEvent
&,void>& rListener
)
79 m_aListeners
.push_back( rListener
);
82 void VclEventListeners::removeListener( const Link
<VclSimpleEvent
&,void>& rListener
)
84 m_aListeners
.erase( std::remove(m_aListeners
.begin(), m_aListeners
.end(), rListener
), m_aListeners
.end() );
87 VclWindowEvent::VclWindowEvent( vcl::Window
* pWin
, sal_uLong n
, void* pDat
) : VclSimpleEvent(n
)
89 pWindow
= pWin
; pData
= pDat
;
92 VclWindowEvent::~VclWindowEvent() {}
94 VclMenuEvent::VclMenuEvent( Menu
* pM
, sal_uLong n
, sal_uInt16 nPos
)
95 : VclSimpleEvent(n
), pMenu(pM
), mnPos(nPos
)
98 VclMenuEvent::~VclMenuEvent()
101 Menu
* VclMenuEvent::GetMenu() const
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */