From 61b76cd8ca6a4a98a2ffe6fb42c73eba561aa87f Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 7 Oct 2016 21:34:51 -0400 Subject: Properly skip the hidden row(s) at the end. This method is supposed to return the first visible row that occurs below the specified hight. The old code would sometimes return a hidden row. Change-Id: Idf32c625c4f51355cd5d8a9f12ae9bbdddd4e5aa --- sc/source/core/data/table2.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'sc/source') diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index df61646e6af8..36ed4efd74e5 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -3679,10 +3679,12 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const for (SCROW nRow = 0; nRow <= MAXROW; ++nRow) { if (!mpHiddenRows->getRangeData(nRow, aData)) + // Failed to fetch the range data for whatever reason. break; if (aData.mbValue) { + // This row is hidden. Skip ahead all hidden rows. nRow = aData.mnRow2; continue; } @@ -3691,7 +3693,21 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const nSum += nNew; if (nSum > nHeight) { - return nRow < MAXROW ? nRow + 1 : MAXROW; + if (nRow >= MAXROW) + return MAXROW; + + // Find the next visible row. + ++nRow; + + if (!mpHiddenRows->getRangeData(nRow, aData)) + // Failed to fetch the range data for whatever reason. + break; + + if (aData.mbValue) + // These rows are hidden. + nRow = aData.mnRow2 + 1; + + return nRow <= MAXROW ? nRow : MAXROW; } } return -1; -- cgit