summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2025-01-24 15:21:48 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2025-01-24 22:01:31 +0100
commitaf3c7a31ea2cb979fa5819d103438ace17864472 (patch)
tree06f12423f871960aa92f5af181a19baf8c1aafef
parent3e447bcca78dec8c2b8f3499969641e008ad7e7f (diff)
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.weghorn@posteo.de> Tested-by: Jenkins
-rw-r--r--toolkit/source/controls/table/AccessibleGridControlTableCell.cxx6
-rw-r--r--toolkit/source/controls/table/tablecontrol_impl.cxx2
2 files changed, 3 insertions, 5 deletions
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;
}