Kaydet (Commit) 71a83295 authored tarafından Noel Grandin's avatar Noel Grandin

convert Link<> to typed

and remove unused maChildEventListeners

Change-Id: I845a9af608c3429cf9ccb0e8041f24f423839513
üst c80fb092
...@@ -112,7 +112,7 @@ protected: ...@@ -112,7 +112,7 @@ protected:
virtual void Click(); virtual void Click();
virtual bool IsPopupMenuOpen(); virtual bool IsPopupMenuOpen();
DECL_LINK( MenuEventListener, VclSimpleEvent* ); DECL_LINK_TYPED( MenuEventListener, VclMenuEvent&, void );
void ProcessMenuEvent( const VclMenuEvent& rVclMenuEvent ); void ProcessMenuEvent( const VclMenuEvent& rVclMenuEvent );
......
...@@ -566,15 +566,10 @@ bool OAccessibleMenuBaseComponent::IsPopupMenuOpen() ...@@ -566,15 +566,10 @@ bool OAccessibleMenuBaseComponent::IsPopupMenuOpen()
IMPL_LINK( OAccessibleMenuBaseComponent, MenuEventListener, VclSimpleEvent*, pEvent ) IMPL_LINK_TYPED( OAccessibleMenuBaseComponent, MenuEventListener, VclMenuEvent&, rEvent, void )
{ {
OSL_ENSURE( pEvent && pEvent->ISA( VclMenuEvent ), "OAccessibleMenuBaseComponent - Unknown MenuEvent!" ); OSL_ENSURE( rEvent.GetMenu(), "OAccessibleMenuBaseComponent - Menu?" );
if ( pEvent && pEvent->ISA( VclMenuEvent ) ) ProcessMenuEvent( rEvent );
{
OSL_ENSURE( static_cast<VclMenuEvent*>(pEvent)->GetMenu(), "OAccessibleMenuBaseComponent - Menu?" );
ProcessMenuEvent( *static_cast<VclMenuEvent*>(pEvent) );
}
return 0;
} }
......
...@@ -40,6 +40,7 @@ class Menu; ...@@ -40,6 +40,7 @@ class Menu;
class MenuBar; class MenuBar;
class VclSimpleEvent; class VclSimpleEvent;
class PopupMenu; class PopupMenu;
class VclMenuEvent;
typedef ::std::vector< typedef ::std::vector<
css::uno::Reference< css::awt::XPopupMenu >* css::uno::Reference< css::awt::XPopupMenu >*
...@@ -65,7 +66,7 @@ private: ...@@ -65,7 +66,7 @@ private:
protected: protected:
::osl::Mutex& GetMutex() { return maMutex; } ::osl::Mutex& GetMutex() { return maMutex; }
DECL_LINK( MenuEventListener, VclSimpleEvent* ); DECL_LINK_TYPED( MenuEventListener, VclMenuEvent&, void );
void ImplCreateMenu( bool bPopup ); void ImplCreateMenu( bool bPopup );
......
...@@ -141,8 +141,7 @@ private: ...@@ -141,8 +141,7 @@ private:
Link<Menu*, bool> aHighlightHdl; // Highlight-Handler Link<Menu*, bool> aHighlightHdl; // Highlight-Handler
Link<Menu*, bool> aSelectHdl; // Highlight-Handler Link<Menu*, bool> aSelectHdl; // Highlight-Handler
VclEventListeners maEventListeners; std::list<Link<VclMenuEvent&,void> > maEventListeners;
VclEventListeners maChildEventListeners;
OUString aTitleText; // PopupMenu text OUString aTitleText; // PopupMenu text
sal_uInt16 nTitleHeight; sal_uInt16 nTitleHeight;
...@@ -357,8 +356,8 @@ public: ...@@ -357,8 +356,8 @@ public:
return nTitleHeight; return nTitleHeight;
} }
void AddEventListener( const Link<>& rEventListener ); void AddEventListener( const Link<VclMenuEvent&,void>& rEventListener );
void RemoveEventListener( const Link<>& rEventListener ); void RemoveEventListener( const Link<VclMenuEvent&,void>& rEventListener );
Menu& operator =( const Menu& rMenu ); Menu& operator =( const Menu& rMenu );
......
...@@ -226,7 +226,7 @@ private: ...@@ -226,7 +226,7 @@ private:
DECL_DLLPRIVATE_LINK_TYPED( ImplCallExecuteCustomMenu, void*, void ); DECL_DLLPRIVATE_LINK_TYPED( ImplCallExecuteCustomMenu, void*, void );
DECL_DLLPRIVATE_LINK_TYPED( ImplUpdateHdl, Idle*, void ); DECL_DLLPRIVATE_LINK_TYPED( ImplUpdateHdl, Idle*, void );
DECL_DLLPRIVATE_LINK( ImplCustomMenuListener, VclMenuEvent* ); DECL_DLLPRIVATE_LINK_TYPED( ImplCustomMenuListener, VclMenuEvent&, void );
DECL_DLLPRIVATE_LINK_TYPED( ImplDropdownLongClickHdl, Timer*, void ); DECL_DLLPRIVATE_LINK_TYPED( ImplDropdownLongClickHdl, Timer*, void );
ToolBox (const ToolBox &) SAL_DELETED_FUNCTION; ToolBox (const ToolBox &) SAL_DELETED_FUNCTION;
......
...@@ -79,17 +79,13 @@ void VCLXMenu::ImplCreateMenu( bool bPopup ) ...@@ -79,17 +79,13 @@ void VCLXMenu::ImplCreateMenu( bool bPopup )
mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) ); mpMenu->AddEventListener( LINK( this, VCLXMenu, MenuEventListener ) );
} }
IMPL_LINK( VCLXMenu, MenuEventListener, VclSimpleEvent*, pEvent ) IMPL_LINK_TYPED( VCLXMenu, MenuEventListener, VclMenuEvent&, rMenuEvent, void )
{ {
DBG_ASSERT( pEvent && pEvent->ISA( VclMenuEvent ), "Unknown Event!" ); DBG_ASSERT( rMenuEvent.GetMenu() && mpMenu, "Menu???" );
if ( pEvent && pEvent->ISA( VclMenuEvent ) )
{
DBG_ASSERT( static_cast<VclMenuEvent*>(pEvent)->GetMenu() && mpMenu, "Menu???" );
VclMenuEvent* pMenuEvent = static_cast<VclMenuEvent*>(pEvent); if ( rMenuEvent.GetMenu() == mpMenu ) // Also called for the root menu
if ( pMenuEvent->GetMenu() == mpMenu ) // Also called for the root menu
{ {
switch ( pMenuEvent->GetId() ) switch ( rMenuEvent.GetId() )
{ {
case VCLEVENT_MENU_SELECT: case VCLEVENT_MENU_SELECT:
{ {
...@@ -160,8 +156,6 @@ IMPL_LINK( VCLXMenu, MenuEventListener, VclSimpleEvent*, pEvent ) ...@@ -160,8 +156,6 @@ IMPL_LINK( VCLXMenu, MenuEventListener, VclSimpleEvent*, pEvent )
default: OSL_FAIL( "MenuEventListener - Unknown event!" ); default: OSL_FAIL( "MenuEventListener - Unknown event!" );
} }
} }
}
return 0;
} }
......
...@@ -340,31 +340,29 @@ void Menu::ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos ) ...@@ -340,31 +340,29 @@ void Menu::ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos )
} }
if ( !aDelData.isDeleted() ) if ( !aDelData.isDeleted() )
maEventListeners.Call( &aEvent );
if( !aDelData.isDeleted() )
{ {
Menu* pMenu = this; // Copy the list, because this can be destroyed when calling a Link...
while ( pMenu ) std::list<Link<VclMenuEvent&,void>> aCopy( maEventListeners );
std::list<Link<VclMenuEvent&,void>>::iterator aIter( aCopy.begin() );
std::list<Link<VclMenuEvent&,void>>::const_iterator aEnd( aCopy.end() );
while ( aIter != aEnd )
{ {
maChildEventListeners.Call( &aEvent ); Link<VclMenuEvent&,void> &rLink = *aIter;
if( std::find(maEventListeners.begin(), maEventListeners.end(), rLink) != maEventListeners.end() )
if( aDelData.isDeleted() ) rLink.Call( aEvent );
break; ++aIter;
pMenu = ( pMenu->pStartedFrom != pMenu ) ? pMenu->pStartedFrom : NULL;
} }
} }
} }
void Menu::AddEventListener( const Link<>& rEventListener ) void Menu::AddEventListener( const Link<VclMenuEvent&,void>& rEventListener )
{ {
maEventListeners.addListener( rEventListener ); maEventListeners.push_back( rEventListener );
} }
void Menu::RemoveEventListener( const Link<>& rEventListener ) void Menu::RemoveEventListener( const Link<VclMenuEvent&,void>& rEventListener )
{ {
maEventListeners.removeListener( rEventListener ); maEventListeners.remove( rEventListener );
} }
MenuItemData* Menu::NbcInsertItem(sal_uInt16 nId, MenuItemBits nBits, MenuItemData* Menu::NbcInsertItem(sal_uInt16 nId, MenuItemBits nBits,
......
...@@ -1851,15 +1851,14 @@ void ToolBox::UpdateCustomMenu() ...@@ -1851,15 +1851,14 @@ void ToolBox::UpdateCustomMenu()
} }
} }
IMPL_LINK( ToolBox, ImplCustomMenuListener, VclMenuEvent*, pEvent ) IMPL_LINK_TYPED( ToolBox, ImplCustomMenuListener, VclMenuEvent&, rEvent, void )
{ {
if( pEvent->GetMenu() == GetMenu() && pEvent->GetId() == VCLEVENT_MENU_SELECT ) if( rEvent.GetMenu() == GetMenu() && rEvent.GetId() == VCLEVENT_MENU_SELECT )
{ {
sal_uInt16 id = GetMenu()->GetItemId( pEvent->GetItemPos() ); sal_uInt16 id = GetMenu()->GetItemId( rEvent.GetItemPos() );
if( id >= TOOLBOX_MENUITEM_START ) if( id >= TOOLBOX_MENUITEM_START )
TriggerItem( id - TOOLBOX_MENUITEM_START, false ); TriggerItem( id - TOOLBOX_MENUITEM_START, false );
} }
return 0;
} }
IMPL_LINK_NOARG_TYPED(ToolBox, ImplCallExecuteCustomMenu, void*, void) IMPL_LINK_NOARG_TYPED(ToolBox, ImplCallExecuteCustomMenu, void*, void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment