Bug 114398 - Calc, on reopen, messes up soft newlines pasted from RichText format
Summary: Calc, on reopen, messes up soft newlines pasted from RichText format
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
(earliest affected) release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
Depends on:
Reported: 2017-12-10 23:28 UTC by Hernan
Modified: 2021-12-30 13:58 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:
Regression By:


Note You need to log in before you can comment on or make changes to this bug.
Description Hernan 2017-12-10 23:28:40 UTC
When copying a multiline text inside a Cell in Calc, in edit mode, if the text is available in the Clipboard as Rich TExt Format and it contains soft newlines (Shift-Enter), then the newlines are correctly shown in Calc. but after closing and reopening they are lost, and the lines are all joined together (nor even a blank/space to separate them).

See steps for detail.

It might not a big deal that "importing" loses some formatting. But 1) this is more than formatting,  2) it looks very bad and unsettling that something looks ok when working with the document, and when you save and reopen you get something radically different.

Steps to Reproduce:
1. Open a new Calc Spreadsheet . Enlarge the first cell, say to half the window width and height.

2. Open Windows Wordpad (or some editor that copies in RichTextFormat) (*)
Type several lines separated not by hard end-of-paragraph newlines (Enter) but instead by soft line-breaks (Shift+Enter) (**)

3. Select those lines, copy to clipboard (Ctrl-C)

4. In Calc, focus in the big cell in edit mode (F2), and paste from the clipboard (Ctrl-V)

5.  All should look basically ok (also if we switch to another cell, sheet, document, etc). Close Calc, saving the file.

6. Open the saved document. 

[*] I experienced this with a programmers text editor (EditPadPro) that, as a bonus, copies the text also as rich text format.

[**] these in RTF correspond to \line commands

Actual Results:  
Result: all newlines are gone. They are not even replaced by spaces, the original lines are joined together (a mess).

Expected Results:
Lines should be lines. As were shown originally when copied inside Calc.

Reproducible: Always

User Profile Reset: No

Additional Info:

User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36
Comment 1 Buovjaga 2017-12-19 14:39:49 UTC
I reproduced (using Writer to produce the text), but I found bug 89920 which is essentially about the same root cause. I confirmed saving to XLSX preserves the line breaks.

Arch Linux 64-bit
Build ID: c3764c6848bd5ce0bbea2a82bedc3f0d55f01dce
CPU threads: 8; OS: Linux 4.14; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group threaded
Built on December 19th 2017

*** This bug has been marked as a duplicate of bug 89920 ***
Comment 2 Andreas Heinisch 2021-12-30 13:32:21 UTC
If I execute the macro:

    Sub Main

    my_cell = ThisComponent.Sheets(0).getCellByPosition(0,0)
    my_cell.String = "aa bb" + chr(10) + "cc dd"

    End Sub

Then I end up in [1] where simpy the AdjustRowHeight is missing. Imho, bug 114398 is not a duplicate of this one, since it ends in [2] where no string or edit cell is set.

[1] https://opengrok.libreoffice.org/xref/core/sc/source/ui/docshell/docfunc.cxx?r=a23a7eea&mo=40925&fi=1270#1270
[2] https://opengrok.libreoffice.org/xref/core/sc/source/ui/view/viewfunc.cxx?r=ec1c4c49&mo=19813&fi=566#566

I set it to NEW then.