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 18:40:20 +0100
commit4211ce171cceee978b6e85ea9accaa6726e774c4 (patch)
treefbcd89aabf710b5c6ddadb9553b793e6fe8edb90
parentaa98ed61a7b1e50bcc4f64ceaea3bb0cda360bb4 (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/+/109899 Tested-by: Jenkins
-rw-r--r--sw/source/uibase/inc/olesh.hxx4
-rw-r--r--sw/source/uibase/shells/olesh.cxx49
2 files changed, 53 insertions, 0 deletions
diff --git a/sw/source/uibase/inc/olesh.hxx b/sw/source/uibase/inc/olesh.hxx
index 4f21b2a0396a..a5c9eb28d051 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 b8207d200c94..b823d9a1e6b4 100644
--- a/sw/source/uibase/shells/olesh.cxx
+++ b/sw/source/uibase/shells/olesh.cxx
@@ -23,10 +23,29 @@
#include <frmsh.hxx>
#include <olesh.hxx>
+#include <sfx2/sidebar/SidebarController.hxx>
+#include <view.hxx>
+
#define ShellClass_SwOleShell
#include <sfx2/msg.hxx>
#include <swslots.hxx>
+using namespace css::uno;
+using namespace sfx2::sidebar;
+
+namespace {
+
+bool inChartContext(SwView& rViewShell)
+{
+ SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(&rViewShell);
+ if (pSidebar)
+ return pSidebar->hasChartContextCurrently();
+
+ return false;
+}
+
+} // anonymous namespace
+
SFX_IMPL_INTERFACE(SwOleShell, SwFrameShell)
void SwOleShell::InitInterface_Impl()
@@ -36,6 +55,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)