Bug 145716 - Saving document as Word (docx) does not preserve paragraph space above/below correctly
Summary: Saving document as Word (docx) does not preserve paragraph space above/below ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: low minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:docx
: 146983 (view as bug list)
Depends on:
Blocks: DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2021-11-16 12:55 UTC by Matthew Kogan
Modified: 2023-12-11 14:01 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
test.odt (8.76 KB, application/vnd.oasis.opendocument.text)
2021-11-17 14:11 UTC, Kevin Suo
Details
test.docx (saved from test.odt) (4.34 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-11-17 14:12 UTC, Kevin Suo
Details
side-by-side comparison in Writer (116.67 KB, image/png)
2021-11-17 14:13 UTC, Kevin Suo
Details
The example file saved as doc format in Writer and the original odt (45.05 KB, image/png)
2023-12-08 22:51 UTC, Gabor Kelemen (allotropia)
Details
The doc and docx versions in Word, plus the doc converted to docx (86.55 KB, image/png)
2023-12-08 22:54 UTC, Gabor Kelemen (allotropia)
Details
Layout options of the doc version in Word (48.98 KB, image/png)
2023-12-08 22:55 UTC, Gabor Kelemen (allotropia)
Details
The docx version in Word after enabling the HTML paragraph auto spacing thingy (80.30 KB, image/png)
2023-12-08 23:10 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Kogan 2021-11-16 12:55:59 UTC
Description:
Word interprets space above/below differently to Writer, so paragraph spacing looks different after saving to docx and opening in Word.

Steps to Reproduce:
1. In Writer, add 3 paragraphs of text and set their space above and below to 1cm.
2. Save as docx.
3. Open docx file in Word.

Actual Results:
The paragraphs have 1cm between them.

Expected Results:
The paragraphs should have 2cm between them, as they do in Writer.


Reproducible: Always


User Profile Reset: No



Additional Info:
It should compensate for the different interpretation so that it looks the same in Word.
Comment 1 Kevin Suo 2021-11-17 14:11:38 UTC
Created attachment 176311 [details]
test.odt
Comment 2 Kevin Suo 2021-11-17 14:12:06 UTC
Created attachment 176312 [details]
test.docx (saved from test.odt)
Comment 3 Kevin Suo 2021-11-17 14:13:53 UTC
Created attachment 176313 [details]
side-by-side comparison in Writer

You even do not need to open that docx in Word. Open that in Writer already shows indirect paragraph spacing.

Confirmed in
Version: 7.3.0.0.alpha1+ / LibreOffice Community
Build ID: 35d9d085436e159bdeb6cba9c94865d6346af530
CPU threads: 8; OS: Linux 5.14; UI render: default; VCL: gtk3
Locale: zh-CN (zh_CN.UTF-8); UI: zh-CN
Calc: threaded
Fedora 34.

Set to NEW.
Comment 4 Kevin Suo 2021-11-17 14:19:49 UTC
Also reproducible in
Version: 6.0.0.0.alpha1+
Build ID: 6eeac3539ea4cac32d126c5e24141f262eb5a4d9
CPU threads: 8; OS: Linux 5.14; UI render: default; VCL: gtk3; 
Locale: zh-CN (zh_CN.UTF-8); Calc: group threaded
Comment 5 Justin L 2022-09-06 17:32:34 UTC
*** Bug 146983 has been marked as a duplicate of this bug. ***
Comment 6 Justin L 2023-05-16 01:04:21 UTC
repro 7.6+
Also repro that when saving to .doc format, the gap is 2cm.

repro that MS Word 2010 looks identical for both doc and docx.

While I can sympathize with the desire that ODT should massage the data to export pixel perfect into DOCX format, the reality will be very different in cases where there are compatibility flags, especially when DOC is different.

The solution is easy - fix the layout once after switching formats and move on.
Comment 7 Gabor Kelemen (allotropia) 2023-12-08 22:51:46 UTC
Created attachment 191325 [details]
The example file saved as doc format in Writer and the original odt

So I did a bit of research into this, and looks like the doc export actually looks the same in Writer as the odt one.
Comment 8 Gabor Kelemen (allotropia) 2023-12-08 22:54:28 UTC
Created attachment 191326 [details]
The doc and docx versions in Word, plus the doc converted to docx

The doc version also looks good in Word (somehow my Word 2016 hides the last paragraph, but 2010 does not - odd), and this good look stays if I convert it to docx with Word.
Comment 9 Gabor Kelemen (allotropia) 2023-12-08 22:55:27 UTC
Created attachment 191327 [details]
Layout options of the doc version in Word

Curiously the doc version has several layout options enabled according to Word, while the docx version has none.
Comment 10 Gabor Kelemen (allotropia) 2023-12-08 23:10:23 UTC
Created attachment 191328 [details]
The docx version in Word after enabling the HTML paragraph auto spacing thingy

And a bit of experimenting resulted in this: the "Don't use HTML paragraph auto spacing" option (whatever this means) is the key to preserving the numbered paragraphs spacing in MSO formats.

So we need to automatically add the compat option: <w:doNotUseHTMLParagraphAutoSpacing/>

Interestingly saving the example file in RTF format also keeps the layout both in Writer and Word. Looking into the specification there is the \htmautsp keyword to Use HTML paragraph auto spacing which is missing from the export - perhaps a lucky coincidence.
Comment 11 Justin L 2023-12-10 12:41:00 UTC
(In reply to Gabor Kelemen (allotropia) from comment #8)
> somehow my Word 2016 hides the last paragraph, but 2010 does not - odd)
That's bug 108772
Comment 12 Matthew Kogan 2023-12-11 14:01:53 UTC
Thank you - I can confirm that setting this compat option does fix it for me too. Here's the documentation for it:
https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.donotusehtmlparagraphautospacing?view=openxml-2.8.1
I'd be delighted if you could implement this.