1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: keymapping.hxx,v $
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 //__________________________________________
40 //__________________________________________
42 #include <com/sun/star/lang/IllegalArgumentException.hpp>
44 //__________________________________________
47 //__________________________________________
53 //__________________________________________
55 can be used to map key identifier to the
56 corresponding key codes ...
60 //______________________________________
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
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
,
85 ::std::equal_to
< sal_Int16
> > Code2IdentifierHash
;
87 //______________________________________
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 //______________________________________
108 virtual ~KeyMapping();
110 //----------------------------------
111 /** @short return a suitable key code
112 for the specified key identifier.
115 string value, which describe the key.
117 @return [css::awt::KeyEvent]
118 the corresponding key code as
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.
133 short value, which describe the key.
135 @return The corresponding string identifier.
137 virtual ::rtl::OUString
mapCodeToIdentifier(sal_uInt16 nCode
);
139 //______________________________________
144 //----------------------------------
145 /** @short check if the given string describe a numeric
146 value ... and convert it.
149 the string value, which should be converted.
153 contains the converted code, but is defined only
154 if this method returns TRUE!
157 TRUE if convertion was successfully.
159 sal_Bool
impl_st_interpretIdentifierAsPureKeyCode(const ::rtl::OUString
& sIdentifier
,
163 } // namespace framework
165 #endif // __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_