summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-09-21 08:03:25 +0200
committerNoel Grandin <noel@peralex.com>2015-09-21 08:03:52 +0200
commit1e67e94f1a308ca60d4934e9fe9d5c048225ebe8 (patch)
treec3bdf0fcec6912bc84e835fe48a80ee9f9391106 /vcl
parentc916152d8562cab868d4c522748ac30029fad179 (diff)
convert Link<> to typed
Change-Id: If3e2b00092440ebd42ae5b73ae2b0e44c3702683
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/osx/a11yfocustracker.hxx2
-rw-r--r--vcl/inc/vcleventlisteners.hxx8
-rw-r--r--vcl/inc/window.h2
-rw-r--r--vcl/osx/a11yfocustracker.cxx24
-rw-r--r--vcl/source/app/svapp.cxx8
-rw-r--r--vcl/source/app/vclevent.cxx24
-rw-r--r--vcl/source/control/tabctrl.cxx10
-rw-r--r--vcl/source/window/event.cxx29
-rw-r--r--vcl/unx/gtk/a11y/atkutil.cxx24
9 files changed, 69 insertions, 62 deletions
diff --git a/vcl/inc/osx/a11yfocustracker.hxx b/vcl/inc/osx/a11yfocustracker.hxx
index 2dc3d82baf60..3dc39261a933 100644
--- a/vcl/inc/osx/a11yfocustracker.hxx
+++ b/vcl/inc/osx/a11yfocustracker.hxx
@@ -74,7 +74,7 @@ protected:
void toolbox_open_floater(vcl::Window *pWindow);
// callback function for Application::addEventListener
- static sal_IntPtr WindowEventHandler(void * pThis, void * pCaller);
+ static void WindowEventHandler(void * pThis, VclSimpleEvent&);
private:
// the accessible object that has the keyboard focus (if any)
diff --git a/vcl/inc/vcleventlisteners.hxx b/vcl/inc/vcleventlisteners.hxx
index 5be40e8634d2..e2f72bf6544b 100644
--- a/vcl/inc/vcleventlisteners.hxx
+++ b/vcl/inc/vcleventlisteners.hxx
@@ -34,11 +34,11 @@
class VCL_DLLPUBLIC VclEventListeners
{
public:
- void Call( VclSimpleEvent* pEvent ) const;
- void addListener( const Link<>& rListener );
- void removeListener( const Link<>& rListener );
+ void Call( VclSimpleEvent& rEvent ) const;
+ void addListener( const Link<VclSimpleEvent&,void>& rListener );
+ void removeListener( const Link<VclSimpleEvent&,void>& rListener );
private:
- std::vector<Link<>> m_aListeners;
+ std::vector<Link<VclSimpleEvent&,void>> m_aListeners;
};
#endif // INCLUDED_VCL_INC_VCLEVENTLISTENERS_HXX
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 00c1785067e7..4eebb7639cad 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -230,7 +230,7 @@ public:
VclPtr<vcl::Window> mpLastFocusWindow;
VclPtr<vcl::Window> mpDlgCtrlDownWindow;
std::vector<Link<VclWindowEvent&,void>> maEventListeners;
- VclEventListeners maChildEventListeners;
+ std::vector<Link<VclWindowEvent&,void>> maChildEventListeners;
// The canvas interface for this VCL window. Is persistent after the first GetCanvas() call
::com::sun::star::uno::WeakReference< ::com::sun::star::rendering::XCanvas > mxCanvas;
diff --git a/vcl/osx/a11yfocustracker.cxx b/vcl/osx/a11yfocustracker.cxx
index 0f3182deaffc..8823ba8df2fe 100644
--- a/vcl/osx/a11yfocustracker.cxx
+++ b/vcl/osx/a11yfocustracker.cxx
@@ -43,42 +43,40 @@ getWindow(const ::VclSimpleEvent *pEvent)
// callback function for Application::addEventListener
-sal_IntPtr AquaA11yFocusTracker::WindowEventHandler(
- void * pThis, void * pCaller)
+void AquaA11yFocusTracker::WindowEventHandler(void * pThis, VclSimpleEvent& rEvent)
{
AquaA11yFocusTracker *pFocusTracker = static_cast<AquaA11yFocusTracker *>(
pThis);
- VclSimpleEvent const *pEvent = static_cast<VclSimpleEvent const *>(pCaller);
- switch (pEvent->GetId())
+ switch (rEvent.GetId())
{
case VCLEVENT_WINDOW_PAINT:
- pFocusTracker-> toolbox_open_floater( getWindow(pEvent) );
+ pFocusTracker-> toolbox_open_floater( getWindow(&rEvent) );
break;
case VCLEVENT_WINDOW_GETFOCUS:
- pFocusTracker->window_got_focus( getWindow(pEvent) );
+ pFocusTracker->window_got_focus( getWindow(&rEvent) );
break;
case VCLEVENT_OBJECT_DYING:
- pFocusTracker->m_aDocumentWindowList.erase( getWindow(pEvent) );
+ pFocusTracker->m_aDocumentWindowList.erase( getWindow(&rEvent) );
// intentional pass through ..
case VCLEVENT_TOOLBOX_HIGHLIGHTOFF:
- pFocusTracker->toolbox_highlight_off( getWindow(pEvent) );
+ pFocusTracker->toolbox_highlight_off( getWindow(&rEvent) );
break;
case VCLEVENT_TOOLBOX_HIGHLIGHT:
- pFocusTracker->toolbox_highlight_on( getWindow(pEvent) );
+ pFocusTracker->toolbox_highlight_on( getWindow(&rEvent) );
break;
case VCLEVENT_TABPAGE_ACTIVATE:
- pFocusTracker->tabpage_activated( getWindow(pEvent) );
+ pFocusTracker->tabpage_activated( getWindow(&rEvent) );
break;
case VCLEVENT_MENU_HIGHLIGHT:
// Inspired by code in WindowEventHandler in
// vcl/unx/gtk/a11y/atkutil.cxx, find out what kind of event
// it is to avoid blindly using a static_cast and crash,
// fdo#47275.
- if( const VclMenuEvent* pMenuEvent = dynamic_cast < const VclMenuEvent* > (pEvent) )
+ if( const VclMenuEvent* pMenuEvent = dynamic_cast < const VclMenuEvent* > (&rEvent) )
{
pFocusTracker->menu_highlighted( pMenuEvent );
}
- else if( const VclAccessibleEvent* pAccEvent = dynamic_cast < const VclAccessibleEvent* > (pEvent) )
+ else if( const VclAccessibleEvent* pAccEvent = dynamic_cast < const VclAccessibleEvent* > (&rEvent) )
{
Reference< XAccessible > xAccessible = pAccEvent->GetAccessible();
if( xAccessible.is() )
@@ -88,8 +86,6 @@ sal_IntPtr AquaA11yFocusTracker::WindowEventHandler(
default:
break;
};
-
- return 0;
}
AquaA11yFocusTracker::AquaA11yFocusTracker() :
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index c57ca13d947e..b25b738b1c19 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -674,7 +674,7 @@ void Application::ImplCallEventListeners( sal_uLong nEvent, vcl::Window *pWin, v
VclWindowEvent aEvent( pWin, nEvent, pData );
if ( pSVData->maAppData.mpEventListeners )
- pSVData->maAppData.mpEventListeners->Call( &aEvent );
+ pSVData->maAppData.mpEventListeners->Call( aEvent );
}
void Application::ImplCallEventListeners( VclSimpleEvent& rEvent )
@@ -682,10 +682,10 @@ void Application::ImplCallEventListeners( VclSimpleEvent& rEvent )
ImplSVData* pSVData = ImplGetSVData();
if ( pSVData->maAppData.mpEventListeners )
- pSVData->maAppData.mpEventListeners->Call( &rEvent );
+ pSVData->maAppData.mpEventListeners->Call( rEvent );
}
-void Application::AddEventListener( const Link<>& rEventListener )
+void Application::AddEventListener( const Link<VclSimpleEvent&,void>& rEventListener )
{
ImplSVData* pSVData = ImplGetSVData();
if( !pSVData->maAppData.mpEventListeners )
@@ -693,7 +693,7 @@ void Application::AddEventListener( const Link<>& rEventListener )
pSVData->maAppData.mpEventListeners->addListener( rEventListener );
}
-void Application::RemoveEventListener( const Link<>& rEventListener )
+void Application::RemoveEventListener( const Link<VclSimpleEvent&,void>& rEventListener )
{
ImplSVData* pSVData = ImplGetSVData();
if( pSVData->maAppData.mpEventListeners )
diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx
index 6cc4523ba983..bcbe518f7b7b 100644
--- a/vcl/source/app/vclevent.cxx
+++ b/vcl/source/app/vclevent.cxx
@@ -43,25 +43,25 @@ VclAccessibleEvent::~VclAccessibleEvent()
}
-void VclEventListeners::Call( VclSimpleEvent* pEvent ) const
+void VclEventListeners::Call( VclSimpleEvent& rEvent ) const
{
if ( m_aListeners.empty() )
return;
// Copy the list, because this can be destroyed when calling a Link...
- std::vector<Link<>> aCopy( m_aListeners );
- std::vector<Link<>>::iterator aIter( aCopy.begin() );
- std::vector<Link<>>::const_iterator aEnd( aCopy.end() );
- if( pEvent->IsA( VclWindowEvent::StaticType() ) )
+ std::vector<Link<VclSimpleEvent&,void>> aCopy( m_aListeners );
+ std::vector<Link<VclSimpleEvent&,void>>::iterator aIter( aCopy.begin() );
+ std::vector<Link<VclSimpleEvent&,void>>::const_iterator aEnd( aCopy.end() );
+ if( rEvent.IsA( VclWindowEvent::StaticType() ) )
{
- VclWindowEvent* pWinEvent = static_cast<VclWindowEvent*>(pEvent);
+ VclWindowEvent* pWinEvent = static_cast<VclWindowEvent*>(&rEvent);
ImplDelData aDel( pWinEvent->GetWindow() );
while ( aIter != aEnd && ! aDel.IsDead() )
{
- Link<> &rLink = *aIter;
+ Link<VclSimpleEvent&,void> &rLink = *aIter;
// check this hasn't been removed in some re-enterancy scenario fdo#47368
if( std::find(m_aListeners.begin(), m_aListeners.end(), rLink) != m_aListeners.end() )
- rLink.Call( pEvent );
+ rLink.Call( rEvent );
++aIter;
}
}
@@ -69,20 +69,20 @@ void VclEventListeners::Call( VclSimpleEvent* pEvent ) const
{
while ( aIter != aEnd )
{
- Link<> &rLink = *aIter;
+ Link<VclSimpleEvent&,void> &rLink = *aIter;
if( std::find(m_aListeners.begin(), m_aListeners.end(), rLink) != m_aListeners.end() )
- rLink.Call( pEvent );
+ rLink.Call( rEvent );
++aIter;
}
}
}
-void VclEventListeners::addListener( const Link<>& rListener )
+void VclEventListeners::addListener( const Link<VclSimpleEvent&,void>& rListener )
{
m_aListeners.push_back( rListener );
}
-void VclEventListeners::removeListener( const Link<>& rListener )
+void VclEventListeners::removeListener( const Link<VclSimpleEvent&,void>& rListener )
{
m_aListeners.erase( std::remove(m_aListeners.begin(), m_aListeners.end(), rListener ), m_aListeners.end() );
}
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 2cda79ca6a34..a8f7a51a29d4 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -1008,19 +1008,17 @@ IMPL_LINK_NOARG(TabControl, ImplListBoxSelectHdl)
return 0;
}
-IMPL_LINK( TabControl, ImplWindowEventListener, VclSimpleEvent*, pEvent )
+IMPL_LINK_TYPED( TabControl, ImplWindowEventListener, VclWindowEvent&, rEvent, void )
{
- if ( pEvent && pEvent->ISA( VclWindowEvent ) && (pEvent->GetId() == VCLEVENT_WINDOW_KEYINPUT) )
+ if ( rEvent.GetId() == VCLEVENT_WINDOW_KEYINPUT )
{
- VclWindowEvent* pWindowEvent = static_cast< VclWindowEvent* >(pEvent);
// Do not handle events from TabControl or its children, which is done in Notify(), where the events can be consumed.
- if ( !IsWindowOrChild( pWindowEvent->GetWindow() ) )
+ if ( !IsWindowOrChild( rEvent.GetWindow() ) )
{
- KeyEvent* pKeyEvent = static_cast< KeyEvent* >(pWindowEvent->GetData());
+ KeyEvent* pKeyEvent = static_cast< KeyEvent* >(rEvent.GetData());
ImplHandleKeyEvent( *pKeyEvent );
}
}
- return 0;
}
void TabControl::MouseButtonDown( const MouseEvent& rMEvt )
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index 20ee6164abbb..fbbf24532ac7 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -214,8 +214,8 @@ void Window::CallEventListeners( sal_uLong nEvent, void* pData )
if (!mpWindowImpl->maEventListeners.empty())
{
- // Copy the list, because this can be destroyed when calling a Link...
- std::vector<Link<VclWindowEvent&,void>> aCopy( mpWindowImpl->maEventListeners );
+ // Copy the list, because this can be destroyed when calling a Link...
+ std::vector<Link<VclWindowEvent&,void>> aCopy( mpWindowImpl->maEventListeners );
for ( Link<VclWindowEvent&,void>& rLink : aCopy )
{
if (aDelData.IsDead()) break;
@@ -238,7 +238,19 @@ void Window::CallEventListeners( sal_uLong nEvent, void* pData )
if ( aDelData.IsDead() )
return;
- pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent );
+ if (!mpWindowImpl->maEventListeners.empty())
+ {
+ // Copy the list, because this can be destroyed when calling a Link...
+ std::vector<Link<VclWindowEvent&,void>> aCopy( mpWindowImpl->maChildEventListeners );
+ for ( Link<VclWindowEvent&,void>& rLink : aCopy )
+ {
+ if (aDelData.IsDead())
+ return;
+ // check this hasn't been removed in some re-enterancy scenario fdo#47368
+ if( std::find(mpWindowImpl->maChildEventListeners.begin(), mpWindowImpl->maChildEventListeners.end(), rLink) != mpWindowImpl->maChildEventListeners.end() )
+ rLink.Call( aEvent );
+ }
+ }
if ( aDelData.IsDead() )
return;
@@ -268,15 +280,18 @@ void Window::RemoveEventListener( const Link<VclWindowEvent&,void>& rEventListen
}
}
-void Window::AddChildEventListener( const Link<>& rEventListener )
+void Window::AddChildEventListener( const Link<VclWindowEvent&,void>& rEventListener )
{
- mpWindowImpl->maChildEventListeners.addListener( rEventListener );
+ mpWindowImpl->maChildEventListeners.push_back( rEventListener );
}
-void Window::RemoveChildEventListener( const Link<>& rEventListener )
+void Window::RemoveChildEventListener( const Link<VclWindowEvent&,void>& rEventListener )
{
if (mpWindowImpl)
- mpWindowImpl->maChildEventListeners.removeListener( rEventListener );
+ {
+ auto& rListeners = mpWindowImpl->maChildEventListeners;
+ rListeners.erase( std::remove(rListeners.begin(), rListeners.end(), rEventListener ), rListeners.end() );
+ }
}
ImplSVEvent * Window::PostUserEvent( const Link<void*,void>& rLink, void* pCaller, bool bReferenceLink )
diff --git a/vcl/unx/gtk/a11y/atkutil.cxx b/vcl/unx/gtk/a11y/atkutil.cxx
index c3eb4a50485a..d77b4a913189 100644
--- a/vcl/unx/gtk/a11y/atkutil.cxx
+++ b/vcl/unx/gtk/a11y/atkutil.cxx
@@ -577,12 +577,11 @@ static void handle_menu_highlighted(::VclMenuEvent const * pEvent)
/*****************************************************************************/
-sal_IntPtr WindowEventHandler(void *, void * p)
+void WindowEventHandler(void *, VclSimpleEvent& rEvent)
{
- VclSimpleEvent * pEvent = static_cast<VclSimpleEvent *>(p);
try
{
- switch (pEvent->GetId())
+ switch (rEvent.GetId())
{
case VCLEVENT_WINDOW_SHOW:
break;
@@ -591,7 +590,7 @@ sal_IntPtr WindowEventHandler(void *, void * p)
case VCLEVENT_WINDOW_CLOSE:
break;
case VCLEVENT_WINDOW_GETFOCUS:
- handle_get_focus(static_cast< ::VclWindowEvent const * >(pEvent));
+ handle_get_focus(static_cast< ::VclWindowEvent const * >(&rEvent));
break;
case VCLEVENT_WINDOW_LOSEFOCUS:
break;
@@ -606,11 +605,11 @@ sal_IntPtr WindowEventHandler(void *, void * p)
break;
case VCLEVENT_MENU_HIGHLIGHT:
- if (const VclMenuEvent* pMenuEvent = dynamic_cast<const VclMenuEvent*>(pEvent))
+ if (const VclMenuEvent* pMenuEvent = dynamic_cast<const VclMenuEvent*>(&rEvent))
{
handle_menu_highlighted(pMenuEvent);
}
- else if (const VclAccessibleEvent* pAccEvent = dynamic_cast<const VclAccessibleEvent*>(pEvent))
+ else if (const VclAccessibleEvent* pAccEvent = dynamic_cast<const VclAccessibleEvent*>(&rEvent))
{
uno::Reference< accessibility::XAccessible > xAccessible = pAccEvent->GetAccessible();
if (xAccessible.is())
@@ -619,22 +618,22 @@ sal_IntPtr WindowEventHandler(void *, void * p)
break;
case VCLEVENT_TOOLBOX_HIGHLIGHT:
- handle_toolbox_highlight(static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow());
+ handle_toolbox_highlight(static_cast< ::VclWindowEvent const * >(&rEvent)->GetWindow());
break;
case VCLEVENT_TOOLBOX_BUTTONSTATECHANGED:
- handle_toolbox_buttonchange(static_cast< ::VclWindowEvent const * >(pEvent));
+ handle_toolbox_buttonchange(static_cast< ::VclWindowEvent const * >(&rEvent));
break;
case VCLEVENT_OBJECT_DYING:
- g_aWindowList.erase( static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow() );
+ g_aWindowList.erase( static_cast< ::VclWindowEvent const * >(&rEvent)->GetWindow() );
// fallthrough intentional !
case VCLEVENT_TOOLBOX_HIGHLIGHTOFF:
- handle_toolbox_highlightoff(static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow());
+ handle_toolbox_highlightoff(static_cast< ::VclWindowEvent const * >(&rEvent)->GetWindow());
break;
case VCLEVENT_TABPAGE_ACTIVATE:
- handle_tabpage_activated(static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow());
+ handle_tabpage_activated(static_cast< ::VclWindowEvent const * >(&rEvent)->GetWindow());
break;
case VCLEVENT_COMBOBOX_SETTEXT:
@@ -653,10 +652,9 @@ sal_IntPtr WindowEventHandler(void *, void * p)
{
g_warning("Focused object has invalid index in parent");
}
- return 0;
}
-static Link<> g_aEventListenerLink( NULL, WindowEventHandler );
+static Link<VclSimpleEvent&,void> g_aEventListenerLink( NULL, WindowEventHandler );
/*****************************************************************************/