diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-02-18 13:38:12 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-02-18 15:48:31 +0000 |
commit | 548c2274c9ba7542d6bcae5fefd1400ee4e22fc3 (patch) | |
tree | 7963bec49ed00b89090bd213a7db36a85bc88f87 /vcl | |
parent | 423b79e7366203db3f57dea75b8cb9eb852b5614 (diff) |
move from boost::signal to typed Link
it doesn't really gain us much to have a handful of
boost::signal use in a sea of Links
This also fixes a regression in
commit 051b29e1025253f35f87a04e297760aa8b40611f
Author: Luboš Luňák <l.lunak@collabora.com>
Date: Sun Sep 14 15:45:02 2014 +0200
convert Edit autocomplete Hdl to boost signals2
where the conversion was...
- if ( maAutocompleteHdl.IsSet() )
+ if ( autocompleteSignal.empty() )
instead of the correct
+ if ( !autocompleteSignal.empty() )
Change-Id: I27270d94c782485c0a7e929bc4980af4527fe82b
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/listbox.hxx | 21 | ||||
-rw-r--r-- | vcl/inc/pch/precompiled_vcl.hxx | 2 | ||||
-rw-r--r-- | vcl/source/control/combobox.cxx | 44 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 34 | ||||
-rw-r--r-- | vcl/source/control/imp_listbox.cxx | 14 | ||||
-rw-r--r-- | vcl/source/control/listbox.cxx | 16 |
6 files changed, 44 insertions, 87 deletions
diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx index 611f6b07dfde..f316e8f7501d 100644 --- a/vcl/inc/listbox.hxx +++ b/vcl/inc/listbox.hxx @@ -24,8 +24,6 @@ #include <vcl/floatwin.hxx> #include <vcl/quickselectionengine.hxx> -#include <boost/signals2/signal.hpp> - #include <vector> #include <memory> @@ -231,6 +229,7 @@ private: Link<LinkParamNone*,void> maSelectHdl; Link<LinkParamNone*,void> maCancelHdl; Link<ImplListBoxWindow*,void> maDoubleClickHdl; + Link<UserDrawEvent*, void> maUserDrawHdl; Link<LinkParamNone*,void> maMRUChangedHdl; Link<sal_Int32,void> maFocusHdl; Link<LinkParamNone*,void> maListItemSelectHdl; @@ -332,11 +331,10 @@ public: void SetSelectHdl( const Link<LinkParamNone*,void>& rLink ) { maSelectHdl = rLink; } void SetCancelHdl( const Link<LinkParamNone*,void>& rLink ) { maCancelHdl = rLink; } void SetDoubleClickHdl( const Link<ImplListBoxWindow*,void>& rLink ) { maDoubleClickHdl = rLink; } + void SetUserDrawHdl( const Link<UserDrawEvent*, void>& rLink ) { maUserDrawHdl = rLink; } void SetMRUChangedHdl( const Link<LinkParamNone*,void>& rLink ) { maMRUChangedHdl = rLink; } void SetFocusHdl( const Link<sal_Int32,void>& rLink ) { maFocusHdl = rLink ; } - boost::signals2::signal< void ( UserDrawEvent* ) > userDrawSignal; - void SetListItemSelectHdl( const Link<LinkParamNone*,void>& rLink ) { maListItemSelectHdl = rLink ; } bool IsSelectionChanged() const { return mbSelectionChanged; } sal_uInt16 GetSelectModifier() const { return mnSelectModifier; } @@ -460,9 +458,7 @@ public: void SetSelectHdl( const Link<LinkParamNone*,void>& rLink ) { maLBWindow->SetSelectHdl( rLink ); } void SetCancelHdl( const Link<LinkParamNone*,void>& rLink ) { maLBWindow->SetCancelHdl( rLink ); } void SetDoubleClickHdl( const Link<ImplListBoxWindow*,void>& rLink ) { maLBWindow->SetDoubleClickHdl( rLink ); } - - boost::signals2::signal< void ( UserDrawEvent* ) > userDrawSignal; - + void SetUserDrawHdl( const Link<UserDrawEvent*, void>& rLink ) { maLBWindow->SetUserDrawHdl( rLink ); } void SetFocusHdl( const Link<sal_Int32,void>& rLink ) { maLBWindow->SetFocusHdl( rLink ); } void SetListItemSelectHdl( const Link<LinkParamNone*,void>& rLink ) { maLBWindow->SetListItemSelectHdl( rLink ); } void SetSelectionChangedHdl( const Link<sal_Int32,void>& rLnk ) { maLBWindow->GetEntryList()->SetSelectionChangedHdl( rLnk ); } @@ -535,6 +531,9 @@ private: Rectangle maFocusRect; Size maUserItemSize; + Link<void*,void> maMBDownHdl; + Link<UserDrawEvent*, void> maUserDrawHdl; + /// bitfield bool mbUserDrawEnabled : 1; bool mbInUserDraw : 1; @@ -563,8 +562,8 @@ public: void MBDown(); - boost::signals2::signal< void ( ImplWin* ) > buttonDownSignal; - boost::signals2::signal< void ( UserDrawEvent* ) > userDrawSignal; + void SetMBDownHdl( const Link<void*,void>& rLink ) { maMBDownHdl = rLink; } + void SetUserDrawHdl( const Link<UserDrawEvent*, void>& rLink ) { maUserDrawHdl = rLink; } void SetUserItemSize( const Size& rSz ) { maUserItemSize = rSz; } @@ -588,14 +587,14 @@ class ImplBtn : public PushButton { private: bool mbDown; + Link<void*,void> maMBDownHdl; public: ImplBtn( vcl::Window* pParent, WinBits nWinStyle = 0 ); virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; void MBDown(); - - boost::signals2::signal< void ( ImplBtn* ) > buttonDownSignal; + void SetMBDownHdl( const Link<void*,void>& rLink ) { maMBDownHdl = rLink; } }; void ImplInitDropDownButton( PushButton* pButton ); diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx index 4d79b7caac3b..d3ef8195580e 100644 --- a/vcl/inc/pch/precompiled_vcl.hxx +++ b/vcl/inc/pch/precompiled_vcl.hxx @@ -59,8 +59,6 @@ #include <boost/multi_array.hpp> #include <boost/optional.hpp> #include <boost/shared_array.hpp> -#include <boost/signals2/connection.hpp> -#include <boost/signals2/signal.hpp> #include <osl/conditn.hxx> #include <osl/diagnose.h> #include <osl/diagnose.hxx> diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 9d0bc7e1dc5b..c474cd350a9d 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -21,8 +21,6 @@ #include <set> -#include <boost/signals2/connection.hpp> - #include <comphelper/string.hxx> #include <tools/debug.hxx> #include <tools/rc.h> @@ -61,7 +59,6 @@ struct ComboBox::Impl sal_Int32 m_nMaxWidthChars; Link<ComboBox&,void> m_SelectHdl; Link<ComboBox&,void> m_DoubleClickHdl; - boost::signals2::scoped_connection m_AutocompleteConnection; explicit Impl(ComboBox & rThis) : m_rThis(rThis) @@ -82,13 +79,12 @@ struct ComboBox::Impl DECL_DLLPRIVATE_LINK_TYPED( ImplSelectHdl, LinkParamNone*, void ); DECL_DLLPRIVATE_LINK_TYPED( ImplCancelHdl, LinkParamNone*, void ); DECL_DLLPRIVATE_LINK_TYPED( ImplDoubleClickHdl, ImplListBoxWindow*, void ); + DECL_DLLPRIVATE_LINK_TYPED( ImplClickBtnHdl, void*, void ); DECL_DLLPRIVATE_LINK_TYPED( ImplPopupModeEndHdl, FloatingWindow*, void ); DECL_DLLPRIVATE_LINK_TYPED( ImplSelectionChangedHdl, sal_Int32, void ); + DECL_DLLPRIVATE_LINK_TYPED( ImplUserDrawHdl, UserDrawEvent*, void ); + DECL_DLLPRIVATE_LINK_TYPED( ImplAutocompleteHdl, Edit&, void ); DECL_DLLPRIVATE_LINK_TYPED( ImplListItemSelectHdl , LinkParamNone*, void ); - - void ImplClickButtonHandler( ImplBtn* ); - void ImplUserDrawHandler( UserDrawEvent* ); - void ImplAutocompleteHandler( Edit* ); }; @@ -215,8 +211,7 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) m_pImpl->m_pBtn = VclPtr<ImplBtn>::Create( this, WB_NOLIGHTBORDER | WB_RECTSTYLE ); ImplInitDropDownButton( m_pImpl->m_pBtn ); - m_pImpl->m_pBtn->buttonDownSignal.connect( [this]( ImplBtn* pImplBtn ) - { this->m_pImpl->ImplClickButtonHandler( pImplBtn ); } ); + m_pImpl->m_pBtn->SetMBDownHdl( LINK( m_pImpl.get(), ComboBox::Impl, ImplClickBtnHdl ) ); m_pImpl->m_pBtn->Show(); nEditStyle |= WB_NOBORDER; @@ -248,8 +243,7 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) m_pImpl->m_pImplLB->SetSelectHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplSelectHdl) ); m_pImpl->m_pImplLB->SetCancelHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplCancelHdl) ); m_pImpl->m_pImplLB->SetDoubleClickHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplDoubleClickHdl) ); - m_pImpl->m_pImplLB->userDrawSignal.connect( [this]( UserDrawEvent* pUserDrawEvent ) - { this->m_pImpl->ImplUserDrawHandler( pUserDrawEvent ); } ); + m_pImpl->m_pImplLB->SetUserDrawHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplUserDrawHdl) ); m_pImpl->m_pImplLB->SetSelectionChangedHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplSelectionChangedHdl) ); m_pImpl->m_pImplLB->SetListItemSelectHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplListItemSelectHdl) ); m_pImpl->m_pImplLB->Show(); @@ -293,25 +287,17 @@ void ComboBox::EnableAutocomplete( bool bEnable, bool bMatchCase ) m_pImpl->m_isMatchCase = bMatchCase; if ( bEnable ) - { - if( !m_pImpl->m_AutocompleteConnection.connected()) - { - m_pImpl->m_pSubEdit->SignalConnectAutocomplete( - &m_pImpl->m_AutocompleteConnection, - [this] (Edit *const pEdit) { m_pImpl->ImplAutocompleteHandler(pEdit); } - ); - } - } + m_pImpl->m_pSubEdit->SetAutocompleteHdl( LINK(m_pImpl.get(), ComboBox::Impl, ImplAutocompleteHdl) ); else - m_pImpl->m_AutocompleteConnection.disconnect(); + m_pImpl->m_pSubEdit->SetAutocompleteHdl( Link<Edit&,void>() ); } bool ComboBox::IsAutocompleteEnabled() const { - return m_pImpl->m_AutocompleteConnection.connected(); + return m_pImpl->m_pSubEdit->GetAutocompleteHdl().IsSet(); } -void ComboBox::Impl::ImplClickButtonHandler( ImplBtn* ) +IMPL_LINK_NOARG_TYPED(ComboBox::Impl, ImplClickBtnHdl, void*, void) { m_rThis.CallEventListeners( VCLEVENT_DROPDOWN_PRE_OPEN ); m_pSubEdit->GrabFocus(); @@ -352,10 +338,10 @@ IMPL_LINK_NOARG_TYPED(ComboBox::Impl, ImplPopupModeEndHdl, FloatingWindow*, void m_rThis.CallEventListeners( VCLEVENT_DROPDOWN_CLOSE ); } -void ComboBox::Impl::ImplAutocompleteHandler( Edit* pEdit ) +IMPL_LINK_TYPED(ComboBox::Impl, ImplAutocompleteHdl, Edit&, rEdit, void) { - Selection aSel = pEdit->GetSelection(); - AutocompleteAction eAction = pEdit->GetAutocompleteAction(); + Selection aSel = rEdit.GetSelection(); + AutocompleteAction eAction = rEdit.GetAutocompleteAction(); /* If there is no current selection do not auto complete on Tab/Shift-Tab since then we would not cycle to the next field. @@ -363,7 +349,7 @@ void ComboBox::Impl::ImplAutocompleteHandler( Edit* pEdit ) if ( aSel.Len() || ((eAction != AUTOCOMPLETE_TABFORWARD) && (eAction != AUTOCOMPLETE_TABBACKWARD)) ) { - OUString aFullText = pEdit->GetText(); + OUString aFullText = rEdit.GetText(); OUString aStartText = aFullText.copy( 0, (sal_Int32)aSel.Max() ); sal_Int32 nStart = m_pImplLB->GetCurrentPos(); @@ -407,7 +393,7 @@ void ComboBox::Impl::ImplAutocompleteHandler( Edit* pEdit ) { OUString aText = m_pImplLB->GetEntryList()->GetEntryText( nPos ); Selection aSelection( aText.getLength(), aStartText.getLength() ); - pEdit->SetText( aText, aSelection ); + rEdit.SetText( aText, aSelection ); } } } @@ -1319,7 +1305,7 @@ void ComboBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, D } -void ComboBox::Impl::ImplUserDrawHandler( UserDrawEvent* pEvent ) +IMPL_LINK_TYPED(ComboBox::Impl, ImplUserDrawHdl, UserDrawEvent*, pEvent, void) { m_rThis.UserDraw(*pEvent); } diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 7520cb416d0d..5af9723e181c 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -66,8 +66,6 @@ #include <officecfg/Office/Common.hxx> -#include <boost/signals2/signal.hpp> - #include <memory> using namespace ::com::sun::star; @@ -157,21 +155,14 @@ void Impl_IMEInfos::DestroyAttribs() nLen = 0; } -struct Edit::Impl -{ - boost::signals2::signal< void (Edit *) > m_AutocompleteSignal; -}; - Edit::Edit( WindowType nType ) : Control( nType ) - , m_pImpl(new Impl) { ImplInitEditData(); } Edit::Edit( vcl::Window* pParent, WinBits nStyle ) : Control( WINDOW_EDIT ) - , m_pImpl(new Impl) { ImplInitEditData(); ImplInit( pParent, nStyle ); @@ -179,7 +170,6 @@ Edit::Edit( vcl::Window* pParent, WinBits nStyle ) Edit::Edit( vcl::Window* pParent, const ResId& rResId ) : Control( WINDOW_EDIT ) - , m_pImpl(new Impl) { rResId.SetRT( RSC_EDIT ); WinBits nStyle = ImplInitRes( rResId ); @@ -1659,12 +1649,12 @@ bool Edit::ImplHandleKeyEvent( const KeyEvent& rKEvt ) ImplCopyToSelectionClipboard(); } - if (bGoEnd && !m_pImpl->m_AutocompleteSignal.empty() && !rKEvt.GetKeyCode().GetModifier()) + if (bGoEnd && maAutocompleteHdl.IsSet() && !rKEvt.GetKeyCode().GetModifier()) { if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.getLength()) ) { meAutocompleteAction = AUTOCOMPLETE_KEYINPUT; - m_pImpl->m_AutocompleteSignal( this ); + maAutocompleteHdl.Call(*this); } } @@ -1759,12 +1749,12 @@ bool Edit::ImplHandleKeyEvent( const KeyEvent& rKEvt ) if ( !mbReadOnly ) { ImplInsertText(OUString(rKEvt.GetCharCode()), nullptr, true); - if (!m_pImpl->m_AutocompleteSignal.empty()) + if (maAutocompleteHdl.IsSet()) { if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.getLength()) ) { meAutocompleteAction = AUTOCOMPLETE_KEYINPUT; - m_pImpl->m_AutocompleteSignal( this ); + maAutocompleteHdl.Call(*this); } } } @@ -2125,12 +2115,12 @@ void Edit::Command( const CommandEvent& rCEvt ) Invalidate(); // #i25161# call auto complete handler for ext text commit also - if (m_pImpl->m_AutocompleteSignal.empty()) + if (maAutocompleteHdl.IsSet()) { if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.getLength()) ) { meAutocompleteAction = AUTOCOMPLETE_KEYINPUT; - m_pImpl->m_AutocompleteSignal( this ); + maAutocompleteHdl.Call(*this); } } } @@ -2752,7 +2742,7 @@ void Edit::SetSubEdit(Edit* pEdit) mpSubEdit->mbIsSubEdit = true; mpSubEdit->SetReadOnly(mbReadOnly); - mpSubEdit->m_pImpl->m_AutocompleteSignal.connect(m_pImpl->m_AutocompleteSignal); + mpSubEdit->maAutocompleteHdl = maAutocompleteHdl; } } @@ -3079,14 +3069,4 @@ Selection Edit::GetSurroundingTextSelection() const return GetSelection(); } -void Edit::SignalConnectAutocomplete( - boost::signals2::connection *const pConnection, - std::function<void (Edit *)> slot) -{ - boost::signals2::connection const& rConnection( - m_pImpl->m_AutocompleteSignal.connect(slot)); - if (pConnection) - *pConnection = rConnection; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index 65fd57a0bd61..ed3d39cbd8fd 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -1745,7 +1745,7 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 nCurr = sal::static_int_cast<sal_Int32>(nCurr - GetEntryList()->GetMRUCount()); UserDrawEvent aUDEvt(this, &rRenderContext, aRect, nPos, nCurr); - userDrawSignal(&aUDEvt); + maUserDrawHdl.Call( &aUDEvt ); mbInUserDraw = false; } else @@ -2136,8 +2136,6 @@ ImplListBox::ImplListBox( vcl::Window* pParent, WinBits nWinStyle ) : Control( pParent, nWinStyle ), maLBWindow(VclPtr<ImplListBoxWindow>::Create( this, nWinStyle&(~WB_BORDER) )) { - maLBWindow->userDrawSignal.connect( userDrawSignal ); - // for native widget rendering we must be able to detect this window type SetType( WINDOW_LISTBOXWINDOW ); @@ -2611,8 +2609,8 @@ ImplWin::ImplWin( vcl::Window* pParent, WinBits nWinStyle ) : void ImplWin::MBDown() { - if( IsEnabled() ) - buttonDownSignal( this ); + if (IsEnabled()) + maMBDownHdl.Call(this); } void ImplWin::MouseButtonDown( const MouseEvent& ) @@ -2751,7 +2749,7 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout) { mbInUserDraw = true; UserDrawEvent aUDEvt(this, &rRenderContext, maFocusRect, mnItemPos, 0); - userDrawSignal( &aUDEvt ); + maUserDrawHdl.Call( &aUDEvt ); mbInUserDraw = false; } else @@ -2921,8 +2919,8 @@ ImplBtn::ImplBtn( vcl::Window* pParent, WinBits nWinStyle ) : void ImplBtn::MBDown() { - if( IsEnabled() ) - buttonDownSignal( this ); + if (IsEnabled()) + maMBDownHdl.Call(this); } void ImplBtn::MouseButtonDown( const MouseEvent& ) diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx index e7cc02617fe6..ba78bc64647b 100644 --- a/vcl/source/control/listbox.cxx +++ b/vcl/source/control/listbox.cxx @@ -137,18 +137,15 @@ void ListBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) mpFloatWin->GetDropTarget()->addDropTargetListener(xDrop); mpImplWin = VclPtr<ImplWin>::Create( this, (nStyle & (WB_LEFT|WB_RIGHT|WB_CENTER))|WB_NOBORDER ); - mpImplWin->buttonDownSignal.connect( [this]( Control* pControl ) - { this->ImplClickButtonHandler( pControl ); } ); - mpImplWin->userDrawSignal.connect( [this]( UserDrawEvent* pUserDrawEvent ) - { this->ImplUserDrawHandler( pUserDrawEvent ); } ); + mpImplWin->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) ); + mpImplWin->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) ); mpImplWin->Show(); mpImplWin->GetDropTarget()->addDropTargetListener(xDrop); mpImplWin->SetEdgeBlending(GetEdgeBlending()); mpBtn = VclPtr<ImplBtn>::Create( this, WB_NOLIGHTBORDER | WB_RECTSTYLE ); ImplInitDropDownButton( mpBtn ); - mpBtn->buttonDownSignal.connect( [this]( Control* pControl ) - { this->ImplClickButtonHandler( pControl ); } ); + mpBtn->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) ); mpBtn->Show(); mpBtn->GetDropTarget()->addDropTargetListener(xDrop); } @@ -161,8 +158,7 @@ void ListBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) mpImplLB->SetScrollHdl( LINK( this, ListBox, ImplScrollHdl ) ); mpImplLB->SetCancelHdl( LINK( this, ListBox, ImplCancelHdl ) ); mpImplLB->SetDoubleClickHdl( LINK( this, ListBox, ImplDoubleClickHdl ) ); - mpImplLB->userDrawSignal.connect( [this]( UserDrawEvent* pUserDrawEvent ) - { this->ImplUserDrawHandler( pUserDrawEvent ); } ); + mpImplLB->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) ); mpImplLB->SetFocusHdl( LINK( this, ListBox, ImplFocusHdl ) ); mpImplLB->SetListItemSelectHdl( LINK( this, ListBox, ImplListItemSelectHdl ) ); mpImplLB->SetPosPixel( Point() ); @@ -294,7 +290,7 @@ IMPL_LINK_NOARG_TYPED(ListBox, ImplDoubleClickHdl, ImplListBoxWindow*, void) DoubleClick(); } -void ListBox::ImplClickButtonHandler( Control* ) +IMPL_LINK_NOARG_TYPED(ListBox, ImplClickBtnHdl, void*, void) { if( !mpFloatWin->IsInPopupMode() ) { @@ -1381,7 +1377,7 @@ void ListBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines } } -void ListBox::ImplUserDrawHandler( UserDrawEvent* pEvent ) +IMPL_LINK_TYPED( ListBox, ImplUserDrawHdl, UserDrawEvent*, pEvent, void ) { UserDraw( *pEvent ); } |