diff options
-rw-r--r-- | sc/source/core/data/table2.cxx | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 5a12b0bba520..971c8ad7cd31 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -3971,16 +3971,25 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const break; } - nSum += aRowHeightRange.mnValue; + // find the last common row between hidden & height spans + SCROW nLastCommon = std::min(aData.mnRow2, aRowHeightRange.mnRow2); + assert (nLastCommon >= nRow); + SCROW nCommon = nLastCommon - nRow + 1; - if (nSum > nHeight) + // how much further to go ? + sal_uLong nPixelsLeft = nHeight - nSum; + sal_uLong nCommonPixels = aRowHeightRange.mnValue * nCommon; + + // are we in the zone ? + if (nCommonPixels > nPixelsLeft) { + nRow += (nPixelsLeft + aRowHeightRange.mnValue - 1) / aRowHeightRange.mnValue; + + // FIXME: finding this next row is far from elegant, + // we have a single caller, which subtracts one as well(!?) if (nRow >= pDocument->MaxRow()) return pDocument->MaxRow(); - // Find the next visible row. - ++nRow; - if (!mpHiddenRows->getRangeData(nRow, aData)) // Failed to fetch the range data for whatever reason. break; @@ -3991,6 +4000,10 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const return nRow <= pDocument->MaxRow() ? nRow : pDocument->MaxRow(); } + + // skip the range and keep hunting + nSum += nCommonPixels; + nRow = nLastCommon; } return -1; } |