sc/source/ui/docshell/impex.cxx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
New commits: commit d5ade739771ddf06cc7ee6d4af15672bfcf09ed6 Author: Eike Rathke <er...@redhat.com> AuthorDate: Tue Aug 31 16:04:51 2021 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Tue Aug 31 22:32:08 2021 +0200 CSV/Paste: setting a text format is only necessary when using ScDocumentImport For ScDocument::SetTextCell() it is forced anyway so was actually done twice, in the case of Paste and TextToColumns. Change-Id: I3144e2d316810c702c5ebd84698e8611674adace Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121381 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 577bcd1930c2..27221c581f4e 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -1040,23 +1040,22 @@ static bool lcl_PutString( const bool bForceFormulaText = (!bEvaluateFormulas && rStr[0] == '='); if (nColFormat == SC_COL_TEXT || bForceFormulaText) { - double fDummy; - sal_uInt32 nIndex = 0; - if (bForceFormulaText || rDoc.GetFormatTable()->IsNumberFormat(rStr, nIndex, fDummy)) - { - // Set the format of this cell to Text. - /* TODO: is this even necessary as ScSetStringParam should take - * care of it and we're doing this twice? Investigate all paths - * taken below. */ - sal_uInt32 nFormat = rDoc.GetFormatTable()->GetStandardFormat(SvNumFormatType::TEXT); - ScPatternAttr aNewAttrs(rDoc.GetPool()); - SfxItemSet& rSet = aNewAttrs.GetItemSet(); - rSet.Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat) ); - rDoc.ApplyPattern(nCol, nRow, nTab, aNewAttrs); - } if ( bUseDocImport ) { - if(ScStringUtil::isMultiline(rStr)) + double fDummy; + sal_uInt32 nIndex = 0; + if (bForceFormulaText || rDoc.GetFormatTable()->IsNumberFormat(rStr, nIndex, fDummy)) + { + // Set the format of this cell to Text. + // This is only necessary for ScDocumentImport, + // ScDocument::SetTextCell() forces it by ScSetStringParam. + sal_uInt32 nFormat = rDoc.GetFormatTable()->GetStandardFormat(SvNumFormatType::TEXT); + ScPatternAttr aNewAttrs(rDoc.GetPool()); + SfxItemSet& rSet = aNewAttrs.GetItemSet(); + rSet.Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat) ); + rDoc.ApplyPattern(nCol, nRow, nTab, aNewAttrs); + } + if (ScStringUtil::isMultiline(rStr)) { ScFieldEditEngine& rEngine = rDoc.GetEditEngine(); rEngine.SetTextCurrentDefaults(rStr); @@ -1068,7 +1067,8 @@ static bool lcl_PutString( rDocImport.setStringCell(ScAddress(nCol, nRow, nTab), rStr); return false; } - } else + } + else { rDoc.SetTextCell(ScAddress(nCol, nRow, nTab), rStr); return bMultiLine;