summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2021-01-22 11:55:25 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2021-01-25 16:25:45 +0100
commit7c1dd1001798092248b22ed392b12b6c271a831f (patch)
tree6801ac71e7746a74b3cc278872a5bdd149c0debf
parent2a2e1bcfbeffbed39a90ea61486f95041579c6d4 (diff)
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109903
-rw-r--r--sw/source/uibase/inc/olesh.hxx4
-rw-r--r--sw/source/uibase/shells/olesh.cxx48
2 files changed, 52 insertions, 0 deletions
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)