Bug 119952 - FILEOPEN Negative margins coming from Word are not handled
Summary: FILEOPEN Negative margins coming from Word are not handled
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Attila Szűcs
URL:
Whiteboard: target:7.3.0 target:7.2.0.0.beta2
Keywords: filter:docx
: 64876 118489 120113 (view as bug list)
Depends on:
Blocks: DOCX-Page
  Show dependency treegraph
 
Reported: 2018-09-18 09:03 UTC by Aron Budea
Modified: 2022-06-14 16:37 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample DOCX (13.84 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-09-18 09:03 UTC, Aron Budea
Details
Screenshot in Word (29.51 KB, image/png)
2018-09-18 09:05 UTC, Aron Budea
Details
Sample DOCX compared MSO LO (117.09 KB, image/png)
2019-09-17 14:24 UTC, Timur
Details

Note You need to log in before you can comment on or make changes to this bug.
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. ***