diff options
-rw-r--r-- | framework/inc/uielement/menubarmanager.hxx | 11 | ||||
-rw-r--r-- | framework/source/layoutmanager/layoutmanager.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/generictoolbarcontroller.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/menubarmanager.cxx | 43 | ||||
-rw-r--r-- | framework/source/uielement/menubarwrapper.cxx | 3 | ||||
-rw-r--r-- | framework/source/uielement/resourcemenucontroller.cxx | 2 | ||||
-rw-r--r-- | framework/source/uielement/toolbarmanager.cxx | 20 | ||||
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 2 | ||||
-rw-r--r-- | svtools/source/control/calendar.cxx | 15 | ||||
-rw-r--r-- | svx/source/gallery2/galbrws2.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/utlui/unotools.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 17 | ||||
-rw-r--r-- | vcl/workben/vcldemo.cxx | 9 |
14 files changed, 43 insertions, 93 deletions
diff --git a/framework/inc/uielement/menubarmanager.hxx b/framework/inc/uielement/menubarmanager.hxx index b462d8d88659..e8f1e65ae2c3 100644 --- a/framework/inc/uielement/menubarmanager.hxx +++ b/framework/inc/uielement/menubarmanager.hxx @@ -81,9 +81,7 @@ class MenuBarManager : public css::frame::XStatusListener , const css::uno::Reference< css::frame::XFrame >& rFrame, const css::uno::Reference< css::util::XURLTransformer >& _xURLTransformer, Menu* pAddonMenu, - bool bDelete, - bool bDeleteChildren, - bool popup); + bool popup); public: MenuBarManager( @@ -94,7 +92,6 @@ class MenuBarManager : public css::frame::XStatusListener , const OUString& aModuleIdentifier, Menu* pMenu, bool bDelete, - bool bDeleteChildren, bool bHasMenuBar = true ); virtual ~MenuBarManager() override; @@ -145,8 +142,7 @@ class MenuBarManager : public css::frame::XStatusListener , const css::uno::Reference< css::frame::XFrame >& rFrame, const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider, const OUString& rModuleIdentifier, - bool bDelete, - bool bDeleteChildren ); + bool bDelete ); void SetItemContainer( const css::uno::Reference< css::container::XIndexAccess >& rItemContainer ); void GetPopupController( PopupControllerCache& rPopupController ); @@ -197,12 +193,11 @@ class MenuBarManager : public css::frame::XStatusListener , bool CreatePopupMenuController( MenuItemHandler* pMenuItemHandler ); void AddMenu(MenuBarManager* pSubMenuManager,const OUString& _sItemCommand,sal_uInt16 _nItemId); sal_uInt16 FillItemCommand(OUString& _rItemCommand, Menu* _pMenu,sal_uInt16 _nIndex) const; - void Init(const css::uno::Reference< css::frame::XFrame >& rFrame,Menu* pAddonMenu,bool bDelete,bool bDeleteChildren,bool _bHandlePopUp); + void Init(const css::uno::Reference< css::frame::XFrame >& rFrame,Menu* pAddonMenu,bool _bHandlePopUp); void SetHdl(); bool m_bDisposed; bool m_bDeleteMenu; - bool m_bDeleteChildren; bool m_bActive; bool m_bIsBookmarkMenu; bool m_bShowMenuImages; diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 6c5c6695740e..2b011bc6cc41 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -1171,7 +1171,7 @@ throw (uno::RuntimeException, std::exception) Reference< XDispatchProvider > xDispatchProvider; VclPtr<MenuBar> pMenuBar = VclPtr<MenuBar>::Create(); - m_pInplaceMenuBar = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer, xDispatchProvider, aModuleIdentifier, pMenuBar, true, true ); + m_pInplaceMenuBar = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer, xDispatchProvider, aModuleIdentifier, pMenuBar, true ); m_pInplaceMenuBar->SetItemContainer( xMergedMenuBar ); SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx index 21da2b088b9a..d76aaab12640 100644 --- a/framework/source/uielement/generictoolbarcontroller.cxx +++ b/framework/source/uielement/generictoolbarcontroller.cxx @@ -346,7 +346,7 @@ MenuToolbarController::createPopupWindow() throw (css::uno::RuntimeException, st Reference< XDispatchProvider > xDispatch; Reference< XURLTransformer > xURLTransformer = URLTransformer::create( m_xContext ); pMenu = VclPtr<Toolbarmenu>::Create(); - m_xMenuManager.set( new MenuBarManager( m_xContext, m_xFrame, xURLTransformer, xDispatch, m_aModuleIdentifier, pMenu, true, true, false ) ); + m_xMenuManager.set( new MenuBarManager( m_xContext, m_xFrame, xURLTransformer, xDispatch, m_aModuleIdentifier, pMenu, false, false ) ); if (m_xMenuManager.is()) { MenuBarManager& rMgr = dynamic_cast<MenuBarManager&>(*m_xMenuManager.get()); diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index b167d71a04e3..d78b7ce8a29b 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -124,7 +124,7 @@ MenuBarManager::MenuBarManager( const Reference< XURLTransformer >& _xURLTransformer, const Reference< XDispatchProvider >& rDispatchProvider, const OUString& rModuleIdentifier, - Menu* pMenu, bool bDelete, bool bDeleteChildren, bool bHasMenuBar ): + Menu* pMenu, bool bDelete, bool bHasMenuBar ): OWeakObject() , m_bDisposed( false ) , m_bRetrieveImages( false ) @@ -137,7 +137,7 @@ MenuBarManager::MenuBarManager( , m_sIconTheme( SvtMiscOptions().GetIconTheme() ) { m_xPopupMenuControllerFactory = frame::thePopupMenuControllerFactory::get(m_xContext); - FillMenuManager( pMenu, rFrame, rDispatchProvider, rModuleIdentifier, bDelete, bDeleteChildren ); + FillMenuManager( pMenu, rFrame, rDispatchProvider, rModuleIdentifier, bDelete ); } MenuBarManager::MenuBarManager( @@ -145,8 +145,6 @@ MenuBarManager::MenuBarManager( const Reference< XFrame >& rFrame, const Reference< XURLTransformer >& _xURLTransformer, Menu* pAddonMenu, - bool bDelete, - bool bDeleteChildren, bool popup): OWeakObject() , m_bDisposed( false ) @@ -159,7 +157,7 @@ MenuBarManager::MenuBarManager( , m_xURLTransformer(_xURLTransformer) , m_sIconTheme( SvtMiscOptions().GetIconTheme() ) { - Init(rFrame,pAddonMenu,bDelete,bDeleteChildren, popup); + Init(rFrame,pAddonMenu, popup); } Any SAL_CALL MenuBarManager::queryInterface( const Type & rType ) throw ( RuntimeException, std::exception ) @@ -547,13 +545,13 @@ void MenuBarManager::RemoveListener() pItemHandler->xMenuItemDispatch.clear(); - // Remove popup menu from menu structure (regardless whether an - // xPopupMenu proxy has been set up for it; calling SetPopupMenu for - // a non-popup child will effectively do nothing: - m_pVCLMenu->SetPopupMenu( pItemHandler->nItemId, nullptr ); - if ( pItemHandler->xPopupMenu.is() ) { + { + // Remove popup menu from menu structure + m_pVCLMenu->SetPopupMenu( pItemHandler->nItemId, nullptr ); + } + Reference< css::lang::XEventListener > xEventListener( pItemHandler->xPopupMenuController, UNO_QUERY ); if ( xEventListener.is() ) { @@ -1129,12 +1127,11 @@ bool MenuBarManager::CreatePopupMenuController( MenuItemHandler* pMenuItemHandle void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rFrame, const Reference< XDispatchProvider >& rDispatchProvider, - const OUString& rModuleIdentifier, bool bDelete, bool bDeleteChildren ) + const OUString& rModuleIdentifier, bool bDelete ) { m_xFrame = rFrame; m_bActive = false; m_bDeleteMenu = bDelete; - m_bDeleteChildren = bDeleteChildren; m_pVCLMenu = pMenu; m_bIsBookmarkMenu = false; m_xDispatchProvider = rDispatchProvider; @@ -1241,8 +1238,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF else if ( aItemCommand.startsWith( ADDONSPOPUPMENU_URL_PREFIX_STR ) ) { // A special addon popup menu, must be created with a different ctor - MenuBarManager* pSubMenuManager = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer, - pPopup, bDeleteChildren, bDeleteChildren, true ); + MenuBarManager* pSubMenuManager = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer, pPopup, true ); AddMenu(pSubMenuManager,aItemCommand,nItemId); } else @@ -1290,8 +1286,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF if ( pSubMenu ) { MenuBarManager* pSubMenuManager = new MenuBarManager( m_xContext, m_xFrame, - m_xURLTransformer,pSubMenu, true, - false, false ); + m_xURLTransformer,pSubMenu, false ); AddMenu(pSubMenuManager,aItemCommand,nItemId); (pSubMenuManager->m_aMenuItemCommand).clear(); @@ -1308,8 +1303,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF { MenuBarManager* pSubMenuMgr = new MenuBarManager( m_xContext, rFrame, m_xURLTransformer, rDispatchProvider, aModuleIdentifier, - pPopup, bDeleteChildren, bDeleteChildren, - m_bHasMenuBar ); + pPopup, false, m_bHasMenuBar ); AddMenu(pSubMenuMgr,aItemCommand,nItemId); } } @@ -1816,8 +1810,6 @@ void MenuBarManager::SetItemContainer( const Reference< XIndexAccess >& rItemCon delete pItemHandler; } m_aMenuItemHandlerVector.clear(); - - // Remove top-level parts m_pVCLMenu->Clear(); sal_uInt16 nId = 1; @@ -1827,7 +1819,7 @@ void MenuBarManager::SetItemContainer( const Reference< XIndexAccess >& rItemCon // Refill menu manager again Reference< XDispatchProvider > xDispatchProvider; - FillMenuManager( m_pVCLMenu, xFrame, xDispatchProvider, m_aModuleIdentifier, false, true ); + FillMenuManager( m_pVCLMenu, xFrame, xDispatchProvider, m_aModuleIdentifier, false ); // add itself as frame action listener m_xFrame->addFrameActionListener( Reference< XFrameActionListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); @@ -1907,12 +1899,10 @@ sal_uInt16 MenuBarManager::FillItemCommand(OUString& _rItemCommand, Menu* _pMenu } return nItemId; } -void MenuBarManager::Init(const Reference< XFrame >& rFrame, Menu* pAddonMenu, bool bDelete, - bool bDeleteChildren, bool _bHandlePopUp) +void MenuBarManager::Init(const Reference< XFrame >& rFrame, Menu* pAddonMenu, bool _bHandlePopUp) { m_bActive = false; - m_bDeleteMenu = bDelete; - m_bDeleteChildren = bDeleteChildren; + m_bDeleteMenu = false; m_pVCLMenu = pAddonMenu; m_xFrame = rFrame; m_bIsBookmarkMenu = true; @@ -1937,8 +1927,7 @@ void MenuBarManager::Init(const Reference< XFrame >& rFrame, Menu* pAddonMenu, b Reference< XDispatchProvider > xDispatchProvider; MenuBarManager* pSubMenuManager = new MenuBarManager( m_xContext, rFrame, m_xURLTransformer, xDispatchProvider, aModuleIdentifier, pPopupMenu, - !_bHandlePopUp && bDeleteChildren, - !_bHandlePopUp && bDeleteChildren ); + false ); Reference< XStatusListener > xSubMenuManager( static_cast< OWeakObject *>( pSubMenuManager ), UNO_QUERY ); diff --git a/framework/source/uielement/menubarwrapper.cxx b/framework/source/uielement/menubarwrapper.cxx index d420fa14d8b4..3e45a3e02189 100644 --- a/framework/source/uielement/menubarwrapper.cxx +++ b/framework/source/uielement/menubarwrapper.cxx @@ -184,8 +184,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th xDispatchProvider, aModuleIdentifier, pVCLMenuBar, - false, - true ); + false ); m_xMenuBarManager.set( static_cast< OWeakObject *>( pMenuBarManager ), UNO_QUERY ); } diff --git a/framework/source/uielement/resourcemenucontroller.cxx b/framework/source/uielement/resourcemenucontroller.cxx index 12d3d0946dc3..4230177f7230 100644 --- a/framework/source/uielement/resourcemenucontroller.cxx +++ b/framework/source/uielement/resourcemenucontroller.cxx @@ -326,7 +326,7 @@ void ResourceMenuController::itemActivated( const css::awt::MenuEvent& /*rEvent* VCLXMenu* pAwtMenu = VCLXMenu::GetImplementation( m_xPopupMenu ); css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider( m_xFrame, css::uno::UNO_QUERY ); m_xMenuBarManager.set( new framework::MenuBarManager( - m_xContext, m_xFrame, m_xURLTransformer, xDispatchProvider, m_aModuleName, pAwtMenu->GetMenu(), false, true, !m_bContextMenu && !m_bInToolbar ) ); + m_xContext, m_xFrame, m_xURLTransformer, xDispatchProvider, m_aModuleName, pAwtMenu->GetMenu(), false, !m_bContextMenu && !m_bInToolbar ) ); m_xFrame->addFrameActionListener( m_xMenuBarManager.get() ); } } diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 76e4d154be26..a76e552932a3 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -1332,13 +1332,7 @@ void ToolBarManager::ImplClearPopupMenu( ToolBox *pToolBar ) // remove config entries from menu, so we have a clean menu to start with // remove submenu first - VclPtr<::PopupMenu> pItemMenu = pMenu->GetPopupMenu( 1 ); - if( pItemMenu ) - { - pItemMenu->Clear(); - pItemMenu.disposeAndClear(); - pMenu->SetPopupMenu( 1, pItemMenu ); - } + pMenu->SetPopupMenu( 1, nullptr ); // remove all items that were not added by the toolbar itself sal_uInt16 i; @@ -1509,18 +1503,6 @@ bool ToolBarManager::MenuItemAllowed( sal_uInt16 ) const pMenu->CopyItem( *aQuickCustomizationMenu.get(), i ); } - // set submenu to toolbar menu - if( aQuickCustomizationMenu->GetPopupMenu( 1 ) ) - { - // create an own submenu to avoid auto-delete when resource menu is deleted - VclPtr<::PopupMenu> pItemMenu = VclPtr<::PopupMenu>::Create(); - - for( i=0; i< aQuickCustomizationMenu->GetPopupMenu( 1 )->GetItemCount(); i++) - pItemMenu->CopyItem( *aQuickCustomizationMenu->GetPopupMenu( 1 ), i ); - - pMenu->SetPopupMenu( 1, pItemMenu ); - } - // Set the title of the menu pMenu->SetText( pToolBar->GetText() ); diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index fd5bb59af9d4..5139c369dc80 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -580,14 +580,14 @@ void ScContentTree::Command( const CommandEvent& rCEvt ) // Drag-Drop Modus ScopedVclPtrInstance<PopupMenu> aPop; - ScopedVclPtrInstance<ScPopupMenu> aDropMenu( ScResId( RID_POPUP_DROPMODE ) ); + VclPtrInstance<ScPopupMenu> aDropMenu( ScResId( RID_POPUP_DROPMODE ) ); aDropMenu->CheckItem( RID_DROPMODE_URL + pParentWindow->GetDropMode() ); aPop->InsertItem( 1, pParentWindow->GetStrDragMode() ); aPop->SetPopupMenu( 1, aDropMenu.get() ); // angezeigtes Dokument - ScopedVclPtrInstance<ScPopupMenu> aDocMenu; + VclPtrInstance<ScPopupMenu> aDocMenu; aDocMenu->SetMenuFlags( aDocMenu->GetMenuFlags() | MenuFlags::NoAutoMnemonics ); sal_uInt16 i=0; sal_uInt16 nPos=0; diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 1e6b910f8b33..f11fccd97eec 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -287,7 +287,7 @@ void SfxTemplateManagerDlg::dispose() mpSearchView.clear(); mpLocalView.clear(); mpActionMenu.disposeAndClear(); - mpTemplateDefaultMenu.disposeAndClear(); + mpTemplateDefaultMenu.clear(); ModalDialog::dispose(); } diff --git a/svtools/source/control/calendar.cxx b/svtools/source/control/calendar.cxx index d51b05f4fff3..9865781c1a6c 100644 --- a/svtools/source/control/calendar.cxx +++ b/svtools/source/control/calendar.cxx @@ -1155,7 +1155,6 @@ void Calendar::ImplShowMenu( const Point& rPos, const Date& rDate ) Date aOldFirstDate = GetFirstMonth(); ScopedVclPtrInstance<PopupMenu> aPopupMenu; - VclPtr<PopupMenu> pYearPopupMenus[MENU_YEAR_COUNT]; sal_uInt16 nMonthOff; sal_uInt16 nCurItemId; sal_uInt16 nYear = rDate.GetYear()-1; @@ -1172,13 +1171,13 @@ void Calendar::ImplShowMenu( const Point& rPos, const Date& rDate ) // construct menu (include years with different months) for ( i = 0; i < MENU_YEAR_COUNT; i++ ) { - pYearPopupMenus[i] = VclPtr<PopupMenu>::Create(); + VclPtrInstance<PopupMenu> pYearPopupMenu; for ( j = 1; j <= 12; j++ ) - pYearPopupMenus[i]->InsertItem( nYearIdCount+j, + pYearPopupMenu->InsertItem( nYearIdCount+j, maCalendarWrapper.getDisplayName( i18n::CalendarDisplayIndex::MONTH, j-1, 1)); aPopupMenu->InsertItem( 10+i, OUString::number( nYear+i ) ); - aPopupMenu->SetPopupMenu( 10+i, pYearPopupMenus[i] ); + aPopupMenu->SetPopupMenu( 10+i, pYearPopupMenu ); nYearIdCount += 1000; } @@ -1186,14 +1185,6 @@ void Calendar::ImplShowMenu( const Point& rPos, const Date& rDate ) nCurItemId = aPopupMenu->Execute( this, rPos ); mbMenuDown = false; - // destroy menu - aPopupMenu->SetPopupMenu( 2, nullptr ); - for ( i = 0; i < MENU_YEAR_COUNT; i++ ) - { - aPopupMenu->SetPopupMenu( 10+i, nullptr ); - pYearPopupMenus[i].disposeAndClear(); - } - if ( nCurItemId ) { sal_uInt16 nTempMonthOff = nMonthOff % 12; diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx index e6160a5f65ed..3b5207437059 100644 --- a/svx/source/gallery2/galbrws2.cxx +++ b/svx/source/gallery2/galbrws2.cxx @@ -113,7 +113,7 @@ private: sal_uIntPtr mnObjectPos; bool mbPreview; ScopedVclPtr<PopupMenu> mpPopupMenu; - ScopedVclPtr<PopupMenu> mpBackgroundPopup; + VclPtr<PopupMenu> mpBackgroundPopup; VclPtr<GalleryBrowser2> mpBrowser; typedef std::map< int, CommandInfo > CommandInfoMap; @@ -150,6 +150,7 @@ GalleryThemePopup::GalleryThemePopup( , mpBackgroundPopup( VclPtr<PopupMenu>::Create() ) , mpBrowser( pBrowser ) { + mpPopupMenu->SetPopupMenu( MN_BACKGROUND, mpBackgroundPopup ); // SID_GALLERY_ENABLE_ADDCOPY m_aCommandInfo.insert( @@ -308,7 +309,6 @@ void GalleryThemePopup::ExecutePopup( vcl::Window *pWindow, const ::Point &aPos else { mpPopupMenu->EnableItem( MN_BACKGROUND ); - mpPopupMenu->SetPopupMenu( MN_BACKGROUND, mpBackgroundPopup ); mpBackgroundPopup->SetSelectHdl( LINK( this, GalleryThemePopup, BackgroundMenuSelectHdl ) ); } diff --git a/sw/source/uibase/utlui/unotools.cxx b/sw/source/uibase/utlui/unotools.cxx index 4a89a65a9229..9dec8ec22798 100644 --- a/sw/source/uibase/utlui/unotools.cxx +++ b/sw/source/uibase/utlui/unotools.cxx @@ -451,7 +451,6 @@ static const sal_Int16 nZoomValues[] = void SwOneExampleFrame::CreatePopup(const Point& rPt) { ScopedVclPtrInstance<PopupMenu> aPop; - ScopedVclPtrInstance<PopupMenu> aSubPop1; ResStringArray& rArr = aMenuRes.GetMenuArray(); aPop->InsertItem(ITEM_UP, rArr.GetString(rArr.FindIndex(ST_MENU_UP ))); @@ -470,6 +469,7 @@ void SwOneExampleFrame::CreatePopup(const Point& rPt) sal_Int16 nZoom = 0; aZoom >>= nZoom; + VclPtrInstance<PopupMenu> aSubPop1; for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(nZoomValues); ++i) { OUString sTemp = unicode::formatPercent(nZoomValues[i], diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index cd1b3fd9498c..fbc6ac1eb40a 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -578,8 +578,7 @@ void Menu::RemoveItem( sal_uInt16 nPos ) ImplCallEventListeners( VCLEVENT_MENU_REMOVEITEM, nPos ); } -void ImplCopyItem( Menu* pThis, const Menu& rMenu, sal_uInt16 nPos, sal_uInt16 nNewPos, - sal_uInt16 nMode = 0 ) +void ImplCopyItem( Menu* pThis, const Menu& rMenu, sal_uInt16 nPos, sal_uInt16 nNewPos ) { MenuItemType eType = rMenu.GetItemType( nPos ); @@ -621,13 +620,8 @@ void ImplCopyItem( Menu* pThis, const Menu& rMenu, sal_uInt16 nPos, sal_uInt16 n if ( pSubMenu ) { // create auto-copy - if ( nMode == 1 ) - { - VclPtr<PopupMenu> pNewMenu = VclPtr<PopupMenu>::Create( *pSubMenu ); - pThis->SetPopupMenu( nId, pNewMenu ); - } - else - pThis->SetPopupMenu( nId, pSubMenu ); + VclPtr<PopupMenu> pNewMenu = VclPtr<PopupMenu>::Create( *pSubMenu ); + pThis->SetPopupMenu( nId, pNewMenu ); } } } @@ -790,6 +784,9 @@ void Menu::SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu ) if ( static_cast<PopupMenu*>(pData->pSubMenu.get()) == pMenu ) return; + // remove old menu + pData->pSubMenu.disposeAndClear(); + // data exchange pData->pSubMenu = pMenu; @@ -1203,7 +1200,7 @@ Menu& Menu::operator=( const Menu& rMenu ) // copy items sal_uInt16 nCount = rMenu.GetItemCount(); for ( sal_uInt16 i = 0; i < nCount; i++ ) - ImplCopyItem( this, rMenu, i, MENU_APPEND, 1 ); + ImplCopyItem( this, rMenu, i, MENU_APPEND ); nDefaultItem = rMenu.nDefaultItem; aActivateHdl = rMenu.aActivateHdl; diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index e1b65851edcf..5458bb4799fd 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -1813,8 +1813,6 @@ public: class DemoWidgets : public WorkWindow { VclPtr<MenuBar> mpBar; - VclPtr<PopupMenu> mpPopup; - VclPtr<VclBox> mpBox; VclPtr<ToolBox> mpToolbox; VclPtr<PushButton> mpButton; @@ -1869,9 +1867,9 @@ public: mpBar = VclPtr<MenuBar>::Create(); mpBar->InsertItem(0,"File"); - mpPopup = VclPtr<PopupMenu>::Create(); - mpPopup->InsertItem(0,"Item"); - mpBar->SetPopupMenu(0, mpPopup); + VclPtrInstance<PopupMenu> pPopup; + pPopup->InsertItem(0,"Item"); + mpBar->SetPopupMenu(0, pPopup); SetMenuBar(mpBar); Show(); @@ -1886,7 +1884,6 @@ public: mpToolbox.disposeAndClear(); mpButton.disposeAndClear(); mpBox.disposeAndClear(); - mpPopup.disposeAndClear(); mpBar.disposeAndClear(); WorkWindow::dispose(); } |