Bug 114398 - Calc, on reopen, messes up soft newlines pasted from RichText format (comment 5)
Summary: Calc, on reopen, messes up soft newlines pasted from RichText format (comment 5)
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:24.8.0
Keywords:
Depends on:
Blocks: Calc-Cells
  Show dependency treegraph
 
Reported: 2017-12-10 23:28 UTC by Hernan
Modified: 2024-05-31 13:42 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
f2Newline.ods: source for RTF copy/paste using Writer (10.78 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-05-30 13:35 UTC, Justin L
Details

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
Description:
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
Version: 6.1.0.0.alpha0+
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.
Comment 3 Justin L 2022-09-20 15:17:21 UTC
I think this is probably a duplicate of bug 103829, and thus should be fixed in LO 7.5 (where text:line-break is now both imported and exported again).
Comment 4 Buovjaga 2022-09-22 14:24:23 UTC
(In reply to Justin L from comment #3)
> I think this is probably a duplicate of bug 103829, and thus should be fixed
> in LO 7.5 (where text:line-break is now both imported and exported again).

Yes, it is fixed, thanks for notifying.

Version: 7.5.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 00c5b0ca9264c5440bc70a68c425127ba5a47003
CPU threads: 2; OS: Windows 10.0 Build 19044; UI render: default; VCL: win
Locale: fi-FI (fi_FI); UI: en-US
Calc: threaded Jumbo

*** This bug has been marked as a duplicate of bug 103829 ***
Comment 5 Andreas Heinisch 2023-04-10 20:26:59 UTC
Changed to new due to:
https://www.youtube.com/watch?v=MIgLmpuKnoM

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 first the following list using the commands in the brackets:
    LINE 1 (ENTER)
    LINE 2 (SHIFT+ENTER)
    LINE 3 (ENTER)
    LINE 4 (SHIFT+ENTER)
    LINE 5

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. 

Result: all soft newlines are gone. They are not even replaced by spaces, the original lines are joined together (a mess).
Comment 6 Justin L 2024-05-30 13:35:04 UTC
Created attachment 194459 [details]
f2Newline.ods: source for RTF copy/paste using Writer

repro 24.8+

Steps to reproduce.
1.) Open f2Newline.ods in Writer, select all (Ctrl-A) and copy (Ctrl-C)
2.) start a new Calc document
3.) press F2 to enter edit mode (VERY IMPORTANT)
4.) paste special (shift-Ctrl-V) Rich text formatting. [regular paste works too]
5.) save as ODS format
6.) reload
Comment 7 Commit Notification 2024-05-31 13:28:35 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/068befc95ab8d7c368e76f08447827dbdea21014

tdf#114398 ods export: output <text:line-break/> when CELLTYPE_EDIT

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.