framework/JunitTest_framework_complex.mk | 2 vcl/headless/svpframe.cxx | 70 ++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 3 deletions(-)
New commits: commit b55a3b23b9c33c1875c5a47c5798ada44dd25052 Author: Neil Roberts <[email protected]> AuthorDate: Fri Sep 19 22:07:15 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sun Sep 21 13:09:48 2025 +0200 Enable the AcceleratorsConfiguration JUnitTest The test now runs successfully and it has some useful tests. Change-Id: If0653ee16ef18ad3c69ec4f710b5b95ca95bb32d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191220 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/framework/JunitTest_framework_complex.mk b/framework/JunitTest_framework_complex.mk index a582235b8d41..d5cb35394c8a 100644 --- a/framework/JunitTest_framework_complex.mk +++ b/framework/JunitTest_framework_complex.mk @@ -62,11 +62,11 @@ $(eval $(call gb_JunitTest_add_sourcefiles,framework_complex,\ $(eval $(call gb_JunitTest_add_classes,framework_complex,\ complex.dispatches.checkdispatchapi \ + complex.accelerators.AcceleratorsConfigurationTest \ )) # these were disabled in the old build system too, please check # carefully before reenabling # complex.ModuleManager.CheckXModuleManager \ - complex.accelerators.AcceleratorsConfigurationTest \ complex.api_internal.CheckAPI \ complex.broken_document.LoadDocument \ complex.desktop.DesktopTerminate \ commit beafc69eaca9324f669555679fe9569a0e77f4d6 Author: Neil Roberts <[email protected]> AuthorDate: Fri Sep 19 22:03:19 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sun Sep 21 13:09:35 2025 +0200 headless/svpframe: Add a dummy implementation of GetKeyName This is inspired by the MacOS implementation of GetKeyName where all the key names are hardcoded in the function. The main reason to do this is that if GetKeyName returns an empty string then getPreferredKeyEventsForCommandList on XCUBasedAcceleratorConfiguration will refuse to return any keys. This makes testing the accelerator configurations a bit difficult when running headless. Change-Id: I3677192fe47932c9ad7f0c571315c8fdc0c5d069 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191219 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx index 00672935d256..555e15ea31b3 100644 --- a/vcl/headless/svpframe.cxx +++ b/vcl/headless/svpframe.cxx @@ -387,9 +387,75 @@ void SvpSalFrame::EndExtTextInput( EndExtTextInputFlags ) { } -OUString SvpSalFrame::GetKeyName( sal_uInt16 ) +OUString SvpSalFrame::GetKeyName(sal_uInt16 nKeyCode) { - return OUString(); + // Skip key combinations with any modifiers that we don’t support + if ((nKeyCode & KEY_MODIFIERS_MASK & ~(KEY_SHIFT | KEY_MOD1 | KEY_MOD2)) != 0) + return OUString(); + + OUStringBuffer aResult; + + if ((nKeyCode & KEY_MOD1) != 0) + aResult.append("Ctrl+"); + if ((nKeyCode & KEY_MOD2) != 0) + aResult.append("Alt+"); + if ((nKeyCode & KEY_SHIFT) != 0) + aResult.append("Shift+"); + + static const struct + { + sal_uInt16 code; + const char* name; + } keyMap[] = { + { KEY_DOWN, "Down" }, + { KEY_UP, "Up" }, + { KEY_LEFT, "Left" }, + { KEY_RIGHT, "Right" }, + { KEY_HOME, "Home" }, + { KEY_END, "End" }, + { KEY_PAGEUP, "PgUp" }, + { KEY_PAGEDOWN, "PgDown" }, + { KEY_RETURN, "Ret" }, + { KEY_ESCAPE, "Esc" }, + { KEY_TAB, "Tab" }, + { KEY_BACKSPACE, "BkSpace" }, + { KEY_SPACE, "Space" }, + { KEY_DELETE, "Del" }, + { KEY_ADD, "+" }, + { KEY_SUBTRACT, "-" }, + { KEY_DIVIDE, "/" }, + { KEY_MULTIPLY, "*" }, + { KEY_POINT, "." }, + { KEY_COMMA, "," }, + { KEY_LESS, "<" }, + { KEY_GREATER, ">" }, + { KEY_EQUAL, "=" }, + { KEY_TILDE, "~" }, + { KEY_BRACKETLEFT, "[" }, + { KEY_BRACKETRIGHT, "]" }, + { KEY_SEMICOLON, ";" }, + { KEY_QUOTERIGHT, "'" }, + { KEY_RIGHTCURLYBRACKET, "}" }, + { KEY_NUMBERSIGN, "#" }, + { KEY_COLON, ":" }, + }; + + sal_uInt16 nUnmodifiedCode = (nKeyCode & KEY_CODE_MASK); + + if (nUnmodifiedCode >= KEY_A && nUnmodifiedCode <= KEY_Z) + aResult.append(char('A' + nUnmodifiedCode - KEY_A)); + else if (nUnmodifiedCode >= KEY_F1 && nUnmodifiedCode <= KEY_F26) + aResult.append(OUStringChar('F') + OUString::number(nUnmodifiedCode - KEY_F1 + 1)); + else if (nUnmodifiedCode >= KEY_0 && nUnmodifiedCode <= KEY_9) + aResult.append(char('0' + nUnmodifiedCode - KEY_0)); + else if (auto it = std::find_if(keyMap, keyMap + std::size(keyMap), + [=](const auto& p) { return p.code == nUnmodifiedCode; }); + it != keyMap + std::size(keyMap)) + aResult.appendAscii(it->name); + else + return OUString(); + + return aResult.makeStringAndClear(); } bool SvpSalFrame::MapUnicodeToKeyCode( sal_Unicode, LanguageType, vcl::KeyCode& )
