summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-03-17 22:44:26 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-03-21 10:50:21 +0100
commit479620d84a761297e013ca76fd429d938f3d2d8f (patch)
treeb81b066fe3d4cb1573953685b35aae275fb4cacc
parenttdf#135220 sw: fix layout after SwUndoDelete (diff)
downloadcore-479620d84a761297e013ca76fd429d938f3d2d8f.tar.gz
core-479620d84a761297e013ca76fd429d938f3d2d8f.zip
Resolves: tdf#148054 Advance offset for all columns, tdf#104927 regression
Regression from commit 621c189173b35ac7f5ce4c578f57045479c63ab6 CommitDate: Sat Jan 9 05:13:55 2021 +0100 tdf#104927 consider character width for CSV import that for fixed width introduced a visual count of character widths for CJK IVS characters but did not advance the character offset for skipped hidden columns. Instead of having to ask bDetermineRange three times in the loop, split off an extra loop for bDetermineRange, advancing the offset then is straight forward and just only non-skipped columns are extracted and written to document. Change-Id: Ib6ab6b68c5fc0f6ff854d629d75742c39ed6ddf5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131722 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 6b768542ddd52573bbdb0e7b5b85ce5a9dd4551d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131606 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sc/source/ui/docshell/impex.cxx72
1 files changed, 44 insertions, 28 deletions
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index b44e58b0e343..260db563e203 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1483,39 +1483,55 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
bool bMultiLine = false;
if ( bFixed ) // Fixed line length
{
- sal_Int32 nStartIdx = 0;
- // Yes, the check is nCol<=rDoc.MaxCol()+1, +1 because it is only an
- // overflow if there is really data following to be put behind
- // the last column, which doesn't happen if info is
- // SC_COL_SKIP.
- for ( i=0; i<nInfoCount && nCol <= rDoc.MaxCol()+1; i++ )
+ if (bDetermineRange)
{
- sal_uInt8 nFmt = pColFormat[i];
- if (nFmt != SC_COL_SKIP) // otherwise don't increment nCol either
+ // Yes, the check is nCol<=rDoc.MaxCol()+1, +1 because it
+ // is only an overflow if there is really data following to
+ // be put behind the last column, which doesn't happen if
+ // info is SC_COL_SKIP.
+ for (i=0; i < nInfoCount && nCol <= rDoc.MaxCol()+1; ++i)
{
- if (nCol > rDoc.MaxCol())
- bOverflowCol = true; // display warning on import
- else if (!bDetermineRange)
+ const sal_uInt8 nFmt = pColFormat[i];
+ if (nFmt != SC_COL_SKIP) // otherwise don't increment nCol either
{
- sal_Int32 nNextIdx = nStartIdx;
- if ( i + 1 < nInfoCount )
- CountVisualWidth( aLine, nNextIdx, pColStart[i+1] - pColStart[i] );
+ if (nCol > rDoc.MaxCol())
+ bOverflowCol = true; // display warning on import
+ ++nCol;
+ }
+ }
+ }
+ else
+ {
+ sal_Int32 nStartIdx = 0;
+ // Same maxcol+1 check reason as above.
+ for (i=0; i < nInfoCount && nCol <= rDoc.MaxCol()+1; ++i)
+ {
+ sal_Int32 nNextIdx = nStartIdx;
+ if (i + 1 < nInfoCount)
+ CountVisualWidth( aLine, nNextIdx, pColStart[i+1] - pColStart[i] );
+ else
+ nNextIdx = nLineLen;
+ sal_uInt8 nFmt = pColFormat[i];
+ if (nFmt != SC_COL_SKIP) // otherwise don't increment nCol either
+ {
+ if (nCol > rDoc.MaxCol())
+ bOverflowCol = true; // display warning on import
else
- nNextIdx = nLineLen;
-
- bool bIsQuoted = false;
- aCell = lcl_GetFixed( aLine, nStartIdx, nNextIdx, bIsQuoted, bOverflowCell );
- if (bIsQuoted && bQuotedAsText)
- nFmt = SC_COL_TEXT;
-
- bMultiLine |= lcl_PutString(
- aDocImport, !mbOverwriting, nCol, nRow, nTab, aCell, nFmt,
- &aNumFormatter, bDetectNumFormat, bSkipEmptyCells, aTransliteration, aCalendar,
- pEnglishTransliteration.get(), pEnglishCalendar.get());
-
- nStartIdx = nNextIdx;
+ {
+ bool bIsQuoted = false;
+ aCell = lcl_GetFixed( aLine, nStartIdx, nNextIdx, bIsQuoted, bOverflowCell );
+ if (bIsQuoted && bQuotedAsText)
+ nFmt = SC_COL_TEXT;
+
+ bMultiLine |= lcl_PutString(
+ aDocImport, !mbOverwriting, nCol, nRow, nTab, aCell, nFmt,
+ &aNumFormatter, bDetectNumFormat, bSkipEmptyCells,
+ aTransliteration, aCalendar,
+ pEnglishTransliteration.get(), pEnglishCalendar.get());
+ }
+ ++nCol;
}
- ++nCol;
+ nStartIdx = nNextIdx;
}
}
}