sw/source/core/access/accmap.cxx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
New commits: commit 18e930165086fa08a91e1ba890ac3f52badbbf53 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jan 24 15:32:35 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jan 25 09:42:46 2024 +0100 sw a11y: Send SELECTION_CHANGED_{ADD,REMOVE} event for doc `AccessibleEventId::SELECTION_CHANGED_ADD` and `AccessibleEventId::SELECTION_CHANGED_REMOVE` events need to be sent for the selection container whose selection changed, not the child that was (un)selected. The latter should be set as the `NewValue` of the event, see the doc in offapi/com/sun/star/accessibility/AccessibleEventId.idl . Therefore, adjust the handling for (un)selected shapes in Writer: Set the doc view's a11y object as the source, just as it is already done for the `AccessibleEventId::SELECTION_CHANGED_WITHIN` case, and set the (un)selected shape as the `NewValue`. With a Writer doc having two shapes and the first one selected, clicking on the other one to switch selection to that one would previously result in this warning when using the qt6 VCL plugin with Orca running: warn:vcl.qt:114611:114611:vcl/qt6/../qt5/QtAccessibleEventListener.cxx:363: Selection add/remove event without the (un)selected accessible set warn:vcl.qt:114611:114611:vcl/qt6/../qt5/QtAccessibleEventListener.cxx:363: Selection add/remove event without the (un)selected accessible set Using gtk3 and this pyatspi script: #!/usr/bin/python3 import pyatspi def listener(e): try: if e.host_application.name != 'soffice': return except: return print(e) pyatspi.Registry.registerEventListener(listener, 'object:state-changed:selected') pyatspi.Registry.registerEventListener(listener, 'object:selection-changed') pyatspi.Registry.start() would previously give this output for that case: object:state-changed:selected(0, 0, 0) source: [panel | Shape 1] host_application: [application | soffice] sender: [application | soffice] object:selection-changed(0, 0, 0) source: [panel | Shape 1] host_application: [application | soffice] sender: [application | soffice] object:state-changed:selected(1, 0, 0) source: [panel | Shape 2] host_application: [application | soffice] sender: [application | soffice] object:selection-changed(0, 0, 0) source: [panel | Shape 2] host_application: [application | soffice] sender: [application | soffice] (i.e. both, the "state-changed:selected" as well as the "selection-changed" AT-SPI events were previously sent for the shapes.) With this change in place, this gives the expected output: object:state-changed:selected(0, 0, 0) source: [panel | Shape 1] host_application: [application | soffice] sender: [application | soffice] object:selection-changed(0, 0, 0) source: [document text | Untitled 1 - LibreOfficeDev Document] host_application: [application | soffice] sender: [application | soffice] object:state-changed:selected(1, 0, 0) source: [panel | Shape 2] host_application: [application | soffice] sender: [application | soffice] object:selection-changed(0, 0, 0) source: [document text | Untitled 1 - LibreOfficeDev Document] host_application: [application | soffice] sender: [application | soffice] Change-Id: Id2017f70a8e53043b4c303f69464ddd39f280097 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162519 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index bb0f209bb049..aa34fdf2d568 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -1517,12 +1517,17 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa ++pShape; } + rtl::Reference<SwAccessibleContext> xDocView = GetDocumentView_(false); + assert(xDocView.is()); + for (const auto& rpShape : vecxShapeRemove) { - ::accessibility::AccessibleShape *pAccShape = rpShape.get(); - if (pAccShape) + if (rpShape.is()) { - pAccShape->CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE, uno::Any(), uno::Any(), -1); + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; + aEvent.NewValue <<= uno::Reference<XAccessible>(rpShape); + xDocView->FireAccessibleEvent(aEvent); } } @@ -1554,20 +1559,20 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa const unsigned int SELECTION_WITH_NUM = 10; if (vecxShapeAdd.size() > SELECTION_WITH_NUM ) { - rtl::Reference<SwAccessibleContext> xDoc = GetDocumentView_(false); - assert(xDoc.is()); AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; - xDoc->FireAccessibleEvent(aEvent); + xDocView->FireAccessibleEvent(aEvent); } else { for (const auto& rpShape : vecxShapeAdd) { - ::accessibility::AccessibleShape *pAccShape = rpShape.get(); - if (pAccShape) + if (rpShape.is()) { - pAccShape->CommitChange(AccessibleEventId::SELECTION_CHANGED_ADD, uno::Any(), uno::Any(), -1); + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; + aEvent.NewValue <<= uno::Reference<XAccessible>(rpShape); + xDocView->FireAccessibleEvent(aEvent); } } }