LibreOffice Module sw (master) 1
olesh.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sfx2/objface.hxx>
21#include <vcl/EnumContext.hxx>
22#include <view.hxx>
23#include <frmsh.hxx>
24#include <olesh.hxx>
25
27
28#define ShellClass_SwOleShell
29#include <sfx2/msg.hxx>
30#include <swslots.hxx>
31
32using namespace css::uno;
33using namespace sfx2::sidebar;
34
35namespace {
36
37bool inChartOrMathContext(const SwView& rViewShell)
38{
39 SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(&rViewShell);
40 if (pSidebar)
41 return pSidebar->hasChartOrMathContextCurrently();
42
43 return false;
44}
45
46} // anonymous namespace
47
49
50void SwOleShell::InitInterface_Impl()
51{
52 GetStaticInterface()->RegisterPopupMenu("oleobject");
53
54 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Ole_Toolbox);
55}
56
57void SwOleShell::Activate(bool bMDI)
58{
59 if(!inChartOrMathContext(GetView()))
61 else
62 {
63 // Avoid context changes for chart/math during activation / deactivation.
64 const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
65
67
68 SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
69 }
70}
71
73{
74 if(!inChartOrMathContext(GetView()))
76 else
77 {
78 // Avoid context changes for chart/math during activation / deactivation.
79 const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
80
82
83 SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
84 }
85}
86
88 SwFrameShell(_rView)
89
90{
91 SetName("Object");
93}
94
95/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Activate(bool bMDI)
bool SetContextBroadcasterEnabled(const bool bIsEnabled)
void SetContextName(const OUString &rsContextName)
virtual void Deactivate(bool bMDI)
void SetName(const OUString &rName)
SwView & GetView()
Definition: basesh.hxx:59
SwOleShell(SwView &rView)
Definition: olesh.cxx:87
virtual void Deactivate(bool bMDI) override
Definition: olesh.cxx:72
virtual void Activate(bool bMDI) override
Definition: olesh.cxx:57
Definition: view.hxx:146
bool hasChartOrMathContextCurrently() const
static const OUString & GetContextName(const Context eContext)
#define SFX_OBJECTBAR_OBJECT
#define SFX_IMPL_INTERFACE(Class, SuperClass)