build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / vcl / source / window / commandevent.cxx
blob7946f561ff7350e1b4374c11a12ed087dcf02139
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <string.h>
22 #include <vcl/commandevent.hxx>
24 CommandExtTextInputData::CommandExtTextInputData( const OUString& rText,
25 const ExtTextInputAttr* pTextAttr, sal_Int32 nCursorPos, sal_uInt16 nCursorFlags,
26 bool bOnlyCursor)
27 : maText(rText)
29 if ( pTextAttr && !maText.isEmpty() )
31 mpTextAttr.reset( new ExtTextInputAttr[maText.getLength()] );
32 memcpy( mpTextAttr.get(), pTextAttr, maText.getLength()*sizeof(ExtTextInputAttr) );
35 mnCursorPos = nCursorPos;
36 mnCursorFlags = nCursorFlags;
37 mbOnlyCursor = bOnlyCursor;
40 CommandExtTextInputData::CommandExtTextInputData( const CommandExtTextInputData& rData ) :
41 maText( rData.maText )
43 if ( rData.mpTextAttr && !maText.isEmpty() )
45 mpTextAttr.reset( new ExtTextInputAttr[maText.getLength()] );
46 memcpy( mpTextAttr.get(), rData.mpTextAttr.get(), maText.getLength()*sizeof(ExtTextInputAttr) );
49 mnCursorPos = rData.mnCursorPos;
50 mnCursorFlags = rData.mnCursorFlags;
51 mbOnlyCursor = rData.mbOnlyCursor;
54 CommandExtTextInputData::~CommandExtTextInputData()
58 CommandInputContextData::CommandInputContextData( LanguageType eLang )
60 meLanguage = eLang;
63 CommandWheelData::CommandWheelData()
65 mnDelta = 0;
66 mnNotchDelta = 0;
67 mnLines = 0.0;
68 mnWheelMode = CommandWheelMode::NONE;
69 mnCode = 0;
70 mbHorz = false;
71 mbDeltaIsPixel = false;
74 CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta,
75 double nScrollLines,
76 CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier,
77 bool bHorz, bool bDeltaIsPixel )
79 mnDelta = nWheelDelta;
80 mnNotchDelta = nWheelNotchDelta;
81 mnLines = nScrollLines;
82 mnWheelMode = nWheelMode;
83 mnCode = nKeyModifier;
84 mbHorz = bHorz;
85 mbDeltaIsPixel = bDeltaIsPixel;
88 CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY )
90 mnDeltaX = nDeltaX;
91 mnDeltaY = nDeltaY;
94 CommandModKeyData::CommandModKeyData( sal_uInt16 nCode, bool bDown )
96 mbDown = bDown;
97 mnCode = nCode;
100 CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd )
102 mnStart = nStart;
103 mnEnd = nEnd;
106 CommandEvent::CommandEvent()
108 mpData = nullptr;
109 mnCommand = CommandEventId::NONE;
110 mbMouseEvent = false;
113 CommandEvent::CommandEvent( const Point& rMousePos,
114 CommandEventId nCmd, bool bMEvt, const void* pCmdData ) :
115 maPos( rMousePos )
117 mpData = const_cast<void*>(pCmdData);
118 mnCommand = nCmd;
119 mbMouseEvent = bMEvt;
122 const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const
124 if ( mnCommand == CommandEventId::ExtTextInput )
125 return static_cast<const CommandExtTextInputData*>(mpData);
126 else
127 return nullptr;
130 const CommandWheelData* CommandEvent::GetWheelData() const
132 if ( mnCommand == CommandEventId::Wheel )
133 return static_cast<const CommandWheelData*>(mpData);
134 else
135 return nullptr;
138 const CommandScrollData* CommandEvent::GetAutoScrollData() const
140 if ( mnCommand == CommandEventId::AutoScroll )
141 return static_cast<const CommandScrollData*>(mpData);
142 else
143 return nullptr;
146 const CommandModKeyData* CommandEvent::GetModKeyData() const
148 if( mnCommand == CommandEventId::ModKeyChange )
149 return static_cast<const CommandModKeyData*>(mpData);
150 else
151 return nullptr;
154 const CommandDialogData* CommandEvent::GetDialogData() const
156 if( mnCommand == CommandEventId::ShowDialog )
157 return static_cast<const CommandDialogData*>(mpData);
158 else
159 return nullptr;
162 CommandMediaData* CommandEvent::GetMediaData() const
164 if( mnCommand == CommandEventId::Media )
165 return static_cast<CommandMediaData*>(mpData);
166 else
167 return nullptr;
170 const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const
172 if( mnCommand == CommandEventId::SelectionChange )
173 return static_cast<const CommandSelectionChangeData*>(mpData);
174 else
175 return nullptr;
178 const CommandSwipeData* CommandEvent::GetSwipeData() const
180 if( mnCommand == CommandEventId::Swipe )
181 return static_cast<const CommandSwipeData*>(mpData);
182 else
183 return nullptr;
186 const CommandLongPressData* CommandEvent::GetLongPressData() const
188 if( mnCommand == CommandEventId::LongPress )
189 return static_cast<const CommandLongPressData*>(mpData);
190 else
191 return nullptr;
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */