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
54 struct KeysNameReplacement
60 struct KeyboardReplacements
62 const char* pLangName
;
63 const KeysNameReplacement
* pReplacements
;
67 // CAUTION CAUTION CAUTION
68 // Every string value in the replacements tables must be in UTF-8
69 // but with the UTF-8 bytes encoded, not as such! Be careful!
71 static const struct KeysNameReplacement aImplReplacements_Asturian
[] =
73 { PAPUGA_KEY_BACK
, "Retrocesu" },
74 { PAPUGA_KEY_ENTER
, "Intro" },
75 { PAPUGA_KEY_SPACEBAR
, "Espaciu" },
76 { PAPUGA_KEY_HOME
, "Aniciu" },
77 { PAPUGA_KEY_UP
, "Arriba" },
78 { PAPUGA_KEY_PAGEUP
, "Re P\xc3\xa1" "x" },
79 { PAPUGA_KEY_LEFT
, "Izquierda" },
80 { PAPUGA_KEY_RIGHT
, "Drecha" },
81 { PAPUGA_KEY_END
, "Fin" },
82 { PAPUGA_KEY_DOWN
, "Abaxo" },
83 { PAPUGA_KEY_PAGEDOWN
, "Av P\xc3\xa1" "x" },
84 { PAPUGA_KEY_INSERT
, "Ins" },
85 { PAPUGA_KEY_DELETE
, "Supr" },
86 { PAPUGA_KEY_SHIFT
, "May\xc3\xba" "s" },
89 static const struct KeysNameReplacement aImplReplacements_Catalan
[] =
91 { PAPUGA_KEY_BACK
, "Retroc\xc3\xa9" "s" },
92 { PAPUGA_KEY_ENTER
, "Retorn" },
93 { PAPUGA_KEY_SPACEBAR
, "Espai" },
94 { PAPUGA_KEY_HOME
, "Inici" },
95 { PAPUGA_KEY_UP
, "Amunt" },
96 { PAPUGA_KEY_PAGEUP
, "Re P\xc3\xa0" "g" },
97 { PAPUGA_KEY_LEFT
, "Esquerra" },
98 { PAPUGA_KEY_RIGHT
, "Dreta" },
99 { PAPUGA_KEY_END
, "Fi" },
100 { PAPUGA_KEY_DOWN
, "Avall" },
101 { PAPUGA_KEY_PAGEDOWN
, "Av P\xc3\xa0" "g" },
102 { PAPUGA_KEY_INSERT
, "Ins" },
103 { PAPUGA_KEY_DELETE
, "Supr" },
104 { PAPUGA_KEY_SHIFT
, "Maj" },
107 static const struct KeysNameReplacement aImplReplacements_Estonian
[] =
109 { PAPUGA_KEY_RIGHT
, "Nool paremale" },
110 { PAPUGA_KEY_LEFT
, "Nool vasakule" },
111 { PAPUGA_KEY_UP
, "Nool \xc3\xbc" "les" },
112 { PAPUGA_KEY_DOWN
, "Nool alla" },
113 { PAPUGA_KEY_BACK
, "Tagasil\xc3\xbc" "ke" },
114 { PAPUGA_KEY_ENTER
, "Enter" },
115 { PAPUGA_KEY_SPACEBAR
, "T\xc3\xbc" "hik" },
118 static const struct KeysNameReplacement aImplReplacements_Lithuanian
[] =
120 { PAPUGA_KEY_ESC
, "Gr" },
121 { PAPUGA_KEY_BACK
, "Naikinti" },
122 { PAPUGA_KEY_ENTER
, "\xc4\xae" "vesti" },
123 { PAPUGA_KEY_SPACEBAR
, "Tarpas" },
124 { PAPUGA_KEY_HOME
, "Prad" },
125 { PAPUGA_KEY_UP
, "Auk\xc5\xa1" "tyn" },
126 { PAPUGA_KEY_PAGEUP
, "Psl\xe2\x86\x91" },
127 { PAPUGA_KEY_LEFT
, "Kair\xc4\x97" "n" },
128 { PAPUGA_KEY_RIGHT
, "De\xc5\xa1" "in\xc4\x97" "n" },
129 { PAPUGA_KEY_END
, "Pab" },
130 { PAPUGA_KEY_DOWN
, "\xc5\xbd" "emyn" },
131 { PAPUGA_KEY_PAGEDOWN
, "Psl\xe2\x86\x93" },
132 { PAPUGA_KEY_INSERT
, "\xc4\xae" "terpti" },
133 { PAPUGA_KEY_DELETE
, "\xc5\xa0" "al" },
134 { PAPUGA_KEY_CONTROL
, "Vald" },
135 { PAPUGA_KEY_SHIFT
, "Lyg2" },
136 { PAPUGA_KEY_ALT
, "Alt" },
139 static const struct KeysNameReplacement aImplReplacements_Slovenian
[] =
141 { PAPUGA_KEY_ESC
, "Ube\xc5\xbe" "nica" },
142 { PAPUGA_KEY_BACK
, "Vra\xc4\x8d" "alka" },
143 { PAPUGA_KEY_ENTER
, "Vna\xc5\xa1" "alka" },
144 { PAPUGA_KEY_SPACEBAR
, "Preslednica" },
145 { PAPUGA_KEY_HOME
, "Za\xc4\x8d" "etek" },
146 { PAPUGA_KEY_UP
, "Navzgor" },
147 { PAPUGA_KEY_PAGEUP
, "Prej\xc5\xa1" "nja stran" },
148 { PAPUGA_KEY_LEFT
, "Levo" },
149 { PAPUGA_KEY_RIGHT
, "Desno" },
150 { PAPUGA_KEY_END
, "Konec" },
151 { PAPUGA_KEY_DOWN
, "Navzdol" },
152 { PAPUGA_KEY_PAGEDOWN
, "Naslednja stran" },
153 { PAPUGA_KEY_INSERT
, "Vrivalka" },
154 { PAPUGA_KEY_DELETE
, "Brisalka" },
155 { PAPUGA_KEY_CONTROL
, "Krmilka" },
156 { PAPUGA_KEY_SHIFT
, "Dvigalka" },
157 { PAPUGA_KEY_ALT
, "Izmenjalka" },
160 static const struct KeysNameReplacement aImplReplacements_Spanish
[] =
162 { PAPUGA_KEY_BACK
, "Retroceso" },
163 { PAPUGA_KEY_ENTER
, "Intro" },
164 { PAPUGA_KEY_SPACEBAR
, "Espacio" },
165 { PAPUGA_KEY_HOME
, "Inicio" },
166 { PAPUGA_KEY_UP
, "Arriba" },
167 { PAPUGA_KEY_PAGEUP
, "Re P\xc3\xa1" "g" },
168 { PAPUGA_KEY_LEFT
, "Izquierda" },
169 { PAPUGA_KEY_RIGHT
, "Derecha" },
170 { PAPUGA_KEY_END
, "Fin" },
171 { PAPUGA_KEY_DOWN
, "Abajo" },
172 { PAPUGA_KEY_PAGEDOWN
, "Av P\xc3\xa1" "g" },
173 { PAPUGA_KEY_INSERT
, "Ins" },
174 { PAPUGA_KEY_DELETE
, "Supr" },
175 { PAPUGA_KEY_SHIFT
, "May\xc3\xba" "s" },
178 static const struct KeysNameReplacement aImplReplacements_Hungarian
[] =
180 { PAPUGA_KEY_RIGHT
, "Jobbra" },
181 { PAPUGA_KEY_LEFT
, "Balra" },
182 { PAPUGA_KEY_UP
, "Fel" },
183 { PAPUGA_KEY_DOWN
, "Le" },
184 { PAPUGA_KEY_ENTER
, "Enter" },
185 { PAPUGA_KEY_SPACEBAR
, "Sz\xc3\xb3" "k\xc3\xb6" "z" },
188 static const struct KeyboardReplacements aKeyboards
[] =
190 { "ast",aImplReplacements_Asturian
, SAL_N_ELEMENTS(aImplReplacements_Asturian
) },
191 { "ca", aImplReplacements_Catalan
, SAL_N_ELEMENTS(aImplReplacements_Catalan
) },
192 { "et", aImplReplacements_Estonian
, SAL_N_ELEMENTS(aImplReplacements_Estonian
) },
193 { "hu", aImplReplacements_Hungarian
, SAL_N_ELEMENTS(aImplReplacements_Hungarian
) },
194 { "lt", aImplReplacements_Lithuanian
, SAL_N_ELEMENTS(aImplReplacements_Lithuanian
) },
195 { "sl", aImplReplacements_Slovenian
, SAL_N_ELEMENTS(aImplReplacements_Slovenian
) },
196 { "es", aImplReplacements_Spanish
, SAL_N_ELEMENTS(aImplReplacements_Spanish
) },
199 // translate keycodes, used within the displayed menu shortcuts
200 OUString
getKeysReplacementName( OUString
const & pLang
, LONG nSymbol
)
202 for( unsigned int n
= 0; n
< SAL_N_ELEMENTS(aKeyboards
); n
++ )
204 if( pLang
.equalsAscii( aKeyboards
[n
].pLangName
) )
206 const struct KeysNameReplacement
* pRepl
= aKeyboards
[n
].pReplacements
;
207 for( int m
= aKeyboards
[n
].nReplacements
; m
; )
209 if( nSymbol
== pRepl
[--m
].aSymbol
)
210 return OUString( pRepl
[m
].pName
, strlen(pRepl
[m
].pName
), RTL_TEXTENCODING_UTF8
);
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */