Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / vcl / win / source / window / keynames.cxx
blob153fc073c0fe802cf885f47167ed294d762d3d7f
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 <string.h>
21 #include <rtl/ustring.hxx>
22 #include <sal/macros.h>
24 #include <windows.h>
26 #define KEY_ESC 0x10000
27 #define KEY_BACK 0xE0000
28 #define KEY_ENTER 0x1C0000
29 #define KEY_SPACEBAR 0x390000
30 #define KEY_HOME 0x1470000
31 #define KEY_UP 0x1480000
32 #define KEY_PAGEUP 0x1490000
33 #define KEY_LEFT 0x14B0000
34 #define KEY_RIGHT 0x14D0000
35 #define KEY_END 0x14F0000
36 #define KEY_DOWN 0x1500000
37 #define KEY_PAGEDOWN 0x1510000
38 #define KEY_INSERT 0x1520000
39 #define KEY_DELETE 0x1530000
40 #define KEY_CONTROL 0x21D0000
41 #define KEY_SHIFT 0x22A0000
42 #define KEY_ALT 0x2380000
45 namespace vcl_sal {
47 struct KeysNameReplacement
49 LONG aSymbol;
50 const char* pName;
53 struct KeyboardReplacements
55 const char* pLangName;
56 const KeysNameReplacement* pReplacements;
57 int nReplacements;
60 // ====================================================================
62 // CAUTION CAUTION CAUTION
63 // every string value in the replacements tables must be in UTF8
64 // be careful with your editor !
66 // ====================================================================
68 static const struct KeysNameReplacement aImplReplacements_Catalan[] =
70 { KEY_BACK, "Retrocés" },
71 { KEY_ENTER, "Retorn" },
72 { KEY_SPACEBAR, "Espai" },
73 { KEY_HOME, "Inici" },
74 { KEY_UP, "Amunt" },
75 { KEY_PAGEUP, "Re Pàg" },
76 { KEY_LEFT, "Esquerra" },
77 { KEY_RIGHT, "Dreta" },
78 { KEY_END, "Fi" },
79 { KEY_DOWN, "Avall" },
80 { KEY_PAGEDOWN, "Av Pàg" },
81 { KEY_INSERT, "Ins" },
82 { KEY_DELETE, "Supr" },
83 { KEY_SHIFT, "Maj" },
86 static const struct KeyboardReplacements aKeyboards[] =
88 { "ca", aImplReplacements_Catalan, SAL_N_ELEMENTS(aImplReplacements_Catalan) },
91 // translate keycodes, used within the displayed menu shortcuts
92 rtl::OUString getKeysReplacementName( rtl::OUString pLang, LONG nSymbol )
94 for( unsigned int n = 0; n < SAL_N_ELEMENTS(aKeyboards); n++ )
96 if( pLang.equalsAscii( aKeyboards[n].pLangName ) )
98 const struct KeysNameReplacement* pRepl = aKeyboards[n].pReplacements;
99 for( int m = aKeyboards[n].nReplacements ; m ; )
101 if( nSymbol == pRepl[--m].aSymbol )
102 return rtl::OUString( pRepl[m].pName, strlen(pRepl[m].pName), RTL_TEXTENCODING_UTF8 );
107 return rtl::OUString();
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */