Bug 147279 - DDE link from Pivot Table to Writer loses CR and LF control characters
Summary: DDE link from Pivot Table to Writer loses CR and LF control characters
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.1.8.1 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-08 08:53 UTC by titanemdg
Modified: 2022-10-09 16:54 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 titanemdg 2022-02-08 08:53:23 UTC
Description:
When I do DDE link from a pivot table that cell contains CR+LF(windows) or LF(Unix)they become a space in the destination Writer document

Steps to Reproduce:
1.Create a pivot table in a sheet from a database table
2.Copy a cell that have a multi line and CR/LF (or LF unix)
3.Paste it in a Writer document as DDE link
4.Check the cell in the new table: it is flatten and CR/LF becomes a Space characters



Actual Results:
CR/LF becomes a Space character

Expected Results:
Do not modify CR/LF characters


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
If the paste is not a DDE then CR/LF are preserved. Paste in text editor preserves CR/LF
Comment 1 Mike Kaganski 2022-10-08 17:32:23 UTC
Code pointer:

This is done explicitly in ScServerObject::GetData [1]:

> aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, ' ', false ) );

No idea what could break - looks like there may be opposite expectations in some people, who prefer the current way, or maybe it's simply the code that is used in very different scenarios? Eike, do you have an idea?

[1] https://opengrok.libreoffice.org/xref/core/sc/source/ui/docshell/servobj.cxx?r=8930b1f6#195
Comment 2 Mike Kaganski 2022-10-09 15:26:00 UTC
Reading SwDDETable::ChangeContent [1], it may be even that it can't be changed at all: it seems that the format transferred over DDE is simply a text, where each table line is separated by newline, and each table cell is separated by a tab. And there's no escaping, like use of quotes in CSV.

[1] https://opengrok.libreoffice.org/xref/core/sw/source/core/fields/ddetbl.cxx?r=9fdb06d6#135
Comment 3 Mike Kaganski 2022-10-09 16:54:58 UTC
OTOH, when I enable DDE in Excel (see https://stackoverflow.com/questions/55868217), and put the following formula into a spreadsheet there:

="abc"&CHAR(9)&"def"&CHAR(13)&"ghi"

then run the following VBA from Word:

Sub DDETest()
  ch = DDEInitiate("Excel", "D:\Documents\DDETest.xlsm")
  s = DDERequest(ch, "R1C1")
  DDETerminate ch
  MsgBox s
End Sub

the text arriving from Excel is exactly

"abc	def
ghi"

including the double quotes. It actually looks to me that Excel uses normal TSV, with double quotes according to CSV standard...