diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-02-15 18:36:25 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-02-16 16:12:34 +0100 |
commit | 5599dfc71b4bd0a2f9130cb51a0dc8fe7eaf9fdb (patch) | |
tree | b1300848c8357b11466f44d25c4ba1f5cabbdd3e /framework | |
parent | 11669b9cf970d953d41b8dd2c5ce85d6fa7e31ef (diff) |
MSForms: Extract menu creation to a separate method
No functional change is intended.
Change-Id: Ieb88e746b08c6a6daac14c08a206db73cbeef8a9
Reviewed-on: https://gerrit.libreoffice.org/67903
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/services/layoutmanager.hxx | 1 | ||||
-rw-r--r-- | framework/source/layoutmanager/layoutmanager.cxx | 104 |
2 files changed, 57 insertions, 48 deletions
diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx index eaecc6fa8e87..1cd9f1d99ff7 100644 --- a/framework/inc/services/layoutmanager.hxx +++ b/framework/inc/services/layoutmanager.hxx @@ -173,6 +173,7 @@ namespace framework // menu bar + void implts_createMenuBar( const OUString& rMenuBarName ); void impl_clearUpMenuBar(); void implts_reset( bool bAttach ); void implts_updateMenuBarClose(); diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index ae58c71deb72..b48e69c3b9e6 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -153,6 +153,57 @@ LayoutManager::~LayoutManager() m_pGlobalSettings.reset(); } +void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName) +{ + SolarMutexClearableGuard aWriteLock; + + if (!m_bInplaceMenuSet && !m_xMenuBar.is()) + { + m_xMenuBar = implts_createElement( rMenuBarName ); + if ( m_xMenuBar.is() ) + { + SolarMutexGuard aGuard; + + SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); + if ( pSysWindow ) + { + Reference< awt::XMenuBar > xMenuBar; + + Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY ); + if ( xPropSet.is() ) + { + try + { + xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar; + } + catch (const beans::UnknownPropertyException&) + { + } + catch (const lang::WrappedTargetException&) + { + } + } + + if ( xMenuBar.is() ) + { + VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar ); + if ( pAwtMenuBar ) + { + MenuBar* pMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu()); + if ( pMenuBar ) + { + pSysWindow->SetMenuBar(pMenuBar); + pMenuBar->SetDisplayable( m_bMenuVisible ); + implts_updateMenuBarClose(); + } + } + } + } + } + } + aWriteLock.clear(); +} + // Internal helper function void LayoutManager::impl_clearUpMenuBar() { @@ -1379,7 +1430,6 @@ void SAL_CALL LayoutManager::createElement( const OUString& aName ) SolarMutexClearableGuard aReadLock; Reference< XFrame > xFrame = m_xFrame; - bool bInPlaceMenu = m_bInplaceMenuSet; aReadLock.clear(); if ( !xFrame.is() ) @@ -1415,55 +1465,13 @@ void SAL_CALL LayoutManager::createElement( const OUString& aName ) bMustBeLayouted = m_xToolbarManager->isLayoutDirty(); } else if ( aElementType.equalsIgnoreAsciiCase("menubar") && - aElementName.equalsIgnoreAsciiCase("menubar") ) + aElementName.equalsIgnoreAsciiCase("menubar") && + implts_isFrameOrWindowTop(xFrame) ) { - // #i38743# don't create a menubar if frame isn't top - if ( !bInPlaceMenu && !m_xMenuBar.is() && implts_isFrameOrWindowTop( xFrame )) - { - m_xMenuBar = implts_createElement( aName ); - if ( m_xMenuBar.is() ) - { - SolarMutexGuard aGuard; + implts_createMenuBar( aName ); + if (m_bMenuVisible) + bNotify = true; - SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow ); - if ( pSysWindow ) - { - Reference< awt::XMenuBar > xMenuBar; - - Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY ); - if ( xPropSet.is() ) - { - try - { - xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar; - } - catch (const beans::UnknownPropertyException&) - { - } - catch (const lang::WrappedTargetException&) - { - } - } - - if ( xMenuBar.is() ) - { - VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar ); - if ( pAwtMenuBar ) - { - MenuBar* pMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu()); - if ( pMenuBar ) - { - pSysWindow->SetMenuBar(pMenuBar); - pMenuBar->SetDisplayable( m_bMenuVisible ); - if ( m_bMenuVisible ) - bNotify = true; - implts_updateMenuBarClose(); - } - } - } - } - } - } aWriteLock.clear(); } else if ( aElementType.equalsIgnoreAsciiCase("statusbar") && |