diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-10-22 21:25:15 +0200 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-24 12:54:10 +0200 |
commit | 18c2358d3b0658b20daa045a8950cb2bfb15bd7b (patch) | |
tree | f73a84d68e10df27e310099d86b2f1cec42adcc9 /sc | |
parent | 76899152ec3d1924cc72d2b869e197a1e34a0a1a (diff) |
cool#7332 calc perf: GetEmptyLinesInBlock
reuse existing method to find area of sheet which contains data - this method already caches the necessary data.
Also add a shortcut for the common case in ScColumn::IsEmptyData to avoid performing more expensive lookup operation.
Change-Id: I24c7466d804ffc53cb2568923717f60ff4bc5186
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158276
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/column2.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 14 |
2 files changed, 13 insertions, 5 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index e01a3458f6fc..3abb568befbc 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -1318,6 +1318,10 @@ bool ScColumn::HasVisibleDataAt(SCROW nRow) const bool ScColumn::IsEmptyData(SCROW nStartRow, SCROW nEndRow) const { + // simple case + if (maCells.block_size() == 1 && maCells.begin()->type == sc::element_type_empty) + return true; + std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nStartRow); sc::CellStoreType::const_iterator it = aPos.first; if (it == maCells.end()) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 3887f19b3d5c..9b325a5dbe82 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1517,8 +1517,11 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co SCCOL nLastContentCol = mpDoc->MaxCol(); if ( nX2 < mpDoc->MaxCol() ) - nLastContentCol = sal::static_int_cast<SCCOL>( - nLastContentCol - mpDoc->GetEmptyLinesInBlock( nX2+1, nY1, nTab, mpDoc->MaxCol(), nY2, nTab, DIR_RIGHT ) ); + { + SCROW nEndRow; + mpDoc->GetCellArea(nTab, nLastContentCol, nEndRow); + } + SCCOL nLoopStartX = nX1; if ( nX1 > 0 ) --nLoopStartX; // start before nX1 for rest of long text to the left @@ -4319,11 +4322,12 @@ void ScOutputData::DrawEdit(bool bPixelToLogic) } tools::Long nLayoutSign = bLayoutRTL ? -1 : 1; - //! store nLastContentCol as member! SCCOL nLastContentCol = mpDoc->MaxCol(); if ( nX2 < mpDoc->MaxCol() ) - nLastContentCol = sal::static_int_cast<SCCOL>( - nLastContentCol - mpDoc->GetEmptyLinesInBlock( nX2+1, nY1, nTab, mpDoc->MaxCol(), nY2, nTab, DIR_RIGHT ) ); + { + SCROW nEndRow; + mpDoc->GetCellArea(nTab, nLastContentCol, nEndRow); + } tools::Long nRowPosY = nScrY; for (SCSIZE nArrY=0; nArrY+1<nArrCount; nArrY++) // 0 of the rest of the merged |