wina11y: Use OAccessible in AccTopWindowListener::HandleWindowOpened

Window::GetAccessible returns an OAccessible. Use that
more specific type instead of the abstract XAccessible
UNO interface. OAccessible also implements the
XAccessibleContext interface itself, so there is no need
to request that one separately.

Change-Id: Ia40a9e5684ce321f0e5aff7ccd34bd3c488e1ab9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210437
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Michael Weghorn
2026-09-03 09:23:30 +02:00
parent 02952b5956
commit c6b7c9a7a7
@@ -46,28 +46,24 @@ void AccTopWindowListener::HandleWindowOpened(vcl::Window* pWindow)
if (!pSystemData)
return;
Reference<css::accessibility::XAccessible> xAccessible = pWindow->GetAccessible();
if (!xAccessible.is())
return;
Reference<css::accessibility::XAccessibleContext> xContext = xAccessible->getAccessibleContext();
if(!xContext.is())
rtl::Reference<comphelper::OAccessible> pAccessible = pWindow->GetAccessible();
if (!pAccessible.is())
return;
// add all listeners
m_aAccObjectManager.SaveTopWindowHandle(pSystemData->hWnd, xAccessible.get());
m_aAccObjectManager.SaveTopWindowHandle(pSystemData->hWnd, pAccessible.get());
AddAllListeners(xAccessible.get(), nullptr, pSystemData->hWnd);
AddAllListeners(pAccessible.get(), nullptr, pSystemData->hWnd);
if (pWindow->GetStyle() & WB_MOVEABLE)
m_aAccObjectManager.IncreaseState(xAccessible.get(), static_cast<unsigned short>(-1) /* U_MOVEBLE */ );
m_aAccObjectManager.IncreaseState(pAccessible.get(), static_cast<unsigned short>(-1) /* U_MOVEBLE */ );
short role = xContext->getAccessibleRole();
short role = pAccessible->getAccessibleRole();
if (role == css::accessibility::AccessibleRole::POPUP_MENU ||
role == css::accessibility::AccessibleRole::MENU )
{
m_aAccObjectManager.NotifyAccEvent(xAccessible.get(), UnoMSAAEvent::MENUPOPUPSTART);
m_aAccObjectManager.NotifyAccEvent(pAccessible.get(), UnoMSAAEvent::MENUPOPUPSTART);
}
if (role == css::accessibility::AccessibleRole::FRAME ||
@@ -75,7 +71,7 @@ void AccTopWindowListener::HandleWindowOpened(vcl::Window* pWindow)
role == css::accessibility::AccessibleRole::WINDOW ||
role == css::accessibility::AccessibleRole::ALERT)
{
m_aAccObjectManager.NotifyAccEvent(xAccessible.get(), UnoMSAAEvent::SHOW);
m_aAccObjectManager.NotifyAccEvent(pAccessible.get(), UnoMSAAEvent::SHOW);
}
}