summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2016-10-30 14:34:18 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2016-10-30 15:50:31 +0200
commit94876fe2704cb5107234ad76c86122ac9d95f866 (patch)
treed55701606099ce3db9f3b051166a4ba33fb58e7f /framework
parent99da628e17e873a5fa2f726e7a1732b21c3d4b33 (diff)
Let Menu dispose submenus
(I'm not sure about how good are the changes from ScopedVclPtr to non-scoped, and disposeAndClear to clear. They aren't really needed, because of the VclReferenceBase::mbDisposed logic. But at least they should be safe, as long as we have disposeOnce calls in Menu's dtor.) See also previous commits: 4433d95b374c13a3501cdf3a6e273f68eb49873a ("MenuItemData now properly disposes the submenu") 89c23b4aaef931b5d6009efaf44ce6e6c976e8d4 ("Sub menus no longer need manual disposing") Change-Id: I9d455a94590f5eec9b097947f6984f1b3e477b52
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/uielement/menubarmanager.hxx11
-rw-r--r--framework/source/layoutmanager/layoutmanager.cxx2
-rw-r--r--framework/source/uielement/generictoolbarcontroller.cxx2
-rw-r--r--framework/source/uielement/menubarmanager.cxx43
-rw-r--r--framework/source/uielement/menubarwrapper.cxx3
-rw-r--r--framework/source/uielement/resourcemenucontroller.cxx2
-rw-r--r--framework/source/uielement/toolbarmanager.cxx20
7 files changed, 24 insertions, 59 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() );