Bugzilla – Attachment 72546 Details for
Bug 54165
Unable to localize key names
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Allow localized shortcut names on Windows
0001-fdo-54165-Allow-localized-shortcut-names-on-Windows.patch (text/plain), 6.58 KB, created by
Jesus Corrius
on 2013-01-05 16:32:49 UTC
(
hide
)
Description:
Allow localized shortcut names on Windows
Filename:
MIME Type:
Creator:
Jesus Corrius
Created:
2013-01-05 16:32:49 UTC
Size:
6.58 KB
patch
obsolete
>From 0b4fa48c5a4e2b4a0eb153a73bd209cd9fe9fc1a Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Jes=C3=BAs?= <jesus@softcatala.org> >Date: Sat, 5 Jan 2013 17:29:51 +0100 >Subject: [PATCH] fdo#54165: Allow localized shortcut names on Windows > >Change-Id: Ic75f6b41187e7027e877b08c81bd79ea72d157e3 >--- > vcl/Library_vcl.mk | 1 + > vcl/inc/win/salframe.h | 7 +++ > vcl/win/source/window/keynames.cxx | 81 ++++++++++++++++++++++++++++++++++++ > vcl/win/source/window/salframe.cxx | 38 +++++++++++------ > 4 files changed, 114 insertions(+), 13 deletions(-) > create mode 100755 vcl/win/source/window/keynames.cxx > >diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk >index c3898bc..ed843bf 100644 >--- a/vcl/Library_vcl.mk >+++ b/vcl/Library_vcl.mk >@@ -641,6 +641,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ > vcl/win/source/gdi/winlayout \ > vcl/win/source/gdi/wntgdi \ > vcl/win/source/window/salframe \ >+ vcl/win/source/window/keynames \ > vcl/win/source/window/salmenu \ > vcl/win/source/window/salobj \ > )) >diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h >index 4c0f63c..54e10bd 100644 >--- a/vcl/inc/win/salframe.h >+++ b/vcl/inc/win/salframe.h >@@ -137,6 +137,13 @@ public: > > void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect ); > >+// get foreign key names >+namespace vcl_sal { >+ rtl::OUString getKeysReplacementName( >+ rtl::OUString pLang, >+ LONG nSymbol ); >+} >+ > #endif // _SV_SALFRAME_H > > /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ >diff --git a/vcl/win/source/window/keynames.cxx b/vcl/win/source/window/keynames.cxx >new file mode 100755 >index 0000000..57fb811 >--- /dev/null >+++ b/vcl/win/source/window/keynames.cxx >@@ -0,0 +1,81 @@ >+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ >+/* >+ * This file is part of the LibreOffice project. >+ * >+ * This Source Code Form is subject to the terms of the Mozilla Public >+ * License, v. 2.0. If a copy of the MPL was not distributed with this >+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. >+ * >+ * This file incorporates work covered by the following license notice: >+ * >+ * Licensed to the Apache Software Foundation (ASF) under one or more >+ * contributor license agreements. See the NOTICE file distributed >+ * with this work for additional information regarding copyright >+ * ownership. The ASF licenses this file to you under the Apache >+ * License, Version 2.0 (the "License"); you may not use this file >+ * except in compliance with the License. You may obtain a copy of >+ * the License at http://www.apache.org/licenses/LICENSE-2.0 . >+ */ >+ >+#include <string.h> >+#include <rtl/ustring.hxx> >+#include <sal/macros.h> >+ >+#include <windows.h> >+ >+namespace vcl_sal { >+ >+ struct KeysNameReplacement >+ { >+ LONG aSymbol; >+ const char* pName; >+ }; >+ >+ struct KeyboardReplacements >+ { >+ const char* pLangName; >+ const KeysNameReplacement* pReplacements; >+ int nReplacements; >+ }; >+ >+ // ==================================================================== >+ // >+ // CAUTION CAUTION CAUTION >+ // every string value in the replacements tables must be in UTF8 >+ // be careful with your editor ! >+ // >+ // ==================================================================== >+ >+ static const struct KeysNameReplacement aImplReplacements_Catalan[] = >+ { >+ { MAKELPARAM(0, MapVirtualKeyW(VK_SHIFT, 0)), "Maj" }, >+ { MAKELPARAM(0, MapVirtualKeyW(VK_BACK, 0)), "Retrocés" }, >+ }; >+ >+ static const struct KeyboardReplacements aKeyboards[] = >+ { >+ { "ca", aImplReplacements_Catalan, SAL_N_ELEMENTS(aImplReplacements_Catalan) }, >+ }; >+ >+ // translate keycodes, used within the displayed menu shortcuts >+ rtl::OUString getKeysReplacementName( rtl::OUString pLang, LONG nSymbol ) >+ { >+ for( unsigned int n = 0; n < SAL_N_ELEMENTS(aKeyboards); n++ ) >+ { >+ if( pLang.equalsAscii( aKeyboards[n].pLangName ) ) >+ { >+ const struct KeysNameReplacement* pRepl = aKeyboards[n].pReplacements; >+ for( int m = aKeyboards[n].nReplacements ; m ; ) >+ { >+ if( nSymbol == pRepl[--m].aSymbol ) >+ return rtl::OUString( pRepl[m].pName, strlen(pRepl[m].pName), RTL_TEXTENCODING_UTF8 ); >+ } >+ } >+ } >+ >+ return rtl::OUString(); >+ } >+ >+} >+ >+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ >diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx >index bdee3e1..f5573d4 100644 >--- a/vcl/win/source/window/salframe.cxx >+++ b/vcl/win/source/window/salframe.cxx >@@ -2387,23 +2387,35 @@ static void ImplGetKeyNameText( LONG lParam, sal_Unicode* pBuf, > int nKeyLen = 0; > if ( lParam ) > { >- nKeyLen = GetKeyNameTextW( lParam, aKeyBuf, nMaxKeyLen ); >- DBG_ASSERT( nKeyLen <= nMaxKeyLen, "Invalid key name length!" ); >- if( nKeyLen > nMaxKeyLen ) >- nKeyLen = 0; >- else if( nKeyLen > 0 ) >- { >- // Capitalize just the first letter of key names >- CharLowerBuffW( aKeyBuf, nKeyLen ); >+ rtl::OUString aLang = Application::GetSettings().GetUILanguageTag().getLanguage(); >+ rtl::OUString aRet; > >- bool bUpper = true; >- for( WCHAR *pW=aKeyBuf, *pE=pW+nKeyLen; pW < pE; ++pW ) >+ aRet = ::vcl_sal::getKeysReplacementName( aLang, lParam ); >+ if( aRet.isEmpty() ) >+ { >+ nKeyLen = GetKeyNameTextW( lParam, aKeyBuf, nMaxKeyLen ); >+ DBG_ASSERT( nKeyLen <= nMaxKeyLen, "Invalid key name length!" ); >+ if( nKeyLen > nMaxKeyLen ) >+ nKeyLen = 0; >+ else if( nKeyLen > 0 ) > { >- if( bUpper ) >- CharUpperBuffW( pW, 1 ); >- bUpper = (*pW=='+') || (*pW=='-') || (*pW==' ') || (*pW=='.'); >+ // Capitalize just the first letter of key names >+ CharLowerBuffW( aKeyBuf, nKeyLen ); >+ >+ bool bUpper = true; >+ for( WCHAR *pW=aKeyBuf, *pE=pW+nKeyLen; pW < pE; ++pW ) >+ { >+ if( bUpper ) >+ CharUpperBuffW( pW, 1 ); >+ bUpper = (*pW=='+') || (*pW=='-') || (*pW==' ') || (*pW=='.'); >+ } > } > } >+ else >+ { >+ nKeyLen = aRet.getLength(); >+ wcscpy_s( aKeyBuf, nKeyLen, aRet.getStr() ); >+ } > } > > if ( (nKeyLen > 0) || pReplace ) >-- >1.7.9 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 54165
:
72375
| 72546 |
73002