Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / sfx2 / source / sidebar / SidebarChildWindow.cxx
blobe75687dfea43562e4e7caa11246ba5a32ce297fb
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/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>
28 namespace sfx2::sidebar {
30 SFX_IMPL_DOCKINGWINDOW_WITHID(SidebarChildWindow, SID_SIDEBAR);
32 SidebarChildWindow::SidebarChildWindow(vcl::Window* pParentWindow, sal_uInt16 nId,
33 SfxBindings* pBindings, SfxChildWinInfo* pInfo)
34 : SfxChildWindow(pParentWindow, nId)
36 auto pDockWin = VclPtr<SidebarDockingWindow>::Create(
37 pBindings, *this, pParentWindow, WB_STDDOCKWIN | WB_OWNERDRAWDECORATION | WB_CLIPCHILDREN
38 | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE);
39 SetWindow(pDockWin);
40 SetAlignment(SfxChildAlignment::RIGHT);
42 pDockWin->SetHelpId(HID_SIDEBAR_WINDOW);
43 pDockWin->SetOutputSizePixel(Size(GetDefaultWidth(pDockWin), 450));
45 if (pInfo && pInfo->aExtraString.isEmpty() && pInfo->aModule != "sdraw"
46 && pInfo->aModule != "simpress")
48 // When this is the first start (never had the sidebar open yet),
49 // default to non-expanded sidebars in Writer and Calc.
51 // HACK: unfortunately I haven't found a clean solution to do
52 // this, so do it this way:
54 if (!comphelper::LibreOfficeKit::isActive())
56 pDockWin->SetSizePixel(
57 Size(TabBar::GetDefaultWidth() * GetWindow()->GetDPIScaleFactor(),
58 pDockWin->GetSizePixel().Height()));
62 pDockWin->Initialize(pInfo);
64 if (comphelper::LibreOfficeKit::isActive())
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 pDockWin->SetFloatingSize(Size(pDockWin->GetSizePixel().Width() * GetWindow()->GetDPIScaleFactor(),
70 pDockWin->GetSizePixel().Height()));
71 pDockWin->SetFloatingMode(true);
74 SetHideNotDelete(true);
76 pDockWin->Show();
79 sal_Int32 SidebarChildWindow::GetDefaultWidth(vcl::Window const* pWindow)
81 if (pWindow != nullptr)
83 // Width of the paragraph panel.
84 const static sal_Int32 nMaxPropertyPageWidth(146);
86 return pWindow->LogicToPixel(Point(nMaxPropertyPageWidth,1), MapMode(MapUnit::MapAppFont)).X()
87 + TabBar::GetDefaultWidth() * pWindow->GetDPIScaleFactor();
89 else
90 return 0;
93 } // end of namespace sfx2::sidebar
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */