svx/source/table/accessibletableshape.cxx |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

New commits:
commit d079415f7ddc4e47cbdfe527d1b5dcd3565599dc
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Aug 30 15:21:10 2022 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Aug 30 23:51:22 2022 +0200

    svx a11y: Simplify AccessibleTableShapeImpl::getColumnAndRow
    
    Just use division and modulo instead of a custom loop.
    
    Change-Id: I70a975d6c73d4c3f645d250b9c571fe6e35cd702
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139063
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/svx/source/table/accessibletableshape.cxx 
b/svx/source/table/accessibletableshape.cxx
index 3876c9104710..50d213fda3e9 100644
--- a/svx/source/table/accessibletableshape.cxx
+++ b/svx/source/table/accessibletableshape.cxx
@@ -199,17 +199,14 @@ Reference< XAccessible > 
AccessibleTableShapeImpl::getAccessibleChild(sal_Int32
 
 void AccessibleTableShapeImpl::getColumnAndRow( sal_Int32 nChildIndex, 
sal_Int32& rnColumn, sal_Int32& rnRow )
 {
-    rnRow = 0;
-    rnColumn = nChildIndex;
-
     if( mxTable.is() )
     {
         const sal_Int32 nColumnCount = mxTable->getColumnCount();
-        while( rnColumn >= nColumnCount )
-        {
-            rnRow++;
-            rnColumn -= nColumnCount;
-        }
+        if (nColumnCount == 0)
+            throw IndexOutOfBoundsException();
+
+        rnColumn = nChildIndex % nColumnCount;
+        rnRow = nChildIndex / nColumnCount;
 
         if( rnRow < mxTable->getRowCount() )
             return;

Reply via email to