[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - include/vcl sw/source vcl/source

Kshitij Pathania kshitijpathania at gmail.com
Tue Jul 10 10:10:52 UTC 2018


 include/vcl/EnumContext.hxx        |    1 +
 include/vcl/notebookbar.hxx        |    3 +++
 sw/source/uibase/uiview/pview.cxx  |   13 ++++++++++++-
 vcl/source/control/notebookbar.cxx |   21 +++++++++++++++++++--
 vcl/source/window/EnumContext.cxx  |    8 +++++---
 5 files changed, 40 insertions(+), 6 deletions(-)

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

    Notebookbar:Context for printpreview is working.
    
    This is a combination of 3 commits.
    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>
    
    tdf#118546: GetNotebookBar() may return nullptr
    
    Change-Id: I411ea0abcb5fd5fac0db7fe0c4bad16a0c1b9d77
    Reviewed-on: https://gerrit.libreoffice.org/57006
    Reviewed-by: Kshitij Pathania <kshitijpathania at gmail.com>
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    
    Conserved the alphabetical order in contexts.
    
    ThreeDObject is remained on top as its entry begin with 3.
    All others are sorted now except the generalised ones in last.
    
    Change-Id: Id56550da450f0d2a0dd770a78360d20ada90f048
    Reviewed-on: https://gerrit.libreoffice.org/56984
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/57190

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)


More information about the Libreoffice-commits mailing list