summaryrefslogtreecommitdiff
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
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
-rw-r--r--sc/inc/document.hxx6
-rw-r--r--sc/source/core/data/table2.cxx18
2 files changed, 23 insertions, 1 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 727e68c805f2..2dbe866a5769 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1689,6 +1689,12 @@ public:
SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow ) const;
SC_DLLPUBLIC sal_uLong GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
+
+ /**
+ * Given the height i.e. total vertical distance from the top of the sheet
+ * grid, return the first visible row whose top position is below the
+ * specified height.
+ */
SCROW GetRowForHeight( SCTAB nTab, sal_uLong nHeight ) const;
sal_uLong GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const;
SC_DLLPUBLIC sal_uLong GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
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;