Bug 98823 - FILEOPEN: 3-pages .docx with images in table shown incorrect
Summary: FILEOPEN: 3-pages .docx with images in table shown incorrect
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected) rc
Hardware: All All
: medium normal
Assignee: Not Assigned
Keywords: bibisected, bisected, filter:docx
Depends on:
Blocks: DOCX-Tables DOCX-Images
  Show dependency treegraph
Reported: 2016-03-22 14:33 UTC by Alexander
Modified: 2023-01-12 20:28 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:

file with bug (283.57 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2016-03-22 14:33 UTC, Alexander
screen (193.99 KB, image/png)
2016-03-22 14:34 UTC, Alexander
PDF showing the expected result (290.25 KB, application/pdf)
2016-03-22 15:15 UTC, Pedro
The example file in current master (395.74 KB, image/png)
2023-01-12 16:16 UTC, Gabor Kelemen (allotropia)

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2016-03-22 14:33:03 UTC
Created attachment 123770 [details]
file with bug

When open attached file displaying random collage of images instead ordered list. As displayed on screenshot.
Comment 1 Alexander 2016-03-22 14:34:13 UTC
Created attachment 123771 [details]
Comment 2 Pedro 2016-03-22 15:15:34 UTC
Created attachment 123774 [details]
PDF showing the expected result
Comment 3 QA Administrators 2017-12-10 16:39:32 UTC Comment hidden (obsolete)
Comment 4 H.C Hsu 2018-11-29 08:50:04 UTC
Still exists in version
The file can't open unless transforming to pdf file.

Version: (x64)
Build ID: 0f25a3c36f27fd51453b9a9115f236b83c143684
CPU threads: 8; OS: Windows 10.0; UI render: GL; VCL: win; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-11-27_20:06:55
Locale: zh-TW (zh_TW); UI-Language: en-US
Calc: threaded
Comment 5 QA Administrators 2019-11-30 03:38:41 UTC Comment hidden (obsolete)
Comment 6 Pedro 2019-12-01 18:30:09 UTC
Apparently it became impossible to open this document with LibreOffice somewhere between version 5.0.5 and 5.4.7 (just tested with the last version in the 5.x branch)
Currently neither version 6.2.8 nor 6.3.3 can open it.
Marking this as a Regression.

FWIW it opens instantly in OpenOffice 4.1.7 (although with some composition errors)
Comment 7 raal 2019-12-08 09:24:15 UTC Comment hidden (obsolete)
Comment 8 Timur 2019-12-09 11:38:51 UTC
There's bug 104347 but based on comment there, it's basically the same issue as in this one, I don't see a need for separate bug. But, never mind.
Comment 9 Timur 2022-03-02 13:26:38 UTC
This was never OK. OO opened just 1 page, LO 5.2 oldest was 1 page.
LO 5.2 master and 6.4 in Linux hang without showing pages. 
LO 7.0 and 7.4+ in Linux open 3 pages but hang after open showing 1st page. 
LO 7.4+ in Windows doesn't show pages at all, just hangs. 

So there were changes in 5.2 and improvement in 7.0. 
 8c00cefb4eea369ac7910b0969fbf122f8cf394a is the first change in 5.2
    source 0ba2229a57527e78f237119efa413f122c9ca74b
    prev 4b62ad397c1ed137cbe69aa0882d290a92052e9a

author	Miklos Vajna <vmiklos@collabora.co.uk>	2016-08-30 
commit 0ba2229a57527e78f237119efa413f122c9ca74b (patch)
Related: tdf#44986 DOCX import: handle w:gridAfter by faking cells
 60317d7294364e84db01e9406123e855f0ec4aba is the first change commit in 7.0
    source fd7749fddc5a767461dfced55369af48e5a6d561
    prev 10e08b1d398e6aa91aa4ced0ca6c966349be8b5d
author	Miklos Vajna <vmiklos@collabora.com>	2020-02-14 
commit fd7749fddc5a767461dfced55369af48e5a6d561 (patch)
sw: fix handling of table vs fly overlaps in the AddVerticalFlyOffsets case

Note: this is 2007 DOCX. If resaved in MSO, it's still 3 pages with content  differently positioned in MSO, but it also hangs in LO.

CC Miklos. Since these are your commits, please make a comment. Thanks.
Comment 10 Miklos Vajna 2022-03-03 07:36:19 UTC
This is certainly a bug, but in case this started to be more visible with the gridAfter commit, then it was always there, just docx files didn't generate those "after" cells, so it was harder to run into this problem. You could probably craft an ODT file which had the same problem even before the gridAfter DOCX commit.

So this is definitely a problem, it is worth to fix, but I would not consider it a regression. Hope this helps. Thanks!
Comment 11 Gabor Kelemen (allotropia) 2023-01-12 16:16:32 UTC
Created attachment 184617 [details]
The example file in current master

Now this opens without endless loop, but layout is very different from the one seen on 
attachment 123774 [details]

Version: (X86_64) / LibreOffice Community
Build ID: d993327eab0a2c9c8820c6528075b01de68b0ec6
CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: hu-HU (hu_HU.UTF-8); UI: en-US
Calc: threaded

The fix was from bug 152106 and bug 104347 was also about an endless loop.

Can we refocus this one to the layout differences?
Comment 12 Gabor Kelemen (allotropia) 2023-01-12 20:17:29 UTC
One issue I see is that the images have the Allow overlap setting turned off in Word, but turned on in Writer. This is bug 134114.
Comment 13 Gabor Kelemen (allotropia) 2023-01-12 20:27:44 UTC
Another issue is the vertical positioning of images is defined as below Line, which is incorrectly imported (as Writer does not have exactly that kind of positioning), see bug 127071