vcl/unx/gtk4/a11y.cxx | 21 ++++++--------------- winaccessibility/source/UAccCOM/MAccessible.cxx | 21 +++++++++------------ 2 files changed, 15 insertions(+), 27 deletions(-)
New commits: commit 42f839a5371ffc25e7181606b53d339ba0c8c9ee Author: Michael Weghorn <[email protected]> AuthorDate: Mon Nov 13 16:16:55 2023 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Nov 14 08:09:38 2023 +0100 gtk4 a11y: Set accessible name and description Set the accessible name and accessible description via the corresponding properties in the gtk4 a11y API, `GTK_ACCESSIBLE_PROPERTY_LABEL` (accessible name) and `GTK_ACCESSIBLE_PROPERTY_DESCRIPTION` (accessible description). Drop the initial proof of concept that was setting the text returned by the Text interface as accessible name instead. This also makes it much easier to find a specific item in the LO a11y tree in Accerciser. Change-Id: I9dac4c33185b589a63dda03fa7dd342a6ed460ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159385 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/unx/gtk4/a11y.cxx b/vcl/unx/gtk4/a11y.cxx index 2dad6615e1e3..43835956581a 100644 --- a/vcl/unx/gtk4/a11y.cxx +++ b/vcl/unx/gtk4/a11y.cxx @@ -464,21 +464,6 @@ static void lo_accessible_get_property(GObject* object, guint property_id, GValu { GtkAccessibleRole eRole(map_accessible_role(accessible->uno_accessible)); g_value_set_enum(value, eRole); - - // for now set GTK_ACCESSIBLE_PROPERTY_LABEL as a proof of concept - if (accessible->uno_accessible) - { - css::uno::Reference<css::accessibility::XAccessibleContext> xContext( - accessible->uno_accessible->getAccessibleContext()); - css::uno::Reference<css::accessibility::XAccessibleText> xAccessibleText( - xContext, css::uno::UNO_QUERY); - if (xAccessibleText) - { - gtk_accessible_update_property( - GTK_ACCESSIBLE(accessible), GTK_ACCESSIBLE_PROPERTY_LABEL, - xAccessibleText->getText().toUtf8().getStr(), -1); - } - } break; } default: @@ -589,6 +574,12 @@ lo_accessible_new(GdkDisplay* pDisplay, GtkAccessible* pParent, GtkAccessible* pGtkAccessible = GTK_ACCESSIBLE(ret); + // set accessible name and description + gtk_accessible_update_property(pGtkAccessible, GTK_ACCESSIBLE_PROPERTY_LABEL, + xContext->getAccessibleName().toUtf8().getStr(), + GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, + xContext->getAccessibleDescription().toUtf8().getStr(), -1); + applyStates(pGtkAccessible, xContext); applyObjectAttributes(GTK_ACCESSIBLE(ret), xContext); commit 4ae31181cdd857b896c9fb6ab1fa57a41d76025f Author: Michael Weghorn <[email protected]> AuthorDate: Mon Nov 13 15:54:06 2023 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Nov 14 08:09:25 2023 +0100 wina11y: Drop "using namespace css:accessibility::AccessibleRole" And while at it, also replace the local variable that holds the role with 2 `sal_Int16` ones adhering to our naming scheme instead of calling it "Role". Change-Id: Ia49cfd23f919098eaea929601c4c432be3fcfe63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159383 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 7497a2f09f7e..6c1367185cac 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -188,9 +188,6 @@ void lcl_addIA2State(AccessibleStates& rStates, sal_Int64 nUnoState, sal_Int16 n } -using namespace com::sun::star::accessibility::AccessibleRole; - - AccObjectWinManager* CMAccessible::g_pAccObjectManager = nullptr; CMAccessible::CMAccessible(): @@ -1822,14 +1819,14 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR m_xAccessible->getAccessibleContext(); if(!pRContext.is()) return E_FAIL; - long Role = pRContext->getAccessibleRole(); + const sal_Int16 nRole = pRContext->getAccessibleRole(); *groupLevel = 0; *similarItemsInGroup = 0; *positionInGroup = 0; - if (Role != AccessibleRole::DOCUMENT && Role != AccessibleRole::DOCUMENT_PRESENTATION && - Role != AccessibleRole::DOCUMENT_SPREADSHEET && Role != AccessibleRole::DOCUMENT_TEXT) + if (nRole != AccessibleRole::DOCUMENT && nRole != AccessibleRole::DOCUMENT_PRESENTATION && + nRole != AccessibleRole::DOCUMENT_SPREADSHEET && nRole != AccessibleRole::DOCUMENT_TEXT) { Reference< XAccessibleGroupPosition > xGroupPosition( pRContext, UNO_QUERY ); if ( xGroupPosition.is() ) @@ -1854,7 +1851,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR Reference<XAccessibleContext> pRParentContext = pParentAcc->getAccessibleContext(); - if( Role == RADIO_BUTTON ) + if (nRole == AccessibleRole::RADIO_BUTTON) { int index = 0; int number = 0; @@ -1874,7 +1871,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR { if( getTheParentOfMember(pRParentContext->getAccessibleChild(j).get()) == static_cast<XAccessible*>(pRAcc.get()) && - pRParentContext->getAccessibleChild(j)->getAccessibleContext()->getAccessibleRole() == RADIO_BUTTON) + pRParentContext->getAccessibleChild(j)->getAccessibleContext()->getAccessibleRole() == AccessibleRole::RADIO_BUTTON) number++; if (pRParentContext->getAccessibleChild(j).get() == m_xAccessible.get()) index = number; @@ -1887,7 +1884,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR return S_OK; } - else if ( COMBO_BOX == Role ) + else if (nRole == AccessibleRole::COMBO_BOX) { *groupLevel = 1; *similarItemsInGroup = 0; @@ -1935,7 +1932,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR } return S_OK; } - else if ( PAGE_TAB == Role ) + else if (nRole == AccessibleRole::PAGE_TAB) { *groupLevel = 1; sal_Int64 nChildCount = pRParentContext->getAccessibleChildCount(); @@ -1958,8 +1955,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_groupPosition(long __RPC_FAR { level++; pRParentContext = pParentAcc->getAccessibleContext(); - Role = pRParentContext->getAccessibleRole(); - if( (Role == TREE) || (Role == LIST) ) + const sal_Int16 nParentRole = pRParentContext->getAccessibleRole(); + if ((nParentRole == AccessibleRole::TREE) || (nParentRole == AccessibleRole::LIST)) isFound = true; pParentAcc = pRParentContext->getAccessibleParent(); }
