diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-08-21 09:49:51 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-08-21 18:49:32 +0200 |
commit | 525ba5e4d7936dbf4209354dd5a143af93270b95 (patch) | |
tree | 9e023f483b9430a2a6dfdaaef71cd668f95b0b2b /winaccessibility | |
parent | 0c7a5e6f419a679afef35cb8b3f203eae9e6231c (diff) |
wina11y: Unify handling to set action description
Drop `AccObject::UpdateDefaultAction` and let
`AccObject::UpdateActionDesc` take care of
setting the action description for all roles.
It's unclear to me
* why the action description would only be set
for particular roles
* why `AccObject::UpdateActionDesc` would call
`AccObject::UpdateDefaultAction` for particular
roles if it was basically setting the description
the same way that `AccObject::UpdateActionDesc`
does directly for other roles (except for
`AccObject::UpdateDefaultAction` not checking
that there's at least one action).
Also simplify the code a bit while at it.
Testing with the "Don't Save" button in the "Save Document?"
dialog seen when pressing Alt+F4 with a modified Writer doc
gives the expected result in NVDA's Python console:
>>> focus.role
<Role.BUTTON: 9>
>>> focus.name
'Don’t Save'
>>> focus.IAccessibleActionObject.nActions()
1
>>> focus.IAccessibleActionObject.description(0)
'press'
If any particular reason for not setting the action description
for particular roles should show up in the future, they can
still be excluded in one central place now.
Change-Id: I5569f70739135172ddb604f1f1bd958e32626ab0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172182
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'winaccessibility')
-rw-r--r-- | winaccessibility/inc/AccObject.hxx | 3 | ||||
-rw-r--r-- | winaccessibility/source/service/AccObject.cxx | 61 | ||||
-rw-r--r-- | winaccessibility/source/service/AccObjectWinManager.cxx | 2 |
3 files changed, 9 insertions, 57 deletions
diff --git a/winaccessibility/inc/AccObject.hxx b/winaccessibility/inc/AccObject.hxx index 46fc12aa65e1..1d922a8e2889 100644 --- a/winaccessibility/inc/AccObject.hxx +++ b/winaccessibility/inc/AccObject.hxx @@ -59,7 +59,6 @@ private: css::uno::Reference < css::accessibility::XAccessibleAction > m_xAccActionRef; css::uno::Reference < css::accessibility::XAccessibleContext > m_xAccContextRef; - void UpdateActionDesc(); void UpdateRole(); DWORD GetMSAAStateFromUNO(sal_Int64 xState);//translate state from UNO to MSAA value @@ -74,7 +73,7 @@ public: virtual ~AccObject(); bool UpdateAccessibleInfoFromUnoToMSAA( ); //implement accessible information mapping - void UpdateDefaultAction(); + void UpdateActionDesc(); IMAccessible* GetIMAccessible(); //return COM interface in acc object css::uno::Reference<css::accessibility::XAccessible> const& GetXAccessible(); diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx index bd06d941c37f..1effc0650992 100644 --- a/winaccessibility/source/service/AccObject.cxx +++ b/winaccessibility/source/service/AccObject.cxx @@ -357,7 +357,7 @@ void AccObject::UpdateAction() { if( m_xAccActionRef->getAccessibleActionCount() > 0 ) { - UpdateDefaultAction( ); + UpdateActionDesc(); m_pIMAcc->SetDefaultAction( reinterpret_cast<hyper>(m_xAccActionRef.get())); } @@ -388,33 +388,6 @@ void AccObject::UpdateValue() } /** - * Set special default action description string via UNO role. - * @param Role UNO role - * @return - */ -void AccObject::UpdateDefaultAction( ) -{ - if(!m_xAccActionRef.is()) - return ; - - switch(m_accRole) - { - case PUSH_BUTTON: - case TOGGLE_BUTTON: - case RADIO_BUTTON: - case MENU_ITEM: - case RADIO_MENU_ITEM: - case CHECK_MENU_ITEM: - case LIST_ITEM: - case CHECK_BOX: - case TREE_ITEM: - case BUTTON_DROPDOWN: - m_pIMAcc->Put_ActionDescription( o3tl::toW(m_xAccActionRef->getAccessibleActionDescription(sal_Int32(0)).getStr()) ); - return; - } -} - -/** * Set value property via pAny. * @param pAny New value. * @return @@ -732,6 +705,7 @@ AccObject* AccObject::NextChild() return *pInd; return nullptr; } + /** * update action description desc * @param @@ -742,34 +716,13 @@ void AccObject::UpdateActionDesc() if (!m_pIMAcc) return; - long Role = m_accRole; - - if( Role == PUSH_BUTTON || Role == RADIO_BUTTON || Role == MENU_ITEM || - Role == LIST_ITEM || Role == CHECK_BOX || Role == TREE_ITEM || - Role == CHECK_MENU_ITEM || Role == RADIO_MENU_ITEM ) - { - UpdateDefaultAction( ); - } - else - { - - if( m_xAccActionRef.is() ) - { - if( m_xAccActionRef->getAccessibleActionCount() > 0 ) - { - if (!(Role == SPIN_BOX || Role == COMBO_BOX || Role == DATE_EDITOR || - Role == EDIT_BAR || Role == PASSWORD_TEXT || Role == TEXT)) - { - const OUString sActionDesc = m_xAccActionRef->getAccessibleActionDescription(0); - // if string is non-empty, action is set. - if (!sActionDesc.isEmpty()) - m_pIMAcc->Put_ActionDescription(o3tl::toW(sActionDesc.getStr())); - } - } - } - } + if (!m_xAccActionRef.is() || m_xAccActionRef->getAccessibleActionCount() <= 0) + return; + const OUString sActionDesc = m_xAccActionRef->getAccessibleActionDescription(0); + m_pIMAcc->Put_ActionDescription(o3tl::toW(sActionDesc.getStr())); } + /** * update role information from uno to com * @param diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx index bf3c63825903..cc72fc502f1f 100644 --- a/winaccessibility/source/service/AccObjectWinManager.cxx +++ b/winaccessibility/source/service/AccObjectWinManager.cxx @@ -176,7 +176,7 @@ bool AccObjectWinManager::NotifyAccEvent(XAccessible* pXAcc, UnoMSAAEvent eEvent case UnoMSAAEvent::STATE_FOCUSED: { UpdateAccFocus(pXAcc); - selfAccObj->UpdateDefaultAction( ); + selfAccObj->UpdateActionDesc(); UpdateValue(pXAcc); NotifyWinEvent( EVENT_OBJECT_FOCUS,hAcc, OBJID_CLIENT,dChildID ); break; |