Bug 138782 - FILEOPEN DOCX Horizontal position of shape anchored to paragraph wrapping around another shape is incorrect
Summary: FILEOPEN DOCX Horizontal position of shape anchored to paragraph wrapping aro...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.1.0.4 release
Hardware: All All
: medium normal
Assignee: Attila Bakos (NISZ)
URL:
Whiteboard: target:7.2.0 target:7.1.4
Keywords: filter:docx
: 106339 109218 130427 137270 137850 139105 139650 140823 142185 (view as bug list)
Depends on:
Blocks: DOCX-Anchor-and-Text-Wrap
  Show dependency treegraph
 
Reported: 2020-12-09 17:31 UTC by NISZ LibreOffice Team
Modified: 2023-02-28 13:08 UTC (History)
10 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from Word (24.10 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-12-09 17:31 UTC, NISZ LibreOffice Team
Details
Screenshot of the original documents first page side by side in Word and Writer (65.60 KB, image/png)
2020-12-09 17:31 UTC, NISZ LibreOffice Team
Details
Screenshot of the original documents second page side by side in Word and Writer (127.34 KB, image/png)
2020-12-09 17:32 UTC, NISZ LibreOffice Team
Details
How it looks in 7.2 master after fix (318.09 KB, image/jpeg)
2021-05-05 06:38 UTC, Attila Bakos (NISZ)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2020-12-09 17:31:18 UTC
Created attachment 168009 [details]
Example file from Word

Attached file contains some loremipsum text and shapes that have empty paragraphs wrapping around them. Their horizontal positioning is the default that Word 13 gives them: to column.
Another shape next to them is anchored to such wrapping empty paragraphs, while a third one is anchored to the same paragraph as the first shape.
This is repeated in one column setting and both column of a two column section.

When opened in Writer the shape anchored to a wrapping paragraph is incorrectly positioned: horizontally it is shifted by the width of the first shape that is wrapped by its anchoring paragraph.
The first shape and the shape anchored to the same paragraph as the first one is correctly positioned horizontally.

Writer shows the horizontal positioning of all these shapes as to “Paragraph area” but to have the same layout as Word has, the horizontal positioning should be to “Left paragraph border”.
(Which may be to “Right paragraph border” in case of RTL documents...)

Of course thought must be given to DOCX save interoperability: manually changing the horizontal alignment creates the desired layout, but there is no similar option in DOCX, so the changed layout does not survive saving. 
Maybe just the layout should be a bit more clever.

Steps to reproduce:
    1. Open attached document
    2. Observe the position of the shapes

Actual results:
The orange and green shapes are more to the right below the purple ones.

Expected results:
Layout as in Word.

LibreOffice details:
Version: 7.2.0.0.alpha0+ (x64)
Build ID: 796c7f612603490dda9277ced0f6ab3cce3bc116
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: default; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: CL

Also in: 
Version: 6.0.0.3
Build ID: 64a0f66915f38c6217de274f0aa8e15618924765
CPU threads: 4; OS: Windows 6.3; UI render: default; 
Locale: en-US (hu_HU); Calc: CL

Version: 5.0.0.5
Build ID: 1b1a90865e348b492231e1c451437d7a15bb262b
Locale: hu-HU (hu_HU)

Version: 4.2.0.4
Build ID: 05dceb5d363845f2cf968344d7adab8dcfb2ba71

Not yet in:
Verzió: 4.1.0.4
Build az.: 89ea49ddacd9aa532507cbf852f2bb22b1ace28

But the empty paragraphs don’t wrap around the first shapes either.
Comment 1 NISZ LibreOffice Team 2020-12-09 17:31:43 UTC
Created attachment 168010 [details]
Screenshot of the original documents first page side by side in Word and Writer
Comment 2 NISZ LibreOffice Team 2020-12-09 17:32:02 UTC
Created attachment 168011 [details]
Screenshot of the original documents second page side by side in Word and Writer
Comment 3 Xisco Faulí 2020-12-09 19:44:56 UTC
Reproduced in

Version: 7.2.0.0.alpha0+
Build ID: 84af20ef3ea72190784e9e7be820684c2558ba8c
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 4 NISZ LibreOffice Team 2020-12-10 07:54:52 UTC
The 2016-saved version of bug #37315 example also suffers from this (among a lot of other problems...):

https://bugs.documentfoundation.org/show_bug.cgi?id=37315#c29
Comment 5 Commit Notification 2021-05-04 17:34:42 UTC
Attila Bakos (NISZ) committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5812fb81013cc124a9b6a0b9912a34cc715fc495

tdf#138782 DOCX import: fix frame positions of old docs

It will be available in 7.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.
Comment 6 Attila Bakos (NISZ) 2021-05-05 06:27:26 UTC
*** Bug 106339 has been marked as a duplicate of this bug. ***
Comment 7 Attila Bakos (NISZ) 2021-05-05 06:28:38 UTC
*** Bug 137850 has been marked as a duplicate of this bug. ***
Comment 8 Attila Bakos (NISZ) 2021-05-05 06:29:08 UTC
*** Bug 130427 has been marked as a duplicate of this bug. ***
Comment 9 Attila Bakos (NISZ) 2021-05-05 06:29:28 UTC
*** Bug 137270 has been marked as a duplicate of this bug. ***
Comment 10 Attila Bakos (NISZ) 2021-05-05 06:30:02 UTC
*** Bug 109218 has been marked as a duplicate of this bug. ***
Comment 11 Attila Bakos (NISZ) 2021-05-05 06:30:37 UTC
*** Bug 139105 has been marked as a duplicate of this bug. ***
Comment 12 Attila Bakos (NISZ) 2021-05-05 06:31:26 UTC
*** Bug 140823 has been marked as a duplicate of this bug. ***
Comment 13 Attila Bakos (NISZ) 2021-05-05 06:38:17 UTC
Created attachment 171639 [details]
How it looks in 7.2 master after fix
Comment 14 Timur 2021-05-05 07:43:42 UTC
Congrats to all of you on so many bugs found and resolved. 
Please clarify: bug is fileopen but some duplicates are filesave?

Note for QA: now all those should be tested for MSO DOC variant (and perhaps new bug opened).
Bibisect repo is frequently updated, but fixes are at even higher pace :)
Comment 15 Xisco Faulí 2021-05-05 08:55:52 UTC
Verified in

Version: 7.2.0.0.alpha0+ / LibreOffice Community
Build ID: 1a99b4e44190e182d56a04678850d62635d74c65
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: x11
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

@Attila Bakos, thanks for fixing this issue!!
Comment 16 Commit Notification 2021-05-05 08:58:31 UTC
Attila Bakos (NISZ) committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/4e7ef3f7421febc08e621bf9ca276cec7b032808

tdf#138782 DOCX import: fix frame positions of old docs

It will be available in 7.1.4.

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 17 Attila Bakos (NISZ) 2021-05-05 09:40:57 UTC
(In reply to Timur from comment #14)
> Congrats to all of you on so many bugs found and resolved. 
> Please clarify: bug is fileopen but some duplicates are filesave?
> 
> Note for QA: now all those should be tested for MSO DOC variant (and perhaps
> new bug opened).
> Bibisect repo is frequently updated, but fixes are at even higher pace :)

Hello Timur,

Yes, there are import and export issues, but this problem was an importing problem in the Writerfilter DomainMapper, what I fixed. All of the export situations what have been fixed mentioned that: export to docx and reopen, so the reopen part is the interesting. On the other hand in Word all of the exported docx files rendered correctly so there was no export problem.
Please note, i only fixed docx. The doc variants were not tested.
I hope this enough for clarifying.
Have a nice day! :)
Comment 18 Timur 2021-05-05 13:16:35 UTC
Just to add that DOC is OK in general (MSO DOC is different than DOCX).
I opened a new one for bug 137270.
Comment 19 NISZ LibreOffice Team 2021-05-10 06:36:36 UTC
*** Bug 142185 has been marked as a duplicate of this bug. ***
Comment 20 NISZ LibreOffice Team 2021-07-16 10:08:23 UTC
*** Bug 139650 has been marked as a duplicate of this bug. ***