Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / shells / olesh.cxx
blob28e8e153eeb16fbe1cdbf750ea1297d130749f49
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/objface.hxx>
21 #include <vcl/EnumContext.hxx>
22 #include <view.hxx>
23 #include <frmsh.hxx>
24 #include <olesh.hxx>
26 #include <sfx2/sidebar/SidebarController.hxx>
28 #define ShellClass_SwOleShell
29 #include <sfx2/msg.hxx>
30 #include <swslots.hxx>
32 using namespace css::uno;
33 using namespace sfx2::sidebar;
35 namespace {
37 bool inChartOrMathContext(const SwView& rViewShell)
39 SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(&rViewShell);
40 if (pSidebar)
41 return pSidebar->hasChartOrMathContextCurrently();
43 return false;
46 } // anonymous namespace
48 SFX_IMPL_INTERFACE(SwOleShell, SwFrameShell)
50 void SwOleShell::InitInterface_Impl()
52 GetStaticInterface()->RegisterPopupMenu("oleobject");
54 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Ole_Toolbox);
57 void SwOleShell::Activate(bool bMDI)
59 if(!inChartOrMathContext(GetView()))
60 SwFrameShell::Activate(bMDI);
61 else
63 // Avoid context changes for chart/math during activation / deactivation.
64 const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
66 SwFrameShell::Activate(bMDI);
68 SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
72 void SwOleShell::Deactivate(bool bMDI)
74 if(!inChartOrMathContext(GetView()))
75 SwFrameShell::Deactivate(bMDI);
76 else
78 // Avoid context changes for chart/math during activation / deactivation.
79 const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
81 SwFrameShell::Deactivate(bMDI);
83 SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
87 SwOleShell::SwOleShell(SwView &_rView) :
88 SwFrameShell(_rView)
91 SetName("Object");
92 SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::OLE));
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */