summaryrefslogtreecommitdiff
path: root/sfx2/source/notebookbar/SfxNotebookBar.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/notebookbar/SfxNotebookBar.cxx')
-rw-r--r--sfx2/source/notebookbar/SfxNotebookBar.cxx39
1 files changed, 38 insertions, 1 deletions
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index dd7a41c5baea..5640e46c374e 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -13,8 +13,14 @@
#include <unotools/viewoptions.hxx>
#include <vcl/notebookbar.hxx>
#include <vcl/syswin.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
+#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
using namespace sfx2;
+using namespace css::uno;
+using namespace css::ui;
void SfxNotebookBar::ExecMethod(SfxBindings& rBindings)
{
@@ -33,7 +39,7 @@ void SfxNotebookBar::StateMethod(SfxBindings& rBindings, const OUString& rUIFile
}
void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
- const css::uno::Reference<css::frame::XFrame> xFrame,
+ const Reference<css::frame::XFrame> xFrame,
const OUString& rUIFile)
{
assert(pSysWindow);
@@ -42,13 +48,44 @@ void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
if (aViewOpt.IsVisible())
{
+ RemoveListeners(pSysWindow);
+
// setup if necessary
pSysWindow->SetNotebookBar(rUIFile, xFrame);
pSysWindow->GetNotebookBar()->Show();
+
+ SfxViewFrame* pView = SfxViewFrame::Current();
+
+ if(pView)
+ {
+ Reference<XContextChangeEventMultiplexer> xMultiplexer
+ = ContextChangeEventMultiplexer::get(
+ ::comphelper::getProcessComponentContext());
+
+ if(xFrame.is() && xMultiplexer.is())
+ {
+ xMultiplexer->addContextChangeEventListener(
+ pSysWindow->GetNotebookBar().get(),
+ xFrame->getController());
+ }
+ }
}
else if (auto pNotebookBar = pSysWindow->GetNotebookBar())
pNotebookBar->Hide();
}
+void SfxNotebookBar::RemoveListeners(SystemWindow* pSysWindow)
+{
+ Reference<XContextChangeEventMultiplexer> xMultiplexer
+ = ContextChangeEventMultiplexer::get(
+ ::comphelper::getProcessComponentContext());
+
+ if (pSysWindow->GetNotebookBar() && xMultiplexer.is())
+ {
+ xMultiplexer->removeAllContextChangeEventListeners(
+ pSysWindow->GetNotebookBar().get());
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */