test/source/a11y/AccessibilityTools.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
New commits: commit 150f89d3b39fd062af56e21aa6d185758af67c0e Author: Colomban Wendling <cwendl...@hypra.fr> AuthorDate: Thu Jul 21 16:36:32 2022 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 27 17:04:17 2022 +0200 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.wegh...@posteo.de> Tested-by: Jenkins 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()); }