Bug 113979 - Paste unformated text does not ignore empty cells
Summary: Paste unformated text does not ignore empty cells
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.3.0.0.beta1
Hardware: All All
: medium normal
Assignee: Laurent Balland
URL:
Whiteboard: target:6.1.0
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2017-11-21 18:42 UTC by Laurent Balland
Modified: 2018-03-17 14:32 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file (7.74 KB, application/vnd.oasis.opendocument.spreadsheet)
2017-11-21 18:42 UTC, Laurent Balland
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Balland 2017-11-21 18:42:02 UTC
Created attachment 137897 [details]
Example file

Description: Pasting raw text, with empty columns, erase cells

Steps to reproduce:
1. Create a new sheet, with formulas in column D = SUM(A1:C1) (or open attached document)
2. Copy this text:
1;2;3;;60
2;3;4;;61
Note: successive semi colons indicate an empty column
3. Click on menu button of Paste button > Unformated text
4. In dialog, check semi colon as separator, OK

Actual result:
Formula in column D are erased.

Expected result:
Formula in column D should be kept

Workaround: paste in another sheet, copy again and paste special with "Skip empty cells" option

Reproduce with:
- Version: 5.3.0.1 (x64)
Build ID: 3b800451b1d0c48045de03b5b3c7bbbac87f20d9
Threads CPU : 2; Version de l'OS :Windows 6.1; UI Render : par défaut; Moteur de mise en page : nouveau; 
Locale : fr-FR (fr_FR); Calc: CL
- Version: 5.3.6.1
Build ID: 686f202eff87ef707079aeb7f485847613344eb7
Threads CPU : 2; Version de l'OS :Windows 6.1; UI Render : par défaut; Moteur de mise en page : nouveau; 
Locale : fr-FR (fr_FR); Calc: group

NOT reproduce with (works as expected):
- Version: 5.2.7.2 (x64)
Build ID: 2b7f1e640c46ceb28adf43ee075a6e8b8439ed10
Threads CPU : 2; Version de l'OS :Windows 6.1; UI Render : par défaut; 
Locale : fr-FR (fr_FR); Calc: CL
- Version: 5.3.0.0.alpha1 (x64)
Build ID: f4ca1573fcf445164c068c1046ab5d084e1b005f
Threads CPU : 2; Version de l'OS :Windows 6.1; UI Render : par défaut; 
Locale : fr-FR (fr_FR); Calc: CL
Comment 1 Laurent Balland 2017-11-21 18:54:18 UTC
Reproduce with:
- Version: 5.3.0.0.beta1 (x64)
Build ID: 690f553ecb3efd19143acbf01f3af4e289e94536
Threads CPU : 2; Version de l'OS :Windows 6.1; UI Render : par défaut; Layout Engine: new; 
Locale : fr-FR (fr_FR); Calc: CL
- Version: 5.4.2.1 (x64)
Build ID: dfa67a98bede79c671438308dc9036d50465d2cb
Threads CPU : 2; OS : Windows 6.1; UI Render : par défaut; 
Locale : fr-FR (fr_FR); Calc: CL

Set as regression
Comment 2 Laurent Balland 2017-11-21 20:22:05 UTC
Reproduce with:
- Version: 5.3.0.0.alpha1+ (x64)
Build ID: 9745d29227e471ce40e9992fefd92e10a48696fb
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; Layout Engine: new; 
TinderBox: Win-x86_64@62-TDF, Branch:MASTER, Time: 2016-11-18_21:55:13
Locale: fr-FR (fr_FR); Calc: CL

NOT reproduce with:
- Version: 5.3.0.0.alpha1+
Build ID: bbd44f8f89839b5abb4ec6c7ea195431de5b2f48
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2016-10-26_23:19:45
Locale: fr-FR (fr_FR); Calc: CL

Regression was introduced between 2016-10-26_23:19:45 and 2016-11-18_21:55:13

Still present in recent master:
- Version: 6.0.0.0.alpha1+ (x64)
Build ID: 6d24213d55df33c7bb5f10d511dcfc82b745db38
CPU threads: 4; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2017-11-18_04:09:43
Locale: fr-FR (fr_FR); Calc: CL
Comment 3 Xisco Faulí 2017-11-21 20:25:07 UTC
Regression introduced by:

author	Tamás Gulácsi <tgulacsi78@gmail.com>	2016-11-11 20:11:01 (GMT)
committer	Eike Rathke <erack@redhat.com>	2016-11-12 14:43:22 (GMT)
commit 96175a4bc6687c3adc31b9e0246fe49db2b7675e (patch)
tree 2cefbbe0c0f8be5a0b4ad5c402fd80bab80bbdf5
parent f57502e75cae1020f3fcfa5919802a78a6ccb6ff (diff)
tdf#69981 - sc: blank empty cells in TextToColumns
If the string is empty, we must delete the destination cell.
This is done, iff we don't return early (rStr.isEmpty() check).
Instead, add a fast path for the empty string.

Bisected with: bibisect-linux-64-5.3

Adding Cc: to Tamás Gulácsi
Comment 4 Laurent Balland 2017-11-21 20:59:43 UTC
I came to the same conclusion with a manual bisection ;-)

It seems that this behavior was intentionally introduced with commit 96175a4bc6687c3adc31b9e0246fe49db2b7675e
https://cgit.freedesktop.org/libreoffice/core/commit/sc/source/ui?id=96175a4bc6687c3adc31b9e0246fe49db2b7675e

to fix bug 69981 for Text to column function.

Shall we have a different behavior when pasting raw text?
@Eike: any advice?
Comment 5 Laurent Balland 2017-11-21 21:39:51 UTC
Or shall we have an option "Skip empty cells" to let user decide which behavior he is expecting?
Comment 6 Tamás Gulácsi 2017-11-22 08:12:18 UTC
The "Text to Columns" case is clear, you don't want to have anything there which weren't in the text before.
The simplest case for this is converting ",a,b,c" to columns - you want "_ a b c" and not ",a,b,c a b c".

I can accept that pasting raw text may behave differently, and skip empty cells, but that should be at least configurable, is someone want it differently/consistently.
Comment 7 Laurent Balland 2017-11-22 10:37:10 UTC
(In reply to Tamás Gulácsi from comment #6)
> The "Text to Columns" case is clear, you don't want to have anything there
> which weren't in the text before.
> The simplest case for this is converting ",a,b,c" to columns - you want "_ a
> b c" and not ",a,b,c a b c".
I do not totally agree with you. It's OK for the *first* column: if text starts with a separator, first column must be empty.
But if text contains several successive separator, user may (or not) want to keep the previous content of the cell.
Lets consider for example in column A: ",b,,d,,f". 
In Text to column with comma as separator, with previous behavior (prior 5.3) content of column C and E where preserved (and column A was not emptied which was the bug). With new behavior (from version 5.3), column A, C and E are emptied.

As this was the behavior from the beginning, not erasing columns C and E should be consider as a feature.

An option "Skip empty cells" would make all users happy, if Text to column function considers to erase first column if text starts with a separator.
Comment 8 crutko 2017-11-22 11:18:23 UTC
I confirm the bug explained here or what I consider as so or at least a loss of functionality. I clearly use this disappeared feature everyday since I put formulas between pasted raw text. Therefore, thanks to Laurent investigation, I had to revert to an ancient version that works it should.
OS : linux
version : back to 5.2.7.2

What I clearly ask is for an option to tick just like in copy-special paste from csv to sheet
Comment 9 Commit Notification 2017-12-21 22:17:13 UTC
Laurent BP committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3bd4957191f12457c17404645bab0794639c95f8

tdf#113979 Add option to Skip empty cells

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.
Comment 10 Commit Notification 2017-12-21 22:45:35 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8f3f6755d7f7355493e873954513fdaeb4dceca9

Have one getSkipEmptyCellsIndex(), assert array length, tdf#113979 follow-up

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.
Comment 11 Laurent Balland 2017-12-22 16:21:29 UTC
Thanks Eike for your reviewing.

@all: Eike suggested that "Skip empty cells" may be a bit ambiguous, as it doesn't indicate whether source or target cells are meant. Specifically, the source doesn't have "cells" yet.. concluding empty target cells then is really confusing and not what was meant.

I proposed "Skip empty cells", because it is the wording used in Paste Special.

Do you have any suggestion to be clearer, such as "Empty field content overwrites target cell" which sounds too long?
Comment 12 Laurent Balland 2017-12-27 21:53:08 UTC
(In reply to Laurent BP from comment #11)
> @all: Eike suggested that "Skip empty cells" may be a bit ambiguous

The import dialog appears in 3 cases:
- open CSV file: the new option is hidden
- text to column
- paste unformated text

We may use two different texts for the option, according which case is used:
- open CSV file: no text as the option is hidden
- text to column: in this case the text in the first column contains delimiters, and "empty field" may be more appropriate to describe when there is two successive delimiters (or text starts with a delimiter)
- paste unformated text: in this case, I thinks we can keep "Skip empty cells" because this case is very same the option "Skip empty cells" in Paste Special dialog

Any suggestion?
Comment 13 Commit Notification 2018-01-23 11:46:14 UTC
Laurent BP committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/help/commit/?id=94375babd75d8b611311bab682f9017e0485d19b

tdf#113979 Skip empty cells option
Comment 14 Xisco Faulí 2018-02-26 11:42:31 UTC
A polite ping to Laurent BP: is this bug fixed? if so, could you
please close it as RESOLVED FIXED ? Thanks
Comment 15 Laurent Balland 2018-02-26 13:30:35 UTC
Actually the bug is fixed but Eike was not happy with the wording. Shall we close this report and open a new one to improve wording?
Comment 16 Laurent Balland 2018-03-17 14:31:22 UTC
I opened bug 116448 for the problem of the wording of this option.
Close this one.