sc/source/core/data/column2.cxx |    4 ++++
 sc/source/ui/view/output2.cxx   |   14 +++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

New commits:
commit 8db72aab30ec81c26452a363b8ef9d6a98a07632
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sun Oct 22 21:25:15 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Oct 23 09:38:24 2023 +0200

    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/+/158338
    Tested-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index d037685c66e4..a2f8ca5ea25a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1328,6 +1328,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 c80c6483bc5e..1b67ab4f4b24 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1513,8 +1513,11 @@ void ScOutputData::LayoutStrings(bool bPixelToLogic)
 
     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
@@ -4394,11 +4397,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

Reply via email to