Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/include/vcl/sysdata.hxx
Line
Count
Source (jump to first uncovered line)
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
#ifndef INCLUDED_VCL_SYSDATA_HXX
21
#define INCLUDED_VCL_SYSDATA_HXX
22
23
#include <sal/types.h>
24
#include <vcl/dllapi.h>
25
#include <config_vclplug.h>
26
27
class SalFrame;
28
29
#ifdef MACOSX
30
// predeclare the native classes to avoid header/include problems
31
typedef struct CGContext *CGContextRef;
32
typedef struct CGLayer   *CGLayerRef;
33
typedef const struct __CTFont * CTFontRef;
34
#ifdef __OBJC__
35
@class NSView;
36
#else
37
class NSView;
38
#endif
39
#endif
40
41
#ifdef IOS
42
typedef const struct __CTFont * CTFontRef;
43
typedef struct CGContext *CGContextRef;
44
#endif
45
46
#if defined(_WIN32)
47
#include <prewin.h>
48
#include <windef.h>
49
#include <postwin.h>
50
#endif
51
52
struct VCL_DLLPUBLIC SystemEnvData
53
{
54
    enum class Toolkit { Invalid, Gen, Gtk, Qt };
55
    Toolkit             toolkit;        // the toolkit in use
56
#if defined(_WIN32)
57
    HWND                hWnd;           // the window hwnd
58
#elif defined( MACOSX )
59
    NSView*             mpNSView;       // the cocoa (NSView *) implementing this object
60
    bool                mbOpenGL;       // use an OpenGL providing NSView
61
#elif defined( ANDROID )
62
    // Nothing
63
#elif defined( IOS )
64
    // Nothing
65
#elif defined( UNX )
66
    enum class Platform { Invalid, Wayland, Xcb, WASM };
67
68
    void*               pDisplay;       // the relevant display connection
69
    SalFrame*           pSalFrame;      // contains a salframe, if object has one
70
    void*               pWidget;        // the corresponding widget
71
    void*               pVisual;        // the visual in use
72
    int                 nScreen;        // the current screen of the window
73
    Platform            platform;       // the windowing system in use
74
private:
75
    sal_uIntPtr         aWindow;        // the window of the object
76
public:
77
78
    void SetWindowHandle(sal_uIntPtr nWindow)
79
0
    {
80
0
        aWindow = nWindow;
81
0
    }
82
83
    // SalFrame can be any SalFrame, just needed to determine which backend to use
84
    // to resolve the window handle
85
    sal_uIntPtr GetWindowHandle(const SalFrame* pReference) const;
86
87
#endif
88
89
    SystemEnvData()
90
12.7k
        : toolkit(Toolkit::Invalid)
91
#if defined(_WIN32)
92
        , hWnd(nullptr)
93
#elif defined( MACOSX )
94
        , mpNSView(nullptr)
95
        , mbOpenGL(false)
96
#elif defined( ANDROID )
97
#elif defined( IOS )
98
#elif defined( UNX )
99
12.7k
        , pDisplay(nullptr)
100
12.7k
        , pSalFrame(nullptr)
101
12.7k
        , pWidget(nullptr)
102
12.7k
        , pVisual(nullptr)
103
12.7k
        , nScreen(0)
104
12.7k
        , platform(Platform::Invalid)
105
12.7k
        , aWindow(0)
106
#endif
107
12.7k
    {
108
12.7k
    }
109
};
110
111
struct SystemParentData
112
{
113
    sal_uInt32      nSize;            // size in bytes of this structure
114
#if defined(_WIN32)
115
    HWND            hWnd;             // the window hwnd
116
#elif defined( MACOSX )
117
    NSView*         pView;            // the cocoa (NSView *) implementing this object
118
#elif defined( ANDROID )
119
    // Nothing
120
#elif defined( IOS )
121
    // Nothing
122
#elif defined( UNX )
123
    sal_uIntPtr     aWindow;          // the window of the object
124
    bool            bXEmbedSupport:1; // decides whether the object in question
125
                                      // should support the XEmbed protocol
126
#endif
127
};
128
129
struct SystemMenuData
130
{
131
#if defined(_WIN32)
132
    HMENU           hMenu;          // the menu handle of the menu bar
133
#else
134
    // Nothing
135
#endif
136
};
137
138
struct SystemGraphicsData
139
{
140
    sal_uInt32      nSize;          // size in bytes of this structure
141
#if defined(_WIN32)
142
    HDC             hDC;            // handle to a device context
143
    HWND            hWnd;           // optional handle to a window
144
#elif defined( MACOSX )
145
    CGContextRef    rCGContext;     // CoreGraphics graphic context
146
#elif defined( ANDROID )
147
    // Nothing
148
#elif defined( IOS )
149
    CGContextRef    rCGContext;     // CoreGraphics graphic context
150
#elif defined( UNX )
151
    void*           pDisplay;       // the relevant display connection
152
    sal_uIntPtr     hDrawable;      // a drawable
153
    void*           pVisual;        // the visual in use
154
    int             nScreen;        // the current screen of the drawable
155
#endif
156
#if USE_HEADLESS_CODE
157
    void*           pSurface;       // the cairo surface when using svp-based backends, which includes gtk[3|4]
158
#endif
159
    SystemGraphicsData()
160
8
        : nSize( sizeof( SystemGraphicsData ) )
161
#if defined(_WIN32)
162
        , hDC( nullptr )
163
        , hWnd( nullptr )
164
#elif defined( MACOSX )
165
        , rCGContext( nullptr )
166
#elif defined( ANDROID )
167
    // Nothing
168
#elif defined( IOS )
169
        , rCGContext( NULL )
170
#elif defined( UNX )
171
8
        , pDisplay( nullptr )
172
8
        , hDrawable( 0 )
173
8
        , pVisual( nullptr )
174
8
        , nScreen( 0 )
175
#endif
176
#if USE_HEADLESS_CODE
177
8
        , pSurface( nullptr )
178
#endif
179
8
    { }
180
};
181
182
struct SystemWindowData
183
{
184
#if defined(_WIN32)                  // meaningless on Windows
185
#elif defined( MACOSX )
186
    bool            bOpenGL;        // create an OpenGL providing NSView
187
    bool            bLegacy;        // create a 2.1 legacy context, only valid if bOpenGL == true
188
#elif defined( ANDROID )
189
    // Nothing
190
#elif defined( IOS )
191
    // Nothing
192
#elif defined( UNX )
193
    void*           pVisual;        // the visual to be used
194
    bool            bClipUsingNativeWidget; // default is false, true will attempt to clip the childwindow with a native widget
195
#endif
196
};
197
198
#endif // INCLUDED_VCL_SYSDATA_HXX
199
200
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */