summaryrefslogtreecommitdiff
path: root/accessibility
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-08-01 18:12:18 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2023-08-02 05:09:07 +0200
commit256926cace5819b0107e8d24579e05bcab9b5a7e (patch)
treefcf21bdde57965fa58757d7f169f4bf2b7e2cd7c /accessibility
parent47ca3f1f762352b488d58b3bf23d5776576f1cca (diff)
tdf#156473 a11y: Don't use selection index as child index
`XAccessibleSelection::getSelectedAccessibleChild` takes the index into the selection, not the child index, as its documentation (in `offapi/com/sun/star/accessibility/XAccessibleSelection.idl`) says: > @param nSelectedChildIndex > This index refers only to the selected children, not to all the > children of this object. Even if all children are selected, the > indices enumerating the selected children need not be the same > as those enumerating all children. If only single selection is > supported the only valid value is 0. The previous handling here in `AccessibleGridControlTable::getSelectedAccessibleChild` was treating it as the child index, though. Therefore trying to get the selected children would break once any row other than the first was selected. Fix this by calculating the actual row/column index of the cell from the given *selection* index. This could be observed e.g. with the qt6 VCL plugin by querying selection from Accerciser, with the last row selected in the table from the tdf#156473 macro in LO and the corresponding table object selected in Accerciser's tree view of the LO a11y hierarchy: Before: In [41]: sel = acc.querySelection() In [42]: sel.nSelectedChildren Out[42]: 5 In [43]: sel.getSelectedChild(0) In [44]: sel.getSelectedChild(0) == None Out[44]: True With the fix in place: In [48]: sel = acc.querySelection() In [49]: sel.nSelectedChildren Out[49]: 5 In [50]: sel.getSelectedChild(0) Out[50]: <Atspi.Accessible object at 0x7fcaeaddb900 (AtspiAccessible at 0x3ae4a80)> In [51]: sel.getSelectedChild(0).name Out[51]: 'C1 , R4 , ' In [52]: sel.getSelectedChild(1).name Out[52]: 'C2 , R4 , ' In [53]: sel.getSelectedChild(4).name Out[53]: 'Column 5 , R4 , ' Change-Id: Id7d42a89b913d2ed101a9edb45dee5f3d870dbbd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155190 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'accessibility')
-rw-r--r--accessibility/source/extended/AccessibleGridControlTable.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/accessibility/source/extended/AccessibleGridControlTable.cxx b/accessibility/source/extended/AccessibleGridControlTable.cxx
index 579826195be2..4629a4b3ee66 100644
--- a/accessibility/source/extended/AccessibleGridControlTable.cxx
+++ b/accessibility/source/extended/AccessibleGridControlTable.cxx
@@ -253,10 +253,16 @@ AccessibleGridControlTable::getSelectedAccessibleChild( sal_Int64 nSelectedChild
SolarMutexGuard aSolarGuard;
ensureIsAlive();
- if(isAccessibleChildSelected(nSelectedChildIndex))
- return getAccessibleChild(nSelectedChildIndex);
- else
- return nullptr;
+ if (nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount())
+ throw lang::IndexOutOfBoundsException("Invalid index into selection", *this);
+
+ const sal_Int32 nColCount = getAccessibleColumnCount();
+ assert(nColCount > 0 && "Column count non-positive, but child count > 0");
+ const sal_Int32 nIndexInSelectedRowsSequence = nSelectedChildIndex / nColCount;
+ const Sequence<sal_Int32> aSelectedRows = getSelectedAccessibleRows();
+ const sal_Int32 nRowIndex = aSelectedRows[nIndexInSelectedRowsSequence];
+ const sal_Int32 nColIndex = nSelectedChildIndex % nColCount;
+ return getAccessibleCellAt(nRowIndex, nColIndex);
}
//not implemented yet, because only row selection possible
void SAL_CALL AccessibleGridControlTable::deselectAccessibleChild(