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