vcl/qt5/QtAccessibleWidget.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
New commits: commit 2690b0079c160ab68b98d720432bb0949624c78b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Aug 3 14:14:27 2022 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Aug 4 08:34:31 2022 +0200 qt a11y: Consider QObject hierarchy to find parent The a11y hierarchy of the whole application includes a11y objects that have no LO-internal a11y objects associated with them, but are handled solely by the Qt library, like the Qt application at the root of the a11y hierarchy. Therefore, fall back to using the QObject hierarchy when looking for the parent of an a11y object. This e.g. makes the scenario of starting at the top-level application object, moving the hierarchy down two levels, then up again work, which now and ends up at the application object again. With the application a11y object ("soffice.bin") selected in the Accerciser tree view of the a11y hierarchy, this can be achieved with the following commands in Accerciser's IPython console: In [4]: acc.name Out[5]: 'soffice.bin' In [5]: acc.get_child_at_index(0).get_child_at_index(0).get_parent().get_parent().name Out[6]: 'soffice.bin' It previously failed like this, which is one of the reasons why restoring bookmarks in Accerciser didn't work when using the qt6 VCL plugin: In [1]: acc.get_child_at_index(0).get_child_at_index(0).get_parent().get_parent().name --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /usr/lib/python3/dist-packages/pyatspi/__init__.py in <module> ----> 1 acc.get_child_at_index(00).get_child_at_index(0)0.(get_parent).(get_parent).nameAttributeError In [1]: acc.get_child_at_index(0).get_child_at_index(0) Out[2]: <Atspi.Accessible object at 0x7fd3b8d11140 (AtspiAccessible at 0x56252b30bd40)> In [2]: acc.get_child_at_index(0).get_child_at_index(0).name Out[3]: 'VCL ImplGetDefaultWindow (Type = 362)' In [3]: acc.get_child_at_index(0).get_child_at_index(0).get_parent() In [4]: acc.get_child_at_index(0).get_child_at_index(0).get_parent() == None Out[5]: True Change-Id: Iba197a2e943671591fa0ee5641a7b330eae8822a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137747 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index fd0a858c564c..1634912c8fa7 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -275,8 +275,19 @@ QAccessibleInterface* QtAccessibleWidget::parent() const if (!xAc.is()) return nullptr; - return QAccessible::queryAccessibleInterface(new QtXAccessible(xAc->getAccessibleParent())); + if (xAc->getAccessibleParent().is()) + return QAccessible::queryAccessibleInterface(new QtXAccessible(xAc->getAccessibleParent())); + + // go via the QObject hierarchy; some a11y objects like the application + // (at the root of the a11y hierarchy) are handled solely by Qt and have + // no LO-internal a11y objects associated with them + QObject* pObj = object(); + if (pObj && pObj->parent()) + return QAccessible::queryAccessibleInterface(pObj->parent()); + + return nullptr; } + QAccessibleInterface* QtAccessibleWidget::child(int index) const { Reference<XAccessibleContext> xAc = getAccessibleContextImpl();