Bug 113571 - Copy of cell with multi-line text is pasted as CSV for unformatted text, enclosed in double quotes and with quote escaping (FORMATTING)
Summary: Copy of cell with multi-line text is pasted as CSV for unformatted text, encl...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: All All
: medium minor
Assignee: Eike Rathke
URL:
Whiteboard: target:6.0.0
Keywords: preBibisect, regression
Depends on:
Blocks: Clipboard
  Show dependency treegraph
 
Reported: 2017-11-01 14:34 UTC by Clemens Prill
Modified: 2017-11-21 15:15 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Clemens Prill 2017-11-01 14:34:20 UTC
Description:
When I try to copy and paste XML data from LibreOffice, it ends in tuples of double quotes inserted in my pasted data. This is not expected by the user.

Steps to Reproduce:
1. Copy this XML data:

<?xml version="1.0" encoding="UTF-8"?>
<test>
  <hello>world</hello>
</test>

2. Paste the copied XML data into a single cell
3. copy the cell of step 2
4. paste the copied content into any editor

Actual Results:  
"<?xml version=""1.0"" encoding=""UTF-8""?>
<test>
  <hello>world</hello>
</test>"

Expected Results:
<?xml version="1.0" encoding="UTF-8"?>
<test>
  <hello>world</hello>
</test>


Reproducible: Always


User Profile Reset: No



Additional Info:
This behavior is the same under Office 365 but it is really bad user experience: What you see and copy should be what you get.

Using the 'clear' function on the cell is a workaround.


User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
Comment 1 Buovjaga 2017-11-10 14:27:34 UTC
Repro.

Problem not in 3.3, but already in 3.6

Arch Linux 64-bit, KDE Plasma 5
Version: 6.0.0.0.alpha1+
Build ID: 1aba1955f161cc112dab80b6b3e78ec7761616fc
CPU threads: 8; OS: Linux 4.13; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on November 10th 2017

Arch Linux 64-bit
LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4

Arch Linux 64-bit
Version 3.6.7.2 (Build ID: e183d5b)
Comment 2 Buovjaga 2017-11-10 14:29:28 UTC
Already in
Win 10
LibreOffice 3.5.0rc3 
Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735
Comment 3 Eike Rathke 2017-11-10 14:51:48 UTC
Seems that for multi-line text a CSV format is used (does not happen with a single line), the entire text surrounded by double quotes and inner double quotes escaped by doubling them. The same happens if *within* a cell it's pasted with Shift+Ctrl+V and unformatted text, or into Writer fwiw.

Need to investigate if there is a (good) reason for that. Seems odd at least.
Comment 4 Eike Rathke 2017-11-10 19:08:42 UTC
So apparently this is related to the fix for bug 32213 where
https://cgit.freedesktop.org/libreoffice/calc/commit/?id=cdcd262ea4aa3c3e407b14ed533e514f75de2d3a
in ScTransferObj::GetData() constructs the ScExportTextOptions with mbAddQuotes=true to maintain line breaks and proper cell distribution. That is some internal "unformatted (but CSV-like)" text and probably the reason that MS-Office does it similar.
You can't have both behaviour in one format.

The only solution is to offer two text variants to the clipboard and/or, depending on the consumer, generate one or the other, if that is possible. The problem here is that for non-in-cell paste the existing quoted format is needed, but for in-cell or external unformatted paste the non-quoted format is needed.
Comment 5 Commit Notification 2017-11-13 12:00:26 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=1568e51ff288e43b0a97257dbe3d3c81bdb1d386

SotClipboardFormatId::STRING_TSVC "Unformatted text [TSV-Calc]", tdf#113571

It will be available in 6.0.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 6 Commit Notification 2017-11-13 17:44:18 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

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

Resolves: tdf#113571 paste-special "Unformatted text [TSV-Calc]", tdf#32213

It will be available in 6.0.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 7 Commit Notification 2017-11-14 16:41:15 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=329eeefcbd65ea88f0c8c3f034d49ba73045d059

Distinguish single/multiple cell copy for plain text, tdf#113571 follow-up

It will be available in 6.0.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 8 Commit Notification 2017-11-21 15:15:22 UTC
Serge Krot committed a patch related to this issue.
It has been pushed to "master":

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

tdf#113571, tdf#32213, tdf#50746: Make "paste unformatted text"

It will be available in 6.0.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.