merged tag ooo/OOO330_m14
[LibreOffice.git] / framework / source / inc / accelerators / keymapping.hxx
blobe254378867b693dde6c8eec70858b1b01e1e57c8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_
29 #define __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_
31 //__________________________________________
32 // own includes
34 #include <general.h>
35 #include <stdtypes.h>
37 //__________________________________________
38 // interface includes
39 #include <com/sun/star/lang/IllegalArgumentException.hpp>
41 //__________________________________________
42 // other includes
44 //__________________________________________
45 // definition
47 namespace framework
50 //__________________________________________
51 /**
52 can be used to map key identifier to the
53 corresponding key codes ...
55 class KeyMapping
57 //______________________________________
58 // const, types
60 private:
62 //---------------------------------------
63 /** @short is used to map a key code
64 to the right key identifier, which is
65 used to make the xml file "human readable"
67 struct KeyIdentifierInfo
69 sal_Int16 Code ;
70 const char* Identifier;
73 //---------------------------------------
74 /** @short hash structure to map identifier to key codes. */
75 typedef BaseHash< sal_Int16 > Identifier2CodeHash;
77 //---------------------------------------
78 /** @short hash structure to map key codes to identifier. */
79 typedef ::std::hash_map< sal_Int16 ,
80 ::rtl::OUString ,
81 ShortHashCode ,
82 ::std::equal_to< sal_Int16 > > Code2IdentifierHash;
84 //______________________________________
85 // member
87 private:
89 static KeyIdentifierInfo KeyIdentifierMap[];
91 //---------------------------------------
92 /** @short hash to map identifier to key codes. */
93 Identifier2CodeHash m_lIdentifierHash;
95 //---------------------------------------
96 /** @short hash to map key codes to identifier. */
97 Code2IdentifierHash m_lCodeHash;
99 //______________________________________
100 // interface
102 public:
104 KeyMapping();
105 virtual ~KeyMapping();
107 //----------------------------------
108 /** @short return a suitable key code
109 for the specified key identifier.
111 @param sIdentifier
112 string value, which describe the key.
114 @return [css::awt::KeyEvent]
115 the corresponding key code as
116 short value.
118 @throw [css::lang::IllegalArgumentException]
119 if the given identifier does not describe
120 a well known key code.
122 virtual sal_uInt16 mapIdentifierToCode(const ::rtl::OUString& sIdentifier)
123 throw(css::lang::IllegalArgumentException);
125 //----------------------------------
126 /** @short return a suitable key identifier
127 for the specified key code.
129 @param nCode
130 short value, which describe the key.
132 @return The corresponding string identifier.
134 virtual ::rtl::OUString mapCodeToIdentifier(sal_uInt16 nCode);
136 //______________________________________
137 // helper
139 private:
141 //----------------------------------
142 /** @short check if the given string describe a numeric
143 value ... and convert it.
145 @param sIdentifier
146 the string value, which should be converted.
149 @param rCode
150 contains the converted code, but is defined only
151 if this method returns TRUE!
153 @return [boolean]
154 TRUE if convertion was successfully.
156 sal_Bool impl_st_interpretIdentifierAsPureKeyCode(const ::rtl::OUString& sIdentifier,
157 sal_uInt16& rCode );
160 } // namespace framework
162 #endif // __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_