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 //__________________________________________
37 //__________________________________________
39 #include <com/sun/star/lang/IllegalArgumentException.hpp>
41 //__________________________________________
44 //__________________________________________
50 //__________________________________________
52 can be used to map key identifier to the
53 corresponding key codes ...
57 //______________________________________
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
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
,
82 ::std::equal_to
< sal_Int16
> > Code2IdentifierHash
;
84 //______________________________________
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 //______________________________________
105 virtual ~KeyMapping();
107 //----------------------------------
108 /** @short return a suitable key code
109 for the specified key identifier.
112 string value, which describe the key.
114 @return [css::awt::KeyEvent]
115 the corresponding key code as
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.
130 short value, which describe the key.
132 @return The corresponding string identifier.
134 virtual ::rtl::OUString
mapCodeToIdentifier(sal_uInt16 nCode
);
136 //______________________________________
141 //----------------------------------
142 /** @short check if the given string describe a numeric
143 value ... and convert it.
146 the string value, which should be converted.
150 contains the converted code, but is defined only
151 if this method returns TRUE!
154 TRUE if convertion was successfully.
156 sal_Bool
impl_st_interpretIdentifierAsPureKeyCode(const ::rtl::OUString
& sIdentifier
,
160 } // namespace framework
162 #endif // __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_