Bug 116486 - FILEOPEN: DOCX: paragraph position is wrong due to flying object
Summary: FILEOPEN: DOCX: paragraph position is wrong due to flying object
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.1 all versions
Hardware: All All
: medium normal
Assignee: Patrick Jaap
URL:
Whiteboard: target:6.1.0 target:6.0.4
Keywords:
Depends on:
Blocks: DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2018-03-19 09:52 UTC by Patrick Jaap
Modified: 2018-05-29 09:29 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
minimal file causing the bug (19.22 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-03-19 09:53 UTC, Patrick Jaap
Details
render of current LO master (12.54 KB, application/pdf)
2018-03-19 09:53 UTC, Patrick Jaap
Details
file opened in MSO 2013 (161.24 KB, application/pdf)
2018-03-19 09:53 UTC, Patrick Jaap
Details
Better (simpler) test file (21.93 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-04-07 14:53 UTC, Patrick Jaap
Details
situation in LO Writer (4.15 KB, image/png)
2018-04-07 14:57 UTC, Patrick Jaap
Details
situation in MSO (5.22 KB, image/png)
2018-04-07 14:59 UTC, Patrick Jaap
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Jaap 2018-03-19 09:52:55 UTC
Description:
The attached docx file causes the following problem: There is a text box anchored in the header but positioned in the body of the document. Then, there is a date line, placed a few cm relative below the top. 

In LO master the position of the date is independent from the text box

In MSO the position is measured relative to the text box. 

you can see the difference in the attached PDFs.



Steps to Reproduce:
1. Open the minimal.docx in Writer

Actual Results:  
Date is directly below the text box

Expected Results:
Date has a few cm distance to the text box


Reproducible: Always


User Profile Reset: No



Additional Info:


User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0
Comment 1 Patrick Jaap 2018-03-19 09:53:20 UTC
Created attachment 140701 [details]
minimal file causing the bug
Comment 2 Patrick Jaap 2018-03-19 09:53:38 UTC
Created attachment 140702 [details]
render of current LO master
Comment 3 Patrick Jaap 2018-03-19 09:53:56 UTC
Created attachment 140703 [details]
file opened in MSO 2013
Comment 4 Mike Kaganski 2018-03-19 14:03:22 UTC
This is independent of the floating box anchoring (i.e., to header, or to body content). Paragraph's top/bottom spacings don't take floating objects into account.

Tested with Version: 6.0.2.1 (x64)
Build ID: f7f06a8f319e4b62f9bc5095aa112a65d2f3ac89
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: ru-RU (ru_RU); Calc: CL
Comment 5 Patrick Jaap 2018-03-19 14:14:11 UTC
(In reply to Mike Kaganski from comment #4)
> This is independent of the floating box anchoring (i.e., to header, or to
> body content). Paragraph's top/bottom spacings don't take floating objects
> into account.

That doesn't sound good. Do you have any code pointers where the (final) position of the paragraph is calculated?
Comment 6 Mike Kaganski 2018-03-19 14:22:37 UTC
This change: https://gerrit.libreoffice.org/28692 - did something related IMO.
Comment 7 Patrick Jaap 2018-03-20 10:46:31 UTC
(In reply to Mike Kaganski from comment #6)
> This change: https://gerrit.libreoffice.org/28692 - did something related
> IMO.

Thanks for the link. For what I understood, in this code area, relations of paragraphs and their common distance is adjusted. In order to involve the consideration of fly objects, the "final" position of the fly objects has to be known. 

Also, I checked that the bug also occurs when the fly frame is anchored in the body and you are right. 

Do you have any idea where the updated calculation of the paragraph position should be placed?

Thanks!
Comment 8 Xisco Faulí 2018-03-20 11:15:46 UTC
Also reproduced in

Version: 4.3.0.0.alpha1+
Build ID: c15927f20d4727c3b8de68497b6949e72f9e6e9e

Version 4.1.0.0.alpha0+ (Build ID: efca6f15609322f62a35619619a6d5fe5c9bd5a)
Comment 9 Mike Kaganski 2018-03-20 20:59:17 UTC
(In reply to Patrick Jaap from comment #7)
> Do you have any idea where the updated calculation of the paragraph position
> should be placed?

Well - actually I cannot give you any more specific code pointer here - the layout code is very complex (one of most complex things in Writer); and it needs deep investigation on my side (which I cannot afford atm, sorry).
Comment 10 Patrick Jaap 2018-04-07 14:53:46 UTC
Created attachment 141188 [details]
Better (simpler) test file

As mentioned, the issue is independent of the header. 

Now, there is just a fly object and a paragraph. The paragraph should be located a few cm below the flying box.
Comment 11 Patrick Jaap 2018-04-07 14:57:52 UTC
Created attachment 141189 [details]
situation in LO Writer
Comment 12 Patrick Jaap 2018-04-07 14:59:23 UTC
Created attachment 141190 [details]
situation in MSO
Comment 13 Commit Notification 2018-04-16 07:15:49 UTC
Patrick Jaap committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d07fc485d46f431405a3f6a002f951a08c559677

tdf#116486 Consider upper margin in paragraph positioning with flys

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Commit Notification 2018-04-17 07:08:47 UTC
Patrick Jaap committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ae910b993f69205866f94ac8928f13f57e94560b&h=libreoffice-6-0

tdf#116486 Consider upper margin in paragraph positioning with flys

It will be available in 6.0.4.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Xisco Faulí 2018-05-29 09:28:14 UTC
A polite ping to Patrick Jaap:
Is this bug fixed? if so, could you please close it as RESOLVED FIXED ? Otherwise, Could you please explain what's missing?
Thanks
Comment 16 Patrick Jaap 2018-05-29 09:29:28 UTC
I'm sorry... this bug is fixed :)