accessibility/source/standard/vclxaccessibletoolboxitem.cxx |   37 ++++++++----
 include/vcl/toolbox.hxx                                     |    3 
 vcl/source/window/toolbox.cxx                               |   22 +++++++
 3 files changed, 50 insertions(+), 12 deletions(-)

New commits:
commit 3c30273d72e1cb6ff6cc1d9afd464ab927e16459
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Sat Jul 13 07:21:17 2024 -0400
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Thu Jul 25 16:19:41 2024 +0200

    tdf#67919 access toolbar button dropdown menu from macOS VoiceOver
    
    The fix was copied from the following NeoOffice source code files which
    are licensed under the Mozilla Public License, v. 2.0:
    
    
https://github.com/neooffice/NeoOffice/blob/NeoOffice-2022_7/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
    
https://github.com/neooffice/NeoOffice/blob/NeoOffice-2022_7/include/vcl/toolbox.hxx
    
https://github.com/neooffice/NeoOffice/blob/NeoOffice-2022_7/vcl/source/window/toolbox.cxx
    
    Change-Id: Ibd24c6df4ecd7fdac1c56763d1daec09936a9b31
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170426
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx 
b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
index 8c95e25bace6..bb6796ba4d76 100644
--- a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
+++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
@@ -632,19 +632,27 @@ OUString SAL_CALL 
VCLXAccessibleToolBoxItem::getToolTipText(  )
 
 sal_Int32 VCLXAccessibleToolBoxItem::getAccessibleActionCount( )
 {
-    // only one action -> "Click"
-    return 1;
+    // "Click" and maybe "Toggle Popup"
+    return ( m_pToolBox && m_pToolBox->ItemHasDropdown( m_nItemId ) ? 2 : 1 );
 }
 
 sal_Bool VCLXAccessibleToolBoxItem::doAccessibleAction ( sal_Int32 nIndex )
 {
     OExternalLockGuard aGuard( this );
 
-    if ( nIndex != 0 )
-        throw IndexOutOfBoundsException();
-
-    if ( m_pToolBox )
-        m_pToolBox->TriggerItem( m_nItemId );
+    switch ( nIndex )
+    {
+        case 0:
+            if ( m_pToolBox )
+                m_pToolBox->TriggerItem( m_nItemId );
+            break;
+        case 1:
+            if ( m_pToolBox && m_pToolBox->ItemHasDropdown( m_nItemId ) )
+                m_pToolBox->TriggerItemDropdown( m_nItemId );
+            break;
+        default:
+            throw IndexOutOfBoundsException();
+    }
 
     return true;
 }
@@ -653,17 +661,22 @@ OUString 
VCLXAccessibleToolBoxItem::getAccessibleActionDescription ( sal_Int32 n
 {
     OExternalLockGuard aGuard( this );
 
-    if ( nIndex != 0 )
-        throw IndexOutOfBoundsException();
-
-    return RID_STR_ACC_ACTION_CLICK;
+    switch ( nIndex )
+    {
+        case 0:
+            return RID_STR_ACC_ACTION_CLICK;
+        case 1:
+            return RID_STR_ACC_ACTION_TOGGLEPOPUP;
+        default:
+            throw IndexOutOfBoundsException();
+    }
 }
 
 Reference< XAccessibleKeyBinding > 
VCLXAccessibleToolBoxItem::getAccessibleActionKeyBinding( sal_Int32 nIndex )
 {
     OContextEntryGuard aGuard( this );
 
-    if ( nIndex != 0 )
+    if (nIndex < 0 || nIndex >= getAccessibleActionCount())
         throw IndexOutOfBoundsException();
 
     return Reference< XAccessibleKeyBinding >();
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index e6bc704f3326..b4b7922ac6a1 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -389,6 +389,9 @@ public:
 
     void                TriggerItem( ToolBoxItemId nItemId );
 
+    bool                ItemHasDropdown( ToolBoxItemId nItemId );
+    void                TriggerItemDropdown( ToolBoxItemId nItemId );
+
     /// Shows or hides items.
     void                ShowItem(ToolBoxItemId nItemId, bool bVisible = true);
 
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 7a4195560f51..a91a9af2a1a7 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -4153,6 +4153,28 @@ void ToolBox::TriggerItem( ToolBoxItemId nItemId )
     ImplActivateItem( aKeyCode );
 }
 
+bool ToolBox::ItemHasDropdown( ToolBoxItemId nItemId )
+{
+    ImplToolItem* pItem = ImplGetItem( nItemId );
+    return pItem && pItem->mnBits & ToolBoxItemBits::DROPDOWN;
+}
+
+void ToolBox::TriggerItemDropdown( ToolBoxItemId nItemId )
+{
+    if( mpFloatWin || !ItemHasDropdown( nItemId ) )
+        return;
+
+    // Prevent highlighting of triggered item
+    mnHighItemId = ToolBoxItemId(0);
+
+    mnDownItemId = mnCurItemId = nItemId;
+    mnCurPos = GetItemPos( mnCurItemId );
+    mnMouseModifier = 0;
+
+    mpData->mbDropDownByKeyboard = false;
+    mpData->maDropdownClickHdl.Call( this );
+}
+
 // calls the button's action handler
 // returns true if action was called
 bool ToolBox::ImplActivateItem( vcl::KeyCode aKeyCode )

Reply via email to