summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-02-15 18:36:25 +0100
committerAndras Timar <andras.timar@collabora.com>2019-02-17 11:02:56 +0100
commit1195bca0342647ae974ed5a1db2b41c5eddf1d4a (patch)
treeab039fb234ed55f15a0695b1a5d6cb59f95d8e2d /framework
parent421ebc945cb86a68b826b3c14b1cee6a21e46ef2 (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> (cherry picked from commit 5599dfc71b4bd0a2f9130cb51a0dc8fe7eaf9fdb) Reviewed-on: https://gerrit.libreoffice.org/67919 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/services/layoutmanager.hxx1
-rw-r--r--framework/source/layoutmanager/layoutmanager.cxx104
2 files changed, 57 insertions, 48 deletions
diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx
index 8ef46a21de72..ed3ec629e7e7 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 2012ee2576bb..9560a88f3013 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -155,6 +155,57 @@ LayoutManager::~LayoutManager()
delete m_pGlobalSettings;
}
+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()
{
@@ -1391,7 +1442,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() )
@@ -1427,55 +1477,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") &&