include/vcl/ctrl.hxx | 8 +++----- sc/source/ui/condformat/condformatdlgentry.cxx | 2 +- svtools/source/table/tablecontrol.cxx | 2 +- vcl/source/control/button.cxx | 8 ++++---- vcl/source/control/combobox.cxx | 4 ++-- vcl/source/control/ctrl.cxx | 8 ++++---- vcl/source/control/edit.cxx | 2 +- vcl/source/control/fixedhyper.cxx | 2 +- vcl/source/control/lstbox.cxx | 4 ++-- vcl/source/control/scrbar.cxx | 4 ++-- vcl/source/control/spinbtn.cxx | 4 ++-- vcl/source/control/spinfld.cxx | 8 ++++---- 12 files changed, 27 insertions(+), 29 deletions(-)
New commits: commit a50cd18768289c65debeed5ec507cf37095365b8 Author: Noel Grandin <n...@peralex.com> Date: Mon Aug 17 11:33:14 2015 +0200 make Control::ImplCallEventListenersAndHandler take a lambda so that we make the Link<> calls type-safe, without having to make this a template method Change-Id: I2e36bd6aa7c63440f72d266b593e101965b5ebce diff --git a/include/vcl/ctrl.hxx b/include/vcl/ctrl.hxx index 0f689d0..115d9dd 100644 --- a/include/vcl/ctrl.hxx +++ b/include/vcl/ctrl.hxx @@ -69,15 +69,13 @@ protected: @param nEvent the event to notify to our event listeners - @param rHandler - the handler to call - @param pCaller - the parameter to pass to the handler call + @param callHandler + the lambda function that calls the handler @return if the Control instance has been destroyed in any of the call */ bool ImplCallEventListenersAndHandler( - sal_uLong nEvent, const Link<>& rHandler, void* pCaller + sal_uLong nEvent, std::function<void()> callHandler ); /** draws the given text onto the given device diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index b48a82b..4365f94 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -78,7 +78,7 @@ bool ScCondFrmtEntry::Notify( NotifyEvent& rNEvt ) { if( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN ) { - ImplCallEventListenersAndHandler( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, maClickHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, [this] () { maClickHdl.Call(this); } ); } return Control::Notify(rNEvt); } diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index d9092aa..4a9632c 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -652,7 +652,7 @@ namespace svt { namespace table void TableControl::Select() { - ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_pImpl->getSelectHandler(), this ); + ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, [this] () { m_pImpl->getSelectHandler().Call(this); } ); if ( m_pImpl->isAccessibleAlive() ) { diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 0157b7d..a1c0dea 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -114,7 +114,7 @@ void Button::SetCommandHandler(const OUString& aCommand) void Button::Click() { - ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, maClickHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, [this] () { maClickHdl.Call(this); } ); } OUString Button::GetStandardText( StandardButtonType eButton ) @@ -1548,7 +1548,7 @@ bool PushButton::PreNotify( NotifyEvent& rNEvt ) void PushButton::Toggle() { - ImplCallEventListenersAndHandler( VCLEVENT_PUSHBUTTON_TOGGLE, maToggleHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_PUSHBUTTON_TOGGLE, [this] () { maToggleHdl.Call(this); } ); } void PushButton::SetSymbol( SymbolType eSymbol ) @@ -2640,7 +2640,7 @@ bool RadioButton::PreNotify( NotifyEvent& rNEvt ) void RadioButton::Toggle() { - ImplCallEventListenersAndHandler( VCLEVENT_RADIOBUTTON_TOGGLE, maToggleHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_RADIOBUTTON_TOGGLE, [this] () { maToggleHdl.Call(this); } ); } bool RadioButton::SetModeRadioImage( const Image& rImage ) @@ -3595,7 +3595,7 @@ bool CheckBox::PreNotify( NotifyEvent& rNEvt ) void CheckBox::Toggle() { - ImplCallEventListenersAndHandler( VCLEVENT_CHECKBOX_TOGGLE, maToggleHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_CHECKBOX_TOGGLE, [this] () { maToggleHdl.Call(this); } ); } void CheckBox::SetState( TriState eState ) diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 7703b30..f7409eb 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -556,12 +556,12 @@ void ComboBox::ToggleDropDown() void ComboBox::Select() { - ImplCallEventListenersAndHandler( VCLEVENT_COMBOBOX_SELECT, m_pImpl->m_SelectHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_COMBOBOX_SELECT, [this] () { m_pImpl->m_SelectHdl.Call(this); } ); } void ComboBox::DoubleClick() { - ImplCallEventListenersAndHandler( VCLEVENT_COMBOBOX_DOUBLECLICK, m_pImpl->m_DoubleClickHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_COMBOBOX_DOUBLECLICK, [this] () { m_pImpl->m_DoubleClickHdl.Call(this); } ); } bool ComboBox::IsAutoSizeEnabled() const { return m_pImpl->m_isDDAutoSize; } diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index 6062d1a..7eafeb3 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -258,7 +258,7 @@ bool Control::Notify( NotifyEvent& rNEvt ) { mbHasControlFocus = true; CompatStateChanged( StateChangedType::ControlFocus ); - if ( ImplCallEventListenersAndHandler( VCLEVENT_CONTROL_GETFOCUS, maGetFocusHdl, this ) ) + if ( ImplCallEventListenersAndHandler( VCLEVENT_CONTROL_GETFOCUS, [this] () { maGetFocusHdl.Call(this); } ) ) // been destroyed within the handler return true; } @@ -272,7 +272,7 @@ bool Control::Notify( NotifyEvent& rNEvt ) { mbHasControlFocus = false; CompatStateChanged( StateChangedType::ControlFocus ); - if ( ImplCallEventListenersAndHandler( VCLEVENT_CONTROL_LOSEFOCUS, maLoseFocusHdl, this ) ) + if ( ImplCallEventListenersAndHandler( VCLEVENT_CONTROL_LOSEFOCUS, [this] () { maLoseFocusHdl.Call(this); } ) ) // been destroyed within the handler return true; } @@ -320,7 +320,7 @@ void Control::AppendLayoutData( const Control& rSubControl ) const } } -bool Control::ImplCallEventListenersAndHandler( sal_uLong nEvent, const Link<>& rHandler, void* pCaller ) +bool Control::ImplCallEventListenersAndHandler( sal_uLong nEvent, std::function<void()> callHandler ) { VclPtr<Control> xThis(this); @@ -328,7 +328,7 @@ bool Control::ImplCallEventListenersAndHandler( sal_uLong nEvent, const Link<>& if ( !xThis->IsDisposed() ) { - rHandler.Call( pCaller ); + callHandler(); if ( !xThis->IsDisposed() ) return false; diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index b4e56f4..8461583 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2416,7 +2416,7 @@ void Edit::Modify() if ( mpUpdateDataTimer ) mpUpdateDataTimer->Start(); - if ( ImplCallEventListenersAndHandler( VCLEVENT_EDIT_MODIFY, maModifyHdl, this ) ) + if ( ImplCallEventListenersAndHandler( VCLEVENT_EDIT_MODIFY, [this] () { maModifyHdl.Call(this); } ) ) // have been destroyed while calling into the handlers return; diff --git a/vcl/source/control/fixedhyper.cxx b/vcl/source/control/fixedhyper.cxx index 4fb5af4..b7a2759 100644 --- a/vcl/source/control/fixedhyper.cxx +++ b/vcl/source/control/fixedhyper.cxx @@ -77,7 +77,7 @@ void FixedHyperlink::MouseButtonUp( const MouseEvent& ) { // calls the link if the control is enabled and the mouse is over the text. if ( IsEnabled() && ImplIsOverText(GetPointerPosPixel()) ) - ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, m_aClickHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, [this] () { m_aClickHdl.Call(this); } ); } void FixedHyperlink::RequestHelp( const HelpEvent& rHEvt ) diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index ba085d7..b89f7f3 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -972,12 +972,12 @@ bool ListBox::PreNotify( NotifyEvent& rNEvt ) void ListBox::Select() { - ImplCallEventListenersAndHandler( VCLEVENT_LISTBOX_SELECT, maSelectHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_LISTBOX_SELECT, [this] () { maSelectHdl.Call(this); } ); } void ListBox::DoubleClick() { - ImplCallEventListenersAndHandler( VCLEVENT_LISTBOX_DOUBLECLICK, maDoubleClickHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_LISTBOX_DOUBLECLICK, [this] () { maDoubleClickHdl.Call(this); } ); } void ListBox::Clear() diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx index 8a4345f..0246276 100644 --- a/vcl/source/control/scrbar.cxx +++ b/vcl/source/control/scrbar.cxx @@ -1323,12 +1323,12 @@ bool ScrollBar::PreNotify( NotifyEvent& rNEvt ) void ScrollBar::Scroll() { - ImplCallEventListenersAndHandler( VCLEVENT_SCROLLBAR_SCROLL, maScrollHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_SCROLLBAR_SCROLL, [this] () { maScrollHdl.Call(this); } ); } void ScrollBar::EndScroll() { - ImplCallEventListenersAndHandler( VCLEVENT_SCROLLBAR_ENDSCROLL, maEndScrollHdl, this ); + ImplCallEventListenersAndHandler( VCLEVENT_SCROLLBAR_ENDSCROLL, [this] () { maEndScrollHdl.Call(this); } ); } long ScrollBar::DoScroll( long nNewPos ) diff --git a/vcl/source/control/spinbtn.cxx b/vcl/source/control/spinbtn.cxx index ad47e9f..4651f9b 100644 --- a/vcl/source/control/spinbtn.cxx +++ b/vcl/source/control/spinbtn.cxx @@ -81,7 +81,7 @@ void SpinButton::Up() ImplMoveFocus(true); } - ImplCallEventListenersAndHandler(VCLEVENT_SPINBUTTON_UP, maUpHdlLink, this); + ImplCallEventListenersAndHandler(VCLEVENT_SPINBUTTON_UP, [this] () { maUpHdlLink.Call(this); } ); } void SpinButton::Down() @@ -94,7 +94,7 @@ void SpinButton::Down() ImplMoveFocus(false); } - ImplCallEventListenersAndHandler(VCLEVENT_SPINBUTTON_DOWN, maDownHdlLink, this); + ImplCallEventListenersAndHandler(VCLEVENT_SPINBUTTON_DOWN, [this] () { maDownHdlLink.Call(this); } ); } void SpinButton::Resize() diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index 7541eef..e7058f8 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -383,22 +383,22 @@ void SpinField::dispose() void SpinField::Up() { - ImplCallEventListenersAndHandler( VCLEVENT_SPINFIELD_UP, maUpHdlLink, this ); + ImplCallEventListenersAndHandler( VCLEVENT_SPINFIELD_UP, [this] () { maUpHdlLink.Call(this); } ); } void SpinField::Down() { - ImplCallEventListenersAndHandler( VCLEVENT_SPINFIELD_DOWN, maDownHdlLink, this ); + ImplCallEventListenersAndHandler( VCLEVENT_SPINFIELD_DOWN, [this] () { maDownHdlLink.Call(this); } ); } void SpinField::First() { - ImplCallEventListenersAndHandler( VCLEVENT_SPINFIELD_FIRST, maFirstHdlLink, this ); + ImplCallEventListenersAndHandler( VCLEVENT_SPINFIELD_FIRST, [this] () { maFirstHdlLink.Call(this); } ); } void SpinField::Last() { - ImplCallEventListenersAndHandler( VCLEVENT_SPINFIELD_LAST, maLastHdlLink, this ); + ImplCallEventListenersAndHandler( VCLEVENT_SPINFIELD_LAST, [this] () { maLastHdlLink.Call(this); } ); } void SpinField::MouseButtonDown( const MouseEvent& rMEvt ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits