From 86f504ee014d17172267f14742b8edd5789cbbc6 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 15 Mar 2016 20:44:50 +0000 Subject: Related: tdf#98637 make this a tractable problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is just too hard, it would all be much easier if the ActionGroup existed right from the start of the entire process. So smuggle in to the ctor the toplevel frame that the menubar will be inserted into so we can use its ActionGroup from the start. That would suggest that we could then just keep the hierarchy in sync as it is created rather than finding opportune moments to update /generate it. Change-Id: I550f94a994210423ab9cea1986e643056cb5bd29 Reviewed-on: https://gerrit.libreoffice.org/23287 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- framework/source/layoutmanager/layoutmanager.cxx | 4 +++- framework/source/uielement/menubarwrapper.cxx | 28 ++++++++++++++---------- framework/source/uifactory/menubarfactory.cxx | 11 ++++++++-- 3 files changed, 28 insertions(+), 15 deletions(-) (limited to 'framework/source') diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 30de7cbc30d1..0651e0f718a1 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -726,11 +726,13 @@ Reference< XUIElement > LayoutManager::implts_createElement( const OUString& aNa Reference< ui::XUIElement > xUIElement; SolarMutexGuard g; - Sequence< PropertyValue > aPropSeq( 2 ); + Sequence< PropertyValue > aPropSeq( 3 ); aPropSeq[0].Name = "Frame"; aPropSeq[0].Value <<= m_xFrame; aPropSeq[1].Name = "Persistent"; aPropSeq[1].Value <<= sal_True; + aPropSeq[2].Name = "Container"; + aPropSeq[2].Value <<= m_xContainerWindow; try { diff --git a/framework/source/uielement/menubarwrapper.cxx b/framework/source/uielement/menubarwrapper.cxx index cc5820c8d59a..4cd67300060f 100644 --- a/framework/source/uielement/menubarwrapper.cxx +++ b/framework/source/uielement/menubarwrapper.cxx @@ -34,6 +34,7 @@ #include #include #include +#include "../layoutmanager/helpers.hxx" using namespace com::sun::star; using namespace com::sun::star::uno; @@ -122,6 +123,20 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th OUString aModuleIdentifier; UIConfigElementWrapperBase::initialize( aArguments ); + bool bMenuOnly( false ); + Reference< XWindow > xContainerWindow; + for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ ) + { + PropertyValue aPropValue; + if ( aArguments[n] >>= aPropValue ) + { + if ( aPropValue.Name == "MenuOnly" ) + aPropValue.Value >>= bMenuOnly; + else if ( aPropValue.Name == "Container" ) + aPropValue.Value >>= xContainerWindow; + } + } + Reference< XFrame > xFrame( m_xWeakFrame ); if ( xFrame.is() && m_xConfigSource.is() ) { @@ -130,7 +145,7 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th VCLXMenuBar* pAwtMenuBar = nullptr; { SolarMutexGuard aSolarMutexGuard; - pVCLMenuBar = new MenuBar(); + pVCLMenuBar = new MenuBar(getTopSystemWindow(xContainerWindow)); } Reference< XModuleManager2 > xModuleManager = ModuleManager::create( m_xContext ); @@ -159,17 +174,6 @@ void SAL_CALL MenuBarWrapper::initialize( const Sequence< Any >& aArguments ) th { } - bool bMenuOnly( false ); - for ( sal_Int32 n = 0; n < aArguments.getLength(); n++ ) - { - PropertyValue aPropValue; - if ( aArguments[n] >>= aPropValue ) - { - if ( aPropValue.Name == "MenuOnly" ) - aPropValue.Value >>= bMenuOnly; - } - } - if ( !bMenuOnly ) { // Initialize menubar manager with our vcl menu bar. There are some situations where we only want to get the menu without any diff --git a/framework/source/uifactory/menubarfactory.cxx b/framework/source/uifactory/menubarfactory.cxx index e9d9f79ce5ab..13025adcfff7 100644 --- a/framework/source/uifactory/menubarfactory.cxx +++ b/framework/source/uifactory/menubarfactory.cxx @@ -34,6 +34,7 @@ #include using namespace com::sun::star::uno; +using namespace com::sun::star::awt; using namespace com::sun::star::lang; using namespace com::sun::star::frame; using namespace com::sun::star::beans; @@ -74,6 +75,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL Reference< XUIConfigurationManager > xCfgMgr; Reference< XUIConfigurationManager > xConfigSource; Reference< XFrame > xFrame; + Reference< XWindow > xContainerWindow; OUString aResourceURL( ResourceURL ); bool bPersistent( true ); bool bExtraMode( false ); @@ -84,6 +86,8 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL Args[n].Value >>= xConfigSource; else if ( Args[n].Name == "Frame" ) Args[n].Value >>= xFrame; + else if ( Args[n].Name == "Container" ) + Args[n].Value >>= xContainerWindow; else if ( Args[n].Name == "ResourceURL" ) Args[n].Value >>= aResourceURL; else if ( Args[n].Name == "Persistent" ) @@ -129,7 +133,7 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL } PropertyValue aPropValue; - Sequence< Any > aPropSeq( _pExtraMode ? 5 : 4); + Sequence< Any > aPropSeq( _pExtraMode ? 6 : 5); aPropValue.Name = "Frame"; aPropValue.Value <<= xFrame; aPropSeq[0] <<= aPropValue; @@ -142,11 +146,14 @@ void MenuBarFactory::CreateUIElement(const OUString& ResourceURL aPropValue.Name = "Persistent"; aPropValue.Value <<= bPersistent; aPropSeq[3] <<= aPropValue; + aPropValue.Name = "Container"; + aPropValue.Value <<= xContainerWindow; + aPropSeq[4] <<= aPropValue; if ( _pExtraMode ) { aPropValue.Name = OUString::createFromAscii(_pExtraMode); aPropValue.Value <<= bExtraMode; - aPropSeq[4] <<= aPropValue; + aPropSeq[5] <<= aPropValue; } SolarMutexGuard aGuard; -- cgit