Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/window/commandevent.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 <algorithm>
21
#include <string.h>
22
23
#include <utility>
24
#include <vcl/commandevent.hxx>
25
26
CommandExtTextInputData::CommandExtTextInputData( OUString aText,
27
    const ExtTextInputAttr* pTextAttr, sal_Int32 nCursorPos, sal_uInt16 nCursorFlags,
28
    bool bOnlyCursor)
29
0
    : maText(std::move(aText))
30
0
{
31
0
    if ( pTextAttr && !maText.isEmpty() )
32
0
    {
33
0
        mpTextAttr.reset( new ExtTextInputAttr[maText.getLength()] );
34
0
        std::copy_n(pTextAttr, maText.getLength(), mpTextAttr.get());
35
0
    }
36
37
0
    mnCursorPos     = nCursorPos;
38
0
    mnCursorFlags   = nCursorFlags;
39
0
    mbOnlyCursor    = bOnlyCursor;
40
0
}
41
42
CommandExtTextInputData::CommandExtTextInputData( const CommandExtTextInputData& rData ) :
43
0
    maText( rData.maText )
44
0
{
45
0
    if ( rData.mpTextAttr && !maText.isEmpty() )
46
0
    {
47
0
        mpTextAttr.reset( new ExtTextInputAttr[maText.getLength()] );
48
0
        std::copy_n(rData.mpTextAttr.get(), maText.getLength(), mpTextAttr.get());
49
0
    }
50
51
0
    mnCursorPos     = rData.mnCursorPos;
52
0
    mnCursorFlags   = rData.mnCursorFlags;
53
0
    mbOnlyCursor    = rData.mbOnlyCursor;
54
0
}
55
56
CommandExtTextInputData::~CommandExtTextInputData()
57
0
{
58
0
}
59
60
CommandWheelData::CommandWheelData()
61
0
{
62
0
    mnDelta         = 0;
63
0
    mnNotchDelta    = 0;
64
0
    mnLines         = 0.0;
65
0
    mnWheelMode     = CommandWheelMode::NONE;
66
0
    mnCode          = 0;
67
0
    mbHorz          = false;
68
0
    mbDeltaIsPixel  = false;
69
0
}
70
71
CommandWheelData::CommandWheelData( tools::Long nWheelDelta, tools::Long nWheelNotchDelta,
72
                                    double nScrollLines,
73
                                    CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier,
74
                                    bool bHorz, bool bDeltaIsPixel )
75
0
{
76
0
    mnDelta         = nWheelDelta;
77
0
    mnNotchDelta    = nWheelNotchDelta;
78
0
    mnLines         = nScrollLines;
79
0
    mnWheelMode     = nWheelMode;
80
0
    mnCode          = nKeyModifier;
81
0
    mbHorz          = bHorz;
82
0
    mbDeltaIsPixel  = bDeltaIsPixel;
83
0
}
84
85
CommandScrollData::CommandScrollData( tools::Long nDeltaX, tools::Long nDeltaY )
86
0
{
87
0
    mnDeltaX    = nDeltaX;
88
0
    mnDeltaY    = nDeltaY;
89
0
}
90
91
CommandModKeyData::CommandModKeyData( ModKeyFlags nCode, bool bDown )
92
0
{
93
0
    mbDown = bDown;
94
0
    mnCode = nCode;
95
0
}
96
97
CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd )
98
0
{
99
0
    mnStart = nStart;
100
0
    mnEnd = nEnd;
101
0
}
102
103
CommandEvent::CommandEvent()
104
0
{
105
0
    mpData          = nullptr;
106
0
    mnCommand       = CommandEventId::NONE;
107
0
    mbMouseEvent    = false;
108
0
}
109
110
CommandEvent::CommandEvent( const Point& rMousePos,
111
                                   CommandEventId nCmd, bool bMEvt, const void* pCmdData ) :
112
0
            maPos( rMousePos )
113
0
{
114
0
    mpData          = const_cast<void*>(pCmdData);
115
0
    mnCommand       = nCmd;
116
0
    mbMouseEvent    = bMEvt;
117
0
}
118
119
const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const
120
0
{
121
0
    if ( mnCommand == CommandEventId::ExtTextInput )
122
0
        return static_cast<const CommandExtTextInputData*>(mpData);
123
0
    else
124
0
        return nullptr;
125
0
}
126
127
const CommandWheelData* CommandEvent::GetWheelData() const
128
0
{
129
0
    if ( mnCommand == CommandEventId::Wheel )
130
0
        return static_cast<const CommandWheelData*>(mpData);
131
0
    else
132
0
        return nullptr;
133
0
}
134
135
const CommandScrollData* CommandEvent::GetAutoScrollData() const
136
0
{
137
0
    if ( mnCommand == CommandEventId::AutoScroll )
138
0
        return static_cast<const CommandScrollData*>(mpData);
139
0
    else
140
0
        return nullptr;
141
0
}
142
143
const CommandModKeyData* CommandEvent::GetModKeyData() const
144
0
{
145
0
    if( mnCommand == CommandEventId::ModKeyChange )
146
0
        return static_cast<const CommandModKeyData*>(mpData);
147
0
    else
148
0
        return nullptr;
149
0
}
150
151
const CommandDialogData* CommandEvent::GetDialogData() const
152
0
{
153
0
    if( mnCommand == CommandEventId::ShowDialog )
154
0
        return static_cast<const CommandDialogData*>(mpData);
155
0
    else
156
0
        return nullptr;
157
0
}
158
159
CommandMediaData* CommandEvent::GetMediaData() const
160
0
{
161
0
    if( mnCommand == CommandEventId::Media )
162
0
        return static_cast<CommandMediaData*>(mpData);
163
0
    else
164
0
        return nullptr;
165
0
}
166
167
const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const
168
0
{
169
0
    if( mnCommand == CommandEventId::SelectionChange )
170
0
        return static_cast<const CommandSelectionChangeData*>(mpData);
171
0
    else
172
0
        return nullptr;
173
0
}
174
175
const CommandGestureSwipeData* CommandEvent::GetGestureSwipeData() const
176
0
{
177
0
    if( mnCommand == CommandEventId::GestureSwipe )
178
0
        return static_cast<const CommandGestureSwipeData*>(mpData);
179
0
    else
180
0
        return nullptr;
181
0
}
182
183
const CommandGestureLongPressData* CommandEvent::GetLongPressData() const
184
0
{
185
0
    if( mnCommand == CommandEventId::GestureLongPress )
186
0
        return static_cast<const CommandGestureLongPressData*>(mpData);
187
0
    else
188
0
        return nullptr;
189
0
}
190
191
const CommandGesturePanData* CommandEvent::GetGesturePanData() const
192
0
{
193
0
    if (mnCommand == CommandEventId::GesturePan)
194
0
        return static_cast<const CommandGesturePanData*>(mpData);
195
0
    else
196
0
        return nullptr;
197
0
}
198
199
const CommandGestureZoomData* CommandEvent::GetGestureZoomData() const
200
0
{
201
0
    if (mnCommand == CommandEventId::GestureZoom)
202
0
        return static_cast<const CommandGestureZoomData*>(mpData);
203
0
    else
204
0
        return nullptr;
205
0
}
206
207
const CommandGestureRotateData* CommandEvent::GetGestureRotateData() const
208
0
{
209
0
    if (mnCommand == CommandEventId::GestureRotate)
210
0
        return static_cast<const CommandGestureRotateData*>(mpData);
211
0
    else
212
0
        return nullptr;
213
0
}
214
215
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */