summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColomban Wendling <cwendling@hypra.fr>2022-07-21 16:36:32 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2022-07-27 17:04:17 +0200
commit150f89d3b39fd062af56e21aa6d185758af67c0e (patch)
tree8eaa977c5a8e540e1db5b33ae870e7d42f448ce4
parent50c480bc1f68bc681fe369e0cb002a8f5b51843a (diff)
Fix comparing some Writer objects
Offscreen objects in Writer are not exposed as children of their parent, but might be reachable through relations. In this case, similar objects can easily be mistakenly deemed equal (e.g. empty paragraphs will have the same role, empty name and description, etc.). Try to avoid this by taking into account the object's relations, which should at least have different targets if they are not the same. Change-Id: Ie6e1aaf388006b76d014ba2bd26aabef88d7dd6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137335 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
-rw-r--r--test/source/a11y/AccessibilityTools.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/source/a11y/AccessibilityTools.cxx b/test/source/a11y/AccessibilityTools.cxx
index f727bd41087f..266e536dd3ba 100644
--- a/test/source/a11y/AccessibilityTools.cxx
+++ b/test/source/a11y/AccessibilityTools.cxx
@@ -88,6 +88,27 @@ bool AccessibilityTools::equals(const uno::Reference<accessibility::XAccessibleC
if (xctx1->getAccessibleIndexInParent() != xctx2->getAccessibleIndexInParent())
return false;
+ /* because in Writer at least some children only are referenced by their relations to others
+ * objects, we need to account for that as their index in parent is incorrect (so not
+ * necessarily unique) */
+ auto relset1 = xctx1->getAccessibleRelationSet();
+ auto relset2 = xctx2->getAccessibleRelationSet();
+ if (relset1.is() != relset2.is())
+ return false;
+ else if (relset1.is())
+ {
+ auto relCount1 = relset1->getRelationCount();
+ auto relCount2 = relset2->getRelationCount();
+ if (relCount1 != relCount2)
+ return false;
+
+ for (sal_Int32 i = 0; i < relCount1; ++i)
+ {
+ if (relset1->getRelation(i) != relset2->getRelation(i))
+ return false;
+ }
+ }
+
return equals(xctx1->getAccessibleParent(), xctx2->getAccessibleParent());
}