From 81695542af1dc2cc74f16a1ce4b4dd540a64817b Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Sat, 27 Oct 2018 17:47:01 +0200 Subject: tdf#120874 Don't show menubar in other windows when one is closed Change-Id: Id0b1af277bd7ec367525663ec6d478d67cde0a40 Reviewed-on: https://gerrit.libreoffice.org/62431 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- sfx2/source/notebookbar/SfxNotebookBar.cxx | 35 +++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'sfx2/source/notebookbar') diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index ee19f6f2bcc4..953bacf4bfe8 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -179,7 +179,8 @@ void SfxNotebookBar::CloseMethod(SystemWindow* pSysWindow) RemoveListeners(pSysWindow); if(pSysWindow->GetNotebookBar()) pSysWindow->CloseNotebookBar(); - SfxNotebookBar::ShowMenubar(true); + if (SfxViewFrame::Current()) + SfxNotebookBar::ShowMenubar(SfxViewFrame::Current(), true); } } @@ -423,6 +424,38 @@ void SfxNotebookBar::ShowMenubar(bool bShow) } } +void SfxNotebookBar::ShowMenubar(SfxViewFrame* pViewFrame, bool bShow) +{ + if (m_bLock) + return; + + m_bLock = true; + + uno::Reference xContext = comphelper::getProcessComponentContext(); + const Reference xModuleManager = frame::ModuleManager::create(xContext); + + Reference xFrame = pViewFrame->GetFrame().GetFrameInterface(); + if (xFrame.is()) + { + const Reference& xLayoutManager = lcl_getLayoutManager(xFrame); + if (xLayoutManager.is()) + { + 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(); + } + } + m_bLock = false; +} + void SfxNotebookBar::ToggleMenubar() { if (SfxViewFrame::Current()) -- cgit