sc/qa/extras/accessibility/basics.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
New commits: commit d92ad32c98c6a094195e10f066968eb60105dff1 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Sep 2 13:11:08 2022 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Sep 2 15:47:53 2022 +0200 tdf#150683 sc a11y: Add a test case for 64-bit a11y cell index Add a simple test case that retrieves the a11y object for the Calc cell in the last row, last column and uses its child index to retrieve the row and column number via the corresponding `XAccessibleTable` methods again. Before changing a11y child indices to 64 bit (s. Change-Id I3af590c988b0e6754fc72545918412f39e8fea07, "[API CHANGE] tdf#150683 a11y: Switch a11y child index to 64 bit"), integer overflows would result in the a11y object getting a negative child index and an `IndexOutOfBoundsException` would be thrown when trying to use that to get the row and column using that. Change-Id: I41bfc0507bd57c3a21ad330638714508855055b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139259 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sc/qa/extras/accessibility/basics.cxx b/sc/qa/extras/accessibility/basics.cxx index ec55ea04ed26..f07a24d1a353 100644 --- a/sc/qa/extras/accessibility/basics.cxx +++ b/sc/qa/extras/accessibility/basics.cxx @@ -85,6 +85,28 @@ CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, TestCalcMenu) CPPUNIT_ASSERT_LESSEQUAL(afterTime, value); } -CPPUNIT_PLUGIN_IMPLEMENT(); +// test that converting cell row/col number <-> child index works +// for the case where 32-bit a11y child indices don't suffice (tdf#150683) +CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, Test64BitChildIndices) +{ + load(u"private:factory/scalc"); + const sal_Int32 nRow = 1048575; + const sal_Int32 nCol = 16383; + + uno::Reference<accessibility::XAccessibleTable> xTable( + getDocumentAccessibleContext()->getAccessibleChild(0)->getAccessibleContext(), // sheet 1 + uno::UNO_QUERY_THROW); + + uno::Reference<accessibility::XAccessible> xCell = xTable->getAccessibleCellAt(nRow, nCol); + const sal_Int64 nChildIndex = xCell->getAccessibleContext()->getAccessibleIndexInParent(); + // child index should be positive for all cells except the first one (A1) + CPPUNIT_ASSERT_GREATER(sal_Int64(0), nChildIndex); + + // test that retrieving the row and column number via the child index again works + CPPUNIT_ASSERT_EQUAL(nRow, xTable->getAccessibleRow(nChildIndex)); + CPPUNIT_ASSERT_EQUAL(nCol, xTable->getAccessibleColumn(nChildIndex)); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */