Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/commandevent.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
#ifndef INCLUDED_VCL_COMMANDEVENT_HXX
21
#define INCLUDED_VCL_COMMANDEVENT_HXX
22
23
#include <memory>
24
#include <tools/gen.hxx>
25
#include <tools/solar.h>
26
#include <vcl/dllapi.h>
27
#include <vcl/keycodes.hxx>
28
#include <o3tl/typed_flags_set.hxx>
29
#include <rtl/ustring.hxx>
30
#include <vcl/GestureEventPan.hxx>
31
#include <vcl/GestureEventZoom.hxx>
32
#include <vcl/GestureEventRotate.hxx>
33
34
class CommandExtTextInputData;
35
class CommandWheelData;
36
class CommandScrollData;
37
class CommandModKeyData;
38
class CommandDialogData;
39
class CommandMediaData;
40
class CommandSelectionChangeData;
41
class CommandGestureSwipeData;
42
class CommandGestureLongPressData;
43
class CommandGesturePanData;
44
class CommandGestureZoomData;
45
class CommandGestureRotateData;
46
47
enum class CommandEventId;
48
49
enum class ExtTextInputAttr {
50
    NONE                  = 0x0000,
51
    GrayWaveline          = 0x0010,
52
    Underline             = 0x0020,
53
    BoldUnderline         = 0x0040,
54
    DottedUnderline       = 0x0080,
55
    DashDotUnderline      = 0x0100,
56
    DoubleUnderline       = 0x0200,
57
    Highlight             = 0x0400,
58
    RedText               = 0x0800,
59
    HalfToneText          = 0x1000
60
};
61
namespace o3tl
62
{
63
    template<> struct typed_flags<ExtTextInputAttr> : is_typed_flags<ExtTextInputAttr, 0x1ff0> {};
64
}
65
66
0
#define EXTTEXTINPUT_CURSOR_INVISIBLE           (sal_uInt16(0x0001))
67
0
#define EXTTEXTINPUT_CURSOR_OVERWRITE           (sal_uInt16(0x0002))
68
69
70
class VCL_DLLPUBLIC CommandEvent
71
{
72
private:
73
    Point                               maPos;
74
    void*                               mpData;
75
    CommandEventId                      mnCommand;
76
    bool                                mbMouseEvent;
77
78
public:
79
                                        CommandEvent();
80
                                        CommandEvent( const Point& rMousePos, CommandEventId nCmd,
81
                                                      bool bMEvt = false, const void* pCmdData = nullptr );
82
83
0
    CommandEventId                      GetCommand() const { return mnCommand; }
84
0
    const Point&                        GetMousePosPixel() const { return maPos; }
85
0
    bool                                IsMouseEvent() const { return mbMouseEvent; }
86
0
    void*                               GetEventData() const { return mpData; }
87
88
    const CommandExtTextInputData*      GetExtTextInputData() const;
89
    const CommandWheelData*             GetWheelData() const;
90
    const CommandScrollData*            GetAutoScrollData() const;
91
    const CommandModKeyData*            GetModKeyData() const;
92
    const CommandDialogData*            GetDialogData() const;
93
          CommandMediaData*             GetMediaData() const;
94
    const CommandSelectionChangeData*   GetSelectionChangeData() const;
95
    const CommandGestureSwipeData*      GetGestureSwipeData() const;
96
    const CommandGestureLongPressData*  GetLongPressData() const;
97
    const CommandGesturePanData*        GetGesturePanData() const;
98
    const CommandGestureZoomData*       GetGestureZoomData() const;
99
    const CommandGestureRotateData*     GetGestureRotateData() const;
100
};
101
102
class VCL_DLLPUBLIC CommandExtTextInputData
103
{
104
private:
105
    OUString            maText;
106
    std::unique_ptr<ExtTextInputAttr[]> mpTextAttr;
107
    sal_Int32           mnCursorPos;
108
    sal_uInt16          mnCursorFlags;
109
    bool                mbOnlyCursor;
110
111
public:
112
                        CommandExtTextInputData( OUString aText,
113
                                                 const ExtTextInputAttr* pTextAttr,
114
                                                 sal_Int32 nCursorPos,
115
                                                 sal_uInt16 nCursorFlags,
116
                                                 bool bOnlyCursor );
117
                        CommandExtTextInputData( const CommandExtTextInputData& rData );
118
                        ~CommandExtTextInputData();
119
120
0
    const OUString&     GetText() const { return maText; }
121
0
    const ExtTextInputAttr* GetTextAttr() const { return mpTextAttr.get(); }
122
123
0
    sal_Int32           GetCursorPos() const { return mnCursorPos; }
124
0
    bool                IsCursorVisible() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_INVISIBLE) == 0; }
125
0
    bool                IsCursorOverwrite() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_OVERWRITE) != 0; }
126
0
    bool                IsOnlyCursorChanged() const { return mbOnlyCursor; }
127
};
128
129
class VCL_DLLPUBLIC CommandInputContextData
130
{
131
};
132
133
enum class CommandWheelMode
134
{
135
    NONE              = 0,
136
    SCROLL            = 1,
137
    ZOOM              = 2,
138
    DATAZOOM          = 3
139
};
140
141
// Magic value used in mnLines field in CommandWheelData
142
0
#define COMMAND_WHEEL_PAGESCROLL        (double(0xFFFFFFFF))
143
144
class VCL_DLLPUBLIC CommandWheelData
145
{
146
private:
147
    tools::Long              mnDelta;
148
    tools::Long              mnNotchDelta;
149
    double            mnLines;
150
    CommandWheelMode  mnWheelMode;
151
    sal_uInt16        mnCode;
152
    bool              mbHorz;
153
    bool              mbDeltaIsPixel;
154
155
public:
156
                    CommandWheelData();
157
                    CommandWheelData( tools::Long nWheelDelta, tools::Long nWheelNotchDelta,
158
                                      double nScrollLines,
159
                                      CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier,
160
                                      bool bHorz, bool bDeltaIsPixel = false );
161
162
0
    tools::Long            GetDelta() const { return mnDelta; }
163
0
    tools::Long            GetNotchDelta() const { return mnNotchDelta; }
164
0
    double          GetScrollLines() const { return mnLines; }
165
0
    bool            IsHorz() const { return mbHorz; }
166
0
    bool            IsDeltaPixel() const { return mbDeltaIsPixel; }
167
168
0
    CommandWheelMode GetMode() const { return mnWheelMode; }
169
170
    sal_uInt16      GetModifier() const
171
0
                        { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); }
172
    bool            IsShift() const
173
0
                        { return ((mnCode & KEY_SHIFT) != 0); }
174
    bool            IsMod1() const
175
0
                        { return ((mnCode & KEY_MOD1) != 0); }
176
    bool            IsMod2() const
177
0
                        { return ((mnCode & KEY_MOD2) != 0); }
178
};
179
180
class CommandScrollData
181
{
182
private:
183
    tools::Long            mnDeltaX;
184
    tools::Long            mnDeltaY;
185
186
public:
187
                    CommandScrollData( tools::Long nDeltaX, tools::Long nDeltaY );
188
189
0
    tools::Long            GetDeltaX() const { return mnDeltaX; }
190
0
    tools::Long            GetDeltaY() const { return mnDeltaY; }
191
};
192
193
class CommandModKeyData
194
{
195
private:
196
    bool            mbDown;
197
    ModKeyFlags     mnCode;
198
199
public:
200
                    CommandModKeyData( ModKeyFlags nCode, bool bDown );
201
202
0
    bool            IsDown()       const { return mbDown; }
203
0
    bool            IsMod1()       const { return bool(mnCode & ModKeyFlags::Mod1Msk); }
204
0
    bool            IsMod2()       const { return bool(mnCode & ModKeyFlags::Mod2Msk); }
205
0
    bool            IsLeftShift()  const { return bool(mnCode & ModKeyFlags::LeftShift); }
206
0
    bool            IsRightShift() const { return bool(mnCode & ModKeyFlags::RightShift); }
207
};
208
209
enum class ShowDialogId
210
{
211
    Preferences       = 1,
212
    About             = 2,
213
};
214
215
class VCL_DLLPUBLIC CommandDialogData
216
{
217
    ShowDialogId   m_nDialogId;
218
public:
219
    CommandDialogData( ShowDialogId nDialogId )
220
0
    : m_nDialogId( nDialogId )
221
0
    {}
222
223
0
    ShowDialogId GetDialogId() const { return m_nDialogId; }
224
};
225
226
// Media Commands
227
enum class MediaCommand
228
{
229
    ChannelDown           = 1, // Decrement the channel value, for example, for a TV or radio tuner.
230
    ChannelUp             = 2, // Increment the channel value, for example, for a TV or radio tuner.
231
    NextTrack             = 3, // Go to next media track/slide.
232
    Pause                 = 4, // Pause. If already paused, take no further action. This is a direct PAUSE command that has no state.
233
    Play                  = 5, // Begin playing at the current position. If already paused, it will resume. This is a direct PLAY command that has no state.
234
    PlayPause             = 6, // Play or pause playback.
235
    PreviousTrack         = 7, // Go to previous media track/slide.
236
    Record                = 8, // Begin recording the current stream.
237
    Rewind                = 9,// Go backward in a stream at a higher rate of speed.
238
    Stop                  = 10,// Stop playback.
239
    MicOnOffToggle        = 11,// Toggle the microphone.
240
    MicrophoneVolumeDown  = 12,// Increase microphone volume.
241
    MicrophoneVolumeMute  = 13,// Mute the microphone.
242
    MicrophoneVolumeUp    = 14,// Decrease microphone volume.
243
    VolumeDown            = 15,// Lower the volume.
244
    VolumeMute            = 16,// Mute the volume.
245
    VolumeUp              = 17,// Raise the volume.
246
    Menu                  = 18,// Button Menu pressed.
247
    PlayHold              = 20,// Button Play (long) pressed.
248
    NextTrackHold         = 21,// Button Right holding pressed.
249
};
250
251
class VCL_DLLPUBLIC CommandMediaData
252
{
253
    MediaCommand m_nMediaId;
254
    bool m_bPassThroughToOS;
255
public:
256
    CommandMediaData(MediaCommand nMediaId)
257
        : m_nMediaId(nMediaId)
258
        , m_bPassThroughToOS(true)
259
0
    {
260
0
    }
261
0
    MediaCommand GetMediaId() const { return m_nMediaId; }
262
0
    void SetPassThroughToOS(bool bPassThroughToOS) { m_bPassThroughToOS = bPassThroughToOS; }
263
0
    bool GetPassThroughToOS() const { return m_bPassThroughToOS; }
264
};
265
266
class CommandSelectionChangeData
267
{
268
private:
269
    sal_uLong          mnStart;
270
    sal_uLong          mnEnd;
271
272
public:
273
    CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd );
274
275
0
    sal_uLong          GetStart() const { return mnStart; }
276
0
    sal_uLong          GetEnd() const { return mnEnd; }
277
};
278
279
class VCL_DLLPUBLIC CommandGestureSwipeData
280
{
281
    double mnVelocityX;
282
public:
283
    CommandGestureSwipeData()
284
        : mnVelocityX(0)
285
0
    {
286
0
    }
287
    CommandGestureSwipeData(double nVelocityX)
288
0
        : mnVelocityX(nVelocityX)
289
0
    {
290
0
    }
291
0
    double getVelocityX() const { return mnVelocityX; }
292
};
293
294
295
class VCL_DLLPUBLIC CommandGestureLongPressData
296
{
297
    double mnX;
298
    double mnY;
299
public:
300
    CommandGestureLongPressData()
301
        : mnX(0)
302
        , mnY(0)
303
0
    {
304
0
    }
305
    CommandGestureLongPressData(double nX, double nY)
306
0
        : mnX(nX)
307
0
        , mnY(nY)
308
0
    {
309
0
    }
310
0
    double getX() const { return mnX; }
311
0
    double getY() const { return mnY; }
312
};
313
314
class VCL_DLLPUBLIC CommandGesturePanData
315
{
316
public:
317
    double const mfX;
318
    double const mfY;
319
    double const mfOffset;
320
    GestureEventPanType const meEventType;
321
    PanningOrientation const meOrientation;
322
323
    CommandGesturePanData(double fX, double fY, GestureEventPanType eEventType, double fOffset,
324
                          PanningOrientation eOrientation)
325
0
        : mfX(fX)
326
0
        , mfY(fY)
327
0
        , mfOffset(fOffset)
328
0
        , meEventType(eEventType)
329
0
        , meOrientation(eOrientation)
330
0
    {}
331
};
332
333
class VCL_DLLPUBLIC CommandGestureZoomData
334
{
335
public:
336
    const double mfX = 0;
337
    const double mfY = 0;
338
    const GestureEventZoomType meEventType = GestureEventZoomType::Begin;
339
    const double mfScaleDelta = 0;
340
341
    CommandGestureZoomData(double fX, double fY, GestureEventZoomType eEventType, double fScale)
342
0
        : mfX(fX)
343
0
        , mfY(fY)
344
0
        , meEventType(eEventType)
345
0
        , mfScaleDelta(fScale)
346
0
    {}
347
};
348
349
class VCL_DLLPUBLIC CommandGestureRotateData
350
{
351
public:
352
    const double mfX = 0;
353
    const double mfY = 0;
354
    const GestureEventRotateType meEventType = GestureEventRotateType::Begin;
355
    const double mfAngleDelta = 0;
356
357
    CommandGestureRotateData(double fX, double fY, GestureEventRotateType eEventType,
358
                             double fAngleDelta)
359
0
        : mfX(fX)
360
0
        , mfY(fY)
361
0
        , meEventType(eEventType)
362
0
        , mfAngleDelta(fAngleDelta)
363
0
    {}
364
};
365
366
enum class CommandEventId
367
{
368
    NONE                    = 0,
369
    ContextMenu             = 1,
370
    StartDrag               = 2,
371
    Wheel                   = 3,
372
    StartAutoScroll         = 4,
373
    AutoScroll              = 5,
374
    StartExtTextInput       = 7,
375
    ExtTextInput            = 8,
376
    EndExtTextInput         = 9,
377
    InputContextChange      = 10,
378
    CursorPos               = 11,
379
    PasteSelection          = 12,
380
    ModKeyChange            = 13,
381
    InputLanguageChange     = 15,
382
    ShowDialog              = 16,
383
    Media                   = 17,
384
    SelectionChange         = 18,
385
    PrepareReconversion     = 19,
386
    QueryCharPosition       = 20,
387
    GestureSwipe            = 21,
388
    GestureLongPress        = 22,
389
    GesturePan              = 23,
390
    GestureZoom             = 24,
391
    GestureRotate           = 25,
392
};
393
394
#endif // INCLUDED_VCL_COMMANDEVENT_HXX
395
396
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */