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