Bug 69981 - Calc - Text to Columns does not split cell correctly if first character is a comma
Summary: Calc - Text to Columns does not split cell correctly if first character is a ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Tamás Gulácsi
URL: http://ask.libreoffice.org/en/questio...
Whiteboard: target:5.3.0 target:6.1.0
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-30 19:30 UTC by devshane42
Modified: 2018-05-07 04:38 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
ODS example (created in v3.3.4.1). (8.10 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-04-04 04:16 UTC, Owen Genat (retired)
Details
Proposed patch (561 bytes, patch)
2016-11-11 13:22 UTC, Tamás Gulácsi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description devshane42 2013-09-30 19:30:41 UTC
Hi

I have a cell containing 3 consecutive commas – ,,, I select the cell, then Data>Text to Columns>Separated by>Comma and the preview window shows 3 blank cells, as I would expect. However, when I click OK, the 3 consecutive commas remain in the original cell.

Another example – I have a cell containing the text -
,2013-09-15 15:14:47,,
I select the cell, then Data>Text to Columns>Separated by>Comma and the preview window shows [blank cell][2013-09-15 15:14:47][blank cell] as I would expect. When I click OK, and the original cell remain unchanged
Comment 1 Joris Muller 2013-10-01 10:52:17 UTC
Thank you for this feedback

BugTriage :
- search for duplicate (keywords = text to column) : Possible link with bug 51700
- information are clear
- easy to reproduce (Windows 7, LibreOffice 4.0.5.2)

Status changed to "new"
Comment 2 Owen Genat (retired) 2013-10-01 22:49:52 UTC
Graphic example of the problem can also be found in the related AskLO question:

http://ask.libreoffice.org/en/question/23311/calc-how-to-split-correctly-cells-containing-commas/?answer=23314#post-id-23314
Comment 3 QA Administrators 2015-04-01 14:40:43 UTC Comment hidden (obsolete)
Comment 4 Owen Genat (retired) 2015-04-04 04:16:17 UTC
Created attachment 114605 [details]
ODS example (created in v3.3.4.1).

Re-tested under GNU/Linux x86_64 using:
v3.3.4.1 OOO330m19 Build: 401
v3.4.6.2 OOO340m1 Build: 602
v3.5.7.2 Build ID: 3215f89-f603614-ab984f2-7348103-1225a5b
v3.6.7.2 Build ID: e183d5b
v4.0.6.2 Build ID: 2e2573268451a50806fcd60ae2d9fe01dd0ce24
v4.1.6.2 Build ID: 40ff705089295be5be0aae9b15123f687c05b0a
v4.2.8.2 Build ID: 48d50dbfc06349262c9d50868e5c1f630a573ebd
v4.3.5.2 Build ID: 3a87456aaa6a95c63eea1c1b3201acedf0751bd5
v4.4.1.2 Build ID: 45e2de17089c24a1fa810c8f975a7171ba4cd432

All versions exhibit the same behaviour: the preview is correct but the result mal-treats each row with a leading delimited (in this case comma).
Comment 5 Owen Genat (retired) 2015-04-04 04:17:20 UTC
As per comment 4, version set to "Inherited from OOo" and hardware set to All/All.
Comment 6 tommy27 2016-04-16 07:23:21 UTC Comment hidden (obsolete)
Comment 7 Tamás Gulácsi 2016-11-10 09:59:49 UTC
It is absolutely reproducible with LibreOffice 5.2.3.1 on Linux Debian amd64 and Windows 2008 Server, too.

The "Text to Columns" shows blanks for blank fields, and/but does not overwrite those fields with blank, but leaves them as is.
Comment 8 Tamás Gulácsi 2016-11-11 13:22:34 UTC
Created attachment 128660 [details]
Proposed patch
Comment 9 Tamás Gulácsi 2016-11-11 13:24:29 UTC
On master:

diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 9cfe424..c37875d 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -957,7 +957,7 @@ static bool lcl_PutString(
 {
     ScDocument* pDoc = &rDocImport.getDoc();
     bool bMultiLine = false;
-    if ( nColFormat == SC_COL_SKIP || rStr.isEmpty() || !ValidCol(nCol) || !ValidRow(nRow) )
+    if ( nColFormat == SC_COL_SKIP || !ValidCol(nCol) || !ValidRow(nRow) )
         return bMultiLine;

     if ( nColFormat == SC_COL_TEXT )


getting rid of that rStr.isEmpty() optimization fixes this problem!
Comment 10 Commit Notification 2016-11-12 14:44:31 UTC
Tamás Gulácsi committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=96175a4bc6687c3adc31b9e0246fe49db2b7675e

tdf#69981 - sc: blank empty cells in TextToColumns

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2018-05-07 04:38:15 UTC
Zdeněk Crhonek committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5f42c9527333034bd01d8b78fdc3c0eb9924d2cb

uitest for bug tdf#69981

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.