sc/source/ui/docshell/impex.cxx |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

New commits:
commit a85b647f7bb6cb869abf22ab9ecce419ad5083e0
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Mar 1 12:55:29 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue Mar 1 18:02:11 2022 +0100

    compress calls to AdjustRowHeight() to just one call (tdf#94677)
    
    This function imports only text, so I think doing one big call
    at the end should be fine.
    
    Change-Id: I267f5857ac11cfb95245434333f2ca5fa7e662cc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130789
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 5ff892fe19ca..c6760535ef30 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1530,7 +1530,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
     SCCOL nStartCol = aRange.aStart.Col();
     SCCOL nEndCol = aRange.aEnd.Col();
     SCROW nStartRow = aRange.aStart.Row();
-    SCTAB nTab = aRange.aStart.Tab();
+    const SCTAB nTab = aRange.aStart.Tab();
 
     bool    bFixed              = pExtOptions->IsFixedLen();
     OUString aSeps              = pExtOptions->GetFieldSeps();  // Need 
non-const for ReadCsvLine(),
@@ -1593,6 +1593,9 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
 
     sal_uInt64 nOriginalStreamPos = rStrm.Tell();
 
+    SCROW nFirstUpdateRowHeight = SCROW_MAX;
+    SCROW nLastUpdateRowHeight = -1;
+
     ScDocumentImport aDocImport(rDoc);
     do
     {
@@ -1706,7 +1709,10 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
             if (!bDetermineRange)
             {
                 if (bMultiLine && !bRangeIsDetermined && pDocSh)
-                    pDocSh->AdjustRowHeight( nRow, nRow, nTab);
+                {   // Adjust just once at the end for a whole range.
+                    nFirstUpdateRowHeight = std::min( nFirstUpdateRowHeight, 
nRow );
+                    nLastUpdateRowHeight = std::max( nLastUpdateRowHeight, 
nRow );
+                }
                 xProgress->SetStateOnPercent( rStrm.Tell() - nOldPos );
             }
             ++nRow;
@@ -1743,10 +1749,15 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
 
         bDetermineRange = !bDetermineRange;     // toggle
     } while (!bDetermineRange);
+
     if ( !mbOverwriting )
         aDocImport.finalize();
 
     xProgress.reset();    // make room for AdjustRowHeight progress
+
+    if( nFirstUpdateRowHeight < nLastUpdateRowHeight && pDocSh )
+        pDocSh->AdjustRowHeight( nFirstUpdateRowHeight, nLastUpdateRowHeight, 
nTab);
+
     if (bRangeIsDetermined)
         EndPaste(false);
 

Reply via email to