toolkit/source/controls/table/AccessibleGridControlTableCell.cxx |    6 +--
 toolkit/source/controls/table/tablecontrol_impl.cxx              |   18 
+++-------
 2 files changed, 9 insertions(+), 15 deletions(-)

New commits:
commit ea0faaf9bb1fab2044e6cef9bc8e3d03f63896ec
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Jan 24 16:06:00 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Jan 24 22:01:40 2025 +0100

    toolkit: Use method with return value instead of out param
    
    Return direct uses of TableControl_Impl::impl_getCellRect
    with uses of TableControl_Impl::calcCellRect
    that returns the Rectangle instead of taking an
    out Rectangle& param.
    
    (Note that the order of the row/col index params is
    reversed in both methods.)
    
    Change-Id: I32af4c14d6193c12bd0bbc91dde14bb526abc48e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180717
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/toolkit/source/controls/table/tablecontrol_impl.cxx 
b/toolkit/source/controls/table/tablecontrol_impl.cxx
index c4bdf8834a69..2a3112cc8841 100644
--- a/toolkit/source/controls/table/tablecontrol_impl.cxx
+++ b/toolkit/source/controls/table/tablecontrol_impl.cxx
@@ -1657,8 +1657,7 @@ namespace svt::table
         PTableRenderer pRenderer = m_pModel ? m_pModel->getRenderer() : 
PTableRenderer();
         if ( pRenderer )
         {
-            tools::Rectangle aCellRect;
-            impl_getCellRect( m_nCurColumn, m_nCurRow, aCellRect );
+            tools::Rectangle aCellRect = calcCellRect(m_nCurRow, m_nCurColumn);
             if ( _bShow )
                 pRenderer->ShowCellCursor( *m_pDataWindow, aCellRect );
             else
@@ -1825,27 +1824,24 @@ namespace svt::table
         // if only one row is selected
         if ( _nPrevRow == _nCurRow )
         {
-            tools::Rectangle aCellRect;
-            impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect );
+            tools::Rectangle aCellRect = calcCellRect(_nCurRow, m_nCurColumn);
             aInvalidateRect.SetTop( aCellRect.Top() );
             aInvalidateRect.SetBottom( aCellRect.Bottom() );
         }
         //if the region is above the current row
         else if(_nPrevRow < _nCurRow )
         {
-            tools::Rectangle aCellRect;
-            impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect );
+            tools::Rectangle aCellRect = calcCellRect(_nPrevRow, m_nCurColumn);
             aInvalidateRect.SetTop( aCellRect.Top() );
-            impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect );
+            aCellRect = calcCellRect(_nCurRow, m_nCurColumn);
             aInvalidateRect.SetBottom( aCellRect.Bottom() );
         }
         //if the region is beneath the current row
         else
         {
-            tools::Rectangle aCellRect;
-            impl_getCellRect( m_nCurColumn, _nCurRow, aCellRect );
+            tools::Rectangle aCellRect = calcCellRect(_nCurRow, m_nCurColumn);
             aInvalidateRect.SetTop( aCellRect.Top() );
-            impl_getCellRect( m_nCurColumn, _nPrevRow, aCellRect );
+            aCellRect = calcCellRect(_nPrevRow, m_nCurColumn);
             aInvalidateRect.SetBottom( aCellRect.Bottom() );
         }
 
commit af3c7a31ea2cb979fa5819d103438ace17864472
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Jan 24 15:21:48 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Jan 24 22:01:31 2025 +0100

    toolkit a11y: Deobfuscate TableControl::calcCellRect
    
    In the only 2 callers of this method, the logic
    so far was this:
    
    1) Retrieve the child index, which is calculated
       from the row index + column index.
    
    2) Revert the calculation from step 1 by calculating
       the row and column index from the child index.
    
    3) Pass the column index calculated this way as the
       `_nRowPos` param and the row index as the
       `_nColPos` param to TableControl::calcCellRect.
       (Note that the param order is reversed from what
       at least I would naively have expected from looking
       at the param names.)
    
    4) In TableControl::calcCellRect, call
       TableControl_Impl::calcCellRect, passing the `_nRowPos`
       param as the `nRow` param and the `_nColPos` as the
       `nCol` param.
       (That looks reasonable.)
    
    5) In TableControl_Impl::calcCellRect,
       call TableControl_Impl::impl_getCellRect, which
       takes row index and column index in the reverse
       order. Pass the TableControl::calcCellRect's
       `nRow` param as TableControl_Impl::impl_getCellRect's
       `_nColumn` param and vice versa.
       (Note that using `_nRowPos`/`nRow` for the row index in
       one method and for the column pos in the other
       method is not what I would naively have expected,
       but together with 3), the order is correct again.)
    
    Make this a bit less confusing by skipping steps 1) and 2)
    and consistently using `_nRowPos`/`nRow` as param name for
    the row index, `_nColumn`/`nCol` for the column index.
    
    Change-Id: Iffb920c45e08c00087e590debebaa286368aee3e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180712
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/toolkit/source/controls/table/AccessibleGridControlTableCell.cxx 
b/toolkit/source/controls/table/AccessibleGridControlTableCell.cxx
index 3c4af9890916..7b134fe46a36 100644
--- a/toolkit/source/controls/table/AccessibleGridControlTableCell.cxx
+++ b/toolkit/source/controls/table/AccessibleGridControlTableCell.cxx
@@ -323,8 +323,7 @@ namespace accessibility
         vcl::Window* pParent = m_aTable.GetAccessibleParentWindow();
         assert(pParent && "implGetBoundingBox - missing parent window");
         tools::Rectangle aGridRect = m_aTable.GetWindowExtentsRelative( 
*pParent );
-        sal_Int64 nIndex = getAccessibleIndexInParent();
-        tools::Rectangle aCellRect = 
m_aTable.calcCellRect(nIndex%m_aTable.GetColumnCount(), 
nIndex/m_aTable.GetColumnCount());
+        tools::Rectangle aCellRect = m_aTable.calcCellRect(getRowPos(), 
getColumnPos());
         tools::Long nX = aGridRect.Left() + aCellRect.Left();
         tools::Long nY = aGridRect.Top() + aCellRect.Top();
         tools::Rectangle aCell( Point( nX, nY ), aCellRect.GetSize());
@@ -334,8 +333,7 @@ namespace accessibility
     AbsoluteScreenPixelRectangle 
AccessibleGridControlTableCell::implGetBoundingBoxOnScreen()
     {
         AbsoluteScreenPixelRectangle aGridRect = 
m_aTable.GetWindowExtentsAbsolute();
-        sal_Int64 nIndex = getAccessibleIndexInParent();
-        tools::Rectangle aCellRect = 
m_aTable.calcCellRect(nIndex%m_aTable.GetColumnCount(), 
nIndex/m_aTable.GetColumnCount());
+        tools::Rectangle aCellRect = m_aTable.calcCellRect(getRowPos(), 
getColumnPos());
         tools::Long nX = aGridRect.Left() + aCellRect.Left();
         tools::Long nY = aGridRect.Top() + aCellRect.Top();
         AbsoluteScreenPixelRectangle aCell( AbsoluteScreenPixelPoint( nX, nY 
), aCellRect.GetSize());
diff --git a/toolkit/source/controls/table/tablecontrol_impl.cxx 
b/toolkit/source/controls/table/tablecontrol_impl.cxx
index 931ab4b155ec..c4bdf8834a69 100644
--- a/toolkit/source/controls/table/tablecontrol_impl.cxx
+++ b/toolkit/source/controls/table/tablecontrol_impl.cxx
@@ -2344,7 +2344,7 @@ namespace svt::table
     tools::Rectangle TableControl_Impl::calcCellRect( sal_Int32 nRow, 
sal_Int32 nCol ) const
     {
         tools::Rectangle aCellRect;
-        impl_getCellRect( nRow, nCol, aCellRect );
+        impl_getCellRect(nCol, nRow, aCellRect);
         return aCellRect;
     }
 

Reply via email to