Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sfx2/source/sidebar/SidebarChildWindow.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 <tools/mapunit.hxx>
21
#include <sfx2/chalign.hxx>
22
#include <sfx2/sidebar/TabBar.hxx>
23
#include <sfx2/bindings.hxx>
24
#include <sfx2/sidebar/SidebarChildWindow.hxx>
25
#include <sfx2/sidebar/SidebarDockingWindow.hxx>
26
#include <sfx2/sfxsids.hrc>
27
#include <helpids.h>
28
#include <comphelper/lok.hxx>
29
30
namespace sfx2::sidebar {
31
32
SFX_IMPL_DOCKINGWINDOW_WITHID(SidebarChildWindow, SID_SIDEBAR);
33
34
SidebarChildWindow::SidebarChildWindow(vcl::Window* pParentWindow, sal_uInt16 nId,
35
                                       SfxBindings* pBindings, SfxChildWinInfo* pInfo)
36
0
    : SfxChildWindow(pParentWindow, nId)
37
0
{
38
0
    auto pDockWin = VclPtr<SidebarDockingWindow>::Create(
39
0
        pBindings, *this, pParentWindow, WB_STDDOCKWIN | WB_OWNERDRAWDECORATION | WB_CLIPCHILDREN
40
0
                                             | WB_SIZEABLE | WB_3DLOOK);
41
0
    SetWindow(pDockWin);
42
0
    SetAlignment(SfxChildAlignment::RIGHT);
43
44
0
    pDockWin->SetHelpId(HID_SIDEBAR_WINDOW);
45
0
    pDockWin->SetOutputSizePixel(Size(GetDefaultWidth(pDockWin), 450));
46
47
0
    if (pInfo && pInfo->aExtraString.isEmpty() && pInfo->aModule != "sdraw"
48
0
        && pInfo->aModule != "simpress" && pInfo->aModule != "smath")
49
0
    {
50
        // When this is the first start (never had the sidebar open yet),
51
        // default to non-expanded sidebars in Writer and Calc.
52
        //
53
        // HACK: unfortunately I haven't found a clean solution to do
54
        // this, so do it this way:
55
        //
56
0
        if (!comphelper::LibreOfficeKit::isActive())
57
0
        {
58
0
            pDockWin->SetSizePixel(
59
0
                Size(TabBar::GetDefaultWidth(),
60
0
                     pDockWin->GetSizePixel().Height()));
61
0
        }
62
0
    }
63
64
0
    pDockWin->Initialize(pInfo);
65
66
0
    if (comphelper::LibreOfficeKit::isActive())
67
0
    {
68
        // Undock sidebar in LOK to allow for resizing freely
69
        // (i.e. when the client window is resized) and collapse
70
        // it so the client can open it on demand.
71
0
        pDockWin->SetFloatingSize(Size(pDockWin->GetSizePixel().Width(),
72
0
                                       pDockWin->GetSizePixel().Height()));
73
0
        pDockWin->SetFloatingMode(true);
74
0
    }
75
76
0
    SetHideNotDelete(true);
77
78
0
    pDockWin->Show();
79
0
}
80
81
sal_Int32 SidebarChildWindow::GetDefaultWidth(vcl::Window const* pWindow)
82
0
{
83
0
    if (pWindow != nullptr)
84
0
    {
85
        // Width of the paragraph panel.
86
0
        const static sal_Int32 nMaxPropertyPageWidth(146);
87
88
0
        return pWindow->LogicToPixel(Point(nMaxPropertyPageWidth,1), MapMode(MapUnit::MapAppFont)).X()
89
0
            + TabBar::GetDefaultWidth();
90
0
    }
91
0
    else
92
0
        return 0;
93
0
}
94
95
} // end of namespace sfx2::sidebar
96
97
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */