vcl/qt5/QtAccessibleWidget.cxx | 52 +++++------------------------------------ 1 file changed, 7 insertions(+), 45 deletions(-)
New commits: commit 02266202e5e5a97d3c97a3d502c59db884a99901 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Mar 6 15:52:44 2023 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Mon Mar 6 19:48:09 2023 +0000 qt a11y: Handle all QAccessible::Relation flags The bits/flags in `QAccessible::Relation` can be set in any combination, while the previous code would only properly handle the case that `QAccessible::AllRelations` is set. This would e.g. mean that QtAccessibleWidget::relations(QAccessible::FlowsTo | QAccessible::FlowsFrom) would not return both relations as it should. The previous handling of the case that just a single flag is set also looks odd, since it would use the sal_Int16 value of the UNO relation as an index into the set of relations... Fix this by always iterating over all relations and applying the filter in `lcl_appendRelation` (only append those that match the filter). (At least for AT-SPI, the previous handling should not have caused any issues in practice, since Qt's AT-SPI bridge always passes `QAccessible::AllRelations` from what I can see.) Change-Id: Icc21ac252db026f607fe8d6041252916b1d9e3a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148352 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index 13823006b6cd..237b2db64735 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -251,42 +251,12 @@ QAccessible::Relation lcl_matchUnoRelation(short relationType) } } -short lcl_matchQtRelation(QAccessible::Relation relationType) -{ - // Qt semantics is the other way around - switch (relationType) - { - case QAccessible::Controlled: - return AccessibleRelationType::CONTROLLER_FOR; - case QAccessible::Controller: - return AccessibleRelationType::CONTROLLED_BY; -#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) - case QAccessible::DescriptionFor: - return AccessibleRelationType::DESCRIBED_BY; - case QAccessible::FlowsFrom: - return AccessibleRelationType::CONTENT_FLOWS_TO; - case QAccessible::FlowsTo: - return AccessibleRelationType::CONTENT_FLOWS_FROM; -#endif - case QAccessible::Labelled: - return AccessibleRelationType::LABEL_FOR; - case QAccessible::Label: - return AccessibleRelationType::LABELED_BY; -#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) - case QAccessible::Described: -#endif - default: - SAL_WARN("vcl.qt", "Unmatched relation: " << relationType); - } - return 0; -} - void lcl_appendRelation(QVector<QPair<QAccessibleInterface*, QAccessible::Relation>>* relations, - AccessibleRelation aRelation) + AccessibleRelation aRelation, QAccessible::Relation match) { QAccessible::Relation aQRelation = lcl_matchUnoRelation(aRelation.RelationType); - // skip in case there's no matching Qt relation - if (!(aQRelation & QAccessible::AllRelations)) + // skip in case there's no Qt relation matching the filter + if (!(aQRelation & match)) return; sal_uInt32 nTargetCount = aRelation.TargetSet.getLength(); @@ -313,19 +283,11 @@ QtAccessibleWidget::relations(QAccessible::Relation match) const Reference<XAccessibleRelationSet> xRelationSet = xAc->getAccessibleRelationSet(); if (xRelationSet.is()) { - if (match == QAccessible::AllRelations) - { - int count = xRelationSet->getRelationCount(); - for (int i = 0; i < count; i++) - { - AccessibleRelation aRelation = xRelationSet->getRelation(i); - lcl_appendRelation(&relations, aRelation); - } - } - else + int count = xRelationSet->getRelationCount(); + for (int i = 0; i < count; i++) { - AccessibleRelation aRelation = xRelationSet->getRelation(lcl_matchQtRelation(match)); - lcl_appendRelation(&relations, aRelation); + AccessibleRelation aRelation = xRelationSet->getRelation(i); + lcl_appendRelation(&relations, aRelation, match); } }