Update ooo320-m1
[ooovba.git] / framework / source / inc / accelerators / keymapping.hxx
bloba8e25a447584b94a8cc30b8e78b67f597b6027a2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: keymapping.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_
32 #define __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_
34 //__________________________________________
35 // own includes
37 #include <general.h>
38 #include <stdtypes.h>
40 //__________________________________________
41 // interface includes
42 #include <com/sun/star/lang/IllegalArgumentException.hpp>
44 //__________________________________________
45 // other includes
47 //__________________________________________
48 // definition
50 namespace framework
53 //__________________________________________
54 /**
55 can be used to map key identifier to the
56 corresponding key codes ...
58 class KeyMapping
60 //______________________________________
61 // const, types
63 private:
65 //---------------------------------------
66 /** @short is used to map a key code
67 to the right key identifier, which is
68 used to make the xml file "human readable"
70 struct KeyIdentifierInfo
72 sal_Int16 Code ;
73 const char* Identifier;
76 //---------------------------------------
77 /** @short hash structure to map identifier to key codes. */
78 typedef BaseHash< sal_Int16 > Identifier2CodeHash;
80 //---------------------------------------
81 /** @short hash structure to map key codes to identifier. */
82 typedef ::std::hash_map< sal_Int16 ,
83 ::rtl::OUString ,
84 ShortHashCode ,
85 ::std::equal_to< sal_Int16 > > Code2IdentifierHash;
87 //______________________________________
88 // member
90 private:
92 static KeyIdentifierInfo KeyIdentifierMap[];
94 //---------------------------------------
95 /** @short hash to map identifier to key codes. */
96 Identifier2CodeHash m_lIdentifierHash;
98 //---------------------------------------
99 /** @short hash to map key codes to identifier. */
100 Code2IdentifierHash m_lCodeHash;
102 //______________________________________
103 // interface
105 public:
107 KeyMapping();
108 virtual ~KeyMapping();
110 //----------------------------------
111 /** @short return a suitable key code
112 for the specified key identifier.
114 @param sIdentifier
115 string value, which describe the key.
117 @return [css::awt::KeyEvent]
118 the corresponding key code as
119 short value.
121 @throw [css::lang::IllegalArgumentException]
122 if the given identifier does not describe
123 a well known key code.
125 virtual sal_uInt16 mapIdentifierToCode(const ::rtl::OUString& sIdentifier)
126 throw(css::lang::IllegalArgumentException);
128 //----------------------------------
129 /** @short return a suitable key identifier
130 for the specified key code.
132 @param nCode
133 short value, which describe the key.
135 @return The corresponding string identifier.
137 virtual ::rtl::OUString mapCodeToIdentifier(sal_uInt16 nCode);
139 //______________________________________
140 // helper
142 private:
144 //----------------------------------
145 /** @short check if the given string describe a numeric
146 value ... and convert it.
148 @param sIdentifier
149 the string value, which should be converted.
152 @param rCode
153 contains the converted code, but is defined only
154 if this method returns TRUE!
156 @return [boolean]
157 TRUE if convertion was successfully.
159 sal_Bool impl_st_interpretIdentifierAsPureKeyCode(const ::rtl::OUString& sIdentifier,
160 sal_uInt16& rCode );
163 } // namespace framework
165 #endif // __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_