summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/notebookbar/SfxNotebookBar.hxx2
-rw-r--r--sfx2/source/control/dispatch.cxx6
-rw-r--r--sfx2/source/notebookbar/NotebookBarPopupMenu.cxx2
-rw-r--r--sfx2/source/notebookbar/NotebookBarPopupMenu.hxx2
-rw-r--r--sfx2/source/notebookbar/SfxNotebookBar.cxx122
5 files changed, 90 insertions, 44 deletions
diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx
index 12373d1ddd62..de831ed45000 100644
--- a/include/sfx2/notebookbar/SfxNotebookBar.hxx
+++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx
@@ -44,8 +44,6 @@ public:
private:
static bool m_bLock;
- static css::uno::Reference<css::frame::XLayoutManager> m_xLayoutManager;
- static css::uno::Reference<css::frame::XFrame> m_xFrame;
DECL_STATIC_LINK_TYPED(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, void);
};
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 0df9c0e893d2..4b57f14956fe 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -1344,6 +1344,12 @@ void SfxDispatcher::Update_Impl( bool bForce )
if ( xLayoutManager.is() )
xLayoutManager->unlock();
+ if ( SfxViewShell::Current() && SfxViewShell::Current()->GetDispatcher() )
+ {
+ const SfxPoolItem *pItem;
+ SfxViewShell::Current()->GetDispatcher()->QueryState(SID_NOTEBOOKBAR, pItem);
+ }
+
return;
}
diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx
index 35c2495387d0..9d36d015fe18 100644
--- a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx
+++ b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx
@@ -52,7 +52,7 @@ NotebookBarPopupMenu::NotebookBarPopupMenu()
}
void NotebookBarPopupMenu::Execute(NotebookBar* pNotebookbar,
- css::uno::Reference<css::frame::XFrame>& xFrame)
+ const Reference<css::frame::XFrame>& xFrame)
{
if (pNotebookbar)
{
diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx
index 80514113a075..0d06a6e788d6 100644
--- a/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx
+++ b/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx
@@ -17,7 +17,7 @@ class NotebookBarPopupMenu : public PopupMenu
public:
explicit NotebookBarPopupMenu();
void Execute(NotebookBar* pNotebookbar,
- css::uno::Reference<css::frame::XFrame>& xFrame);
+ const css::uno::Reference<css::frame::XFrame>& xFrame);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 49956d5ada4d..f3c343902834 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -35,8 +35,24 @@ using namespace css;
#define MENUBAR_STR "private:resource/menubar/menubar"
bool SfxNotebookBar::m_bLock = false;
-Reference<css::frame::XLayoutManager> SfxNotebookBar::m_xLayoutManager;
-css::uno::Reference<css::frame::XFrame> SfxNotebookBar::m_xFrame;
+
+static Reference<frame::XLayoutManager> lcl_getLayoutManager( const Reference<frame::XFrame>& xFrame )
+{
+ css::uno::Reference<css::frame::XLayoutManager> xLayoutManager;
+
+ if (xFrame.is())
+ {
+ Reference<css::beans::XPropertySet> xPropSet(xFrame, UNO_QUERY);
+
+ if (xPropSet.is())
+ {
+ Any aValue = xPropSet->getPropertyValue("LayoutManager");
+ aValue >>= xLayoutManager;
+ }
+ }
+
+ return xLayoutManager;
+}
static OUString lcl_getAppName( vcl::EnumContext::Application eApp )
{
@@ -149,15 +165,21 @@ void SfxNotebookBar::CloseMethod(SystemWindow* pSysWindow)
pSysWindow->CloseNotebookBar();
}
SfxNotebookBar::ShowMenubar(true);
-
- m_xLayoutManager.clear();
- m_xFrame.clear();
}
bool SfxNotebookBar::IsActive()
{
- const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
- vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(m_xFrame));
+ vcl::EnumContext::Application eApp = vcl::EnumContext::Application::Application_Any;
+
+ if (SfxViewFrame::Current())
+ {
+ const Reference<frame::XFrame>& xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+ if (!xFrame.is())
+ return false;
+
+ const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
+ eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame));
+ }
OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/");
aPath.append( lcl_getAppName( eApp ) );
@@ -194,11 +216,15 @@ bool SfxNotebookBar::IsActive()
void SfxNotebookBar::ExecMethod(SfxBindings& rBindings, const OUString& rUIName)
{
// Save active UI file name
- if ( !rUIName.isEmpty() )
+ if ( !rUIName.isEmpty() && SfxViewFrame::Current() )
{
- const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
- vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(m_xFrame));
- lcl_setNotebookbarFileName( eApp, rUIName );
+ const Reference<frame::XFrame>& xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+ if (xFrame.is())
+ {
+ const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
+ vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame));
+ lcl_setNotebookbarFileName( eApp, rUIName );
+ }
}
// trigger the StateMethod
@@ -218,25 +244,12 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
{
assert(pSysWindow);
- m_xFrame = xFrame;
-
- if (!m_xLayoutManager.is())
- {
- Reference<css::beans::XPropertySet> xPropSet(xFrame, UNO_QUERY);
-
- if (xPropSet.is())
- {
- Any aValue = xPropSet->getPropertyValue("LayoutManager");
- aValue >>= m_xLayoutManager;
- }
- }
-
if (IsActive())
{
RemoveListeners(pSysWindow);
const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
- vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(m_xFrame));
+ vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame));
OUString sFile = lcl_getNotebookbarFileName( eApp );
OUString sNewFile = rUIFile + sFile;
OUString sCurrentFile;
@@ -313,38 +326,67 @@ IMPL_STATIC_LINK_TYPED(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, p
if (pNotebookbar)
{
ScopedVclPtrInstance<NotebookBarPopupMenu> pMenu;
- pMenu->Execute(pNotebookbar, m_xFrame);
+ if (SfxViewFrame::Current())
+ {
+ const Reference<frame::XFrame>& xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+ if (xFrame.is())
+ pMenu->Execute(pNotebookbar, xFrame);
+ }
}
}
void SfxNotebookBar::ShowMenubar(bool bShow)
{
- if (!m_bLock && m_xLayoutManager.is())
+ if (!m_bLock)
{
m_bLock = true;
- m_xLayoutManager->lock();
- if (m_xLayoutManager->getElement(MENUBAR_STR).is())
+ if (SfxViewFrame::Current())
{
- if (m_xLayoutManager->isElementVisible(MENUBAR_STR) && !bShow)
- m_xLayoutManager->hideElement(MENUBAR_STR);
- else if(!m_xLayoutManager->isElementVisible(MENUBAR_STR) && bShow)
- m_xLayoutManager->showElement(MENUBAR_STR);
- }
+ const Reference<frame::XFrame>& xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+ if (xFrame.is())
+ {
+ const Reference<frame::XLayoutManager>& xLayoutManager =
+ lcl_getLayoutManager(xFrame);
+
+ if (xLayoutManager.is())
+ {
+ xLayoutManager->lock();
- m_xLayoutManager->unlock();
+ 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 (m_xLayoutManager.is() && m_xLayoutManager->getElement(MENUBAR_STR).is())
+ if (SfxViewFrame::Current())
{
- if (m_xLayoutManager->isElementVisible(MENUBAR_STR))
- SfxNotebookBar::ShowMenubar(false);
- else
- SfxNotebookBar::ShowMenubar(true);
+ const Reference<frame::XFrame>& xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+ if (xFrame.is())
+ {
+ const Reference<frame::XLayoutManager>& xLayoutManager =
+ lcl_getLayoutManager(xFrame);
+
+ if (xLayoutManager.is() && xLayoutManager->getElement(MENUBAR_STR).is())
+ {
+ if (xLayoutManager->isElementVisible(MENUBAR_STR))
+ SfxNotebookBar::ShowMenubar(false);
+ else
+ SfxNotebookBar::ShowMenubar(true);
+ }
+ }
}
}