From a85b647f7bb6cb869abf22ab9ecce419ad5083e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Tue, 1 Mar 2022 12:55:29 +0100 Subject: [PATCH] compress calls to AdjustRowHeight() to just one call (tdf#94677) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- sc/source/ui/docshell/impex.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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);