svtools/source/control/valueacc.cxx | 8 ++++---- vcl/qt5/QtAccessibleEventListener.cxx | 28 +++++++++++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-)
New commits: commit 0dc23570a033b69dfcaec64de18c3c0bbd2ad151 Author: Michael Weghorn <[email protected]> AuthorDate: Fri Apr 14 17:22:57 2023 +0300 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Apr 15 05:38:12 2023 +0200 a11y: Report focusable and focused state for ValueSetItem With this in place, Orca now also announces the selected color when moving focus in the list of available colors in the Writer toolbar font color popup when using the qt6 VCL plugin. Change-Id: I3f14047fe721c4a2bc0c6acb2d32f185d0eed204 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150418 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx index 9e496f6adcc8..1ba2c79dbbab 100644 --- a/svtools/source/control/valueacc.cxx +++ b/svtools/source/control/valueacc.cxx @@ -210,15 +210,15 @@ sal_Int64 SAL_CALL ValueItemAcc::getAccessibleStateSet() if ( !mbIsTransientChildrenDisabled ) nStateSet |= accessibility::AccessibleStateType::TRANSIENT; - // SELECTABLE nStateSet |= accessibility::AccessibleStateType::SELECTABLE; - // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE ); + nStateSet |= accessibility::AccessibleStateType::FOCUSABLE; - // SELECTED if( mpParent->mrParent.GetSelectedItemId() == mpParent->mnId ) { + nStateSet |= accessibility::AccessibleStateType::SELECTED; - // pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED ); + if (mpParent->mrParent.HasChildFocus()) + nStateSet |= accessibility::AccessibleStateType::FOCUSED; } } commit 734d10ed3612d75edcee145475ddd0b0165efeac Author: Michael Weghorn <[email protected]> AuthorDate: Fri Apr 14 16:57:09 2023 +0300 Commit: Michael Weghorn <[email protected]> CommitDate: Sat Apr 15 05:38:02 2023 +0200 qt a11y: Send QAccessible::ObjectCreated event for correct object When an `AccessibleEventId::CHILD` event with its s `NewValue` set is received, that means that this a11y child object has been created, so the `QAccessible::ObjectCreated` event needs to be sent for the newly created object, not the accessible interface of the listener (which is the parent). This makes announcement of (part of) the font color popup button in Writer's toolbar generally work with Orca and the qt6 VCL plugin e.g. the buttons in the popup are now announced (but the colors are not yet). Adapting this for the case where a child has been removed (bridged to Qt as `QAccessible::ObjectDestroyed` event) would currently results in crashes when closing the application e.g. after using the character font color popup in the Writer toolbar. This needs further investigation, so don't send the event for now, but add a `SAL_WARN`. Also warn when receiving a `CHILD` event with neither `OldValue` nore `NewValue` set, since that shouldn't happen, s.a. documentation in `offapi/com/sun/star/accessibility/AccessibleEventId.idl`. Change-Id: I183e71de061489fdc9751620820268f280f1949f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150417 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/qt5/QtAccessibleEventListener.cxx b/vcl/qt5/QtAccessibleEventListener.cxx index f9a4d7b1a2c1..59d7dd0a8717 100644 --- a/vcl/qt5/QtAccessibleEventListener.cxx +++ b/vcl/qt5/QtAccessibleEventListener.cxx @@ -170,7 +170,6 @@ void QtAccessibleEventListener::notifyEvent(const css::accessibility::Accessible { QAccessibleInterface* pQAccessibleInterface = m_pAccessibleWidget; - Reference<XAccessible> xChild; switch (aEvent.EventId) { case AccessibleEventId::NAME_CHANGED: @@ -213,14 +212,29 @@ void QtAccessibleEventListener::notifyEvent(const css::accessibility::Accessible } case AccessibleEventId::CHILD: { - QAccessible::Event event = QAccessible::InvalidEvent; - if (aEvent.OldValue >>= xChild) - event = QAccessible::ObjectDestroyed; + Reference<XAccessible> xChild; if (aEvent.NewValue >>= xChild) - event = QAccessible::ObjectCreated; - if (event != QAccessible::InvalidEvent) + { + QAccessible::updateAccessibility(new QAccessibleEvent( + QtAccessibleRegistry::getQObject(xChild), QAccessible::ObjectCreated)); + return; + } + if (aEvent.OldValue >>= xChild) + { + // Forwarding as QAccessible::ObjectDestroyed event currently results in crashes on close + // e.g. after using the character font color popup in the Writer toolbar, which + // needs further investigation, so don't send the event for now. + /* QAccessible::updateAccessibility( - new QAccessibleEvent(pQAccessibleInterface, event)); + new QAccessibleEvent(QtAccessibleRegistry::getQObject(xChild), QAccessible::ObjectDestroyed)); + */ + SAL_WARN("vcl.qt", + "Not forwarding AccessibleEventId::CHILD event for removed child " + "since it may cause crashes."); + return; + } + SAL_WARN("vcl.qt", + "Ignoring invalid AccessibleEventId::CHILD event without any child set."); return; } case AccessibleEventId::HYPERTEXT_CHANGED:
