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
diff --git a/sw/source/uibase/inc/olesh.hxx b/sw/source/uibase/inc/olesh.hxx
index 4f21b2a..a5c9eb2 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 b8207d2..b823d9a 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)