Bug 166305 - FILESAVE DOCX Left page with big margin incorrectly saved
Summary: FILESAVE DOCX Left page with big margin incorrectly saved
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.1.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:26.2.0
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-Page Writer-Styles-Page-Odd-Even
  Show dependency treegraph
 
Reported: 2025-04-23 09:59 UTC by Gabor Kelemen (allotropia)
Modified: 2025-06-19 16:35 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
The example file saved as docx with patch of the bug 165083 (7.65 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-04-23 09:59 UTC, Gabor Kelemen (allotropia)
Details
The original file in Writer and the docx in Word after the patch (79.15 KB, image/png)
2025-04-23 09:59 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2025-04-23 09:59:05 UTC
Created attachment 200465 [details]
The example file saved as docx with patch of the bug 165083

This is a followup to bug 165083

When attachment 199019 [details] - after fixing above bug with https://gerrit.libreoffice.org/c/core/+/183146/2 but also before the regression causing it - is saved as docx and reloaded in Word or Writer, the second pages large left margin appears on the right side of the page.

1. Open attachment 199019 [details] 
2. Save as docx
3. Reload
-> the second pages large margin is on the right side instead of left

The first pages large margin is correctly on the right side, this is fixed with the above patch. Second page was okay-ish before the patch, now it is back to the previously incorrect state.


This seems to have started first in 7.1 with:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=5a234ba7f02660ab770f2744d0b936e5607ddafe

author	Justin Luth <justin.luth@collabora.com>	2020-08-28 15:00:48 +0300
committer	Justin Luth <justin_luth@sil.org>	2020-09-24 19:18:31 +0200
commit 5a234ba7f02660ab770f2744d0b936e5607ddafe (patch)

tdf#132149 ww8export: use left page properties for left style

Before in 7.0 the large margins were on the correct side on both pages.
Comment 1 Gabor Kelemen (allotropia) 2025-04-23 09:59:39 UTC
Created attachment 200466 [details]
The original file in Writer and the docx in Word after the patch
Comment 2 Mateusz Wlazłowski 2025-04-25 20:44:33 UTC
Can confirm


Version: 25.2.2.2 (X86_64) / LibreOffice Community
Build ID: 7370d4be9e3cf6031a51beef54ff3bda878e3fac
CPU threads: 8; OS: Linux 6.11; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Flatpak
Calc: threaded
Comment 3 Justin L 2025-06-18 19:24:36 UTC
At first glance my example document (132149_pgBreak3.odt - which is attachment 164711 [details] from bug 132149 comment 13) is almost identical to this bug's bigMargins.odt.

However the key difference is the default page style (which is not even used in both cases). 
-bigMargins.odt has a "Mirrored" default page style, and therefore writes <w:mirrorMargins/> in settings.xml.
-132149_pgBreak3.odt has a "Right and Left" page layout which doesn't trigger any settings.xml change.

And indeed, prior to my comment 0 change, when we import the round-tripped bigMarginsRT.docx, we didn't get a left page with a 7.62cm left margin, we got a 10cm left margin (from the right-page settings).

With comment 0's commit, the margin is now correctly 7.62 cm - it just got swapped during import because of that settings flag.

Oliver's code that he reverted in bug 165083 looks mostly correct. I think that the problem is just that "CurrentSection" does not seem to be very accurate...
Comment 4 Commit Notification 2025-06-19 12:38:25 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/a4e7d0028efb8fa07d0877aff81fb406f9464fb4

tdf#161521 tdf#166305 docx export: fix page margins when mirrorMargins

It will be available in 26.2.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.