accessibility/inc/standard/vclxaccessiblemenuitem.hxx    |    1 +
 accessibility/source/standard/vclxaccessiblemenuitem.cxx |   10 ++++++++++
 framework/source/uielement/toolbarmanager.cxx            |   10 +++++-----
 include/vcl/menu.hxx                                     |    1 +
 vcl/source/window/menu.cxx                               |   11 +++++++++++
 5 files changed, 28 insertions(+), 5 deletions(-)

New commits:
commit b88198c183dfb10c97409e83ea5ad7793811e7fb
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Dec 18 09:30:02 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Dec 20 17:10:00 2023 +0100

    tdf#123864 a11y: Evaluate checkable/toggle flag for more toolbar items
    
        commit 4342408a8359e590f57b016baaf7d8dcfdebdbd4
        Author: Carsten Driesner <c...@openoffice.org>
        Date:   Thu May 6 18:15:21 2010 +0200
    
            fwk142: #i104293 Use Commands.xcu files to mark commands which 
support a toggle state
    
    introduced a `UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON` state
    to mark commands that can be toggled, see `framework/inc/properties.h`.
    
    Despite that one being set for the `.uno:Underline` command in
    `officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu`,
    the underline button in Writer's formatting toolbar would not expose
    the CHECKABLE a11y state even after
    
        commit 78241a40628e5721aa50cb0fa13a63333343f766
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Mon Dec 18 08:48:12 2023 +0100
    
            tdf#123864 a11y: Handle new CHECKABLE state in misc places
    
    because the state set in the .xcu file was only applied
    in `ToolBarManager::CreateControllers` in the code path where
    no controller is set.
    
    There seems to be no particular reason for that, so move this
    out of that block so this gets run for other items, too.
    
    With this in place, the underline button in Writer's formatting
    toolbar now has the checkable AT-SPI state when using the gtk3
    VCL plugin.
    
    (Orca still doesn't announce the button as checked when it is,
    despite the checked state also being set then, but that's another
    aspect that will be addressed in a separate commit.)
    
    Change-Id: Ib9200077a95feea3ce7c0380b9b8f31c96632223
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160903
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161038

diff --git a/framework/source/uielement/toolbarmanager.cxx 
b/framework/source/uielement/toolbarmanager.cxx
index 51855edd6402..cde8b89f41bb 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -1121,15 +1121,15 @@ void ToolBarManager::CreateControllers()
                         xController.set( new GenericToolbarController( 
m_xContext, m_xFrame, m_pToolBar, nId, aCommandURL ));
                     else
                         xController.set( new GenericToolbarController( 
m_xContext, m_xFrame, *m_pWeldedToolBar, aCommandURL ));
-
-                    // Accessibility support: Set toggle button role for 
specific commands
-                    sal_Int32 nProps = 
vcl::CommandInfoProvider::GetPropertiesForCommand(aCommandURL, 
m_aModuleIdentifier);
-                    if ( nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 
)
-                        m_pImpl->SetItemCheckable( nId );
                 }
             }
         }
 
+        // Accessibility support: Set toggle button role for specific commands
+        const sal_Int32 nProps = 
vcl::CommandInfoProvider::GetPropertiesForCommand(aCommandURL, 
m_aModuleIdentifier);
+        if (nProps & UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON)
+            m_pImpl->SetItemCheckable(nId);
+
         // Associate ID and controller to be able to retrieve
         // the controller from the ID later.
         m_aControllerMap[ nId ] = xController;
commit 2bd0e347f15c50f354386b775d681243a5dd52a8
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Dec 18 09:10:36 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Dec 20 17:09:52 2023 +0100

    tdf#123864 a11y: Handle new checkable state for VCLXAccessibleMenuItem
    
    Add reporting for the new CHECKABLE a11y state introduced in
    
        commit d6c6472bbe1c90b733a4d69c4c8528f4de3750d3
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Mon Nov 13 15:53:44 2023 +0100
    
            tdf#123864 a11y: Add new AccessibleStateType::CHECKABLE
    
    for `VCLXAccessibleMenuItem`.
    
    `MenuItemData::HasCheck` looks like it already provides
    what's needed to say whether an item is checkable, therefore
    add a `Menu::IsItemCheckable` that makes use of this and
    and a `VCLXAccessibleMenuItem::IsCheckable` that
    makes use of that in turn.
    
    Extend `VCLXAccessibleMenuItem::FillAccessibleStateSet` to
    use the latter to report the CHECKABLE state accordingly.
    
    Change-Id: Id23196ef2527a71a338102a5143a8bd6fd41db84
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160902
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161037

diff --git a/accessibility/inc/standard/vclxaccessiblemenuitem.hxx 
b/accessibility/inc/standard/vclxaccessiblemenuitem.hxx
index ddc50a8f3577..4eec5fa6746e 100644
--- a/accessibility/inc/standard/vclxaccessiblemenuitem.hxx
+++ b/accessibility/inc/standard/vclxaccessiblemenuitem.hxx
@@ -41,6 +41,7 @@ class VCLXAccessibleMenuItem :  public 
cppu::ImplInheritanceHelper<
 protected:
     virtual bool            IsFocused() override;
     virtual bool            IsSelected() override;
+    virtual bool            IsCheckable();
     virtual bool            IsChecked() override;
 
     virtual bool            IsHighlighted() override;
diff --git a/accessibility/source/standard/vclxaccessiblemenuitem.cxx 
b/accessibility/source/standard/vclxaccessiblemenuitem.cxx
index 2c4e8043c00b..03bdc88c93c5 100644
--- a/accessibility/source/standard/vclxaccessiblemenuitem.cxx
+++ b/accessibility/source/standard/vclxaccessiblemenuitem.cxx
@@ -66,6 +66,14 @@ bool VCLXAccessibleMenuItem::IsSelected()
     return IsHighlighted();
 }
 
+bool VCLXAccessibleMenuItem::IsCheckable()
+{
+    if (!m_pParent)
+        return false;
+
+    const sal_uInt16 nItemId = m_pParent->GetItemId(m_nItemPos);
+    return m_pParent->IsItemCheckable(nItemId);
+}
 
 bool VCLXAccessibleMenuItem::IsChecked()
 {
@@ -107,6 +115,8 @@ void VCLXAccessibleMenuItem::FillAccessibleStateSet( 
sal_Int64& rStateSet )
     if ( IsSelected() )
         rStateSet |= AccessibleStateType::SELECTED;
 
+    if (IsCheckable())
+        rStateSet |= AccessibleStateType::CHECKABLE;
     if ( IsChecked() )
         rStateSet |= AccessibleStateType::CHECKED;
 }
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 2442eef9202f..a28182e51fe2 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -275,6 +275,7 @@ public:
 
     void CheckItem( sal_uInt16 nItemId, bool bCheck = true );
     void CheckItem( std::u16string_view rIdent, bool bCheck = true );
+    bool IsItemCheckable(sal_uInt16 nItemId) const;
     bool IsItemChecked( sal_uInt16 nItemId ) const;
 
     virtual void SelectItem(sal_uInt16 nItemId) = 0;
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 3a66b962ebd6..82d630742ab5 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -907,6 +907,17 @@ void Menu::CheckItem( std::u16string_view rIdent , bool 
bCheck )
     CheckItem( GetItemId( rIdent ), bCheck );
 }
 
+bool Menu::IsItemCheckable(sal_uInt16 nItemId) const
+{
+    size_t nPos;
+    MenuItemData* pData = pItemList->GetData(nItemId, nPos);
+
+    if (!pData)
+        return false;
+
+    return pData->HasCheck();
+}
+
 bool Menu::IsItemChecked( sal_uInt16 nItemId ) const
 {
     size_t          nPos;

Reply via email to