summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2016-10-07 21:34:51 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2016-10-07 22:05:11 -0400
commit61b76cd8ca6a4a98a2ffe6fb42c73eba561aa87f (patch)
tree79d796580f77435031f5df2095b002d94acfd78d /sc/source
parent06f91e5c6d4528de00a188f0f8ba4b5678b94ad3 (diff)
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
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/table2.cxx18
1 files changed, 17 insertions, 1 deletions
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;