[Libreoffice-commits] core.git: include/vcl sw/source vcl/source

Kshitij Pathania kshitijpathania at gmail.com
Wed Jul 4 10:46:27 UTC 2018


 include/vcl/EnumContext.hxx        |    2 +-
 include/vcl/notebookbar.hxx        |    3 +++
 sw/source/uibase/uiview/pview.cxx  |   11 ++++++++++-
 vcl/source/control/notebookbar.cxx |   21 +++++++++++++++++++--
 vcl/source/window/EnumContext.cxx  |    1 +
 5 files changed, 34 insertions(+), 4 deletions(-)

New commits:
commit d05b7b32d9ecb6fcb4a268eb68cdcee09bafa6dd
Author: Kshitij Pathania <kshitijpathania at gmail.com>
Date:   Mon Jul 2 18:48:19 2018 +0530

    Notebookbar:Context for printpreview is now working
    
    Also the context stuff is now working well even
    after print preview is set
    
    Change-Id: Ia43f512394cf4d162b4019257c039aecb664df22
    Reviewed-on: https://gerrit.libreoffice.org/56740
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/vcl/EnumContext.hxx b/include/vcl/EnumContext.hxx
index fb64302ccf4d..d5f1e91aa1f4 100644
--- a/include/vcl/EnumContext.hxx
+++ b/include/vcl/EnumContext.hxx
@@ -96,7 +96,7 @@ public:
         Text,
         TextObject,
         Trendline,
-
+        Printpreview,
         // Default context of an application.  Do we need this?
         Default,
 
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 1138834932a1..2a83ada829e0 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")
@@ -1157,6 +1159,13 @@ 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
+    SfxViewFrame::Current()->GetWindow().GetSystemWindow()->GetNotebookBar()->ControlListener(true);
+
     SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
     if ( !pOldSh )
     {
@@ -1221,7 +1230,7 @@ SwPagePreview::~SwPagePreview()
     delete pVShell;
 
     m_pViewWin.disposeAndClear();
-
+    SfxViewFrame::Current()->GetWindow().GetSystemWindow()->GetNotebookBar()->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..895333e16e43 100644
--- a/vcl/source/window/EnumContext.cxx
+++ b/vcl/source/window/EnumContext.cxx
@@ -194,6 +194,7 @@ void EnumContext::ProvideContextContainers()
     AddEntry("Text", Context::Text);
     AddEntry("TextObject", Context::TextObject);
     AddEntry("Trendline", Context::Trendline);
+    AddEntry("Printpreview", Context::Printpreview);
 
 }
 


More information about the Libreoffice-commits mailing list