From 1b786fb2db9b555fd9882487f1f0375bd93f6e32 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Thu, 6 Oct 2016 21:34:27 +0200 Subject: tdf#102776 : switching the menubar in all windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I74804605ec9dd15d1e4dbea15f09709dbf9c8770 Reviewed-on: https://gerrit.libreoffice.org/29580 Tested-by: Jenkins Reviewed-by: Szymon Kłos --- sfx2/source/notebookbar/SfxNotebookBar.cxx | 48 +++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 182b70aee2ae..73053b8b6fdc 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -353,29 +353,49 @@ void SfxNotebookBar::ShowMenubar(bool bShow) { m_bLock = true; - if (SfxViewFrame::Current()) + Reference xFrame; + vcl::EnumContext::Application eCurrentApp = vcl::EnumContext::Application::Application_None; + uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); + const Reference xModuleManager = frame::ModuleManager::create( xContext ); + + if ( SfxViewFrame::Current() ) { - const Reference& xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - if (xFrame.is()) + xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); + eCurrentApp = vcl::EnumContext::GetApplicationEnum( xModuleManager->identify( xFrame ) ); + } + + SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(); + while( pViewFrame ) + { + xFrame = pViewFrame->GetFrame().GetFrameInterface(); + if ( xFrame.is() ) { - const Reference& xLayoutManager = - lcl_getLayoutManager(xFrame); + vcl::EnumContext::Application eApp = + vcl::EnumContext::GetApplicationEnum( xModuleManager->identify( xFrame ) ); - if (xLayoutManager.is()) + if ( eApp == eCurrentApp ) { - xLayoutManager->lock(); + const Reference& xLayoutManager = + lcl_getLayoutManager( xFrame ); - if (xLayoutManager->getElement(MENUBAR_STR).is()) + if (xLayoutManager.is()) { - if (xLayoutManager->isElementVisible(MENUBAR_STR) && !bShow) - xLayoutManager->hideElement(MENUBAR_STR); - else if(!xLayoutManager->isElementVisible(MENUBAR_STR) && bShow) - xLayoutManager->showElement(MENUBAR_STR); - } + xLayoutManager->lock(); + + if (xLayoutManager->getElement(MENUBAR_STR).is()) + { + if (xLayoutManager->isElementVisible(MENUBAR_STR) && !bShow) + xLayoutManager->hideElement(MENUBAR_STR); + else if(!xLayoutManager->isElementVisible(MENUBAR_STR) && bShow) + xLayoutManager->showElement(MENUBAR_STR); + } - xLayoutManager->unlock(); + xLayoutManager->unlock(); + } } } + + pViewFrame = SfxViewFrame::GetNext( *pViewFrame ); } m_bLock = false; } -- cgit