sw/source/uibase/inc/olesh.hxx    |    4 +++
 sw/source/uibase/shells/olesh.cxx |   48 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

New commits:
commit 7c1dd1001798092248b22ed392b12b6c271a831f
Author:     Tamás Zolnai <tamas.zol...@collabora.com>
AuthorDate: Fri Jan 22 11:55:25 2021 +0100
Commit:     Tamás Zolnai <tamas.zol...@collabora.com>
CommitDate: Mon Jan 25 16:25:45 2021 +0100

    tdf#139830: keep the right context for chart after view switch (writer).
    
    Change-Id: Id4829e4bf8f52e2348ebd7874c77e245b18a2bb9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109812
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109903

diff --git a/sw/source/uibase/inc/olesh.hxx b/sw/source/uibase/inc/olesh.hxx
index 30979029ed16..be3bb7305a98 100644
--- a/sw/source/uibase/inc/olesh.hxx
+++ b/sw/source/uibase/inc/olesh.hxx
@@ -30,6 +30,10 @@ private:
     /// SfxInterface initializer.
     static void InitInterface_Impl();
 
+protected:
+    virtual void Activate(bool bMDI) override;
+    virtual void Deactivate(bool bMDI) override;
+
 public:
     SwOleShell(SwView &rView);
 };
diff --git a/sw/source/uibase/shells/olesh.cxx 
b/sw/source/uibase/shells/olesh.cxx
index c688072f9094..a373e2b1ae58 100644
--- a/sw/source/uibase/shells/olesh.cxx
+++ b/sw/source/uibase/shells/olesh.cxx
@@ -29,11 +29,29 @@
 #include <olesh.hxx>
 
 #include <cmdid.h>
+#include <sfx2/sidebar/SidebarController.hxx>
+#include <sfx2/sidebar/Tools.hxx>
+#include <view.hxx>
 
 #define ShellClass_SwOleShell
 #include <sfx2/msg.hxx>
 #include <swslots.hxx>
 
+using namespace css::uno;
+
+namespace {
+
+bool inChartContext(SwView& rViewShell)
+{
+    sfx2::sidebar::SidebarController* pSidebar = 
sfx2::sidebar::Tools::GetSidebarController(&rViewShell);
+    if (pSidebar)
+        return pSidebar->hasChartContextCurrently();
+
+    return false;
+}
+
+} // anonymous namespace
+
 SFX_IMPL_INTERFACE(SwOleShell, SwFrameShell)
 
 void SwOleShell::InitInterface_Impl()
@@ -43,6 +61,36 @@ void SwOleShell::InitInterface_Impl()
     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, 
SfxVisibilityFlags::Invisible, ToolbarId::Ole_Toolbox);
 }
 
+void SwOleShell::Activate(bool bMDI)
+{
+    if(!inChartContext(GetView()))
+        SwFrameShell::Activate(bMDI);
+    else
+    {
+        // Avoid context changes for chart during activation / deactivation.
+        const bool bIsContextBroadcasterEnabled 
(SfxShell::SetContextBroadcasterEnabled(false));
+
+        SwFrameShell::Activate(bMDI);
+
+        SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
+    }
+}
+
+void SwOleShell::Deactivate(bool bMDI)
+{
+    if(!inChartContext(GetView()))
+        SwFrameShell::Deactivate(bMDI);
+    else
+    {
+        // Avoid context changes for chart during activation / deactivation.
+        const bool bIsContextBroadcasterEnabled 
(SfxShell::SetContextBroadcasterEnabled(false));
+
+        SwFrameShell::Deactivate(bMDI);
+
+        SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
+    }
+}
+
 SwOleShell::SwOleShell(SwView &_rView) :
     SwFrameShell(_rView)
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to