Bug 76022 - DOC/DOCX import: Tables don't wrap around floating shapes (also wrong in old versions of MSO, but "correct" in MSO2013)
Summary: DOC/DOCX import: Tables don't wrap around floating shapes (also wrong in old ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.6.0
Keywords: filter:doc, filter:docx
: 106840 107628 112359 117132 119914 137822 (view as bug list)
Depends on:
Blocks: DOC-Frames DOCX-Anchor-and-Text-Wrap DOCX-compatibilityMode-15 60558 120262 155040
  Show dependency treegraph
 
Reported: 2014-03-11 10:34 UTC by Sven-Jacobi
Modified: 2023-08-18 18:52 UTC (History)
13 users (show)

See Also:
Crash report or crash signature:


Attachments
doc with textframe layout problem (34.00 KB, application/msword)
2014-03-11 10:34 UTC, Sven-Jacobi
Details
the same bugdoc stored as normal docx via MSO 2013 (18.17 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2015-06-22 08:51 UTC, Sven-Jacobi
Details
The minimized docx example file in Word and Writer (178.59 KB, image/png)
2020-09-08 13:01 UTC, NISZ LibreOffice Team
Details
Same Settings In Word And Writer 7.1 with the sample file (206.80 KB, image/png)
2020-09-08 14:40 UTC, Attila Bakos (NISZ)
Details
tableWrapping.odt: fundamental difference between LO and MS Word in table wrapping. (62.67 KB, application/vnd.oasis.opendocument.text)
2023-03-16 16:03 UTC, Justin L
Details
tableWrapping2.odt: one case where LO does wrap a table (poorly) (68.25 KB, application/vnd.oasis.opendocument.text)
2023-03-17 20:28 UTC, Justin L
Details
76022_tableWrappingOptimal.docx: bizarre layout in MS 2010 (18.66 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-03-27 18:12 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sven-Jacobi 2014-03-11 10:34:53 UTC
Created attachment 95588 [details]
doc with textframe layout problem

The attached document is containing two tables which are placed within textframes. If the document is loaded within LibreOffice then it looks like the two tables are lying upon each other (which is not the case if loaded with Word).
Comment 1 Jean-Baptiste Faure 2014-03-12 08:18:03 UTC
Confirmed with versions 4.2.3.0.0+ and 4.1.5 under Linux / Ubuntu 13.10. It is clear that something goes wrong.
Changed version number to 4.1.5.

Note: when opened in LibreOffice, the file has only one text frame (it contains the table 1) anchored to the character.

Hi Miklos, this one me be interesting for you.

Best regards. JBF
Comment 2 Joel Madero 2015-05-02 15:44:20 UTC Comment hidden (obsolete)
Comment 3 Buovjaga 2015-06-21 13:19:20 UTC Comment hidden (obsolete)
Comment 4 Sven-Jacobi 2015-06-22 08:51:36 UTC
Created attachment 116721 [details]
the same bugdoc stored as normal docx via MSO 2013

This bug is still happening with my latest LibreOffice (4.3.72)...The XML version saved back with MSO 2013 is having the same layout problems but might be better to debug this issue.
Comment 5 Buovjaga 2015-06-22 14:33:49 UTC
Ok, I confirmed in MSO 2013. In LibO, the tables are on top of each other both in the doc & docx, while they are fine in MSO.

Win 8.1 32-bit
MSO 2013

LibO Version: 5.1.0.0.alpha1+
Build ID: 2885e157674dbefa7d9b984a399fabd1238eeedd
TinderBox: Win-x86@39, Branch:master, Time: 2015-06-22_07:52:27
Locale: fi-FI (fi_FI)
Comment 6 QA Administrators 2016-09-20 10:11:37 UTC Comment hidden (obsolete)
Comment 7 Timur 2017-01-31 12:43:51 UTC
There are many frame bugs, I'm not sure which are related. Bug 78756. Bug 66039.
Comment 8 QA Administrators 2018-10-02 02:54:46 UTC Comment hidden (obsolete)
Comment 9 Xisco Faulí 2019-01-03 23:48:35 UTC
Still reproducible in

Version: 6.3.0.0.alpha0+
Build ID: 49c61f660d05ab13140d4349a0b3f6efba742022
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded
Comment 10 Justin L 2019-01-24 17:16:52 UTC
(In reply to Buovjaga from comment #3)
> Document looks identical in Word viewer 
Also overlapping in MSWord 2003 - for both the doc and docx
Comment 11 NISZ LibreOffice Team 2020-09-08 13:01:08 UTC
Created attachment 165271 [details]
The minimized docx example file in Word and Writer

It seems like the shape is anchored to page in Word, but it's opened as anchored to paragraph in Writer.
It is also having square wrap in Word.

Setting it manually to anchored To page and Wrap Off recreates the original look.
Comment 12 NISZ LibreOffice Team 2020-09-08 13:01:49 UTC Comment hidden (obsolete)
Comment 13 Attila Bakos (NISZ) 2020-09-08 14:40:18 UTC
Created attachment 165275 [details]
Same Settings In Word And Writer 7.1 with the sample file

In my opinion, basically there is no problem with the positioning/anchoring. Both program uses the same distance (1,22 cm and 2,9 cm) and relative point (page) for positioning, and the textbox -- what includes the first table -- is in the right place, see this attachment.
The problem with the other table which outside the textbox. In Word in spite of the wrap setting, which is optimal (means, the text can be that side what have greater space) there is no surround, but in Writer there is, this is the problem, I think. So this rather a table positioning problem, than a frame. And how can it solved is a so good question...
(I think there is a calculating mechanism in Word which indicates that there is not enough space for the second table and that is the reason for the difference.)
Comment 14 NISZ LibreOffice Team 2021-05-05 07:45:25 UTC
A bit of experimentation in Word:
- The top textbox has the Allow overlap setting enabled. This means that another textbox or shape can overlap it, if that also ha Allow overlap enabled. 
But only if both have it enabled, even if one of them has it disallowed, they can't overlap.
- The normal i.e. non-floating table however does not have an Allow overlap setting among it's settings. However it behaves in my Word 2019 as if it had it disabled: never overlaps the top textbox.

In Writer however the table overlaps the textbox. 
It should behave in Writer in relation to shape objects as if it were having this Allow overlap feature, and it were disabled.
Comment 15 NISZ LibreOffice Team 2021-08-05 13:48:25 UTC Comment hidden (obsolete)
Comment 16 NISZ LibreOffice Team 2021-08-05 14:27:33 UTC Comment hidden (obsolete)
Comment 17 Justin L 2023-03-15 13:44:04 UTC Comment hidden (obsolete)
Comment 18 Miklos Vajna 2023-03-16 14:47:26 UTC Comment hidden (obsolete)
Comment 19 Justin L 2023-03-16 16:03:29 UTC
Created attachment 186008 [details]
tableWrapping.odt: fundamental difference between LO and MS Word in table wrapping.

(In reply to Miklos Vajna from comment #18)
After re-examining, only one the shorter table is anchored (inside a textbox). The longer one is just a normal inline table with no wrapping.

The problem appears to be that LO doesn't consider tables when dealing with image wrapping.

This minimal example (tableWrapping.odt) shows that natively LO doesn't consider tables need to be impacted by floating stuff. When saved as DOCX, MS Word doesn't "fit" the table "beside(under)" the image.
Comment 20 Justin L 2023-03-17 20:18:12 UTC
*** Bug 115625 has been marked as a duplicate of this bug. ***
Comment 21 Justin L 2023-03-17 20:28:41 UTC
Created attachment 186038 [details]
tableWrapping2.odt: one case where LO does wrap a table (poorly)

There is one type of situation where LO does wrap a table, but only if the orientation is set to "LEFT" or "RIGHT" and the wrap is also left/right/parallel (but not optimal).

The code for all this is in sw/source/core/layout/tabfrm.cxx CalcFlyOffsets()
Comment 22 Justin L 2023-03-22 14:56:19 UTC
attachment 139768 [details] (test.docx) from duplicate bug 115625 is a good example with several unique qualities of its own:
-it also imports nicely in MSO2003
-in LO it is a sync'd textbox with an unsynchronized wrap (RES_SURROUND) where in the layout code it looks like it is THROUGH instead of the UI's PARALLEL.

There are also various existing unit tests related to this bug's issues:
-through wrap should be ignored: fdo43573-2-min.docx on page 11
-MS brochure that always exhibits every bug: tdf81345.docx
-parallel wrapping (already works): table-fly-overlap-spacing.docx
-parallel in header (already works): table-fly-overlap.docx

Related but no real impact noticed, but probably useful to verify against to ensure no bad side effects:
-page-remove-fly-no-table.fodt
-tdf105688.docx
-tdf123163-1.docx
-tdf132911.odt
-tdf135061.odt
-tdf151375.ott
-testCustomShapePresetExport.odt
Comment 23 Justin L 2023-03-22 15:08:39 UTC
This is noteworthy: // fly anchored at character or at paragraph
                    bConsiderFly = ... pFly->IsFlyAtContentFrame()  ...
Obviously AsChar has no wrapping, but that ToPage is excluded is unexpected.
Comment 24 Justin L 2023-03-22 18:34:27 UTC
I ran out of time and also running out of confidence. Posting what I have...

https://gerrit.libreoffice.org/c/core/+/149347 related tdf#76022 sync textbox RES_SURROUND text wrapping // quickly fails a make sw.check

https://gerrit.libreoffice.org/c/core/+/149348 related tdf#76022: don't ConsiderFly offsets when wrap is THROUGH

https://gerrit.libreoffice.org/c/core/+/149349 [WIP] tdf#76022 table wrap: always wrap if space
Comment 25 Commit Notification 2023-03-24 18:25:58 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#115625 tdf#76022 sw table: CalcFlyOffset: get correct surround for textbox

It will be available in 7.6.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 26 Commit Notification 2023-03-24 21:17:20 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

related tdf#76022 sw CalcFlyOffset: no ConsiderFly if THROUGH wrap

It will be available in 7.6.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 27 Justin L 2023-03-24 21:22:04 UTC
The document (test.docx) in duplicate bug 115625 is fixed by comment 25's patch, but that is only one instance in many. This bug report is not yet solved.
Comment 28 Justin L 2023-03-27 18:12:11 UTC
Created attachment 186252 [details]
76022_tableWrappingOptimal.docx: bizarre layout in MS 2010

I wanted to know how Microsoft would handle multiple floating objects when one was set to optimal (largest side) wrap. Does it make a one-time decision based on the single fly, or does it take all flies into consideration?

For plain text, the answer clearly seems to be that it takes everything into consideration. [However, LO doesn't.]
For tables, the answer is very mixed. "It depends" on seemingly random considerations.
Comment 29 Justin L 2023-04-18 16:50:06 UTC
*** Bug 117132 has been marked as a duplicate of this bug. ***
Comment 30 Aron Budea 2023-04-19 16:26:39 UTC
Bug 117132 has been closed as duplicate, but that was about completely supporting the feature in Writer, even on the UI, and even when working with ODTs, which doesn't necessarily equate with providing solution to a "DOC/DOCX import" issue. So I'm noting here that consequently the scope of this bug report has been expanded to include those considerations.
Comment 31 Justin L 2023-04-19 16:29:12 UTC
There really shouldn't be a UI component - it should happen automatically.
Comment 32 Aron Budea 2023-04-19 17:29:10 UTC
Is that not an incompatible change with existing LO versions, though?
Comment 33 Justin L 2023-04-19 19:14:29 UTC
(In reply to Aron Budea from comment #32)
> Is that not an incompatible change with existing LO versions, though?

Of course, but the same compat flag that allows MS layout can be used for ODT as well. The inability of table to wrap around flies is not a "feature" that needs to be preserved.
Comment 34 Justin L 2023-05-27 02:00:12 UTC
*** Bug 106840 has been marked as a duplicate of this bug. ***
Comment 35 Justin L 2023-05-27 02:00:43 UTC
*** Bug 119914 has been marked as a duplicate of this bug. ***
Comment 36 Justin L 2023-05-27 16:57:50 UTC
*** Bug 107628 has been marked as a duplicate of this bug. ***
Comment 37 Justin L 2023-06-02 16:23:14 UTC
*** Bug 137822 has been marked as a duplicate of this bug. ***
Comment 38 Justin L 2023-06-06 18:01:36 UTC
*** Bug 112359 has been marked as a duplicate of this bug. ***
Comment 39 Justin L 2023-06-06 18:21:41 UTC
*** Bug 137822 has been marked as a duplicate of this bug. ***