nss: upgrade to release 3.73
[LibreOffice.git] / vcl / source / app / vclevent.cxx
blob1895051ce6333e59663e260940f2f3ce5763e3e9
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 #include <vcl/vclevent.hxx>
21 #include <vcl/window.hxx>
22 #include <vcl/menu.hxx>
24 #include <vcleventlisteners.hxx>
26 void VclEventListeners::Call( VclSimpleEvent& rEvent ) const
28 if ( m_aListeners.empty() )
29 return;
31 // Copy the list, because this can be destroyed when calling a Link...
32 std::vector<Link<VclSimpleEvent&,void>> aCopy( m_aListeners );
33 std::vector<Link<VclSimpleEvent&,void>>::iterator aIter( aCopy.begin() );
34 std::vector<Link<VclSimpleEvent&,void>>::const_iterator aEnd( aCopy.end() );
35 if (VclWindowEvent* pWindowEvent = dynamic_cast<VclWindowEvent*>(&rEvent))
37 VclPtr<vcl::Window> xWin(pWindowEvent->GetWindow());
38 while ( aIter != aEnd && (!xWin || !xWin->IsDisposed()) )
40 Link<VclSimpleEvent&,void> &rLink = *aIter;
41 // check this hasn't been removed in some re-enterancy scenario fdo#47368
42 if( std::find(m_aListeners.begin(), m_aListeners.end(), rLink) != m_aListeners.end() )
43 rLink.Call( rEvent );
44 ++aIter;
47 else
49 while ( aIter != aEnd )
51 Link<VclSimpleEvent&,void> &rLink = *aIter;
52 if( std::find(m_aListeners.begin(), m_aListeners.end(), rLink) != m_aListeners.end() )
53 rLink.Call( rEvent );
54 ++aIter;
59 void VclEventListeners::addListener( const Link<VclSimpleEvent&,void>& rListener )
61 m_aListeners.push_back( rListener );
64 void VclEventListeners::removeListener( const Link<VclSimpleEvent&,void>& rListener )
66 m_aListeners.erase( std::remove(m_aListeners.begin(), m_aListeners.end(), rListener ), m_aListeners.end() );
69 VclWindowEvent::VclWindowEvent( vcl::Window* pWin, VclEventId n, void* pDat ) : VclSimpleEvent(n)
71 pWindow = pWin; pData = pDat;
74 VclWindowEvent::~VclWindowEvent() {}
76 VclMenuEvent::VclMenuEvent( Menu* pM, VclEventId n, sal_uInt16 nPos )
77 : VclSimpleEvent(n), pMenu(pM), mnPos(nPos)
80 VclMenuEvent::~VclMenuEvent()
83 Menu* VclMenuEvent::GetMenu() const
85 return pMenu;
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */