Bug 119952

Summary: FILEOPEN Negative margins coming from Word are not handled
Product: LibreOffice Reporter: Aron Budea <aron.budea>
Component: WriterAssignee: Attila Szűcs <attila.szucs>
Status: VERIFIED FIXED    
Severity: normal CC: 79045_79045, jluth, lduchon, roelandboie
Priority: medium Keywords: filter:docx
Version: Inherited From OOo   
Hardware: All   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=95374
https://bugs.documentfoundation.org/show_bug.cgi?id=120113
https://bugs.documentfoundation.org/show_bug.cgi?id=143384
https://bugs.documentfoundation.org/show_bug.cgi?id=149563
https://bugs.documentfoundation.org/show_bug.cgi?id=149564
Whiteboard: target:7.3.0 target:7.2.0.0.beta2
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 108771    
Attachments: Sample DOCX
Screenshot in Word
Sample DOCX compared MSO LO

Description Aron Budea 2018-09-18 09:03:09 UTC
Created attachment 144973 [details]
Sample DOCX

The attached DOCX has top and bottom margin set to -2" and -1.5" respectively, with some header/footer text. As far as I can see Word treats this as the non-negative value.

In Writer the header/footer aren't shown. After saving, the margins are set to unexpected values, though at least the header/footer text becomes visible.

Observed using LO 6.1.1.2 & 3.3.0 / Windows 7.
In 5.2.0.4 the header/footer are still visible on open (not in 5.3.0.3), though the margins are still incorrect. This change could be bibisected.
Comment 1 Aron Budea 2018-09-18 09:05:55 UTC
Created attachment 144974 [details]
Screenshot in Word
Comment 2 Mike Kaganski 2018-09-18 09:59:04 UTC
Relevant spec:

ECMA-376-1:2016 17.6.11 pgMar (Page Margins)

> A negative value indicates that the contents of the main document shall be measured
> from the bottom of the page extent regardless of the footer for that document, and
> therefore shall overlap the footer text.

A code pointer: SectionPropertyMap::PrepareHeaderFooterProperties (writerfilter/source/dmapper/PropertyMap.cxx)
Comment 3 Mike Kaganski 2018-09-18 10:45:42 UTC
Ww8 implementation for reference: wwSectionManager::SetPageULSpaceItems in sw/source/filter/ww8/ww8par6.cxx
Comment 4 Aron Budea 2018-09-18 16:35:10 UTC
(In reply to Aron Budea from comment #0)
> In 5.2.0.4 the header/footer are still visible on open (not in 5.3.0.3),
> though the margins are still incorrect. This change could be bibisected.
Here's the result with bibisect-linux-64-5.3. Seems unrelated, but apparently an exception is triggered somewhere.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=bdd4a238a1d8a0cbbebbd759011050659668f92b
author		Justin Luth <justin_luth@sil.org>	2016-09-09 12:42:55 +0300
committer	Justin Luth <justin_luth@sil.org>	2016-09-09 12:54:23 +0000

tdf#86926 writerfilter allow fallback if exceptions
Comment 5 Mike Kaganski 2018-09-18 21:36:52 UTC
I believe that there's no need in the bisecting, because there's a need to reimplement the function, and that fixes all this at once. The "regression" part is simply some coincidence.

I created a quick attempt: https://gerrit.libreoffice.org/60730. It is not complete, and I don't plan to continue it ATM. Feel free to continue based on it. Its problems are mentioned in the commit message.
Comment 6 Timur 2019-09-17 14:24:18 UTC
Created attachment 154232 [details]
Sample DOCX compared MSO LO
Comment 7 Timur 2019-09-17 14:24:34 UTC
*** Bug 118489 has been marked as a duplicate of this bug. ***
Comment 8 Commit Notification 2021-07-02 13:09:08 UTC
Attila Szűcs committed a patch related to this issue.
It has been pushed to "master":

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

tdf#119952 DOCX import: fix negative page margins

It will be available in 7.3.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.
Comment 9 Commit Notification 2021-07-05 10:27:13 UTC
Attila Szűcs committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/11c61e5f0544966f3901c8fb4270bb07424942f1

tdf#119952 DOCX import: fix negative page margins

It will be available in 7.2.0.0.beta2.

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.
Comment 10 NISZ LibreOffice Team 2021-07-06 09:18:27 UTC
Verified in: 

Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: bd2f2273d83dcca43eb6b465308707efd45e7adf
CPU threads: 4; OS: Windows 10.0 Build 17134; UI render: default; VCL: win
Locale: hu-HU (hu_HU); UI: hu-HU
Calc: threaded
Comment 11 Timur 2021-07-06 14:07:54 UTC
Thanks for fixing and verification. It should confirm that duplicate is also tested as resolved (I cannot do it myself).
Comment 12 Timur 2021-07-15 12:26:08 UTC
All if fine, original and duplicate DOCX, MSO saved DOC, open and save.
Comment 13 NISZ LibreOffice Team 2021-07-23 06:28:39 UTC
*** Bug 120113 has been marked as a duplicate of this bug. ***
Comment 14 Gabor Kelemen (allotropia) 2022-01-27 19:39:54 UTC
*** Bug 64876 has been marked as a duplicate of this bug. ***