Bug 104902 - unable to display chr(10) or chr(13) in a cell in calc when inserted by a macro
Summary: unable to display chr(10) or chr(13) in a cell in calc when inserted by a macro
Status: ASSIGNED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.1.4.2 release
Hardware: All All
: medium minor
Assignee: Andreas Heinisch
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-UNOAPI
  Show dependency treegraph
 
Reported: 2016-12-24 08:04 UTC by prevotmathieu
Modified: 2021-12-30 18:47 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample file (11.44 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-12-25 22:31 UTC, m.a.riosv
Details

Note You need to log in before you can comment on or make changes to this bug.
Description prevotmathieu 2016-12-24 08:04:20 UTC
On any sheet execute this macro:
****
dim document   as object
dim dispatcher as object

rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$1"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "StringName"
args2(0).Value = "123" & chr(13) & "456"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args2())
****

The A1 cell will display
123456
It should display 
123
456

Interestingly enough, the string is correctly displayed in the formula bar.
Comment 1 m.a.riosv 2016-12-25 22:31:30 UTC
Created attachment 129939 [details]
Sample file

To insert line break libreoffice calc uses chr(10) not chr(13)

https://help.libreoffice.org/Common/Inserting_Line_Breaks_in_Cells
Comment 2 prevotmathieu 2016-12-26 08:58:36 UTC
Yep, I'm aware of the use of chr(10) instead of chr(13),however that doesn't work either.

If you enter 

args2(0).Value = "123" & chr(10) & "456" 

The A1 cell will display
123456
It should display 
123
456

So I reopen the bug and change the title.
Comment 3 m.a.riosv 2016-12-26 21:02:52 UTC
Strange what is happening here.

After run the macro, editing with [F2] make visible the line break but if nothing is changed with the editing before press enter, the visualization issue remains, and saving the file the line break desappears.
But changing something like adding a space at end, makes the line break visible and it's preserver when saving.

That doesn't happend with manual or fomula line break.
Comment 4 QA Administrators 2017-12-27 03:25:13 UTC Comment hidden (obsolete)
Comment 5 prevotmathieu 2017-12-27 09:25:58 UTC
Still present

Version: 5.4.4.2 (x64)
Build ID: 2524958677847fb3bb44820e40380acbe820f960
Threads CPU : 2; OS : Windows 6.19; UI Render : par défaut; 
Locale : fr-FR (fr_FR); Calc: group
Comment 6 Buovjaga 2019-08-11 11:51:13 UTC
(In reply to m.a.riosv from comment #3)
> Strange what is happening here.
> 
> After run the macro, editing with [F2] make visible the line break but if
> nothing is changed with the editing before press enter, the visualization
> issue remains, and saving the file the line break desappears.
> But changing something like adding a space at end, makes the line break
> visible and it's preserver when saving.
> 
> That doesn't happend with manual or fomula line break.

Still repro with file

Arch Linux 64-bit
Version: 6.4.0.0.alpha0+
Build ID: 37fc9f51a8de11d40632e8cda17ccf1fa4b1f503
CPU threads: 8; OS: Linux 5.2; UI render: default; VCL: gtk3; 
Locale: fi-FI (fi_FI.UTF-8); UI-Language: en-US
Calc: threaded
Built on 6 August 2019
Comment 7 himajin100000 2019-09-22 00:38:44 UTC
Just a guess:

probably cell content is displayed as Rich Text, While Formula bar is for normal string.

When Enter Key is manually pressed with Shift key pressed, InsertLineBreak is executed. 

https://opengrok.libreoffice.org/xref/core/editeng/source/editeng/editeng.cxx?r=39214c54#1233

this sets special attribute EE_FEATURE_LINEBR

https://opengrok.libreoffice.org/xref/core/editeng/source/editeng/impedit2.cxx?r=39214c54#3031

https://opengrok.libreoffice.org/xref/core/editeng/source/editeng/editdoc.cxx?r=39214c54#345

and later this will be used to create lines.

https://opengrok.libreoffice.org/xref/core/editeng/source/editeng/impedit3.cxx?r=bb748ba4#1025

CreateLines is called from FormatDoc
https://opengrok.libreoffice.org/xref/core/vcl/source/edit/texteng.cxx?r=73e3604f#1514

and FormatDoc is called from TextEngine::ImpPaint
https://opengrok.libreoffice.org/xref/core/vcl/source/edit/texteng.cxx?r=73e3604f#1881
Comment 8 himajin100000 2019-09-22 08:14:48 UTC
Can anyone explain how "GetString converts line breaks into spaces in EditCell"?
I was unable to understand mainly due to lack of my brain ability.

https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/cellform.cxx?r=fce7c123#162
Comment 9 QA Administrators 2021-09-22 03:37:44 UTC
Dear prevotmathieu,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug