Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <unx/saldisp.hxx>
21 : #include <X11/keysym.h>
22 : #include <sal/macros.h>
23 :
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
35 : #endif
36 :
37 : #include <string.h>
38 : #include <rtl/ustring.hxx>
39 :
40 : namespace vcl_sal {
41 :
42 : struct KeysymNameReplacement
43 : {
44 : KeySym aSymbol;
45 : const char* pName;
46 : };
47 :
48 : struct KeyboardReplacements
49 : {
50 : const char* pLangName;
51 : const KeysymNameReplacement* pReplacements;
52 : int nReplacements;
53 : };
54 :
55 : // ====================================================================
56 : //
57 : // CAUTION CAUTION CAUTION
58 : // every string value in the replacements tables must be in UTF8
59 : // be careful with your editor !
60 : //
61 : // ====================================================================
62 :
63 : static const struct KeysymNameReplacement aImplReplacements_English[] =
64 : {
65 : { XK_Control_L, "Ctrl" },
66 : { XK_Control_R, "Ctrl" },
67 : { XK_Escape, "Esc" },
68 : { XK_space, "Space" },
69 : };
70 :
71 : static const struct KeysymNameReplacement aImplReplacements_Turkish[] =
72 : {
73 : { XK_Control_L, "Ctrl" },
74 : { XK_Control_R, "Ctrl" },
75 : { XK_Right, "Sağ" },
76 : { XK_Left, "Sol" },
77 : { XK_Up, "Yukarı" },
78 : { XK_Down, "Aşağı" },
79 : { XK_space, "Boşluk" }
80 : };
81 :
82 : static const struct KeysymNameReplacement aImplReplacements_Russian[] =
83 : {
84 : { XK_Right, "Вправо" },
85 : { XK_Left, "Влево" },
86 : { XK_Up, "Вверх" },
87 : { XK_Down, "Вниз" },
88 : { XK_space, "Пробел" }
89 : };
90 :
91 : static const struct KeysymNameReplacement aImplReplacements_German[] =
92 : {
93 : { XK_Control_L, "Strg" },
94 : { XK_Control_R, "Strg" },
95 : { XK_Shift_L, "Umschalt" },
96 : { XK_Shift_R, "Umschalt" },
97 : { XK_Alt_L, "Alt" },
98 : { XK_Alt_R, "Alt Gr" },
99 : { XK_Page_Up, "Bild auf" },
100 : { XK_Page_Down, "Bild ab" },
101 : { XK_End, "Ende" },
102 : { XK_Home, "Pos 1" },
103 : { XK_Insert, "Einfg" },
104 : { XK_Delete, "Entf" },
105 : { XK_Escape, "Esc" },
106 : { XK_Right, "Rechts" },
107 : { XK_Left, "Links" },
108 : { XK_Up, "Oben" },
109 : { XK_Down, "Unten" },
110 : { XK_BackSpace, "Rückschritt" },
111 : { XK_Return, "Eingabe" },
112 : { XK_slash, "Schrägstrich" },
113 : { XK_space, "Leertaste" },
114 : { SunXK_Stop, "Stop" },
115 : { SunXK_Again, "Wiederholen" },
116 : { SunXK_Props, "Eigenschaften" },
117 : { SunXK_Undo, "Zurücknehmen" },
118 : { SunXK_Front, "Vordergrund" },
119 : { SunXK_Copy, "Kopieren" },
120 : { SunXK_Open, "Öffnen" },
121 : { SunXK_Paste, "Einsetzen" },
122 : { SunXK_Find, "Suchen" },
123 : { SunXK_Cut, "Ausschneiden" },
124 : };
125 :
126 : static const struct KeysymNameReplacement aImplReplacements_French[] =
127 : {
128 : { XK_Shift_L, "Maj" },
129 : { XK_Shift_R, "Maj" },
130 : { XK_Page_Up, "Pg. Préc" },
131 : { XK_Page_Down, "Pg. Suiv" },
132 : { XK_End, "Fin" },
133 : { XK_Home, "Origine" },
134 : { XK_Insert, "Insérer" },
135 : { XK_Delete, "Suppr" },
136 : { XK_Escape, "Esc" },
137 : { XK_Right, "Droite" },
138 : { XK_Left, "Gauche" },
139 : { XK_Up, "Haut" },
140 : { XK_Down, "Bas" },
141 : { XK_BackSpace, "Ret. Arr" },
142 : { XK_Return, "Retour" },
143 : { XK_KP_Enter, "Entrée" },
144 : { SunXK_Stop, "Stop" },
145 : { SunXK_Again, "Encore" },
146 : { SunXK_Props, "Props" },
147 : { SunXK_Undo, "Annuler" },
148 : { SunXK_Front, "Devant" },
149 : { SunXK_Copy, "Copy" },
150 : { SunXK_Open, "Ouvrir" },
151 : { SunXK_Paste, "Coller" },
152 : { SunXK_Find, "Cher." },
153 : { SunXK_Cut, "Couper" },
154 : };
155 :
156 : static const struct KeysymNameReplacement aImplReplacements_Italian[] =
157 : {
158 : { XK_Shift_L, "Maiusc" },
159 : { XK_Shift_R, "Maiusc" },
160 : { XK_Page_Up, "PgSu" },
161 : { XK_Page_Down, "PgGiu" },
162 : { XK_End, "Fine" },
163 : { XK_Insert, "Ins" },
164 : { XK_Delete, "Canc" },
165 : { XK_Escape, "Esc" },
166 : { XK_Right, "A destra" },
167 : { XK_Left, "A sinistra" },
168 : { XK_Up, "Sposta verso l'alto" },
169 : { XK_Down, "Sposta verso il basso" },
170 : { XK_BackSpace, "Backspace" },
171 : { XK_Return, "Invio" },
172 : { XK_space, "Spazio" },
173 : { SunXK_Stop, "Stop" },
174 : { SunXK_Again, "Ancora" },
175 : { SunXK_Props, "Proprietà" },
176 : { SunXK_Undo, "Annulla" },
177 : { SunXK_Front, "Davanti" },
178 : { SunXK_Copy, "Copia" },
179 : { SunXK_Open, "Apri" },
180 : { SunXK_Paste, "Incolla" },
181 : { SunXK_Find, "Trova" },
182 : { SunXK_Cut, "Taglia" },
183 : };
184 :
185 : static const struct KeysymNameReplacement aImplReplacements_Dutch[] =
186 : {
187 : { XK_Page_Up, "PageUp" },
188 : { XK_Page_Down, "PageDown" },
189 : { XK_Escape, "Esc" },
190 : { XK_Right, "Rechts" },
191 : { XK_Left, "Links" },
192 : { XK_Up, "Boven" },
193 : { XK_Down, "Onder" },
194 : { XK_BackSpace, "Backspace" },
195 : { XK_Return, "Return" },
196 : { XK_space, "Spatiebalk" },
197 : { SunXK_Stop, "Stop" },
198 : { SunXK_Again, "Again" },
199 : { SunXK_Props, "Props" },
200 : { SunXK_Undo, "Undo" },
201 : { SunXK_Front, "Front" },
202 : { SunXK_Copy, "Copy" },
203 : { SunXK_Open, "Open" },
204 : { SunXK_Paste, "Paste" },
205 : { SunXK_Find, "Find" },
206 : { SunXK_Cut, "Cut" },
207 : };
208 :
209 : static const struct KeysymNameReplacement aImplReplacements_Norwegian[] =
210 : {
211 : { XK_Shift_L, "Skift" },
212 : { XK_Shift_R, "Skift" },
213 : { XK_Page_Up, "PageUp" },
214 : { XK_Page_Down, "PageDown" },
215 : { XK_Escape, "Esc" },
216 : { XK_Right, "Høyre" },
217 : { XK_Left, "Venstre" },
218 : { XK_Up, "Opp" },
219 : { XK_Down, "Ned" },
220 : { XK_BackSpace, "Tilbake" },
221 : { XK_Return, "Enter" },
222 : { SunXK_Stop, "Avbryt" },
223 : { SunXK_Again, "Gjenta" },
224 : { SunXK_Props, "Egenskaper" },
225 : { SunXK_Undo, "Angre" },
226 : { SunXK_Front, "Front" },
227 : { SunXK_Copy, "Kopi" },
228 : { SunXK_Open, "Åpne" },
229 : { SunXK_Paste, "Lim" },
230 : { SunXK_Find, "Søk" },
231 : { SunXK_Cut, "Klipp" },
232 : };
233 :
234 : static const struct KeysymNameReplacement aImplReplacements_Swedish[] =
235 : {
236 : { XK_Shift_L, "Skift" },
237 : { XK_Shift_R, "Skift" },
238 : { XK_Page_Up, "PageUp" },
239 : { XK_Page_Down, "PageDown" },
240 : { XK_Escape, "Esc" },
241 : { XK_Right, "Höger" },
242 : { XK_Left, "Vänster" },
243 : { XK_Up, "Up" },
244 : { XK_Down, "Ned" },
245 : { XK_BackSpace, "Backsteg" },
246 : { XK_Return, "Retur" },
247 : { XK_space, "Blank" },
248 : { SunXK_Stop, "Avbryt" },
249 : { SunXK_Again, "Upprepa" },
250 : { SunXK_Props, "Egenskaper" },
251 : { SunXK_Undo, "Ångra" },
252 : { SunXK_Front, "Fram" },
253 : { SunXK_Copy, "Kopiera" },
254 : { SunXK_Open, "Öppna" },
255 : { SunXK_Paste, "Klistra in" },
256 : { SunXK_Find, "Sök" },
257 : { SunXK_Cut, "Klipp ut" },
258 : };
259 :
260 : static const struct KeysymNameReplacement aImplReplacements_Portuguese[] =
261 : {
262 : { XK_Page_Up, "PageUp" },
263 : { XK_Page_Down, "PageDown" },
264 : { XK_Escape, "Esc" },
265 : { XK_Right, "Direita" },
266 : { XK_Left, "Esquerda" },
267 : { XK_Up, "Acima" },
268 : { XK_Down, "Abaixo" },
269 : { XK_BackSpace, "Backspace" },
270 : { XK_Return, "Enter" },
271 : { XK_slash, "Barra" },
272 : { SunXK_Stop, "Stop" },
273 : { SunXK_Again, "Again" },
274 : { SunXK_Props, "Props" },
275 : { SunXK_Undo, "Undo" },
276 : { SunXK_Front, "Front" },
277 : { SunXK_Copy, "Copy" },
278 : { SunXK_Open, "Open" },
279 : { SunXK_Paste, "Paste" },
280 : { SunXK_Find, "Find" },
281 : { SunXK_Cut, "Cut" },
282 : };
283 :
284 : static const struct KeysymNameReplacement aImplReplacements_Spanish[] =
285 : {
286 : { XK_Shift_L, "Mayús" },
287 : { XK_Shift_R, "Mayús" },
288 : { XK_Page_Up, "RePág" },
289 : { XK_Page_Down, "AvPág" },
290 : { XK_End, "Fin" },
291 : { XK_Home, "Inicio" },
292 : { XK_Delete, "Supr" },
293 : { XK_Escape, "Esc" },
294 : { XK_Right, "Hacia la derecha" },
295 : { XK_Left, "Hacia la izquierda" },
296 : { XK_Up, "Hacia arriba" },
297 : { XK_Down, "Hacia abajo" },
298 : { XK_BackSpace, "Ret" },
299 : { XK_Return, "Entrada" },
300 : { XK_space, "Espacio" },
301 : { XK_KP_Enter, "Intro" },
302 : { SunXK_Stop, "Stop" },
303 : { SunXK_Again, "Repetir" },
304 : { SunXK_Props, "Props" },
305 : { SunXK_Undo, "Anular" },
306 : { SunXK_Front, "Delante" },
307 : { SunXK_Copy, "Copiar" },
308 : { SunXK_Open, "Abrir" },
309 : { SunXK_Paste, "Pegar" },
310 : { SunXK_Find, "Buscar" },
311 : { SunXK_Cut, "Cortar" },
312 : };
313 :
314 : static const struct KeysymNameReplacement aImplReplacements_Estonian[] =
315 : {
316 : { XK_Page_Up, "PgUp" },
317 : { XK_Page_Down, "PgDown" },
318 : { XK_End, "End" },
319 : { XK_Home, "Home" },
320 : { XK_Insert, "Ins" },
321 : { XK_Delete, "Del" },
322 : { XK_Escape, "Esc" },
323 : { XK_Right, "Nool paremale" },
324 : { XK_Left, "Nool vasakule" },
325 : { XK_Up, "Nool üles" },
326 : { XK_Down, "Nool alla" },
327 : { XK_BackSpace, "Tagasilüke" },
328 : { XK_Return, "Enter" },
329 : { XK_slash, "Kaldkriips" },
330 : { XK_space, "Tühik" },
331 : { XK_asterisk, "Tärn" },
332 : { SunXK_Stop, "Peata" },
333 : { SunXK_Again, "Korda" },
334 : { SunXK_Props, "Omadused" },
335 : { SunXK_Undo, "Võta tagasi" },
336 : { SunXK_Front, "Esiplaanile" },
337 : { SunXK_Copy, "Kopeeri" },
338 : { SunXK_Open, "Ava" },
339 : { SunXK_Paste, "Aseta" },
340 : { SunXK_Find, "Otsi" },
341 : { SunXK_Cut, "Lõika" },
342 : };
343 :
344 : static const struct KeyboardReplacements aKeyboards[] =
345 : {
346 : { "de", aImplReplacements_German, SAL_N_ELEMENTS(aImplReplacements_German) },
347 : { "es", aImplReplacements_Spanish, SAL_N_ELEMENTS(aImplReplacements_Spanish) },
348 : { "et", aImplReplacements_Estonian, SAL_N_ELEMENTS(aImplReplacements_Estonian) },
349 : { "fr", aImplReplacements_French, SAL_N_ELEMENTS(aImplReplacements_French) },
350 : { "it", aImplReplacements_Italian, SAL_N_ELEMENTS(aImplReplacements_Italian) },
351 : { "nl", aImplReplacements_Dutch, SAL_N_ELEMENTS(aImplReplacements_Dutch) },
352 : { "no", aImplReplacements_Norwegian, SAL_N_ELEMENTS(aImplReplacements_Norwegian) },
353 : { "pt", aImplReplacements_Portuguese, SAL_N_ELEMENTS(aImplReplacements_Portuguese) },
354 : { "ru", aImplReplacements_Russian, SAL_N_ELEMENTS(aImplReplacements_Russian) },
355 : { "sv", aImplReplacements_Swedish, SAL_N_ELEMENTS(aImplReplacements_Swedish) },
356 : { "tr", aImplReplacements_Turkish, SAL_N_ELEMENTS(aImplReplacements_Turkish) },
357 : };
358 :
359 : // translate keycodes, used within the displayed menu shortcuts
360 0 : rtl::OUString getKeysymReplacementName( rtl::OUString pLang, KeySym nSymbol )
361 : {
362 0 : for( unsigned int n = 0; n < SAL_N_ELEMENTS(aKeyboards); n++ )
363 : {
364 0 : if( pLang.equalsAscii( aKeyboards[n].pLangName ) )
365 : {
366 0 : const struct KeysymNameReplacement* pRepl = aKeyboards[n].pReplacements;
367 0 : for( int m = aKeyboards[n].nReplacements ; m ; )
368 : {
369 0 : if( nSymbol == pRepl[--m].aSymbol )
370 0 : return rtl::OUString( pRepl[m].pName, strlen(pRepl[m].pName), RTL_TEXTENCODING_UTF8 );
371 : }
372 : }
373 : }
374 :
375 : // try english fallbacks
376 0 : const struct KeysymNameReplacement* pRepl = aImplReplacements_English;
377 0 : for( int m = SAL_N_ELEMENTS(aImplReplacements_English); m ; )
378 : {
379 0 : if( nSymbol == pRepl[--m].aSymbol )
380 0 : return rtl::OUString( pRepl[m].pName, strlen(pRepl[m].pName), RTL_TEXTENCODING_UTF8 );
381 : }
382 :
383 0 : return rtl::OUString();
384 : }
385 :
386 : }
387 :
388 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|