summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/EnumContext.hxx1
-rw-r--r--include/vcl/notebookbar.hxx3
-rw-r--r--sw/source/uibase/uiview/pview.cxx13
-rw-r--r--vcl/source/control/notebookbar.cxx21
-rw-r--r--vcl/source/window/EnumContext.cxx8
5 files changed, 40 insertions, 6 deletions
diff --git a/include/vcl/EnumContext.hxx b/include/vcl/EnumContext.hxx
index fb64302ccf4d..dfdc8e8a8c94 100644
--- a/include/vcl/EnumContext.hxx
+++ b/include/vcl/EnumContext.hxx
@@ -90,6 +90,7 @@ public:
OLE,
OutlineText,
Pivot,
+ Printpreview,
Series,
SlidesorterPage,
Table,
diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx
index f3490bfeea89..535f157e7810 100644
--- a/include/vcl/notebookbar.hxx
+++ b/include/vcl/notebookbar.hxx
@@ -41,10 +41,13 @@ public:
void DataChanged(const DataChangedEvent& rDCEvt) override;
+ void ControlListener(bool bListen);
+
private:
VclPtr<SystemWindow> m_pSystemWindow;
css::uno::Reference<css::ui::XContextChangeEventListener> m_pEventListener;
std::vector<NotebookbarContextControl*> m_pContextContainers;
+ css::uno::Reference<css::frame::XFrame> mxFrame;
AllSettings DefaultSettings;
AllSettings PersonaSettings;
diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx
index 76f46c2a46dc..7b71101baa8a 100644
--- a/sw/source/uibase/uiview/pview.cxx
+++ b/sw/source/uibase/uiview/pview.cxx
@@ -78,6 +78,8 @@
#include <svx/dialogs.hrc>
#include <memory>
+#include <vcl/EnumContext.hxx>
+#include <vcl/notebookbar.hxx>
using namespace ::com::sun::star;
SFX_IMPL_NAMED_VIEWFACTORY(SwPagePreview, "PrintPreview")
@@ -1174,6 +1176,14 @@ SwPagePreview::SwPagePreview(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh):
CreateScrollbar( true );
CreateScrollbar( false );
+ //notify notebookbar change in context
+ SfxShell::SetContextBroadcasterEnabled(true);
+ SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Printpreview));
+ SfxShell::BroadcastContextForActivation(true);
+ //removelisteners for notebookbar
+ if (auto& pBar = SfxViewFrame::Current()->GetWindow().GetSystemWindow()->GetNotebookBar())
+ pBar->ControlListener(true);
+
SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
if ( !pOldSh )
{
@@ -1238,7 +1248,8 @@ SwPagePreview::~SwPagePreview()
delete pVShell;
m_pViewWin.disposeAndClear();
-
+ if (auto& pBar = SfxViewFrame::Current()->GetWindow().GetSystemWindow()->GetNotebookBar())
+ pBar->ControlListener(false);
m_pScrollFill.disposeAndClear();
m_pHScrollbar.disposeAndClear();
m_pVScrollbar.disposeAndClear();
diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx
index 6c04bcaf7423..9b2381e2cc95 100644
--- a/vcl/source/control/notebookbar.cxx
+++ b/vcl/source/control/notebookbar.cxx
@@ -14,7 +14,7 @@
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/implbase.hxx>
#include <vcl/vclevent.hxx>
-
+#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
/**
* split from the main class since it needs different ref-counting mana
*/
@@ -37,7 +37,7 @@ NotebookBar::NotebookBar(Window* pParent, const OString& rID, const OUString& rU
{
SetStyle(GetStyle() | WB_DIALOGCONTROL);
m_pUIBuilder.reset( new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID, rFrame) );
-
+ mxFrame = rFrame;
// In the Notebookbar's .ui file must exist control handling context
// - implementing NotebookbarContextControl interface with id "ContextContainer"
// or "ContextContainerX" where X is a number >= 1
@@ -154,6 +154,23 @@ void SAL_CALL NotebookBarContextChangeEventListener::notifyContextChangeEvent(co
}
}
+void NotebookBar::ControlListener(bool bListen)
+{
+ if(bListen)
+ {
+ // remove listeners
+ css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (css::ui::ContextChangeEventMultiplexer::get(
+ ::comphelper::getProcessComponentContext()));
+ xMultiplexer->removeContextChangeEventListener(getContextChangeEventListener(),mxFrame->getController());
+ }
+ else
+ {
+ // add listeners
+ css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (css::ui::ContextChangeEventMultiplexer::get(
+ ::comphelper::getProcessComponentContext()));
+ xMultiplexer->addContextChangeEventListener(getContextChangeEventListener(),mxFrame->getController());
+ }
+}
void SAL_CALL NotebookBarContextChangeEventListener::disposing(const ::css::lang::EventObject&)
{
diff --git a/vcl/source/window/EnumContext.cxx b/vcl/source/window/EnumContext.cxx
index e6a1543ad6d9..ec8249d67f1c 100644
--- a/vcl/source/window/EnumContext.cxx
+++ b/vcl/source/window/EnumContext.cxx
@@ -160,9 +160,6 @@ void EnumContext::ProvideContextContainers()
if (!maContextMap.empty())
return;
- AddEntry("any", Context::Any);
- AddEntry("default", Context::Default);
- AddEntry("empty", Context::Empty);
AddEntry("3DObject", Context::ThreeDObject);
AddEntry("Annotation", Context::Annotation);
AddEntry("Auditing", Context::Auditing);
@@ -188,6 +185,7 @@ void EnumContext::ProvideContextContainers()
AddEntry("OLE", Context::OLE);
AddEntry("OutlineText", Context::OutlineText);
AddEntry("Pivot", Context::Pivot);
+ AddEntry("Printpreview", Context::Printpreview);
AddEntry("Series", Context::Series);
AddEntry("SlidesorterPage", Context::SlidesorterPage);
AddEntry("Table", Context::Table);
@@ -195,6 +193,10 @@ void EnumContext::ProvideContextContainers()
AddEntry("TextObject", Context::TextObject);
AddEntry("Trendline", Context::Trendline);
+ // other general contexts
+ AddEntry("any", Context::Any);
+ AddEntry("default", Context::Default);
+ AddEntry("empty", Context::Empty);
}
EnumContext::Context EnumContext::GetContextEnum (const ::rtl::OUString& rsContextName)