sw/qa/core/txtnode/txtnode.cxx                |   23 ++++++++++++++++++++++-
 sw/source/core/txtnode/attrcontentcontrol.cxx |    2 +-
 2 files changed, 23 insertions(+), 2 deletions(-)

New commits:
commit feae19389a2bd6ffe8cb7f2a1a34da4c6efb828b
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Jul 19 08:28:21 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jul 19 15:34:02 2022 +0200

    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.
    
    (cherry picked from commit 40405372fe0bbc00e67f5b0185b0d4c2d6c1e08d)
    
    Change-Id: Ic36419f69cbcdba1a9069332184966cb4b347c49
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137229
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

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 c917de926296..e348432ba7b6 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;

Reply via email to