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
This commit is contained in:
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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() )
|
||||
{
|
||||
|
@@ -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 )
|
||||
|
@@ -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; }
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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 )
|
||||
|
@@ -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()
|
||||
|
@@ -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 )
|
||||
|
@@ -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()
|
||||
|
@@ -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 )
|
||||
|
Reference in New Issue
Block a user