1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <rtl/ustring.hxx>
22 #include <sal/macros.h>
24 #include <win/salframe.h>
26 #if !defined WIN32_LEAN_AND_MEAN
27 # define WIN32_LEAN_AND_MEAN
31 // Use unique ;) names to avoid clashes with the KEY_* (especially
32 // KEY_SHIFT) from <vcl/vclenum.hxx>
34 #define PAPUGA_KEY_ESC 0x10000
35 #define PAPUGA_KEY_BACK 0xE0000
36 #define PAPUGA_KEY_ENTER 0x1C0000
37 #define PAPUGA_KEY_SPACEBAR 0x390000
38 #define PAPUGA_KEY_HOME 0x1470000
39 #define PAPUGA_KEY_UP 0x1480000
40 #define PAPUGA_KEY_PAGEUP 0x1490000
41 #define PAPUGA_KEY_LEFT 0x14B0000
42 #define PAPUGA_KEY_RIGHT 0x14D0000
43 #define PAPUGA_KEY_END 0x14F0000
44 #define PAPUGA_KEY_DOWN 0x1500000
45 #define PAPUGA_KEY_PAGEDOWN 0x1510000
46 #define PAPUGA_KEY_INSERT 0x1520000
47 #define PAPUGA_KEY_DELETE 0x1530000
48 #define PAPUGA_KEY_CONTROL 0x21D0000
49 #define PAPUGA_KEY_SHIFT 0x22A0000
50 #define PAPUGA_KEY_ALT 0x2380000
56 struct KeysNameReplacement
62 struct KeyboardReplacements
64 const char* pLangName
;
65 const KeysNameReplacement
* pReplacements
;
71 // CAUTION CAUTION CAUTION
72 // Every string value in the replacements tables must be in UTF-8
73 // but with the UTF-8 bytes encoded, not as such! Be careful!
75 const struct KeysNameReplacement aImplReplacements_Asturian
[] =
77 { PAPUGA_KEY_BACK
, "Retrocesu" },
78 { PAPUGA_KEY_ENTER
, "Intro" },
79 { PAPUGA_KEY_SPACEBAR
, "Espaciu" },
80 { PAPUGA_KEY_HOME
, "Aniciu" },
81 { PAPUGA_KEY_UP
, "Arriba" },
82 { PAPUGA_KEY_PAGEUP
, "Re P\xc3\xa1" "x" },
83 { PAPUGA_KEY_LEFT
, "Izquierda" },
84 { PAPUGA_KEY_RIGHT
, "Drecha" },
85 { PAPUGA_KEY_END
, "Fin" },
86 { PAPUGA_KEY_DOWN
, "Abaxo" },
87 { PAPUGA_KEY_PAGEDOWN
, "Av P\xc3\xa1" "x" },
88 { PAPUGA_KEY_INSERT
, "Ins" },
89 { PAPUGA_KEY_DELETE
, "Supr" },
90 { PAPUGA_KEY_SHIFT
, "May\xc3\xba" "s" },
93 const struct KeysNameReplacement aImplReplacements_Catalan
[] =
95 { PAPUGA_KEY_BACK
, "Retroc\xc3\xa9" "s" },
96 { PAPUGA_KEY_ENTER
, "Retorn" },
97 { PAPUGA_KEY_SPACEBAR
, "Espai" },
98 { PAPUGA_KEY_HOME
, "Inici" },
99 { PAPUGA_KEY_UP
, "Amunt" },
100 { PAPUGA_KEY_PAGEUP
, "Re P\xc3\xa0" "g" },
101 { PAPUGA_KEY_LEFT
, "Esquerra" },
102 { PAPUGA_KEY_RIGHT
, "Dreta" },
103 { PAPUGA_KEY_END
, "Fi" },
104 { PAPUGA_KEY_DOWN
, "Avall" },
105 { PAPUGA_KEY_PAGEDOWN
, "Av P\xc3\xa0" "g" },
106 { PAPUGA_KEY_INSERT
, "Ins" },
107 { PAPUGA_KEY_DELETE
, "Supr" },
108 { PAPUGA_KEY_SHIFT
, "Maj" },
111 const struct KeysNameReplacement aImplReplacements_Estonian
[] =
113 { PAPUGA_KEY_RIGHT
, "Nool paremale" },
114 { PAPUGA_KEY_LEFT
, "Nool vasakule" },
115 { PAPUGA_KEY_UP
, "Nool \xc3\xbc" "les" },
116 { PAPUGA_KEY_DOWN
, "Nool alla" },
117 { PAPUGA_KEY_BACK
, "Tagasil\xc3\xbc" "ke" },
118 { PAPUGA_KEY_ENTER
, "Enter" },
119 { PAPUGA_KEY_SPACEBAR
, "T\xc3\xbc" "hik" },
122 const struct KeysNameReplacement aImplReplacements_Lithuanian
[] =
124 { PAPUGA_KEY_ESC
, "Gr" },
125 { PAPUGA_KEY_BACK
, "Naikinti" },
126 { PAPUGA_KEY_ENTER
, "\xc4\xae" "vesti" },
127 { PAPUGA_KEY_SPACEBAR
, "Tarpas" },
128 { PAPUGA_KEY_HOME
, "Prad" },
129 { PAPUGA_KEY_UP
, "Auk\xc5\xa1" "tyn" },
130 { PAPUGA_KEY_PAGEUP
, "Psl\xe2\x86\x91" },
131 { PAPUGA_KEY_LEFT
, "Kair\xc4\x97" "n" },
132 { PAPUGA_KEY_RIGHT
, "De\xc5\xa1" "in\xc4\x97" "n" },
133 { PAPUGA_KEY_END
, "Pab" },
134 { PAPUGA_KEY_DOWN
, "\xc5\xbd" "emyn" },
135 { PAPUGA_KEY_PAGEDOWN
, "Psl\xe2\x86\x93" },
136 { PAPUGA_KEY_INSERT
, "\xc4\xae" "terpti" },
137 { PAPUGA_KEY_DELETE
, "\xc5\xa0" "al" },
138 { PAPUGA_KEY_CONTROL
, "Vald" },
139 { PAPUGA_KEY_SHIFT
, "Lyg2" },
140 { PAPUGA_KEY_ALT
, "Alt" },
143 const struct KeysNameReplacement aImplReplacements_Slovenian
[] =
145 { PAPUGA_KEY_ESC
, "Ube\xc5\xbe" "nica" },
146 { PAPUGA_KEY_BACK
, "Vra\xc4\x8d" "alka" },
147 { PAPUGA_KEY_ENTER
, "Vna\xc5\xa1" "alka" },
148 { PAPUGA_KEY_SPACEBAR
, "Preslednica" },
149 { PAPUGA_KEY_HOME
, "Za\xc4\x8d" "etek" },
150 { PAPUGA_KEY_UP
, "Navzgor" },
151 { PAPUGA_KEY_PAGEUP
, "Prej\xc5\xa1" "nja stran" },
152 { PAPUGA_KEY_LEFT
, "Levo" },
153 { PAPUGA_KEY_RIGHT
, "Desno" },
154 { PAPUGA_KEY_END
, "Konec" },
155 { PAPUGA_KEY_DOWN
, "Navzdol" },
156 { PAPUGA_KEY_PAGEDOWN
, "Naslednja stran" },
157 { PAPUGA_KEY_INSERT
, "Vrivalka" },
158 { PAPUGA_KEY_DELETE
, "Brisalka" },
159 { PAPUGA_KEY_CONTROL
, "Krmilka" },
160 { PAPUGA_KEY_SHIFT
, "Dvigalka" },
161 { PAPUGA_KEY_ALT
, "Izmenjalka" },
164 const struct KeysNameReplacement aImplReplacements_Spanish
[] =
166 { PAPUGA_KEY_BACK
, "Retroceso" },
167 { PAPUGA_KEY_ENTER
, "Intro" },
168 { PAPUGA_KEY_SPACEBAR
, "Espacio" },
169 { PAPUGA_KEY_HOME
, "Inicio" },
170 { PAPUGA_KEY_UP
, "Arriba" },
171 { PAPUGA_KEY_PAGEUP
, "Re P\xc3\xa1" "g" },
172 { PAPUGA_KEY_LEFT
, "Izquierda" },
173 { PAPUGA_KEY_RIGHT
, "Derecha" },
174 { PAPUGA_KEY_END
, "Fin" },
175 { PAPUGA_KEY_DOWN
, "Abajo" },
176 { PAPUGA_KEY_PAGEDOWN
, "Av P\xc3\xa1" "g" },
177 { PAPUGA_KEY_INSERT
, "Ins" },
178 { PAPUGA_KEY_DELETE
, "Supr" },
179 { PAPUGA_KEY_SHIFT
, "May\xc3\xba" "s" },
182 const struct KeysNameReplacement aImplReplacements_Hungarian
[] =
184 { PAPUGA_KEY_RIGHT
, "Jobbra" },
185 { PAPUGA_KEY_LEFT
, "Balra" },
186 { PAPUGA_KEY_UP
, "Fel" },
187 { PAPUGA_KEY_DOWN
, "Le" },
188 { PAPUGA_KEY_ENTER
, "Enter" },
189 { PAPUGA_KEY_SPACEBAR
, "Sz\xc3\xb3" "k\xc3\xb6" "z" },
192 const struct KeyboardReplacements aKeyboards
[] =
194 { "ast",aImplReplacements_Asturian
, SAL_N_ELEMENTS(aImplReplacements_Asturian
) },
195 { "ca", aImplReplacements_Catalan
, SAL_N_ELEMENTS(aImplReplacements_Catalan
) },
196 { "et", aImplReplacements_Estonian
, SAL_N_ELEMENTS(aImplReplacements_Estonian
) },
197 { "hu", aImplReplacements_Hungarian
, SAL_N_ELEMENTS(aImplReplacements_Hungarian
) },
198 { "lt", aImplReplacements_Lithuanian
, SAL_N_ELEMENTS(aImplReplacements_Lithuanian
) },
199 { "sl", aImplReplacements_Slovenian
, SAL_N_ELEMENTS(aImplReplacements_Slovenian
) },
200 { "es", aImplReplacements_Spanish
, SAL_N_ELEMENTS(aImplReplacements_Spanish
) },
203 // translate keycodes, used within the displayed menu shortcuts
204 OUString
getKeysReplacementName( OUString
const & pLang
, LONG nSymbol
)
206 for( unsigned int n
= 0; n
< SAL_N_ELEMENTS(aKeyboards
); n
++ )
208 if( pLang
.equalsAscii( aKeyboards
[n
].pLangName
) )
210 const struct KeysNameReplacement
* pRepl
= aKeyboards
[n
].pReplacements
;
211 for( int m
= aKeyboards
[n
].nReplacements
; m
; )
213 if( nSymbol
== pRepl
[--m
].aSymbol
)
214 return OUString( pRepl
[m
].pName
, strlen(pRepl
[m
].pName
), RTL_TEXTENCODING_UTF8
);
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */