tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / framework / source / inc / accelerators / keymapping.hxx
blob272ca051eb49485e4ef6e86cbe120c8ea37e1083
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 #pragma once
22 #include <rtl/ustring.hxx>
23 #include <unordered_map>
25 // definition
27 namespace framework
30 /**
31 can be used to map key identifier to the
32 corresponding key codes ...
34 class KeyMapping
37 // const, types
39 private:
41 /** @short is used to map a key code
42 to the right key identifier, which is
43 used to make the xml file "human readable"
45 struct KeyIdentifierInfo
47 sal_Int16 Code;
48 OUString Identifier;
51 /** @short hash structure to map identifier to key codes. */
52 typedef std::unordered_map<OUString, sal_Int16> Identifier2CodeHash;
54 /** @short hash structure to map key codes to identifier. */
55 typedef std::unordered_map<sal_Int16, OUString> Code2IdentifierHash;
57 // member
59 private:
61 static KeyIdentifierInfo const KeyIdentifierMap[];
63 /** @short hash to map identifier to key codes. */
64 Identifier2CodeHash m_lIdentifierHash;
66 /** @short hash to map key codes to identifier. */
67 Code2IdentifierHash m_lCodeHash;
69 // interface
71 public:
73 KeyMapping();
75 static KeyMapping & get();
77 /** @short return a suitable key code
78 for the specified key identifier.
80 @param sIdentifier
81 string value, which describe the key.
83 @return [css::awt::KeyEvent]
84 the corresponding key code as
85 short value.
87 @throw [css::lang::IllegalArgumentException]
88 if the given identifier does not describe
89 a well known key code.
91 sal_uInt16 mapIdentifierToCode(const OUString& sIdentifier);
93 /** @short return a suitable key identifier
94 for the specified key code.
96 @param nCode
97 short value, which describe the key.
99 @return The corresponding string identifier.
101 OUString mapCodeToIdentifier(sal_uInt16 nCode);
103 // helper
105 private:
107 /** @short check if the given string describe a numeric
108 value ... and convert it.
110 @param sIdentifier
111 the string value, which should be converted.
113 @param rCode
114 contains the converted code, but is defined only
115 if this method returns sal_True!
117 @return [boolean]
118 sal_True if conversion was successful.
120 static bool impl_st_interpretIdentifierAsPureKeyCode(std::u16string_view sIdentifier,
121 sal_uInt16& rCode );
124 } // namespace framework
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */