Coverage Report

Created: 2025-11-16 09:57

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