summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-07-19 08:28:21 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-07-19 09:23:57 +0200
commit40405372fe0bbc00e67f5b0185b0d4c2d6c1e08d (patch)
tree6f9016a56c7ad6865111baa0c7fa30ce1300fee3
parentda9ef0bd92e7ad81d0595d57225ef5b20ea8f66c (diff)
sw content control, date: allow selecting via the keyboard
It was not possible to select the date of a date content control via keyboard. This meant only the mouse handling codepath needed implementing, but it broke accessibility. SwContentControl::ShouldOpenPopup() already knows how to handle dropdowns via the keyboard, extend that to handle date pickers as well. The appearing vcl Calendar / GtkCalendar appears to support keyboard navigation already. Change-Id: Ic36419f69cbcdba1a9069332184966cb4b347c49 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137213 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/qa/core/txtnode/txtnode.cxx23
-rw-r--r--sw/source/core/txtnode/attrcontentcontrol.cxx2
2 files changed, 23 insertions, 2 deletions
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
index 15d2188a8cb6..bd9bcd66d6fc 100644
--- a/sw/qa/core/txtnode/txtnode.cxx
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -270,7 +270,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testDropdownContentControlKeyboard)
CPPUNIT_ASSERT(bShouldOpen);
}
-CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testPicutreContentControlKeyboard)
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testPictureContentControlKeyboard)
{
// Given an already selected picture content control:
SwDoc* pDoc = createSwDoc();
@@ -297,6 +297,27 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testPicutreContentControlKeyboard)
CPPUNIT_ASSERT(bIsInteracting);
}
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testDateContentControlKeyboard)
+{
+ // Given an already selected date content control:
+ SwDoc* pDoc = createSwDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->InsertContentControl(SwContentControlType::DATE);
+
+ // When checking if alt-down should open a popup:
+ SwTextContentControl* pTextContentControl = pWrtShell->CursorInsideContentControl();
+ auto& rFormatContentControl
+ = static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr());
+ std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
+ vcl::KeyCode aKeyCode(KEY_DOWN, KEY_MOD2);
+ bool bShouldOpen = pContentControl->ShouldOpenPopup(aKeyCode);
+
+ // Then make sure that the answer is yes for date:
+ // Without the accompanying fix in place, this test would have failed, the date popup was
+ // mouse-only.
+ CPPUNIT_ASSERT(bShouldOpen);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx
index 8c8b19348006..fb2176024707 100644
--- a/sw/source/core/txtnode/attrcontentcontrol.cxx
+++ b/sw/source/core/txtnode/attrcontentcontrol.cxx
@@ -319,7 +319,7 @@ bool SwContentControl::IsInteractingCharacter(sal_Unicode cCh)
bool SwContentControl::ShouldOpenPopup(const vcl::KeyCode& rKeyCode)
{
- if (HasListItems())
+ if (HasListItems() || GetDate())
{
// Alt-down opens the popup.
return rKeyCode.IsMod2() && rKeyCode.GetCode() == KEY_DOWN;