From eef4d5cbd10a042bd3b5fb555e0bf9b0dd7d1215 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Mon, 18 Dec 2023 09:10:36 +0100 Subject: tdf#123864 a11y: Handle new checkable state for VCLXAccessibleMenuItem Add reporting for the new CHECKABLE a11y state introduced in commit d6c6472bbe1c90b733a4d69c4c8528f4de3750d3 Author: Michael Weghorn 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 --- accessibility/inc/standard/vclxaccessiblemenuitem.hxx | 1 + accessibility/source/standard/vclxaccessiblemenuitem.cxx | 10 ++++++++++ 2 files changed, 11 insertions(+) (limited to 'accessibility') 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; } -- cgit