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 .
20 #include <unx/saldisp.hxx>
21 #include <X11/keysym.h>
22 #include <sal/macros.h>
24 #if !defined (SunXK_Undo)
25 #define SunXK_Undo 0x0000FF65 // XK_Undo
26 #define SunXK_Again 0x0000FF66 // XK_Redo
27 #define SunXK_Find 0x0000FF68 // XK_Find
28 #define SunXK_Stop 0x0000FF69 // XK_Cancel
29 #define SunXK_Props 0x1005FF70
30 #define SunXK_Front 0x1005FF71
31 #define SunXK_Copy 0x1005FF72
32 #define SunXK_Open 0x1005FF73
33 #define SunXK_Paste 0x1005FF74
34 #define SunXK_Cut 0x1005FF75
38 #include <rtl/ustring.hxx>
44 struct KeysymNameReplacement
50 struct KeyboardReplacements
52 const char* pLangName
;
53 const KeysymNameReplacement
* pReplacements
;
59 // CAUTION CAUTION CAUTION
60 // every string value in the replacements tables must be in UTF8
61 // be careful with your editor !
63 const struct KeysymNameReplacement aImplReplacements_English
[] =
65 { XK_Control_L
, "Ctrl" },
66 { XK_Control_R
, "Ctrl" },
68 { XK_space
, "Space" },
69 { XK_Page_Up
, "PgUp"},
70 { XK_Page_Down
, "PgDn"}
73 const struct KeysymNameReplacement aImplReplacements_Turkish
[] =
75 { XK_Control_L
, "Ctrl" },
76 { XK_Control_R
, "Ctrl" },
77 { XK_Right
, "Sa\304\237" },
79 { XK_Up
, "Yukar\304\261" },
80 { XK_Down
, "A\305\237a\304\237\304\261" },
81 { XK_space
, "Bo\305\237luk" }
84 const struct KeysymNameReplacement aImplReplacements_Russian
[] =
86 { XK_Right
, "\320\222\320\277\321\200\320\260\320\262\320\276" },
87 { XK_Left
, "\320\222\320\273\320\265\320\262\320\276" },
88 { XK_Up
, "\320\222\320\262\320\265\321\200\321\205" },
89 { XK_Down
, "\320\222\320\275\320\270\320\267" },
90 { XK_space
, "\320\237\321\200\320\276\320\261\320\265\320\273" }
93 const struct KeysymNameReplacement aImplReplacements_German
[] =
95 { XK_Control_L
, "Strg" },
96 { XK_Control_R
, "Strg" },
97 { XK_Shift_L
, "Umschalt" },
98 { XK_Shift_R
, "Umschalt" },
100 { XK_Alt_R
, "Alt Gr" },
101 { XK_Page_Up
, "Bild auf" },
102 { XK_Page_Down
, "Bild ab" },
104 { XK_Home
, "Pos 1" },
105 { XK_Insert
, "Einfg" },
106 { XK_Delete
, "Entf" },
107 { XK_Escape
, "Esc" },
108 { XK_Right
, "Rechts" },
109 { XK_Left
, "Links" },
111 { XK_Down
, "Unten" },
112 { XK_BackSpace
, "R\303\274ckschritt" },
113 { XK_Return
, "Eingabe" },
114 { XK_slash
, "Schr\303\244gstrich" },
115 { XK_space
, "Leertaste" },
116 { SunXK_Stop
, "Stop" },
117 { SunXK_Again
, "Wiederholen" },
118 { SunXK_Props
, "Eigenschaften" },
119 { SunXK_Undo
, "Zur\303\274cknehmen" },
120 { SunXK_Front
, "Vordergrund" },
121 { SunXK_Copy
, "Kopieren" },
122 { SunXK_Open
, "\303\226ffnen" },
123 { SunXK_Paste
, "Einsetzen" },
124 { SunXK_Find
, "Suchen" },
125 { SunXK_Cut
, "Ausschneiden" },
128 const struct KeysymNameReplacement aImplReplacements_French
[] =
130 { XK_Shift_L
, "Maj" },
131 { XK_Shift_R
, "Maj" },
132 { XK_Page_Up
, "Pg. Pr\303\251c" },
133 { XK_Page_Down
, "Pg. Suiv" },
135 { XK_Home
, "Origine" },
136 { XK_Insert
, "Ins\303\251rer" },
137 { XK_Delete
, "Suppr" },
138 { XK_Escape
, "Esc" },
139 { XK_Right
, "Droite" },
140 { XK_Left
, "Gauche" },
143 { XK_BackSpace
, "Ret. Arr" },
144 { XK_Return
, "Retour" },
145 { XK_space
, "Espace" },
146 { XK_KP_Enter
, "Entr\303\251e" },
147 { SunXK_Stop
, "Stop" },
148 { SunXK_Again
, "Encore" },
149 { SunXK_Props
, "Props" },
150 { SunXK_Undo
, "Annuler" },
151 { SunXK_Front
, "Devant" },
152 { SunXK_Copy
, "Copy" },
153 { SunXK_Open
, "Ouvrir" },
154 { SunXK_Paste
, "Coller" },
155 { SunXK_Find
, "Cher." },
156 { SunXK_Cut
, "Couper" },
159 const struct KeysymNameReplacement aImplReplacements_Italian
[] =
161 { XK_Shift_L
, "Maiusc" },
162 { XK_Shift_R
, "Maiusc" },
163 { XK_Page_Up
, "PgSu" },
164 { XK_Page_Down
, "PgGiu" },
166 { XK_Insert
, "Ins" },
167 { XK_Delete
, "Canc" },
168 { XK_Escape
, "Esc" },
169 { XK_Right
, "A destra" },
170 { XK_Left
, "A sinistra" },
171 { XK_Up
, "Sposta verso l'alto" },
172 { XK_Down
, "Sposta verso il basso" },
173 { XK_BackSpace
, "Backspace" },
174 { XK_Return
, "Invio" },
175 { XK_space
, "Spazio" },
176 { SunXK_Stop
, "Stop" },
177 { SunXK_Again
, "Ancora" },
178 { SunXK_Props
, "Propriet\303\240" },
179 { SunXK_Undo
, "Annulla" },
180 { SunXK_Front
, "Davanti" },
181 { SunXK_Copy
, "Copia" },
182 { SunXK_Open
, "Apri" },
183 { SunXK_Paste
, "Incolla" },
184 { SunXK_Find
, "Trova" },
185 { SunXK_Cut
, "Taglia" },
188 const struct KeysymNameReplacement aImplReplacements_Dutch
[] =
190 { XK_Page_Up
, "PageUp" },
191 { XK_Page_Down
, "PageDown" },
192 { XK_Escape
, "Esc" },
193 { XK_Right
, "Rechts" },
194 { XK_Left
, "Links" },
196 { XK_Down
, "Onder" },
197 { XK_BackSpace
, "Backspace" },
198 { XK_Return
, "Return" },
199 { XK_space
, "Spatiebalk" },
200 { SunXK_Stop
, "Stop" },
201 { SunXK_Again
, "Again" },
202 { SunXK_Props
, "Props" },
203 { SunXK_Undo
, "Undo" },
204 { SunXK_Front
, "Front" },
205 { SunXK_Copy
, "Copy" },
206 { SunXK_Open
, "Open" },
207 { SunXK_Paste
, "Paste" },
208 { SunXK_Find
, "Find" },
209 { SunXK_Cut
, "Cut" },
212 const struct KeysymNameReplacement aImplReplacements_Norwegian
[] =
214 { XK_Shift_L
, "Skift" },
215 { XK_Shift_R
, "Skift" },
216 { XK_Page_Up
, "PageUp" },
217 { XK_Page_Down
, "PageDown" },
218 { XK_Escape
, "Esc" },
219 { XK_Right
, "H\303\270yre" },
220 { XK_Left
, "Venstre" },
223 { XK_BackSpace
, "Tilbake" },
224 { XK_Return
, "Enter" },
225 { SunXK_Stop
, "Avbryt" },
226 { SunXK_Again
, "Gjenta" },
227 { SunXK_Props
, "Egenskaper" },
228 { SunXK_Undo
, "Angre" },
229 { SunXK_Front
, "Front" },
230 { SunXK_Copy
, "Kopi" },
231 { SunXK_Open
, "\303\205pne" },
232 { SunXK_Paste
, "Lim" },
233 { SunXK_Find
, "S\303\270k" },
234 { SunXK_Cut
, "Klipp" },
237 const struct KeysymNameReplacement aImplReplacements_Swedish
[] =
239 { XK_Shift_L
, "Skift" },
240 { XK_Shift_R
, "Skift" },
241 { XK_Page_Up
, "PageUp" },
242 { XK_Page_Down
, "PageDown" },
243 { XK_Escape
, "Esc" },
244 { XK_Right
, "H\303\266ger" },
245 { XK_Left
, "V\303\244nster" },
248 { XK_BackSpace
, "Backsteg" },
249 { XK_Return
, "Retur" },
250 { XK_space
, "Blank" },
251 { SunXK_Stop
, "Avbryt" },
252 { SunXK_Again
, "Upprepa" },
253 { SunXK_Props
, "Egenskaper" },
254 { SunXK_Undo
, "\303\205ngra" },
255 { SunXK_Front
, "Fram" },
256 { SunXK_Copy
, "Kopiera" },
257 { SunXK_Open
, "\303\226ppna" },
258 { SunXK_Paste
, "Klistra in" },
259 { SunXK_Find
, "S\303\266k" },
260 { SunXK_Cut
, "Klipp ut" },
263 const struct KeysymNameReplacement aImplReplacements_Portuguese
[] =
265 { XK_Page_Up
, "PageUp" },
266 { XK_Page_Down
, "PageDown" },
267 { XK_Escape
, "Esc" },
268 { XK_Right
, "Direita" },
269 { XK_Left
, "Esquerda" },
271 { XK_Down
, "Abaixo" },
272 { XK_BackSpace
, "Backspace" },
273 { XK_Return
, "Enter" },
274 { XK_slash
, "Barra" },
275 { SunXK_Stop
, "Stop" },
276 { SunXK_Again
, "Again" },
277 { SunXK_Props
, "Props" },
278 { SunXK_Undo
, "Undo" },
279 { SunXK_Front
, "Front" },
280 { SunXK_Copy
, "Copy" },
281 { SunXK_Open
, "Open" },
282 { SunXK_Paste
, "Paste" },
283 { SunXK_Find
, "Find" },
284 { SunXK_Cut
, "Cut" },
287 const struct KeysymNameReplacement aImplReplacements_Slovenian
[] =
289 { XK_Control_L
, "Krmilka" },
290 { XK_Control_R
, "Krmilka" },
291 { XK_Shift_L
, "Dvigalka" },
292 { XK_Shift_R
, "Dvigalka" },
293 { XK_Alt_L
, "Izmenjalka" },
294 { XK_Alt_R
, "Desna izmenjalka" },
295 { XK_Page_Up
, "Prej\305\241nja stranf" },
296 { XK_Page_Down
, "Naslednja stran" },
298 { XK_Home
, "Za\304\215etek" },
299 { XK_Insert
, "Vstavljalka" },
300 { XK_Delete
, "Brisalka" },
301 { XK_Escape
, "Ube\305\276nica" },
302 { XK_Right
, "Desno" },
304 { XK_Up
, "Navzgor" },
305 { XK_Down
, "Navzdol" },
306 { XK_BackSpace
, "Vra\304\215alka" },
307 { XK_Return
, "Vna\305\241alka" },
308 { XK_slash
, "Po\305\241evnica" },
309 { XK_space
, "Preslednica" },
310 { SunXK_Stop
, "Ustavi" },
311 { SunXK_Again
, "Ponovi" },
312 { SunXK_Props
, "Lastnosti" },
313 { SunXK_Undo
, "Razveljavi" },
314 { SunXK_Front
, "Ospredje" },
315 { SunXK_Copy
, "Kopiraj" },
316 { SunXK_Open
, "Odpri" },
317 { SunXK_Paste
, "Prilepi" },
318 { SunXK_Find
, "Najdi" },
319 { SunXK_Cut
, "Izre\305\276i" },
322 const struct KeysymNameReplacement aImplReplacements_Spanish
[] =
324 { XK_Shift_L
, "May\303\272s" },
325 { XK_Shift_R
, "May\303\272s" },
326 { XK_Page_Up
, "ReP\303\241g" },
327 { XK_Page_Down
, "AvP\303\241g" },
329 { XK_Home
, "Inicio" },
330 { XK_Delete
, "Supr" },
331 { XK_Escape
, "Esc" },
332 { XK_Right
, "Derecha" },
333 { XK_Left
, "Izquierda" },
335 { XK_Down
, "Abajo" },
336 { XK_BackSpace
, "Ret" },
337 { XK_Return
, "Entrada" },
338 { XK_space
, "Espacio" },
339 { XK_KP_Enter
, "Intro" },
340 { SunXK_Stop
, "Detener" },
341 { SunXK_Again
, "Repetir" },
342 { SunXK_Props
, "Props" },
343 { SunXK_Undo
, "Anular" },
344 { SunXK_Front
, "Delante" },
345 { SunXK_Copy
, "Copiar" },
346 { SunXK_Open
, "Abrir" },
347 { SunXK_Paste
, "Pegar" },
348 { SunXK_Find
, "Buscar" },
349 { SunXK_Cut
, "Cortar" },
352 const struct KeysymNameReplacement aImplReplacements_Estonian
[] =
354 { XK_Page_Up
, "PgUp" },
355 { XK_Page_Down
, "PgDown" },
358 { XK_Insert
, "Ins" },
359 { XK_Delete
, "Del" },
360 { XK_Escape
, "Esc" },
361 { XK_Right
, "Nool paremale" },
362 { XK_Left
, "Nool vasakule" },
363 { XK_Up
, "Nool \303\274les" },
364 { XK_Down
, "Nool alla" },
365 { XK_BackSpace
, "Tagasil\303\274ke" },
366 { XK_Return
, "Enter" },
367 { XK_slash
, "Kaldkriips" },
368 { XK_space
, "T\303\274hik" },
369 { XK_asterisk
, "T\303\244rn" },
370 { SunXK_Stop
, "Peata" },
371 { SunXK_Again
, "Korda" },
372 { SunXK_Props
, "Omadused" },
373 { SunXK_Undo
, "V\303\265ta tagasi" },
374 { SunXK_Front
, "Esiplaanile" },
375 { SunXK_Copy
, "Kopeeri" },
376 { SunXK_Open
, "Ava" },
377 { SunXK_Paste
, "Aseta" },
378 { SunXK_Find
, "Otsi" },
379 { SunXK_Cut
, "L\303\265ika" },
382 const struct KeysymNameReplacement aImplReplacements_Catalan
[] =
384 { XK_Shift_L
, "Maj" },
385 { XK_Shift_R
, "Maj" },
386 { XK_Page_Up
, "Re P\303\240g" },
387 { XK_Page_Down
, "Av P\303\240g" },
389 { XK_Home
, "Inici" },
390 { XK_Delete
, "Supr" },
391 { XK_Escape
, "Esc" },
392 { XK_Right
, "Dreta" },
393 { XK_Left
, "Esquerra" },
395 { XK_Down
, "Avall" },
396 { XK_BackSpace
, "Retroc\303\251s" },
397 { XK_Return
, "Retorn" },
398 { XK_space
, "Espai" },
399 { XK_KP_Enter
, "Retorn" },
400 { SunXK_Stop
, "Atura" },
401 { SunXK_Again
, "Repeteix" },
402 { SunXK_Props
, "Props" },
403 { SunXK_Undo
, "Desf\303\251s" },
404 { SunXK_Front
, "Davant" },
405 { SunXK_Copy
, "C\303\262pia" },
406 { SunXK_Open
, "Obre" },
407 { SunXK_Paste
, "Enganxa" },
408 { SunXK_Find
, "Cerca" },
409 { SunXK_Cut
, "Retalla" },
412 const struct KeysymNameReplacement aImplReplacements_Lithuanian
[] =
414 { XK_Control_L
, "Vald" },
415 { XK_Control_R
, "Vald" },
416 { XK_Shift_L
, "Lyg2" },
417 { XK_Shift_R
, "Lyg2" },
419 { XK_Alt_R
, "Lyg3" },
420 { XK_Page_Up
, "Psl\342\206\221" },
421 { XK_Page_Down
, "Psl\342\206\223" },
424 { XK_Insert
, "\304\256terpti" },
425 { XK_Delete
, "\305\240al" },
427 { XK_Right
, "De\305\241in\304\227n" },
428 { XK_Left
, "Kair\304\227n" },
429 { XK_Up
, "Auk\305\241tyn" },
430 { XK_Down
, "\305\275emyn" },
431 { XK_BackSpace
, "Naikinti" },
432 { XK_Return
, "\304\256vesti" },
433 { XK_asterisk
, "\305\275vaig\305\276dut\304\227" },
434 { XK_slash
, "De\305\241ininis br\305\253k\305\241nys" },
435 { XK_space
, "Tarpas" },
436 { SunXK_Stop
, "Stabdyti" },
437 { SunXK_Again
, "Kartoti" },
438 { SunXK_Props
, "Savyb\304\227s" },
439 { SunXK_Undo
, "At\305\241aukti" },
440 { SunXK_Front
, "Priekinis planas" },
441 { SunXK_Copy
, "Kopijuoti" },
442 { SunXK_Open
, "Atverti" },
443 { SunXK_Paste
, "\304\256d\304\227ti" },
444 { SunXK_Find
, "Ie\305\241koti" },
445 { SunXK_Cut
, "I\305\241kirpti" },
448 const struct KeysymNameReplacement aImplReplacements_Hungarian
[] =
450 { XK_Right
, "Jobbra" },
451 { XK_Left
, "Balra" },
454 { XK_Return
, "Enter" },
455 { XK_space
, "Sz\303\263k\303\266z" },
456 { XK_asterisk
, "Csillag" },
457 { XK_slash
, "Oszt\303\241sjel" },
460 const struct KeyboardReplacements aKeyboards
[] =
462 { "ca", aImplReplacements_Catalan
, SAL_N_ELEMENTS(aImplReplacements_Catalan
) },
463 { "de", aImplReplacements_German
, SAL_N_ELEMENTS(aImplReplacements_German
) },
464 { "sl", aImplReplacements_Slovenian
, SAL_N_ELEMENTS(aImplReplacements_Slovenian
) },
465 { "es", aImplReplacements_Spanish
, SAL_N_ELEMENTS(aImplReplacements_Spanish
) },
466 { "et", aImplReplacements_Estonian
, SAL_N_ELEMENTS(aImplReplacements_Estonian
) },
467 { "fr", aImplReplacements_French
, SAL_N_ELEMENTS(aImplReplacements_French
) },
468 { "hu", aImplReplacements_Hungarian
, SAL_N_ELEMENTS(aImplReplacements_Hungarian
) },
469 { "it", aImplReplacements_Italian
, SAL_N_ELEMENTS(aImplReplacements_Italian
) },
470 { "lt", aImplReplacements_Lithuanian
, SAL_N_ELEMENTS(aImplReplacements_Lithuanian
) },
471 { "nl", aImplReplacements_Dutch
, SAL_N_ELEMENTS(aImplReplacements_Dutch
) },
472 { "no", aImplReplacements_Norwegian
, SAL_N_ELEMENTS(aImplReplacements_Norwegian
) },
473 { "pt", aImplReplacements_Portuguese
, SAL_N_ELEMENTS(aImplReplacements_Portuguese
) },
474 { "ru", aImplReplacements_Russian
, SAL_N_ELEMENTS(aImplReplacements_Russian
) },
475 { "sv", aImplReplacements_Swedish
, SAL_N_ELEMENTS(aImplReplacements_Swedish
) },
476 { "tr", aImplReplacements_Turkish
, SAL_N_ELEMENTS(aImplReplacements_Turkish
) },
479 // translate keycodes, used within the displayed menu shortcuts
480 OUString
getKeysymReplacementName( const OUString
& pLang
, KeySym nSymbol
)
482 for(const auto & rKeyboard
: aKeyboards
)
484 if( pLang
.equalsAscii( rKeyboard
.pLangName
) )
486 const struct KeysymNameReplacement
* pRepl
= rKeyboard
.pReplacements
;
487 for( int m
= rKeyboard
.nReplacements
; m
; )
489 if( nSymbol
== pRepl
[--m
].aSymbol
)
490 return OUString( pRepl
[m
].pName
, strlen(pRepl
[m
].pName
), RTL_TEXTENCODING_UTF8
);
495 // try english fallbacks
496 const struct KeysymNameReplacement
* pRepl
= aImplReplacements_English
;
497 for( int m
= SAL_N_ELEMENTS(aImplReplacements_English
); m
; )
499 if( nSymbol
== pRepl
[--m
].aSymbol
)
500 return OUString( pRepl
[m
].pName
, strlen(pRepl
[m
].pName
), RTL_TEXTENCODING_UTF8
);
507 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */