vcl/qt5/QtAccessibleWidget.cxx |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

New commits:
commit e55713dffbe8d8eba18068f6c2af14c10b787220
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Feb 17 15:25:37 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Mon Feb 20 06:15:56 2023 +0000

    qt a11y: Invert relation type to match Qt's semantic
    
    As Jan Arve Sæther pointed out in a review comment [1]
    for a pending Qt change to add more a11y relation
    types to Qt, Qt's semantic for relations is basically
    the other way around (i.e. inversed) as compared
    to the semantic used by AT-SPI or LO.
    
    For example, if an a11y interface `interfaceA` is the label
    for another a11y interface `interfaceB`,
    
        interfaceA->relations()
    
    will contain a pair
    
        { interfaceB, QAccessible::Labelled }
    
    since the target `interfaceB` is labelled by `interfaceA`.
    
    On the other hand in LO, the `XAccessibleRelationSet`
    for an `XAccessibleContext` has the role that the
    a11y object itself has *for* the targets, i.e.
    in that case the
    
        interfaceA->getAccessibleRelationSet()
    
    would contain an item of type
    `AccessibleRelationType::LABEL_FOR` because
    `interfaceA` is a label for the relation target
    `interfaceB`.
    
    Therefore, adapt the mapping between the relation
    types accordingly.
    
    AT-SPI's semantic/handling matches the one that LO has
    again, which is taken care of by the fact that
    Qt maps the relation types the other way around in
    it's AT-SPI bridge again. [2]
    
    There's also a pending Qt change [3] to clarify the
    Qt doc.
    
    [1] 
https://codereview.qt-project.org/c/qt/qtbase/+/428174/comment/eef0cf38_e6ff7dea/
    [2] 
https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/accessible/linux/qspi_constant_mappings.cpp?id=e8322a4cc043e1a150cc4c6b86ee2f9cf858cd24#n98
    [3] https://codereview.qt-project.org/c/qt/qtbase/+/460414
    
    Change-Id: Ic30d878afc477ad3c6a188d22f35078034f8123c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147223
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx
index e2807dd6fecf..7a55bae884f5 100644
--- a/vcl/qt5/QtAccessibleWidget.cxx
+++ b/vcl/qt5/QtAccessibleWidget.cxx
@@ -220,15 +220,16 @@ sal_Int16 
lcl_matchQtTextBoundaryType(QAccessible::TextBoundaryType boundaryType
 
 QAccessible::Relation lcl_matchUnoRelation(short relationType)
 {
+    // Qt semantics is the other way around
     switch (relationType)
     {
-        case AccessibleRelationType::CONTROLLER_FOR:
-            return QAccessible::Controller;
         case AccessibleRelationType::CONTROLLED_BY:
+            return QAccessible::Controller;
+        case AccessibleRelationType::CONTROLLER_FOR:
             return QAccessible::Controlled;
-        case AccessibleRelationType::LABEL_FOR:
-            return QAccessible::Label;
         case AccessibleRelationType::LABELED_BY:
+            return QAccessible::Label;
+        case AccessibleRelationType::LABEL_FOR:
             return QAccessible::Labelled;
         case AccessibleRelationType::INVALID:
         case AccessibleRelationType::CONTENT_FLOWS_FROM:
@@ -245,15 +246,16 @@ QAccessible::Relation lcl_matchUnoRelation(short 
relationType)
 
 short lcl_matchQtRelation(QAccessible::Relation relationType)
 {
+    // Qt semantics is the other way around
     switch (relationType)
     {
-        case QAccessible::Controller:
-            return AccessibleRelationType::CONTROLLER_FOR;
         case QAccessible::Controlled:
+            return AccessibleRelationType::CONTROLLER_FOR;
+        case QAccessible::Controller:
             return AccessibleRelationType::CONTROLLED_BY;
-        case QAccessible::Label:
-            return AccessibleRelationType::LABEL_FOR;
         case QAccessible::Labelled:
+            return AccessibleRelationType::LABEL_FOR;
+        case QAccessible::Label:
             return AccessibleRelationType::LABELED_BY;
         default:
             SAL_WARN("vcl.qt", "Unmatched relation: " << relationType);

Reply via email to