summaryrefslogtreecommitdiff
path: root/winaccessibility
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-04-16 19:02:30 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-04-17 08:07:17 +0200
commit0425b6eb47830b1fe630dc0128d5049f4b3e5582 (patch)
tree980ebd696562177070e139149b1d8e0d15e72e4a /winaccessibility
parentd304fdb3369235ff4916463687b5e625c7fa3650 (diff)
tdf#160695 wina11y: Send status change events for toolbar buttons
When the checked or indeterminate state of a toolbar button changes, forward the corresponding UNO a11y event as a corresponding MSAA event. For roles `AccessibleRole::PUSH_BUTTON` and `AccessibleRole::TOGGLE_BUTTON`, `AccObject::GetMSAAStateFromUNO` uses `STATE_SYSTEM_PRESSED` instead of `STATE_SYSTEM_CHECKED`, so also use `UnoMSAAEvent::STATE_PRESSED` for the event. It's unclear why sending of such events would generally be omitted for "special toolbar items" previously. The events can be used to implement announcement of toggled font attributes in NVDA, e.g. when the "Bold" button in the formatting toolbar is toggled via a keyboard shortcut, similar to how Orca does it (s. tdf#123864). Related NVDA issue for which I plan to submit a PR: [1] [1] https://github.com/nvaccess/nvda/issues/4248 Change-Id: Ic2846e338802c3cb7656de5b77e4df23bd5b0703 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166155 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'winaccessibility')
-rw-r--r--winaccessibility/inc/AccObjectWinManager.hxx2
-rw-r--r--winaccessibility/source/service/AccComponentEventListener.cxx27
-rw-r--r--winaccessibility/source/service/AccObjectWinManager.cxx20
3 files changed, 19 insertions, 30 deletions
diff --git a/winaccessibility/inc/AccObjectWinManager.hxx b/winaccessibility/inc/AccObjectWinManager.hxx
index 024a58fc8655..8e50adaf75c4 100644
--- a/winaccessibility/inc/AccObjectWinManager.hxx
+++ b/winaccessibility/inc/AccObjectWinManager.hxx
@@ -132,8 +132,6 @@ public:
void UpdateChildState(css::accessibility::XAccessible* pXAcc);
- bool IsSpecialToolbarItem(css::accessibility::XAccessible* pXAcc);
-
static short GetRole(css::accessibility::XAccessible* pXAcc);
css::accessibility::XAccessible* GetAccDocByAccTopWin( css::accessibility::XAccessible* pXAcc );
diff --git a/winaccessibility/source/service/AccComponentEventListener.cxx b/winaccessibility/source/service/AccComponentEventListener.cxx
index bc6475754097..a55b585544d2 100644
--- a/winaccessibility/source/service/AccComponentEventListener.cxx
+++ b/winaccessibility/source/service/AccComponentEventListener.cxx
@@ -207,6 +207,19 @@ void AccComponentEventListener::SetComponentState(sal_Int64 state, bool enable)
*/
void AccComponentEventListener::FireStatePropertyChange(sal_Int64 state, bool set)
{
+ if (!m_xAccessible.is())
+ return;
+
+ css::uno::Reference<css::accessibility::XAccessibleContext> xAccContext = m_xAccessible->getAccessibleContext();
+ if (!xAccContext.is())
+ return;
+
+ const sal_Int16 nRole = xAccContext->getAccessibleRole();
+ // for these button roles, MSAA state STATE_SYSTEM_PRESSED is used instead of
+ // STATE_SYSTEM_CHECKED (s. AccObject::GetMSAAStateFromUNO)
+ const bool bPressedInsteadOfChecked
+ = (nRole == AccessibleRole::PUSH_BUTTON) || (nRole == AccessibleRole::TOGGLE_BUTTON);
+
if( set)
{
// new value
@@ -216,11 +229,10 @@ void AccComponentEventListener::FireStatePropertyChange(sal_Int64 state, bool se
case AccessibleStateType::INDETERMINATE:
m_rObjManager.IncreaseState(m_xAccessible.get(), state);
m_rObjManager.UpdateAction(m_xAccessible.get());
-
- if (!m_rObjManager.IsSpecialToolbarItem(m_xAccessible.get()))
- {
+ if (bPressedInsteadOfChecked)
+ m_rObjManager.NotifyAccEvent(m_xAccessible.get(), UnoMSAAEvent::STATE_PRESSED);
+ else
m_rObjManager.NotifyAccEvent(m_xAccessible.get(), UnoMSAAEvent::STATE_CHECKED);
- }
break;
case AccessibleStateType::PRESSED:
m_rObjManager.IncreaseState(m_xAccessible.get(), state);
@@ -256,11 +268,10 @@ void AccComponentEventListener::FireStatePropertyChange(sal_Int64 state, bool se
case AccessibleStateType::INDETERMINATE:
m_rObjManager.DecreaseState(m_xAccessible.get(), state);
m_rObjManager.UpdateAction(m_xAccessible.get());
-
- if (!m_rObjManager.IsSpecialToolbarItem(m_xAccessible.get()))
- {
+ if (bPressedInsteadOfChecked)
+ m_rObjManager.NotifyAccEvent(m_xAccessible.get(), UnoMSAAEvent::STATE_PRESSED);
+ else
m_rObjManager.NotifyAccEvent(m_xAccessible.get(), UnoMSAAEvent::STATE_CHECKED);
- }
break;
case AccessibleStateType::PRESSED:
m_rObjManager.DecreaseState(m_xAccessible.get(), state);
diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx
index 6025a469aa18..2afb59d776db 100644
--- a/winaccessibility/source/service/AccObjectWinManager.cxx
+++ b/winaccessibility/source/service/AccObjectWinManager.cxx
@@ -1062,26 +1062,6 @@ void AccObjectWinManager::UpdateChildState(css::accessibility::XAccessible* pAcc
}
}
-
-bool AccObjectWinManager::IsSpecialToolbarItem(css::accessibility::XAccessible* pXAcc)
-{
- if (pXAcc && oldFocus != pXAcc)
- {
- if (GetParentRole(pXAcc) == AccessibleRole::TOOL_BAR)
- {
- Reference< XAccessibleContext > pRContext(pXAcc->getAccessibleContext());
- if (pRContext.is())
- {
- if (pRContext->getAccessibleRole() == AccessibleRole::TOGGLE_BUTTON)
- {
- return true;
- }
- }
- }
- }
- return false;
-}
-
short AccObjectWinManager::GetRole(css::accessibility::XAccessible* pXAcc)
{
assert(pXAcc != nullptr);