sc/qa/unit/helper/csv_handler.hxx | 2 ++ sc/source/ui/docshell/impex.cxx | 4 ++++ 2 files changed, 6 insertions(+)
New commits: commit da4ff2f93504b6a544ab3617c74c408187809624 Author: Noel Grandin <[email protected]> AuthorDate: Thu Jul 24 15:47:52 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Fri Jul 25 08:18:51 2025 +0200 tdf#167664 slow loading CSV with tokens ending in newline takes the load time from several minutes to several seconds Change-Id: Ie5bed51e4fd9ba45a94f446b2c3e02cd7661fbcc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188286 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins (cherry picked from commit 749a312ea55eaa0c3dc352a0e8a1f32f8b6fd9cf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188306 Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx index 3cb43bead360..439bcee308e8 100644 --- a/sc/qa/unit/helper/csv_handler.hxx +++ b/sc/qa/unit/helper/csv_handler.hxx @@ -100,6 +100,8 @@ public: else if (meStringType == StringType::PureString) { OUString aCSVString(p, n, RTL_TEXTENCODING_UTF8); + if (aCSVString.endsWith(" ")) + aCSVString = aCSVString.copy(0, aCSVString.getLength()-1); OUString aString = mpDoc->GetString(mnCol, mnRow, mnTab); #if DEBUG_CSV_HANDLER diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index b7a27b5b6711..98e05311c356 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1688,6 +1688,10 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm ) bool bIsQuoted = false; p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge, bIsQuoted, bOverflowCell, bRemoveSpace ); + // some dodgy CSVs have a trailing linefeed in each token, which will + // make the code think that we have a multi-line field, which will slow things down a lot. + if (aCell.endsWith(" ")) + aCell = aCell.copy(0, aCell.getLength()-1); sal_uInt8 nFmt = SC_COL_STANDARD; for ( i=nInfoStart; i<nInfoCount; i++ )
