Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/shells/olesh.cxx
Line
Count
Source
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 <sfx2/toolbarids.hxx>
22
#include <vcl/EnumContext.hxx>
23
#include <view.hxx>
24
#include <frmsh.hxx>
25
#include <olesh.hxx>
26
27
#include <sfx2/sidebar/SidebarController.hxx>
28
29
#define ShellClass_SwOleShell
30
#include <sfx2/msg.hxx>
31
#include <swslots.hxx>
32
33
using namespace css::uno;
34
using namespace sfx2::sidebar;
35
36
namespace {
37
38
bool inChartOrMathContext(const SwView& rViewShell)
39
0
{
40
0
    SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(&rViewShell);
41
0
    if (pSidebar)
42
0
        return pSidebar->hasChartOrMathContextCurrently();
43
44
0
    return false;
45
0
}
46
47
} // anonymous namespace
48
49
SFX_IMPL_INTERFACE(SwOleShell, SwFrameShell)
50
51
void SwOleShell::InitInterface_Impl()
52
9
{
53
9
    GetStaticInterface()->RegisterPopupMenu(u"oleobject"_ustr);
54
55
9
    GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Ole_Toolbox);
56
9
}
57
58
void SwOleShell::Activate(bool bMDI)
59
0
{
60
0
    if(!inChartOrMathContext(GetView()))
61
0
        SwFrameShell::Activate(bMDI);
62
0
    else
63
0
    {
64
        // Avoid context changes for chart/math during activation / deactivation.
65
0
        const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
66
67
0
        SwFrameShell::Activate(bMDI);
68
69
0
        SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
70
0
    }
71
0
}
72
73
void SwOleShell::Deactivate(bool bMDI)
74
0
{
75
0
    if(!inChartOrMathContext(GetView()))
76
0
        SwFrameShell::Deactivate(bMDI);
77
0
    else
78
0
    {
79
        // Avoid context changes for chart/math during activation / deactivation.
80
0
        const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
81
82
0
        SwFrameShell::Deactivate(bMDI);
83
84
0
        SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
85
0
    }
86
0
}
87
88
SwOleShell::SwOleShell(SwView &_rView) :
89
0
    SwFrameShell(_rView)
90
91
0
{
92
0
    SetName(u"Object"_ustr);
93
0
    SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::OLE));
94
0
}
95
96
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */