vcl/inc/win/salframe.h | 7 - vcl/win/window/keynames.cxx | 278 +++++++++++++++++++++----------------------- vcl/win/window/salframe.cxx | 51 ++------ 3 files changed, 153 insertions(+), 183 deletions(-)
New commits: commit c608bdee36bd2d914fd8ebfef12b2bebfc204754 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Apr 15 09:15:59 2025 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Apr 15 11:07:15 2025 +0200 Use OUStringBuffer instead of C-style array Change-Id: I1ea51bff7b2eb0f4346a14b558d30efcc7e76a6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184194 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index c49bebe57c51..3c726fd96951 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -38,8 +38,7 @@ #include <rtl/bootstrap.hxx> #include <rtl/character.hxx> -#include <rtl/string.h> -#include <rtl/ustring.h> +#include <rtl/ustrbuf.hxx> #include <sal/log.hxx> #include <osl/module.h> @@ -2193,9 +2192,7 @@ void WinSalFrame::EndExtTextInput( EndExtTextInputFlags nFlags ) SendMessageW( mhWnd, SAL_MSG_ENDEXTTEXTINPUT, static_cast<WPARAM>(nFlags), 0 ); } -static void ImplGetKeyNameText( UINT lParam, sal_Unicode* pBuf, - UINT& rCount, UINT nMaxSize, - const char* pReplace ) +static void ImplGetKeyNameText(UINT lParam, OUStringBuffer& rBuf, const char* pReplace) { static_assert( sizeof( WCHAR ) == sizeof( sal_Unicode ), "must be the same size" ); @@ -2237,58 +2234,46 @@ static void ImplGetKeyNameText( UINT lParam, sal_Unicode* pBuf, if ( (nKeyLen > 0) || pReplace ) { - if( (rCount > 0) && (rCount < nMaxSize) ) - { - pBuf[rCount] = '+'; - rCount++; - } + if (!rBuf.isEmpty()) + rBuf.append('+'); if( nKeyLen > 0 ) { - WCHAR *pW = aKeyBuf, *pE = aKeyBuf + nKeyLen; - while ((pW < pE) && *pW && (rCount < nMaxSize)) - pBuf[rCount++] = *pW++; + rBuf.append(o3tl::toU(aKeyBuf), nKeyLen); } else // fall back to provided default name { - while( *pReplace && (rCount < nMaxSize) ) - { - pBuf[rCount] = *pReplace; - rCount++; - pReplace++; - } + rBuf.appendAscii(pReplace); } } else - rCount = 0; + rBuf.setLength(0); } OUString WinSalFrame::GetKeyName( sal_uInt16 nKeyCode ) { - static const UINT nMaxKeyLen = 350; - sal_Unicode aKeyBuf[ nMaxKeyLen ]; - UINT nKeyBufLen = 0; + OUStringBuffer aKeyBuf; UINT nSysCode = 0; if ( nKeyCode & KEY_MOD1 ) { nSysCode = MapVirtualKeyW( VK_CONTROL, 0 ); nSysCode = (nSysCode << 16) | ((sal_uLong(1)) << 25); - ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, "Ctrl" ); + ImplGetKeyNameText( nSysCode, aKeyBuf, "Ctrl" ); } if ( nKeyCode & KEY_MOD2 ) { nSysCode = MapVirtualKeyW( VK_MENU, 0 ); nSysCode = (nSysCode << 16) | ((sal_uLong(1)) << 25); - ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, "Alt" ); + ImplGetKeyNameText( nSysCode, aKeyBuf, "Alt" ); } if ( nKeyCode & KEY_SHIFT ) { nSysCode = MapVirtualKeyW( VK_SHIFT, 0 ); nSysCode = (nSysCode << 16) | ((sal_uLong(1)) << 25); - ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, "Shift" ); + ImplGetKeyNameText( nSysCode, aKeyBuf, "Shift" ); } sal_uInt16 nCode = nKeyCode & 0x0FFF; @@ -2465,23 +2450,19 @@ OUString WinSalFrame::GetKeyName( sal_uInt16 nKeyCode ) nSysCode = MapVirtualKeyW( nSysCode, 0 ); if ( nSysCode ) nSysCode = (nSysCode << 16) | nSysCode2; - ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, pReplace ); + ImplGetKeyNameText( nSysCode, aKeyBuf, pReplace ); } else { if ( cSVCode ) { - if ( nKeyBufLen > 0 ) - aKeyBuf[ nKeyBufLen++ ] = '+'; - if( nKeyBufLen < nMaxKeyLen ) - aKeyBuf[ nKeyBufLen++ ] = cSVCode; + if (!aKeyBuf.isEmpty()) + aKeyBuf.append('+'); + aKeyBuf.append(cSVCode); } } - if( !nKeyBufLen ) - return OUString(); - - return OUString( aKeyBuf, sal::static_int_cast< sal_uInt16 >(nKeyBufLen) ); + return aKeyBuf.makeStringAndClear(); } static Color ImplWinColorToSal( COLORREF nColor ) commit 6fa7d991980520238607cb8268052dfdc751b176 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Apr 15 08:43:10 2025 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Apr 15 11:07:07 2025 +0200 Make some arrays constexpr Use Unicode literals, instead of using UTF-8 code units. And change the key type from LONG to UINT, to match the type of the value obtained from MapVirtualKeyW. Change-Id: I1eff78cf8ad642310e3966596f0f129e9366d8c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184193 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h index fdf1b98a9873..37f43dafdbe6 100644 --- a/vcl/inc/win/salframe.h +++ b/vcl/inc/win/salframe.h @@ -161,10 +161,9 @@ bool UseDarkMode(); bool OSSupportsDarkMode(); // get foreign key names -namespace vcl_sal { - OUString getKeysReplacementName( - std::u16string_view pLang, - LONG nSymbol ); +namespace vcl_sal +{ +OUString getKeysReplacementName(std::u16string_view pLang, UINT nSymbol); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/win/window/keynames.cxx b/vcl/win/window/keynames.cxx index f0cecb2bd127..557e701908e2 100644 --- a/vcl/win/window/keynames.cxx +++ b/vcl/win/window/keynames.cxx @@ -17,38 +17,34 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <string.h> -#include <o3tl/string_view.hxx> +#include <sal/config.h> + +#include <span> + #include <rtl/ustring.hxx> -#include <sal/macros.h> #include <win/salframe.h> -#if !defined WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif -#include <windows.h> - // Use unique ;) names to avoid clashes with the KEY_* (especially // KEY_SHIFT) from <vcl/vclenum.hxx> -#define PAPUGA_KEY_ESC 0x10000 -#define PAPUGA_KEY_BACK 0xE0000 -#define PAPUGA_KEY_ENTER 0x1C0000 -#define PAPUGA_KEY_SPACEBAR 0x390000 -#define PAPUGA_KEY_HOME 0x1470000 -#define PAPUGA_KEY_UP 0x1480000 -#define PAPUGA_KEY_PAGEUP 0x1490000 -#define PAPUGA_KEY_LEFT 0x14B0000 -#define PAPUGA_KEY_RIGHT 0x14D0000 -#define PAPUGA_KEY_END 0x14F0000 -#define PAPUGA_KEY_DOWN 0x1500000 -#define PAPUGA_KEY_PAGEDOWN 0x1510000 -#define PAPUGA_KEY_INSERT 0x1520000 -#define PAPUGA_KEY_DELETE 0x1530000 -#define PAPUGA_KEY_CONTROL 0x21D0000 -#define PAPUGA_KEY_SHIFT 0x22A0000 -#define PAPUGA_KEY_ALT 0x2380000 +constexpr UINT PAPUGA_KEY_ESC = 0x10000; +constexpr UINT PAPUGA_KEY_BACK = 0xE0000; +constexpr UINT PAPUGA_KEY_ENTER = 0x1C0000; +constexpr UINT PAPUGA_KEY_SPACEBAR = 0x390000; +constexpr UINT PAPUGA_KEY_HOME = 0x1470000; +constexpr UINT PAPUGA_KEY_UP = 0x1480000; +constexpr UINT PAPUGA_KEY_PAGEUP = 0x1490000; +constexpr UINT PAPUGA_KEY_LEFT = 0x14B0000; +constexpr UINT PAPUGA_KEY_RIGHT = 0x14D0000; +constexpr UINT PAPUGA_KEY_END = 0x14F0000; +constexpr UINT PAPUGA_KEY_DOWN = 0x1500000; +constexpr UINT PAPUGA_KEY_PAGEDOWN = 0x1510000; +constexpr UINT PAPUGA_KEY_INSERT = 0x1520000; +constexpr UINT PAPUGA_KEY_DELETE = 0x1530000; +constexpr UINT PAPUGA_KEY_CONTROL = 0x21D0000; +constexpr UINT PAPUGA_KEY_SHIFT = 0x22A0000; +constexpr UINT PAPUGA_KEY_ALT = 0x2380000; namespace vcl_sal { @@ -56,163 +52,157 @@ namespace vcl_sal { struct KeysNameReplacement { - LONG aSymbol; - const char* pName; + UINT aSymbol; + OUString pName; }; struct KeyboardReplacements { - const char* pLangName; - const KeysNameReplacement* pReplacements; - int nReplacements; + std::u16string_view pLangName; + std::span<const KeysNameReplacement> pReplacements; }; } - // CAUTION CAUTION CAUTION - // Every string value in the replacements tables must be in UTF-8 - // but with the UTF-8 bytes encoded, not as such! Be careful! - - const struct KeysNameReplacement aImplReplacements_Asturian[] = + constexpr KeysNameReplacement aImplReplacements_Asturian[] = { - { PAPUGA_KEY_BACK, "Retrocesu" }, - { PAPUGA_KEY_ENTER, "Intro" }, - { PAPUGA_KEY_SPACEBAR, "Espaciu" }, - { PAPUGA_KEY_HOME, "Aniciu" }, - { PAPUGA_KEY_UP, "Arriba" }, - { PAPUGA_KEY_PAGEUP, "Re P\xc3\xa1" "x" }, - { PAPUGA_KEY_LEFT, "Izquierda" }, - { PAPUGA_KEY_RIGHT, "Drecha" }, - { PAPUGA_KEY_END, "Fin" }, - { PAPUGA_KEY_DOWN, "Abaxo" }, - { PAPUGA_KEY_PAGEDOWN, "Av P\xc3\xa1" "x" }, - { PAPUGA_KEY_INSERT, "Ins" }, - { PAPUGA_KEY_DELETE, "Supr" }, - { PAPUGA_KEY_SHIFT, "May\xc3\xba" "s" }, + { PAPUGA_KEY_BACK, u"Retrocesu"_ustr }, + { PAPUGA_KEY_ENTER, u"Intro"_ustr }, + { PAPUGA_KEY_SPACEBAR, u"Espaciu"_ustr }, + { PAPUGA_KEY_HOME, u"Aniciu"_ustr }, + { PAPUGA_KEY_UP, u"Arriba"_ustr }, + { PAPUGA_KEY_PAGEUP, u"Re Páx"_ustr }, + { PAPUGA_KEY_LEFT, u"Izquierda"_ustr }, + { PAPUGA_KEY_RIGHT, u"Drecha"_ustr }, + { PAPUGA_KEY_END, u"Fin"_ustr }, + { PAPUGA_KEY_DOWN, u"Abaxo"_ustr }, + { PAPUGA_KEY_PAGEDOWN, u"Av Páx"_ustr }, + { PAPUGA_KEY_INSERT, u"Ins"_ustr }, + { PAPUGA_KEY_DELETE, u"Supr"_ustr }, + { PAPUGA_KEY_SHIFT, u"Mayús"_ustr }, }; - const struct KeysNameReplacement aImplReplacements_Catalan[] = + constexpr KeysNameReplacement aImplReplacements_Catalan[] = { - { PAPUGA_KEY_BACK, "Retroc\xc3\xa9" "s" }, - { PAPUGA_KEY_ENTER, "Retorn" }, - { PAPUGA_KEY_SPACEBAR, "Espai" }, - { PAPUGA_KEY_HOME, "Inici" }, - { PAPUGA_KEY_UP, "Amunt" }, - { PAPUGA_KEY_PAGEUP, "Re P\xc3\xa0" "g" }, - { PAPUGA_KEY_LEFT, "Esquerra" }, - { PAPUGA_KEY_RIGHT, "Dreta" }, - { PAPUGA_KEY_END, "Fi" }, - { PAPUGA_KEY_DOWN, "Avall" }, - { PAPUGA_KEY_PAGEDOWN, "Av P\xc3\xa0" "g" }, - { PAPUGA_KEY_INSERT, "Ins" }, - { PAPUGA_KEY_DELETE, "Supr" }, - { PAPUGA_KEY_SHIFT, "Maj" }, + { PAPUGA_KEY_BACK, u"Retrocés"_ustr }, + { PAPUGA_KEY_ENTER, u"Retorn"_ustr }, + { PAPUGA_KEY_SPACEBAR, u"Espai"_ustr }, + { PAPUGA_KEY_HOME, u"Inici"_ustr }, + { PAPUGA_KEY_UP, u"Amunt"_ustr }, + { PAPUGA_KEY_PAGEUP, u"Re Pàg"_ustr }, + { PAPUGA_KEY_LEFT, u"Esquerra"_ustr }, + { PAPUGA_KEY_RIGHT, u"Dreta"_ustr }, + { PAPUGA_KEY_END, u"Fi"_ustr }, + { PAPUGA_KEY_DOWN, u"Avall"_ustr }, + { PAPUGA_KEY_PAGEDOWN, u"Av Pàg"_ustr }, + { PAPUGA_KEY_INSERT, u"Ins"_ustr }, + { PAPUGA_KEY_DELETE, u"Supr"_ustr }, + { PAPUGA_KEY_SHIFT, u"Maj"_ustr }, }; - const struct KeysNameReplacement aImplReplacements_Estonian[] = + constexpr KeysNameReplacement aImplReplacements_Estonian[] = { - { PAPUGA_KEY_RIGHT, "Nool paremale" }, - { PAPUGA_KEY_LEFT, "Nool vasakule" }, - { PAPUGA_KEY_UP, "Nool \xc3\xbc" "les" }, - { PAPUGA_KEY_DOWN, "Nool alla" }, - { PAPUGA_KEY_BACK, "Tagasil\xc3\xbc" "ke" }, - { PAPUGA_KEY_ENTER, "Enter" }, - { PAPUGA_KEY_SPACEBAR, "T\xc3\xbc" "hik" }, + { PAPUGA_KEY_RIGHT, u"Nool paremale"_ustr }, + { PAPUGA_KEY_LEFT, u"Nool vasakule"_ustr }, + { PAPUGA_KEY_UP, u"Nool üles"_ustr }, + { PAPUGA_KEY_DOWN, u"Nool alla"_ustr }, + { PAPUGA_KEY_BACK, u"Tagasilüke"_ustr }, + { PAPUGA_KEY_ENTER, u"Enter"_ustr }, + { PAPUGA_KEY_SPACEBAR, u"Tühik"_ustr }, }; - const struct KeysNameReplacement aImplReplacements_Lithuanian[] = + constexpr KeysNameReplacement aImplReplacements_Lithuanian[] = { - { PAPUGA_KEY_ESC, "Gr" }, - { PAPUGA_KEY_BACK, "Naikinti" }, - { PAPUGA_KEY_ENTER, "\xc4\xae" "vesti" }, - { PAPUGA_KEY_SPACEBAR, "Tarpas" }, - { PAPUGA_KEY_HOME, "Prad" }, - { PAPUGA_KEY_UP, "Auk\xc5\xa1" "tyn" }, - { PAPUGA_KEY_PAGEUP, "Psl\xe2\x86\x91" }, - { PAPUGA_KEY_LEFT, "Kair\xc4\x97" "n" }, - { PAPUGA_KEY_RIGHT, "De\xc5\xa1" "in\xc4\x97" "n" }, - { PAPUGA_KEY_END, "Pab" }, - { PAPUGA_KEY_DOWN, "\xc5\xbd" "emyn" }, - { PAPUGA_KEY_PAGEDOWN, "Psl\xe2\x86\x93" }, - { PAPUGA_KEY_INSERT, "\xc4\xae" "terpti" }, - { PAPUGA_KEY_DELETE, "\xc5\xa0" "al" }, - { PAPUGA_KEY_CONTROL, "Vald" }, - { PAPUGA_KEY_SHIFT, "Lyg2" }, - { PAPUGA_KEY_ALT, "Alt" }, + { PAPUGA_KEY_ESC, u"Gr"_ustr }, + { PAPUGA_KEY_BACK, u"Naikinti"_ustr }, + { PAPUGA_KEY_ENTER, u"Įvesti"_ustr }, + { PAPUGA_KEY_SPACEBAR, u"Tarpas"_ustr }, + { PAPUGA_KEY_HOME, u"Prad"_ustr }, + { PAPUGA_KEY_UP, u"Aukštyn"_ustr }, + { PAPUGA_KEY_PAGEUP, u"Psl↑"_ustr }, + { PAPUGA_KEY_LEFT, u"Kairėn"_ustr }, + { PAPUGA_KEY_RIGHT, u"Dešinėn"_ustr }, + { PAPUGA_KEY_END, u"Pab"_ustr }, + { PAPUGA_KEY_DOWN, u"Žemyn"_ustr }, + { PAPUGA_KEY_PAGEDOWN, u"Psl↓"_ustr }, + { PAPUGA_KEY_INSERT, u"Įterpti"_ustr }, + { PAPUGA_KEY_DELETE, u"Šal"_ustr }, + { PAPUGA_KEY_CONTROL, u"Vald"_ustr }, + { PAPUGA_KEY_SHIFT, u"Lyg2"_ustr }, + { PAPUGA_KEY_ALT, u"Alt"_ustr }, }; - const struct KeysNameReplacement aImplReplacements_Slovenian[] = + constexpr KeysNameReplacement aImplReplacements_Slovenian[] = { - { PAPUGA_KEY_ESC, "Ube\xc5\xbe" "nica" }, - { PAPUGA_KEY_BACK, "Vra\xc4\x8d" "alka" }, - { PAPUGA_KEY_ENTER, "Vna\xc5\xa1" "alka" }, - { PAPUGA_KEY_SPACEBAR, "Preslednica" }, - { PAPUGA_KEY_HOME, "Za\xc4\x8d" "etek" }, - { PAPUGA_KEY_UP, "Navzgor" }, - { PAPUGA_KEY_PAGEUP, "Prej\xc5\xa1" "nja stran" }, - { PAPUGA_KEY_LEFT, "Levo" }, - { PAPUGA_KEY_RIGHT, "Desno" }, - { PAPUGA_KEY_END, "Konec" }, - { PAPUGA_KEY_DOWN, "Navzdol" }, - { PAPUGA_KEY_PAGEDOWN, "Naslednja stran" }, - { PAPUGA_KEY_INSERT, "Vrivalka" }, - { PAPUGA_KEY_DELETE, "Brisalka" }, - { PAPUGA_KEY_CONTROL, "Krmilka" }, - { PAPUGA_KEY_SHIFT, "Dvigalka" }, - { PAPUGA_KEY_ALT, "Izmenjalka" }, + { PAPUGA_KEY_ESC, u"Ubežnica"_ustr }, + { PAPUGA_KEY_BACK, u"Vračalka"_ustr }, + { PAPUGA_KEY_ENTER, u"Vnašalka"_ustr }, + { PAPUGA_KEY_SPACEBAR, u"Preslednica"_ustr }, + { PAPUGA_KEY_HOME, u"Začetek"_ustr }, + { PAPUGA_KEY_UP, u"Navzgor"_ustr }, + { PAPUGA_KEY_PAGEUP, u"Prejšnja stran"_ustr }, + { PAPUGA_KEY_LEFT, u"Levo"_ustr }, + { PAPUGA_KEY_RIGHT, u"Desno"_ustr }, + { PAPUGA_KEY_END, u"Konec"_ustr }, + { PAPUGA_KEY_DOWN, u"Navzdol"_ustr }, + { PAPUGA_KEY_PAGEDOWN, u"Naslednja stran"_ustr }, + { PAPUGA_KEY_INSERT, u"Vrivalka"_ustr }, + { PAPUGA_KEY_DELETE, u"Brisalka"_ustr }, + { PAPUGA_KEY_CONTROL, u"Krmilka"_ustr }, + { PAPUGA_KEY_SHIFT, u"Dvigalka"_ustr }, + { PAPUGA_KEY_ALT, u"Izmenjalka"_ustr }, }; - const struct KeysNameReplacement aImplReplacements_Spanish[] = + constexpr KeysNameReplacement aImplReplacements_Spanish[] = { - { PAPUGA_KEY_BACK, "Retroceso" }, - { PAPUGA_KEY_ENTER, "Intro" }, - { PAPUGA_KEY_SPACEBAR, "Espacio" }, - { PAPUGA_KEY_HOME, "Inicio" }, - { PAPUGA_KEY_UP, "Arriba" }, - { PAPUGA_KEY_PAGEUP, "Re P\xc3\xa1" "g" }, - { PAPUGA_KEY_LEFT, "Izquierda" }, - { PAPUGA_KEY_RIGHT, "Derecha" }, - { PAPUGA_KEY_END, "Fin" }, - { PAPUGA_KEY_DOWN, "Abajo" }, - { PAPUGA_KEY_PAGEDOWN, "Av P\xc3\xa1" "g" }, - { PAPUGA_KEY_INSERT, "Ins" }, - { PAPUGA_KEY_DELETE, "Supr" }, - { PAPUGA_KEY_SHIFT, "May\xc3\xba" "s" }, + { PAPUGA_KEY_BACK, u"Retroceso"_ustr }, + { PAPUGA_KEY_ENTER, u"Intro"_ustr }, + { PAPUGA_KEY_SPACEBAR, u"Espacio"_ustr }, + { PAPUGA_KEY_HOME, u"Inicio"_ustr }, + { PAPUGA_KEY_UP, u"Arriba"_ustr }, + { PAPUGA_KEY_PAGEUP, u"Re Pág"_ustr }, + { PAPUGA_KEY_LEFT, u"Izquierda"_ustr }, + { PAPUGA_KEY_RIGHT, u"Derecha"_ustr }, + { PAPUGA_KEY_END, u"Fin"_ustr }, + { PAPUGA_KEY_DOWN, u"Abajo"_ustr }, + { PAPUGA_KEY_PAGEDOWN, u"Av Pág"_ustr }, + { PAPUGA_KEY_INSERT, u"Ins"_ustr }, + { PAPUGA_KEY_DELETE, u"Supr"_ustr }, + { PAPUGA_KEY_SHIFT, u"Mayús"_ustr }, }; - const struct KeysNameReplacement aImplReplacements_Hungarian[] = + constexpr KeysNameReplacement aImplReplacements_Hungarian[] = { - { PAPUGA_KEY_RIGHT, "Jobbra" }, - { PAPUGA_KEY_LEFT, "Balra" }, - { PAPUGA_KEY_UP, "Fel" }, - { PAPUGA_KEY_DOWN, "Le" }, - { PAPUGA_KEY_ENTER, "Enter" }, - { PAPUGA_KEY_SPACEBAR, "Sz\xc3\xb3" "k\xc3\xb6" "z" }, + { PAPUGA_KEY_RIGHT, u"Jobbra"_ustr }, + { PAPUGA_KEY_LEFT, u"Balra"_ustr }, + { PAPUGA_KEY_UP, u"Fel"_ustr }, + { PAPUGA_KEY_DOWN, u"Le"_ustr }, + { PAPUGA_KEY_ENTER, u"Enter"_ustr }, + { PAPUGA_KEY_SPACEBAR, u"Szóköz"_ustr }, }; - const struct KeyboardReplacements aKeyboards[] = + constexpr KeyboardReplacements aKeyboards[] = { - { "ast",aImplReplacements_Asturian, std::size(aImplReplacements_Asturian) }, - { "ca", aImplReplacements_Catalan, std::size(aImplReplacements_Catalan) }, - { "et", aImplReplacements_Estonian, std::size(aImplReplacements_Estonian) }, - { "hu", aImplReplacements_Hungarian, std::size(aImplReplacements_Hungarian) }, - { "lt", aImplReplacements_Lithuanian, std::size(aImplReplacements_Lithuanian) }, - { "sl", aImplReplacements_Slovenian, std::size(aImplReplacements_Slovenian) }, - { "es", aImplReplacements_Spanish, std::size(aImplReplacements_Spanish) }, + { u"ast", aImplReplacements_Asturian }, + { u"ca", aImplReplacements_Catalan }, + { u"et", aImplReplacements_Estonian }, + { u"hu", aImplReplacements_Hungarian }, + { u"lt", aImplReplacements_Lithuanian }, + { u"sl", aImplReplacements_Slovenian }, + { u"es", aImplReplacements_Spanish }, }; // translate keycodes, used within the displayed menu shortcuts - OUString getKeysReplacementName( std::u16string_view pLang, LONG nSymbol ) + OUString getKeysReplacementName(std::u16string_view pLang, UINT nSymbol) { for( const auto& rKeyboard : aKeyboards ) { - if( o3tl::equalsAscii( pLang, rKeyboard.pLangName ) ) + if (pLang == rKeyboard.pLangName) { - const struct KeysNameReplacement* pRepl = rKeyboard.pReplacements; - for( int m = rKeyboard.nReplacements ; m ; ) + for (const auto& rRepl : rKeyboard.pReplacements) { - if( nSymbol == pRepl[--m].aSymbol ) - return OUString( pRepl[m].pName, strlen(pRepl[m].pName), RTL_TEXTENCODING_UTF8 ); + if (nSymbol == rRepl.aSymbol) + return rRepl.pName; } } } diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 5528807bee6a..c49bebe57c51 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -2193,7 +2193,7 @@ void WinSalFrame::EndExtTextInput( EndExtTextInputFlags nFlags ) SendMessageW( mhWnd, SAL_MSG_ENDEXTTEXTINPUT, static_cast<WPARAM>(nFlags), 0 ); } -static void ImplGetKeyNameText( LONG lParam, sal_Unicode* pBuf, +static void ImplGetKeyNameText( UINT lParam, sal_Unicode* pBuf, UINT& rCount, UINT nMaxSize, const char* pReplace ) {