--- toolbarmanager_old.cxx 2007-11-26 21:45:28.000000000 +0800 +++ toolbarmanager_new.cxx 2008-04-16 10:21:54.000000000 +0800 @@ -362,6 +362,9 @@ if ( !aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, OUString::createFromAscii( "CreateDialog" ))) nMenuType |= TOOLBOX_MENUTYPE_CUSTOMIZE; m_pToolBar->SetMenuType( nMenuType ); + //added for issue33668 by shizhoubo + m_pToolBar->SetCommandHdl( LINK( this, ToolBarManager, Command ) ); + //end m_pToolBar->SetMenuButtonHdl( LINK( this, ToolBarManager, MenuButton ) ); m_pToolBar->GetMenu()->SetSelectHdl( LINK( this, ToolBarManager, MenuSelect ) ); m_pToolBar->GetMenu()->SetDeactivateHdl( LINK( this, ToolBarManager, MenuDeactivate ) ); @@ -1697,130 +1700,159 @@ return true; } -IMPL_LINK( ToolBarManager, MenuButton, ToolBox*, pToolBar ) +//added for i33668 by shizhoubo : 200804 +PopupMenu * ToolBarManager::GetToolBarCustomMeun(ToolBox* pToolBar) { - ResetableGuard aGuard( m_aLock ); - - if ( m_bDisposed ) - return 1; - - PopupMenu *pMenu = pToolBar->GetMenu(); - // remove all entries before inserting new ones - ImplClearPopupMenu( pToolBar ); - - // No config menu entries if command ".uno:ConfigureDialog" is not enabled - Reference< XDispatch > xDisp; - com::sun::star::util::URL aURL; - if ( m_xFrame.is() ) - { - Reference< XDispatchProvider > xProv( m_xFrame, UNO_QUERY ); - Reference< XURLTransformer > xTrans( m_xServiceManager->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); - aURL.Complete = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConfigureDialog" )); - xTrans->parseStrict( aURL ); - if ( xProv.is() ) - xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 ); + PopupMenu *pMenu = pToolBar->GetMenu(); + // remove all entries before inserting new ones + ImplClearPopupMenu( pToolBar ); + // No config menu entries if command ".uno:ConfigureDialog" is not enabled + Reference< XDispatch > xDisp; + com::sun::star::util::URL aURL; + if ( m_xFrame.is() ) + { + Reference< XDispatchProvider > xProv( m_xFrame, UNO_QUERY ); + Reference< XURLTransformer > xTrans( m_xServiceManager->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); + aURL.Complete = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConfigureDialog" )); + xTrans->parseStrict( aURL ); + if ( xProv.is() ) + xDisp = xProv->queryDispatch( aURL, ::rtl::OUString(), 0 ); - if ( !xDisp.is() || IsPluginMode() ) - return 1; - } + if ( !xDisp.is() || IsPluginMode() ) + return 0; + } // popup menu for quick customization - sal_Bool bHideDisabledEntries = !SvtMenuOptions().IsEntryHidingEnabled(); - PopupMenu aPopupMenu( FwkResId( POPUPMENU_TOOLBAR_QUICKCUSTOMIZATION )); + sal_Bool bHideDisabledEntries = !SvtMenuOptions().IsEntryHidingEnabled(); + PopupMenu aPopupMenu( FwkResId( POPUPMENU_TOOLBAR_QUICKCUSTOMIZATION )); if ( m_pToolBar->IsCustomize() ) { - USHORT nPos( 0 ); - PopupMenu* pItemMenu( aPopupMenu.GetPopupMenu( 1 )); - + USHORT nPos( 0 ); + PopupMenu* pItemMenu( aPopupMenu.GetPopupMenu( 1 )); sal_Bool bIsFloating( sal_False ); - DockingManager* pDockMgr = Window::GetDockingManager(); - if ( pDockMgr ) - bIsFloating = pDockMgr->IsFloating( m_pToolBar ); - - if ( !bIsFloating ) - { - aPopupMenu.EnableItem( MENUITEM_TOOLBAR_DOCKTOOLBAR, sal_False ); - aPopupMenu.EnableItem( MENUITEM_TOOLBAR_DOCKALLTOOLBAR, sal_False ); - Reference< XDockableWindow > xDockable( VCLUnoHelper::GetInterface( m_pToolBar ), UNO_QUERY ); - if( xDockable.is() ) - aPopupMenu.CheckItem( MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION, xDockable->isLocked() ); - } - else - aPopupMenu.EnableItem( MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION, sal_False ); + DockingManager* pDockMgr = Window::GetDockingManager(); + if ( pDockMgr ) + bIsFloating = pDockMgr->IsFloating( m_pToolBar ); - if ( !m_bCanBeCustomized ) - { - // Non-configurable toolbars should disable configuration menu items - aPopupMenu.EnableItem( MENUITEM_TOOLBAR_VISIBLEBUTTON, sal_False ); - aPopupMenu.EnableItem( MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR, sal_False ); - } + if ( !bIsFloating ) + { + aPopupMenu.EnableItem( MENUITEM_TOOLBAR_DOCKTOOLBAR, sal_False ); + //modify for issue79466 by shizhoubo + aPopupMenu.EnableItem( MENUITEM_TOOLBAR_DOCKALLTOOLBAR, sal_True ); + //end + Reference< XDockableWindow > xDockable( VCLUnoHelper::GetInterface( m_pToolBar ), UNO_QUERY ); + if( xDockable.is() ) + aPopupMenu.CheckItem( MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION, xDockable->isLocked() ); + } + else + aPopupMenu.EnableItem( MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION, sal_False ); - pItemMenu->SetMenuFlags (pItemMenu->GetMenuFlags () | - MENU_FLAG_SHOWCHECKIMAGES); + if ( !m_bCanBeCustomized ) + { + // Non-configurable toolbars should disable configuration menu items + aPopupMenu.EnableItem( MENUITEM_TOOLBAR_VISIBLEBUTTON, sal_False ); + aPopupMenu.EnableItem( MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR, sal_False ); + } + + pItemMenu->SetMenuFlags (pItemMenu->GetMenuFlags () | MENU_FLAG_SHOWCHECKIMAGES); - for ( nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos ) - { - if ( m_pToolBar->GetItemType(nPos) == TOOLBOXITEM_BUTTON ) - { - USHORT nId = m_pToolBar->GetItemId(nPos); - OUString aCommandURL = m_pToolBar->GetItemCommand( nId ); + for ( nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos ) + { + if ( m_pToolBar->GetItemType(nPos) == TOOLBOXITEM_BUTTON ) + { + USHORT nId = m_pToolBar->GetItemId(nPos); + OUString aCommandURL = m_pToolBar->GetItemCommand( nId ); pItemMenu->InsertItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->GetItemText( nId ), MIB_CHECKABLE ); pItemMenu->CheckItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->IsItemVisible( nId ) ); - pItemMenu->SetItemCommand( STARTID_CUSTOMIZE_POPUPMENU+nPos, aCommandURL ); + pItemMenu->SetItemCommand( STARTID_CUSTOMIZE_POPUPMENU+nPos, aCommandURL ); pItemMenu->SetItemImage( STARTID_CUSTOMIZE_POPUPMENU+nPos, - GetImageFromURL( m_xFrame, - aCommandURL, - sal_False, - m_bIsHiContrast )); - } - else - { - pItemMenu->InsertSeparator(); - } - } - } + GetImageFromURL( m_xFrame, + aCommandURL, + sal_False, + m_bIsHiContrast )); + } + else + { + pItemMenu->InsertSeparator(); + } + } + } else { USHORT nPos = aPopupMenu.GetItemPos( MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR ); - if ( nPos != MENU_ITEM_NOTFOUND ) - aPopupMenu.RemoveItem( nPos ); + if ( nPos != MENU_ITEM_NOTFOUND ) + aPopupMenu.RemoveItem( nPos ); } - // copy all menu items to the toolbar menu - if( pMenu->GetItemCount() ) - pMenu->InsertSeparator(); + // copy all menu items to the toolbar menu + if( pMenu->GetItemCount() ) + pMenu->InsertSeparator(); - USHORT i; - for( i=0; i< aPopupMenu.GetItemCount(); i++) - { - sal_uInt16 nId = aPopupMenu.GetItemId( i ); - if ( MenuItemAllowed( nId )) - pMenu->CopyItem( aPopupMenu, i, MENU_APPEND ); - } + USHORT i; + for( i=0; i< aPopupMenu.GetItemCount(); i++) + { + sal_uInt16 nId = aPopupMenu.GetItemId( i ); + if ( MenuItemAllowed( nId )) + pMenu->CopyItem( aPopupMenu, i, MENU_APPEND ); + } - // set submenu to toolbar menu - if( aPopupMenu.GetPopupMenu( 1 ) ) - { - // create an own submenu to avoid auto-delete when resource menu is deleted - PopupMenu *pItemMenu = new PopupMenu(); + // set submenu to toolbar menu + if( aPopupMenu.GetPopupMenu( 1 ) ) + { + // create an own submenu to avoid auto-delete when resource menu is deleted + PopupMenu *pItemMenu = new PopupMenu(); - pItemMenu->SetMenuFlags (pItemMenu->GetMenuFlags () | - MENU_FLAG_SHOWCHECKIMAGES); + pItemMenu->SetMenuFlags (pItemMenu->GetMenuFlags () | MENU_FLAG_SHOWCHECKIMAGES); - for( i=0; i< aPopupMenu.GetPopupMenu( 1 )->GetItemCount(); i++) - pItemMenu->CopyItem( *aPopupMenu.GetPopupMenu( 1 ), i, MENU_APPEND ); + for( i=0; i< aPopupMenu.GetPopupMenu( 1 )->GetItemCount(); i++) + pItemMenu->CopyItem( *aPopupMenu.GetPopupMenu( 1 ), i, MENU_APPEND ); - pMenu->SetPopupMenu( 1, pItemMenu ); - } + pMenu->SetPopupMenu( 1, pItemMenu ); + } - if ( bHideDisabledEntries ) - pMenu->RemoveDisabledEntries(); + if ( bHideDisabledEntries ) + pMenu->RemoveDisabledEntries(); + return pMenu; +} +//end +// addd for 33668 by shizhoubo +IMPL_LINK( ToolBarManager, Command, CommandEvent*, pCmdEvt ) +{ + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + return 1; + if ( pCmdEvt->GetCommand() != COMMAND_CONTEXTMENU ) + return 0; + + PopupMenu * pMenu = GetToolBarCustomMeun(m_pToolBar); + if (pMenu) + { + // make sure all disabled entries will be shown + pMenu->SetMenuFlags( pMenu->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES ); + ::Point aPoint( pCmdEvt->GetMousePosPixel() ); + pMenu->Execute( m_pToolBar, aPoint ); + } + + return 0; +} +//end + +IMPL_LINK( ToolBarManager, MenuButton, ToolBox*, pToolBar ) +{ + ResetableGuard aGuard( m_aLock ); + + if ( m_bDisposed ) + return 1; + //modify for i33668 by shizhoubo:2008:04 + GetToolBarCustomMeun(pToolBar); + //end return 0; }