Bug 159052

Summary: Line break '\n' is changed to '\r\n' when copy text from shape
Product: LibreOffice Reporter: Regina Henschel <rb.henschel>
Component: WriterAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: normal CC: buzea.bogdan, ilmari.lauhakangas, telesto
Priority: medium    
Version: Inherited From OOo   
Hardware: All   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 161022    
Attachments: Example for testing

Description Regina Henschel 2024-01-06 23:46:51 UTC
Created attachment 191791 [details]
Example for testing

Open attached document. It has a shape with text. The text has a line break (shift+enter) between first and second line. To make this distinguishable from a paragraph end (enter), the paragraphs in the shape and in the text are set to 5mm for paragraph distance after.

Bring the shape to edit mode, then mark the complete shape text and copy it to clipboard. Leave the shape and paste the clipboard to the text in the document. Use the format "unformatted text" for pasting.

Error: The line break before the word 'here' is turned into a paragraph end.

The error happens when copying to clipboard. When you use a clipboard viewer (e.g. FreeClipViewer) you can see, that the characters between the words 'break' and 'here' are 0D 0A, but it should be 0A.

There are two reasons:
With the change from commit 5f6e5cb6 the paragraph end is set to LINEEND_LF in https://opengrok.libreoffice.org/xref/core/editeng/source/editeng/impedit2.cxx?r=5f6e5cb6#277. That has the effect, that '/n' is replaced with '/r/n'. I think, that changing line#277 to use GetSystemLineEnd() instead of LINEEND_LF is necessary. But that alone does not fix the error.

The next problematic part is in https://opengrok.libreoffice.org/xref/core/tools/source/stream/stream.cxx?r=2b4094195#1856
Even if the incoming string in rIn has correctly '/n' between the words and parameter eLineEnd has the (for me correct) '/r/n', the line break '/n' is converted to a paragraph end '/r/n' in the tmpl_convertLineEnd() method.

But because I don't know what is needed for other OS than Windows, I will not touch the code there.

I see the problem already in OOo2.3.1, so inherited.
Comment 1 Buovjaga 2024-01-18 18:30:59 UTC
Repro with document

Arch Linux 64-bit, X11
Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 950af5a45723d16cc5e91324f021a2e77470f2ce
CPU threads: 8; OS: Linux 6.7; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 18 January 2024