Bug 114501 - The text/html representation of paragraph styles should explicitly set margin-top: 0, if no spacing above paragraph has been defined
Summary: The text/html representation of paragraph styles should explicitly set margin...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.3.4.2 release
Hardware: x86 (IA32) All
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Clipboard
  Show dependency treegraph
 
Reported: 2017-12-16 18:39 UTC by tbreportbug
Modified: 2023-03-07 04:18 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file (8.86 KB, application/vnd.oasis.opendocument.text)
2017-12-26 17:50 UTC, Buovjaga
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tbreportbug 2017-12-16 18:39:07 UTC
Description:
Copy pasting from OpenOffice/LibreOffice with default formatting, to Thunderbird Mail Composer will ruin the formatting in the Thunderbird Mail Composer. This happens even if the user has unchecked the option "Use Paragraph format instead of Body Text by default" from Thunderird.

Steps to Reproduce:
1. Write text in OpenOffice or Libreoffice with default formatting (line spacing is 1). Select this text and press CTRL+C.
2. Open Thunderbird and go to Preferences -> Composition. From here uncheck the box "Use Paragraph format instead of Body Text by default". Press close.
3. Open Thunderbird and press the Write button to open a new window to write an email.
4. Paste the text you copied from OpenOffice/Libreoffice to this "Write window" of Thunderbird.

Actual Results:  
The formatting of the pasted text is now ruined, because it is paragraph formatted (it should not be). Also if I select all of the text, and change from "Paragraph" to "Body Text", it does not change the formatting the way it should be. 

Expected Results:
By pasting text from OpenOffice/LibreOffice to Thunderbird, the formatting should stay the same, just like it was in the original OpenOffice/LibreOffice file. (And not change into paragraph formatting.)


Reproducible: Always


User Profile Reset: No



Additional Info:
I posted similar problem into BugZilla.Mozilla:

https://bugzilla.mozilla.org/show_bug.cgi?id=1425661

Also similar kind of issue might be with Word:

https://support.mozilla.org/fi/questions/1173599

Help - About LibreOffice

Version: 5.3.4.2
Build ID: f82d347ccc0be322489bf7da61d7e4ad13fe2ff3
CPU Threads: 2; OS Version: Windows 6.0; UI Render: default; Layout Engine: new; 
Locale: fi-FI (fi_FI); Calc: group


User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:52.0) Gecko/20100101 Firefox/52.0
Comment 1 Jean-Baptiste Faure 2017-12-17 22:33:49 UTC
I do not understand your bug description:
1/ what do you mean by "the formating is ruined", please give an exhaustive example: an odt test file, instruction for what part of text must be copied and pasted, what you see in the compose window of Thunderbird and what you should see in the same window.

2/ why do you think that the problem (if there is a problem) is on LibreOffice side and not on Thunderbird side?

Set status to NEEDINFO, please set it back to UNCONFIRMED once requested
informations are provided.

Best regards. JBF
Comment 2 tbreportbug 2017-12-23 19:53:50 UTC
(In reply to Jean-Baptiste Faure from comment #1)
> I do not understand your bug description:
> 1/ what do you mean by "the formating is ruined", please give an exhaustive
> example: an odt test file, instruction for what part of text must be copied
> and pasted, what you see in the compose window of Thunderbird and what you
> should see in the same window.
> 
> 2/ why do you think that the problem (if there is a problem) is on
> LibreOffice side and not on Thunderbird side?
> 
> Set status to NEEDINFO, please set it back to UNCONFIRMED once requested
> informations are provided.
> 
> Best regards. JBF

You can use this service to try out what happens in Thunderbird, because the exact same thing happens in Thunderbird:
https://www-archive.mozilla.org/editor/midasdemo/

Here is a text file you can try called "paste_this_into_thunderbird.odt":
https://ufile.io/u0dpy

That file has been uploaded into the service https://uploadfiles.io/ and it only contains this (not including /START and /END):

/START
Text here

Text here

Text here

Text here

Text here

Text here

Text
Text
Text
Text
End.
/END

When you paste this text from LibreOffice into Thunderbird (or that "midasdemo" website linked up there), you see that the formatting gets ruined. In this case meaning that there is a lot more paragraph spacing above and below each paragraph.

So if I type these "keystrokes" on my keyboard in Thunderbird:

*press A-key*
*press J-key*
*press ENTER-key*
*press ENTER-key*
*press A-key*

And then I type in LibreOffice these exact same "keystrokes":

*press A-key*
*press J-key*
*press ENTER-key*
*press ENTER-key*
*press A-key*

Then these both messages look visually exactly the same. But now, if I paste that particular text from LibreOffice to Thunderbird, then that message looks different from the one I typed in Thunderbird itself. So the text got ruined during this pasting process.

When a user writes text inside either of these programs (Thunderbird and LibreOffice), then the ENTER-key behaves in the exact same way in both of the programs, producing the exact same result. But if the user then pastes from LibreOffice to Thunderbird, then that formatting of the pasted text gets ruined. This is not logical at all. The ENTER-key has the work the same way in all of these very common and useful programs, and copy-pasting just cannot ruin that logic.

Well then you suggest: Paste Without Formatting? No, this is not a proper solution at all. Let's say I have a text (written in OpenOffice/LibreOffice) that is 3000 words long and includes: 30 links, texts that are bolded, unordered lists etc. And I wish to send this text to 20 different people. And I want to change the introduction of the text slightly for all these different people. I just cannot "Paste Without Formatting", because it requires tremendous work to get that formatting then correct.
Comment 3 Buovjaga 2017-12-26 17:50:55 UTC
Created attachment 138659 [details]
Example file
Comment 4 Buovjaga 2017-12-26 17:59:39 UTC Comment hidden (obsolete)
Comment 5 tbreportbug 2019-02-01 19:40:09 UTC
(In reply to Buovjaga from comment #4)
> (In reply to tbreportbug from comment #2)
> > When you paste this text from LibreOffice into Thunderbird (or that
> > "midasdemo" website linked up there), you see that the formatting gets
> > ruined. In this case meaning that there is a lot more paragraph spacing
> > above and below each paragraph.
> 
> That's not the fault of LibreOffice, now is it?
> 
> If you look at the source of the Midas demo after pasting the stuff in, you
> see that inside every empty paragraph they have added a break element.
> Deleting these elements make for a sane line spacing.

The Midas demo does not add additional break elements. It is the LibreOffice that is adding additional paragraph elements!

You can test this by going into LibreOffice, and then export (using Save As...) the document as HTML. So exporting out you get this:

<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">End.</p>


But exporting SHOULD give something like this, to make it render properly in Firefox and Thunderbird:

<p style="margin-bottom: 0cm; line-height: 100%">Text here<br/>
<br/>
Text
here<br/>
<br/>
Text here<br/>
<br/>
Text here<br/>
<br/>
Text
here<br/>
<br/>
Text here<br/>
<br/>
Text<br/>
Text<br/>
Text<br/>
Text<br/>
End.</p>

The problem seems to be obviously with LibreOffice!

Can we now please get this fixed? This problem is completely ruining the usage of Thunderbird!
Comment 6 tbreportbug 2019-02-01 19:52:01 UTC
And using find & replace does not work in LibreOffice. I tried to replaces all $ (new paragraph) with \n (new line break) but this does NOT replace those $ symbols, even though the tool CLAIMS that it changed many entries.
Comment 7 tbreportbug 2019-02-01 20:03:11 UTC
(In reply to tbreportbug from comment #6)
> And using find & replace does not work in LibreOffice. I tried to replaces
> all $ (new paragraph) with \n (new line break) but this does NOT replace
> those $ symbols, even though the tool CLAIMS that it changed many entries.

And even if I use this "trick" (https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=67679#p301299):

START_QUOTE
Enter a line break normally and copy it to the clipboard

Edit > Find & Replace
Search for: $
Options/Regular expressions: ON
Click "Find All"

Edit > Paste
/END_QUOTE

to replace all $ signs, then all of my indentations and unordered list formattings will be ruined in the process.

So using find & replace will not solve this issue.
Comment 8 tbreportbug 2019-02-01 20:20:17 UTC
Currently this is what is EXPORTED from LibreOffice:

<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">End.</p>



One solution would be to make LibreOffice export (and I presume then normal CTRL+C and CTRL+V will work as desired) the above mentioned HTML like this:

<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%; margin-top: 0cm">End.</p>


To reiterate, the problem with the current system seems to be:

1) Paragraphs have default margin-top value. The margin-top value should be 0cm!
Comment 9 Buovjaga 2019-02-01 22:36:44 UTC
Apologies, the <br/> elements inside the empty paragraphs are inserted by LibreOffice. Confirmed by running this command in Linux after copying the text from LibreOffice:
xclip -selection clipboard -o -t text/html

(In reply to tbreportbug from comment #8)
> To reiterate, the problem with the current system seems to be:
> 
> 1) Paragraphs have default margin-top value. The margin-top value should be
> 0cm!

From what I am seeing, if the paragraphs have a default margin-top value, it is not assigned in LibreOffice, but Thunderbird.

Indeed, Richard Marti in the Thunderbird report says: "From toolkit html.css a margin-block-start: 1em; is applied as default for <p>. You'd need also a margin-top: 0 to remove all space above the <p>."

If I look at the styles in Firefox dev tools, I can see the 16px margin-top for the paragraphs in *browser styles*, so this is something the browser (or Thunderbird) is applying.

It's late and I have to think about this more tomorrow. I don't really have a clear picture of what should be done or what would be the perfect result.

For reference, I will include below the clipboard text/html contents from LibreOffice.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title></title>
        <meta name="generator" content="LibreOffice 6.1.4.2 (Linux)"/>
        <style type="text/css">
                @page { size: 21.59cm 27.94cm; margin: 2cm }
                p { margin-bottom: 0.25cm; line-height: 120%; background: transparent }
        </style>
</head>
<body lang="fi-FI" link="#000080" vlink="#800000" dir="ltr"><p style="margin-bottom: 0cm; line-height: 100%">
Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text here</p>
<p style="margin-bottom: 0cm; line-height: 100%"><br/>

</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">Text</p>
<p style="margin-bottom: 0cm; line-height: 100%">End.</p>
</body>
Comment 10 Buovjaga 2019-02-02 20:35:11 UTC
Ok, so having margin-top: 1em for paragraphs is an established practice in browser rendering. Setting the property to 0 does make the formatting mimic the one seen in LibreOffice.

Furthermore, if no spacing above or below and no indentation is set for a paragraph, the shortest rule would be just margin: 0.

Setting to NEW.
Comment 11 QA Administrators 2021-03-06 03:45:10 UTC Comment hidden (obsolete)
Comment 12 QA Administrators 2023-03-07 04:18:10 UTC
Dear tbreportbug,

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://web.libera.chat/?settings=#libreoffice-qa

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

Warm Regards,
QA Team

MassPing-UntouchedBug