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