Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/syswin.hxx
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
#pragma once
21
22
#include <vcl/dllapi.h>
23
#include <vcl/idle.hxx>
24
#include <vcl/window.hxx>
25
#include <vcl/windowstate.hxx>
26
#include <memory>
27
28
class SalInstanceBuilder;
29
class ScreenshotTest;
30
class MenuBar;
31
class MnemonicGenerator;
32
class NotebookBar;
33
class TaskPaneList;
34
class VclBuilder;
35
struct NotebookBarAddonsItem;
36
37
namespace com::sun::star::frame { class XFrame; }
38
39
#define ICON_LO_DEFAULT                 1
40
#define ICON_TEXT_DOCUMENT              2
41
#define ICON_SPREADSHEET_DOCUMENT       4
42
#define ICON_DRAWING_DOCUMENT           6
43
#define ICON_PRESENTATION_DOCUMENT      8
44
#define ICON_TEMPLATE                   11
45
#define ICON_DATABASE_DOCUMENT          12
46
#define ICON_MATH_DOCUMENT              13
47
#define ICON_MACROLIBRARY               1
48
49
enum class MenuBarMode
50
{
51
    Normal, Hide
52
};
53
54
enum class TitleButton
55
{
56
    Docking        = 1,
57
    Hide           = 2,
58
    Menu           = 4,
59
};
60
61
//helper baseclass to ease retro fitting dialogs/tabpages that load a resource
62
//to load a .ui file instead
63
//
64
//vcl requires the Window Children of a Parent Window to be destroyed before
65
//the Parent Window.  VclBuilderContainer owns the VclBuilder which owns the
66
//Children Window. So the VclBuilderContainer dtor must be called before
67
//the Parent Window dtor.
68
//
69
//i.e.  class Dialog : public SystemWindow, public VclBuilderContainer
70
//not   class Dialog : public VclBuilderContainer, public SystemWindow
71
//
72
//With the new 'dispose' framework, it is necessary to force the builder
73
//dispose before the Window dispose; so a Dialog::dispose() method would
74
//finish: disposeBuilder(); SystemWindow::dispose() to capture this ordering.
75
76
class VCL_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") VclBuilderContainer
77
{
78
public:
79
                    VclBuilderContainer();
80
    virtual         ~VclBuilderContainer();
81
    void            disposeBuilder();
82
83
    void setDeferredProperties();
84
85
protected:
86
    std::unique_ptr<VclBuilder> m_pUIBuilder;
87
88
    friend class ::SalInstanceBuilder;
89
    friend class ::ScreenshotTest;
90
};
91
92
class VCL_DLLPUBLIC SystemWindow
93
    : public vcl::Window
94
    , public VclBuilderContainer
95
{
96
    friend class WorkWindow;
97
    class ImplData;
98
99
private:
100
    class LayoutIdle: public Idle {
101
    public:
102
        LayoutIdle(char const * pDebugName, SystemWindow & parent, bool transferable):
103
7.17k
            Idle(pDebugName), parent_(parent),
104
            transferState_(
105
7.17k
                transferable ? TransferState::Transferable : TransferState::NotTransferable)
106
7.17k
        {}
107
108
        bool DecideTransferredExecution() override;
109
110
0
        bool wasTransferred() const { return transferState_ == TransferState::Transferred; }
111
112
    private:
113
        enum class TransferState { NotTransferable, Transferable, Transferred };
114
115
        SystemWindow & parent_;
116
        TransferState transferState_;
117
    };
118
119
    std::unique_ptr<ImplData> mpImplData;
120
    VclPtr<MenuBar> mpMenuBar;
121
    OUString        maNotebookBarUIFile;
122
    Size            maMinOutSize;
123
    MenuBarMode     mnMenuBarMode = MenuBarMode::Normal;
124
    sal_uInt16      mnIcon = 0;
125
    bool            mbDockBtn : 1 = false;
126
    bool            mbHideBtn : 1 = false;
127
    bool            mbSysChild : 1 = false;
128
    bool            mbIsCalculatingInitialLayoutSize : 1 = false;
129
    bool            mbInitialLayoutSizeCalculated : 1 = false;
130
    bool            mbInSetNoteBookBar : 1 = false;
131
    bool            mbPaintComplete : 1 = false;
132
    bool            mbIsDeferredInit : 1 = false;
133
    LayoutIdle      maLayoutIdle;
134
protected:
135
    VclPtr<vcl::Window> mpDialogParent;
136
public:
137
    using Window::ImplIsInTaskPaneList;
138
    SAL_DLLPRIVATE bool ImplIsInTaskPaneList( vcl::Window* pWin );
139
0
    SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; }
140
141
private:
142
    static SAL_DLLPRIVATE void ImplMoveToScreen( tools::Long& io_rX, tools::Long& io_rY, tools::Long i_nWidth, tools::Long i_nHeight, vcl::Window const * i_pConfigureWin );
143
    SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, Window &rBox);
144
    DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void );
145
146
    // try to extract content and return as Bitmap. To do that reliably, a Yield-loop
147
    // like in Execute() has to be executed and it is necessary to detect when the
148
    // paint is finished
149
    virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
150
    virtual void PostPaint(vcl::RenderContext& rRenderContext) override;
151
152
    // ensureRepaint - triggers Application::Yield until the dialog is
153
    // completely repainted. Sometimes needed for dialogs showing progress
154
    // during actions
155
    SAL_DLLPRIVATE void ensureRepaint();
156
157
protected:
158
    // Single argument ctors shall be explicit.
159
    SAL_DLLPRIVATE explicit SystemWindow(
160
        WindowType eType, const char* pIdleDebugName, bool transferableIdle = false);
161
    SAL_DLLPRIVATE void loadUI(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
162
163
    SAL_DLLPRIVATE void SetWindowState(const vcl::WindowData& rData);
164
165
    virtual void settingOptimalLayoutSize(Window *pBox);
166
167
    SAL_DLLPRIVATE void DoInitialLayout();
168
169
    virtual void ImplDeferredInit(vcl::Window* pParent, WinBits nBits);
170
171
public:
172
    virtual         ~SystemWindow() override;
173
    virtual void    dispose() override;
174
175
    virtual bool    EventNotify( NotifyEvent& rNEvt ) override;
176
    virtual bool    PreNotify( NotifyEvent& rNEvt ) override;
177
178
    virtual bool    Close();
179
    virtual void    TitleButtonClick( TitleButton nButton );
180
    virtual void    Resizing( Size& rSize );
181
    virtual void    Resize() override;
182
    virtual Size    GetOptimalSize() const override;
183
    virtual void    queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
184
    SAL_DLLPRIVATE bool            isLayoutEnabled() const;
185
    SAL_DLLPRIVATE void            setOptimalLayoutSize(bool bAllowWindowShrink);
186
0
    bool            isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; }
187
0
    bool            isSettingUpNoteBookBar() const { return mbInSetNoteBookBar; }
188
189
    void            SetIcon( sal_uInt16 nIcon );
190
0
    sal_uInt16          GetIcon() const { return mnIcon; }
191
    // for systems like MacOSX which can display the URL a document is loaded from
192
    // separately from the window title
193
    void            SetRepresentedURL( const OUString& );
194
195
    SAL_DLLPRIVATE void            ShowTitleButton( TitleButton nButton, bool bVisible );
196
    SAL_DLLPRIVATE bool            IsTitleButtonVisible( TitleButton nButton ) const;
197
198
    void            SetMinOutputSizePixel( const Size& rSize );
199
0
    const Size&     GetMinOutputSizePixel() const { return maMinOutSize; }
200
    SAL_DLLPRIVATE void            SetMaxOutputSizePixel( const Size& rSize );
201
    SAL_DLLPRIVATE const Size&     GetMaxOutputSizePixel() const;
202
203
    void            SetWindowState(std::u16string_view rStr);
204
    OUString GetWindowState(vcl::WindowDataMask nMask = vcl::WindowDataMask::All) const;
205
206
    void            SetMenuBar(MenuBar* pMenuBar);
207
6.57k
    MenuBar*        GetMenuBar() const { return mpMenuBar; }
208
    void            SetMenuBarMode( MenuBarMode nMode );
209
    void            CollectMenuBarMnemonics(MnemonicGenerator& rMnemonicGenerator) const;
210
    int             GetMenuBarHeight() const;
211
212
    void SetNotebookBar(const OUString& rUIXMLDescription,
213
                        const css::uno::Reference<css::frame::XFrame>& rFrame,
214
                        std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem,
215
                        bool bReloadNotebookbar = false);
216
217
    void            CloseNotebookBar();
218
    VclPtr<NotebookBar> const & GetNotebookBar() const;
219
220
    TaskPaneList*   GetTaskPaneList();
221
    SAL_DLLPRIVATE void GetWindowState(vcl::WindowData& rData) const;
222
223
    virtual void     SetText( const OUString& rStr ) override;
224
    virtual OUString GetText() const override;
225
226
    /**
227
    Returns the screen number the window is on
228
229
    The Display Screen number is counted the same way that
230
    <code>Application::GetScreenPosSizePixel</code>
231
    and of course <code>SystemWindow::SetScreenNumber</code>
232
    are counted in.
233
234
    In case the window is positioned on multiple screens the
235
    screen number returned will be of the screen containing the
236
    upper left pixel of the frame area (that is of the client
237
    area on system decorated windows, or the frame area of
238
    undecorated resp. owner decorated windows.
239
240
    @returns the screen number
241
242
    @see SystemWindow::SetScreenNumber
243
    */
244
    unsigned int    GetScreenNumber() const;
245
    /**
246
    Move the Window to a new screen. The same rules for
247
    positioning apply as in <code>SystemWindow::GetScreenNumber</code>
248
249
    The Display Screen number is counted the same way that
250
    <code>Application::GetScreenPosSizePixel</code>
251
    and of course <code>SystemWindow::GetScreenNumber</code>
252
    are counted in.
253
254
    @see GetScreenNumber
255
    */
256
    void            SetScreenNumber( unsigned int nNewScreen );
257
258
    void            SetApplicationID( const OUString &rApplicationID );
259
260
    bool            UpdatePositionData();
261
262
    void SetCloseHdl(const Link<SystemWindow&,void>& rLink);
263
    const Link<SystemWindow&,void>& GetCloseHdl() const;
264
265
0
    SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutIdle.IsActive(); }
266
267
    void doDeferredInit(WinBits nBits);
268
269
    // Screenshot interface
270
    VclPtr<VirtualDevice> createScreenshot();
271
};
272
273
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */