Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / win / source / window / keynames.cxx
blob0038ae9dc2114d71f0e83ffe8a0844469a978714
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 #include <string.h>
21 #include <rtl/ustring.hxx>
22 #include <sal/macros.h>
24 #include <windows.h>
26 // Use unique ;) names to avoid clashes with the KEY_* (especially
27 // KEY_SHIFT) from <rsc/rsc-vcl-shared-types.hxx>
29 #define PAPUGA_KEY_ESC 0x10000
30 #define PAPUGA_KEY_BACK 0xE0000
31 #define PAPUGA_KEY_ENTER 0x1C0000
32 #define PAPUGA_KEY_SPACEBAR 0x390000
33 #define PAPUGA_KEY_HOME 0x1470000
34 #define PAPUGA_KEY_UP 0x1480000
35 #define PAPUGA_KEY_PAGEUP 0x1490000
36 #define PAPUGA_KEY_LEFT 0x14B0000
37 #define PAPUGA_KEY_RIGHT 0x14D0000
38 #define PAPUGA_KEY_END 0x14F0000
39 #define PAPUGA_KEY_DOWN 0x1500000
40 #define PAPUGA_KEY_PAGEDOWN 0x1510000
41 #define PAPUGA_KEY_INSERT 0x1520000
42 #define PAPUGA_KEY_DELETE 0x1530000
43 #define PAPUGA_KEY_CONTROL 0x21D0000
44 #define PAPUGA_KEY_SHIFT 0x22A0000
45 #define PAPUGA_KEY_ALT 0x2380000
47 namespace vcl_sal {
49 struct KeysNameReplacement
51 LONG aSymbol;
52 const char* pName;
55 struct KeyboardReplacements
57 const char* pLangName;
58 const KeysNameReplacement* pReplacements;
59 int nReplacements;
62 // CAUTION CAUTION CAUTION
63 // Every string value in the replacements tables must be in UTF-8
64 // but with the UTF-8 bytes encoded, not as such! Be careful!
66 static const struct KeysNameReplacement aImplReplacements_Asturian[] =
68 { PAPUGA_KEY_BACK, "Retrocesu" },
69 { PAPUGA_KEY_ENTER, "Intro" },
70 { PAPUGA_KEY_SPACEBAR, "Espaciu" },
71 { PAPUGA_KEY_HOME, "Aniciu" },
72 { PAPUGA_KEY_UP, "Arriba" },
73 { PAPUGA_KEY_PAGEUP, "Re P\xc3\xa1" "x" },
74 { PAPUGA_KEY_LEFT, "Izquierda" },
75 { PAPUGA_KEY_RIGHT, "Drecha" },
76 { PAPUGA_KEY_END, "Fin" },
77 { PAPUGA_KEY_DOWN, "Abaxo" },
78 { PAPUGA_KEY_PAGEDOWN, "Av P\xc3\xa1" "x" },
79 { PAPUGA_KEY_INSERT, "Ins" },
80 { PAPUGA_KEY_DELETE, "Supr" },
81 { PAPUGA_KEY_SHIFT, "May\xc3\xba" "s" },
84 static const struct KeysNameReplacement aImplReplacements_Catalan[] =
86 { PAPUGA_KEY_BACK, "Retroc\xc3\xa9" "s" },
87 { PAPUGA_KEY_ENTER, "Retorn" },
88 { PAPUGA_KEY_SPACEBAR, "Espai" },
89 { PAPUGA_KEY_HOME, "Inici" },
90 { PAPUGA_KEY_UP, "Amunt" },
91 { PAPUGA_KEY_PAGEUP, "Re P\xc3\xa0" "g" },
92 { PAPUGA_KEY_LEFT, "Esquerra" },
93 { PAPUGA_KEY_RIGHT, "Dreta" },
94 { PAPUGA_KEY_END, "Fi" },
95 { PAPUGA_KEY_DOWN, "Avall" },
96 { PAPUGA_KEY_PAGEDOWN, "Av P\xc3\xa0" "g" },
97 { PAPUGA_KEY_INSERT, "Ins" },
98 { PAPUGA_KEY_DELETE, "Supr" },
99 { PAPUGA_KEY_SHIFT, "Maj" },
102 static const struct KeysNameReplacement aImplReplacements_Estonian[] =
104 { PAPUGA_KEY_RIGHT, "Nool paremale" },
105 { PAPUGA_KEY_LEFT, "Nool vasakule" },
106 { PAPUGA_KEY_UP, "Nool \xc3\xbc" "les" },
107 { PAPUGA_KEY_DOWN, "Nool alla" },
108 { PAPUGA_KEY_BACK, "Tagasil\xc3\xbc" "ke" },
109 { PAPUGA_KEY_ENTER, "Enter" },
110 { PAPUGA_KEY_SPACEBAR, "T\xc3\xbc" "hik" },
113 static const struct KeysNameReplacement aImplReplacements_Lithuanian[] =
115 { PAPUGA_KEY_ESC, "Gr" },
116 { PAPUGA_KEY_BACK, "Naikinti" },
117 { PAPUGA_KEY_ENTER, "\xc4\xae" "vesti" },
118 { PAPUGA_KEY_SPACEBAR, "Tarpas" },
119 { PAPUGA_KEY_HOME, "Prad" },
120 { PAPUGA_KEY_UP, "Auk\xc5\xa1" "tyn" },
121 { PAPUGA_KEY_PAGEUP, "Psl\xe2\x86\x91" },
122 { PAPUGA_KEY_LEFT, "Kair\xc4\x97" "n" },
123 { PAPUGA_KEY_RIGHT, "De\xc5\xa1" "in\xc4\x97" "n" },
124 { PAPUGA_KEY_END, "Pab" },
125 { PAPUGA_KEY_DOWN, "\xc5\xbd" "emyn" },
126 { PAPUGA_KEY_PAGEDOWN, "Psl\xe2\x86\x93" },
127 { PAPUGA_KEY_INSERT, "\xc4\xae" "terpti" },
128 { PAPUGA_KEY_DELETE, "\xc5\xa0" "al" },
129 { PAPUGA_KEY_CONTROL, "Vald" },
130 { PAPUGA_KEY_SHIFT, "Lyg2" },
131 { PAPUGA_KEY_ALT, "Alt" },
134 static const struct KeysNameReplacement aImplReplacements_Slovenian[] =
136 { PAPUGA_KEY_ESC, "Ube\xc5\xbe" "nica" },
137 { PAPUGA_KEY_BACK, "Vra\xc4\x8d" "alka" },
138 { PAPUGA_KEY_ENTER, "Vna\xc5\xa1" "alka" },
139 { PAPUGA_KEY_SPACEBAR, "Preslednica" },
140 { PAPUGA_KEY_HOME, "Za\xc4\x8d" "etek" },
141 { PAPUGA_KEY_UP, "Navzgor" },
142 { PAPUGA_KEY_PAGEUP, "Prej\xc5\xa1" "nja stran" },
143 { PAPUGA_KEY_LEFT, "Levo" },
144 { PAPUGA_KEY_RIGHT, "Desno" },
145 { PAPUGA_KEY_END, "Konec" },
146 { PAPUGA_KEY_DOWN, "Navzdol" },
147 { PAPUGA_KEY_PAGEDOWN, "Naslednja stran" },
148 { PAPUGA_KEY_INSERT, "Vrivalka" },
149 { PAPUGA_KEY_DELETE, "Brisalka" },
150 { PAPUGA_KEY_CONTROL, "Krmilka" },
151 { PAPUGA_KEY_SHIFT, "Dvigalka" },
152 { PAPUGA_KEY_ALT, "Izmenjalka" },
155 static const struct KeysNameReplacement aImplReplacements_Spanish[] =
157 { PAPUGA_KEY_BACK, "Retroceso" },
158 { PAPUGA_KEY_ENTER, "Intro" },
159 { PAPUGA_KEY_SPACEBAR, "Espacio" },
160 { PAPUGA_KEY_HOME, "Inicio" },
161 { PAPUGA_KEY_UP, "Arriba" },
162 { PAPUGA_KEY_PAGEUP, "Re P\xc3\xa1" "g" },
163 { PAPUGA_KEY_LEFT, "Izquierda" },
164 { PAPUGA_KEY_RIGHT, "Derecha" },
165 { PAPUGA_KEY_END, "Fin" },
166 { PAPUGA_KEY_DOWN, "Abajo" },
167 { PAPUGA_KEY_PAGEDOWN, "Av P\xc3\xa1" "g" },
168 { PAPUGA_KEY_INSERT, "Ins" },
169 { PAPUGA_KEY_DELETE, "Supr" },
170 { PAPUGA_KEY_SHIFT, "May\xc3\xba" "s" },
173 static const struct KeysNameReplacement aImplReplacements_Hungarian[] =
175 { PAPUGA_KEY_RIGHT, "Jobbra" },
176 { PAPUGA_KEY_LEFT, "Balra" },
177 { PAPUGA_KEY_UP, "Fel" },
178 { PAPUGA_KEY_DOWN, "Le" },
179 { PAPUGA_KEY_ENTER, "Enter" },
180 { PAPUGA_KEY_SPACEBAR, "Sz\xc3\xb3" "k\xc3\xb6" "z" },
183 static const struct KeyboardReplacements aKeyboards[] =
185 { "ast",aImplReplacements_Asturian, SAL_N_ELEMENTS(aImplReplacements_Asturian) },
186 { "ca", aImplReplacements_Catalan, SAL_N_ELEMENTS(aImplReplacements_Catalan) },
187 { "et", aImplReplacements_Estonian, SAL_N_ELEMENTS(aImplReplacements_Estonian) },
188 { "hu", aImplReplacements_Hungarian, SAL_N_ELEMENTS(aImplReplacements_Hungarian) },
189 { "lt", aImplReplacements_Lithuanian, SAL_N_ELEMENTS(aImplReplacements_Lithuanian) },
190 { "sl", aImplReplacements_Slovenian, SAL_N_ELEMENTS(aImplReplacements_Slovenian) },
191 { "es", aImplReplacements_Spanish, SAL_N_ELEMENTS(aImplReplacements_Spanish) },
194 // translate keycodes, used within the displayed menu shortcuts
195 OUString getKeysReplacementName( OUString pLang, LONG nSymbol )
197 for( unsigned int n = 0; n < SAL_N_ELEMENTS(aKeyboards); n++ )
199 if( pLang.equalsAscii( aKeyboards[n].pLangName ) )
201 const struct KeysNameReplacement* pRepl = aKeyboards[n].pReplacements;
202 for( int m = aKeyboards[n].nReplacements ; m ; )
204 if( nSymbol == pRepl[--m].aSymbol )
205 return OUString( pRepl[m].pName, strlen(pRepl[m].pName), RTL_TEXTENCODING_UTF8 );
210 return OUString();
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */