fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / inc / accelerators / keymapping.hxx
blobdfdd327caa919f9da8dc4c07ebcd8d7f6ed34603
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_KEYMAPPING_HXX
21 #define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_KEYMAPPING_HXX
23 #include <general.h>
24 #include <stdtypes.h>
26 #include <com/sun/star/lang/IllegalArgumentException.hpp>
28 // definition
30 namespace framework
33 /**
34 can be used to map key identifier to the
35 corresponding key codes ...
37 class KeyMapping
40 // const, types
42 private:
44 /** @short is used to map a key code
45 to the right key identifier, which is
46 used to make the xml file "human readable"
48 struct KeyIdentifierInfo
50 sal_Int16 Code;
51 const char* Identifier;
54 /** @short hash structure to map identifier to key codes. */
55 typedef BaseHash< sal_Int16 > Identifier2CodeHash;
57 /** @short hash structure to map key codes to identifier. */
58 typedef std::unordered_map< sal_Int16 ,
59 OUString ,
60 ShortHashCode ,
61 std::equal_to< sal_Int16 > > Code2IdentifierHash;
63 // member
65 private:
67 static KeyIdentifierInfo KeyIdentifierMap[];
69 /** @short hash to map identifier to key codes. */
70 Identifier2CodeHash m_lIdentifierHash;
72 /** @short hash to map key codes to identifier. */
73 Code2IdentifierHash m_lCodeHash;
75 // interface
77 public:
79 KeyMapping();
80 virtual ~KeyMapping();
82 /** @short return a suitable key code
83 for the specified key identifier.
85 @param sIdentifier
86 string value, which describe the key.
88 @return [css::awt::KeyEvent]
89 the corresponding key code as
90 short value.
92 @throw [css::lang::IllegalArgumentException]
93 if the given identifier does not describe
94 a well known key code.
96 sal_uInt16 mapIdentifierToCode(const OUString& sIdentifier)
97 throw(css::lang::IllegalArgumentException);
99 /** @short return a suitable key identifier
100 for the specified key code.
102 @param nCode
103 short value, which describe the key.
105 @return The corresponding string identifier.
107 OUString mapCodeToIdentifier(sal_uInt16 nCode);
109 // helper
111 private:
113 /** @short check if the given string describe a numeric
114 value ... and convert it.
116 @param sIdentifier
117 the string value, which should be converted.
119 @param rCode
120 contains the converted code, but is defined only
121 if this method returns sal_True!
123 @return [boolean]
124 sal_True if conversion was successfully.
126 bool impl_st_interpretIdentifierAsPureKeyCode(const OUString& sIdentifier,
127 sal_uInt16& rCode );
130 } // namespace framework
132 #endif // INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_KEYMAPPING_HXX
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */