1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_vcl.hxx" 30 31 #include <com/sun/star/awt/KeyEvent.hpp> 32 #include <com/sun/star/awt/KeyModifier.hpp> 33 #include <tools/debug.hxx> 34 #include <vcl/event.hxx> 35 36 KeyEvent::KeyEvent (const KeyEvent& rKeyEvent) : 37 maKeyCode (rKeyEvent.maKeyCode), 38 mnRepeat (rKeyEvent.mnRepeat), 39 mnCharCode(rKeyEvent.mnCharCode) 40 {} 41 42 /** inits this vcl KeyEvent with all settings from the given awt event **/ 43 KeyEvent::KeyEvent( const ::com::sun::star::awt::KeyEvent& rEvent ) 44 { 45 maKeyCode = KeyCode( 46 rEvent.KeyCode, 47 (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::SHIFT) != 0, 48 (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD1) != 0, 49 (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD2) != 0, 50 (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD3) != 0); 51 mnRepeat = 0; 52 mnCharCode = rEvent.KeyChar; 53 } 54 55 /** fills out the given awt KeyEvent with all settings from this vcl event **/ 56 void KeyEvent::InitKeyEvent( ::com::sun::star::awt::KeyEvent& rEvent ) const 57 { 58 rEvent.Modifiers = 0; 59 if( GetKeyCode().IsShift() ) 60 rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::SHIFT; 61 if( GetKeyCode().IsMod1() ) 62 rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD1; 63 if( GetKeyCode().IsMod2() ) 64 rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD2; 65 if( GetKeyCode().IsMod3() ) 66 rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD3; 67 68 rEvent.KeyCode = GetKeyCode().GetCode(); 69 rEvent.KeyChar = GetCharCode(); 70 rEvent.KeyFunc = sal::static_int_cast< sal_Int16 >(GetKeyCode().GetFunction()); 71 } 72 73 KeyEvent KeyEvent::LogicalTextDirectionality (TextDirectionality eMode) const 74 { 75 KeyEvent aClone(*this); 76 77 sal_uInt16 nCode = maKeyCode.GetCode(); 78 sal_uInt16 nMod = maKeyCode.GetAllModifier(); 79 80 switch (eMode) 81 { 82 case TextDirectionality_RightToLeft_TopToBottom: 83 switch (nCode) 84 { 85 case KEY_LEFT: aClone.maKeyCode = KeyCode(KEY_RIGHT, nMod); break; 86 case KEY_RIGHT: aClone.maKeyCode = KeyCode(KEY_LEFT, nMod); break; 87 } 88 break; 89 90 case TextDirectionality_TopToBottom_RightToLeft: 91 switch (nCode) 92 { 93 case KEY_DOWN: aClone.maKeyCode = KeyCode(KEY_RIGHT, nMod); break; 94 case KEY_UP: aClone.maKeyCode = KeyCode(KEY_LEFT, nMod); break; 95 case KEY_LEFT: aClone.maKeyCode = KeyCode(KEY_DOWN, nMod); break; 96 case KEY_RIGHT: aClone.maKeyCode = KeyCode(KEY_UP, nMod); break; 97 } 98 break; 99 100 case TextDirectionality_LeftToRight_TopToBottom: 101 /* do nothing */ 102 break; 103 } 104 105 return aClone; 106 } 107 108 109 // ------------------------------------------------------- 110 111 const Point& HelpEvent::GetMousePosPixel() const 112 { 113 //DBG_ASSERT( !mbKeyboardActivated, "Keyboard help has no mouse position !"); 114 return maPos; 115 } 116 117