Bug 136034 - Page margin change substantially after DOCX export
Summary: Page margin change substantially after DOCX export
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected) release
Hardware: All All
: medium normal
Assignee: Not Assigned
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-Page
  Show dependency treegraph
Reported: 2020-08-23 07:55 UTC by Telesto
Modified: 2022-08-25 03:43 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:

Example file (15.96 KB, application/vnd.oasis.opendocument.text)
2020-08-23 07:55 UTC, Telesto
Bibisect log (3.80 KB, text/plain)
2020-08-23 09:37 UTC, Telesto
Screenshot of the problem in Writer (93.96 KB, image/png)
2020-08-24 08:41 UTC, NISZ LibreOffice Team
Screenshot of the original and exported document side by side in Word and Writer (116.36 KB, image/png)
2020-08-24 08:43 UTC, NISZ LibreOffice Team

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2020-08-23 07:55:33 UTC
Page margin change substantially after DOCX export

Steps to Reproduce:
1. open the attached file
2. Select page 2 -> Format page style -> Page tab. look at the margins (top/bottom)
3. Cancel
4. Save as DOCX
5. File reload
6. Select page 2 -> Format page style -> Page tab. look at the margins (top/bottom)

Actual Results:

Expected Results:
0,85/0,74 cm

Reproducible: Always

User Profile Reset: No

Additional Info:
Found in


not in
Build ID: 8a35821d8636a03b8bf4e15b48f59794652c68ba
Comment 1 Telesto 2020-08-23 07:55:46 UTC
Created attachment 164582 [details]
Example file
Comment 2 Telesto 2020-08-23 08:09:47 UTC
Adding you to keep you up to speed, as I used one of you're samples. I you do export to DOCX, so you might have noticed this already..
Comment 3 Luke Kendall 2020-08-23 09:21:29 UTC
I had only noticed it subconsciously.
Luckily for my use cases the conversion is only for input into Calibre for ebook conversion, as it handles .docx far better than .odt (the Calibre developer told me, 5 or so years ago).
Comment 4 Telesto 2020-08-23 09:37:30 UTC
Created attachment 164585 [details]
Bibisect log

commit bde13d042da331626c09db3a2b104cdd7cb5bda1
Author: Matthew Francis <mjay.francis@gmail.com>
Date:   Sat Sep 5 20:43:13 2015 +0800

    commit 196328c91ee889a0a1cbc39ce2549c7405afbef5
    Author:     Adam Co <rattles2013@gmail.com>
    AuthorDate: Tue Aug 20 18:27:41 2013 +0300
    Commit:     Caolán McNamara <caolanm@redhat.com>
    CommitDate: Fri Aug 30 15:56:57 2013 +0000
        fix for IsPlausibleSingleWordSection checking wrong condition
        Change-Id: I503e5944079b6c03413caea27ef940efbd44ced5
        Reviewed-on: https://gerrit.libreoffice.org/5548
        Reviewed-by: Caolán McNamara <caolanm@redhat.com>
        Tested-by: Caolán McNamara <caolanm@redhat.com>

Comment 5 Telesto 2020-08-23 09:40:00 UTC
Reading comment 3 opportunistically as confirmation (to reduce open bug numbers for QA; and me waiting)
Comment 6 Telesto 2020-08-23 09:53:48 UTC
Sorry to bother again :P. You're on top the list for DOCX. Next NISZ. I assume Adam not being around any longer.. in search for someone else who might can take a look/peek at this, some rainy day. 

Regression of the page dimensions started with identified commit. Which created a mess. Improved again between 5.0 - 6.1 (and is this state also in 7.1)
Comment 7 NISZ LibreOffice Team 2020-08-24 08:41:42 UTC
Created attachment 164624 [details]
Screenshot of the problem in Writer

Header/footer values are indeed doubled.
Comment 8 NISZ LibreOffice Team 2020-08-24 08:43:38 UTC
Created attachment 164625 [details]
Screenshot of the original and exported document side by side in Word and Writer

Writer says there is no header/footer originally, but Word says there is and sees the top/bottom margins as header/footer sizes in the exported docx.
Comment 9 Telesto 2020-08-24 09:09:51 UTC
Bug 136065 rather similar; except it shows 0 cm for top/bottom after DOCX export (I don't notice much difference comparing ODT/DOCX visually in that case)
Comment 10 Justin L 2020-08-24 09:50:16 UTC
This is all dealing with emulation of page style flow, so a tricky area. I would say it was just coincidence that it worked prior to Adam's commit.

This looks like an export bug. There are only two w:sectPr's in this document. So page two starts with the second sectPr which defines the top/bottom margin for the rest of the document.

But this is really tricky, because there is no page-break at the end of page 2, and yet there needs to be a section change at that point. The only way this can work in Word is to have a continuous break, since the different margins prevent it from being treated as a single section. But continuous breaks cannot be read by LO well, so we definitely should not be exporting them at this point. (see comments on gerrit proposal https://gerrit.libreoffice.org/c/core/+/100662)

The following commit might help the situation if Adam's commit would be reverted, so that these two pages would not be considered as a plausible single section. But as the gerrit patch shows, Adam's patch is also under contention.
LO 6.1 commit c1d58c46eec5081576979f584151c7e9a4f67fe0
Author: Tamas Bunth <tamas.bunth@collabora.co.uk>
Date:   Fri Dec 1 14:58:17 2017 +0100
    tdf#41650 DOCX export: split para on section break
    Given two pages with entirely different style (resp. not plausible for a
    single section) and a paragraph which starts on the first page and has a
    follow on the second.
    Those page styles are represented in doc/docx structure with sections.
    Doc/Docx does not support having a paragraph in more than one sections.
    Workaround is to split the paragraph into more paragraphs and put the
    section break in between.

[In order for this document to be more compatible, it should use first/even/odd in a single section instead of starting with a separate page style.]
Comment 11 QA Administrators 2022-08-25 03:43:41 UTC Comment hidden (spam)