Bug 157637 - FILESAVE ODT->DOC: native LO offsets in tables as if layoutInCell, but doesn't export that way to DOC
Summary: FILESAVE ODT->DOC: native LO offsets in tables as if layoutInCell, but doesn'...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.4.0.0 alpha0+
Hardware: All All
: low normal
Assignee: Justin L
URL:
Whiteboard: target:25.2.0
Keywords: bibisected, bisected, filter:doc
Depends on: 157707
Blocks: DOC-Anchor-and-Text-Wrap DOCX-compatibilityMode-15 layoutInCell
  Show dependency treegraph
 
Reported: 2023-10-06 13:49 UTC by Justin L
Modified: 2024-08-24 19:40 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
tdf135061_DOC_mso2010.pdf: how tdf135061.odt -> DOC looks in MS Word (20.91 KB, application/pdf)
2023-10-06 13:49 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2023-10-06 13:49:30 UTC
Created attachment 190065 [details]
tdf135061_DOC_mso2010.pdf: how tdf135061.odt -> DOC looks in MS Word

The native way of handling objects anchored in a table cell is to naturally treat the cell as an anchor, and that also works for MS Word 2013+ DOCX (aka compat15).

However, for older versions of MS Word, if layoutInCell is disabled, any flies anchored anywhere in the table are offset from the main table frame instead. (see bug 133552 for the import bug related to this.). At the moment, it looks OK in LO, but MS Word shows that the export is actually not OK.

Since 7.4, LibreOffice properly exports the layoutInCell property to DOC format. However, that broke the ODT->DOC conversion, since native ODT doesn't need to specify GetFollowTextFlow(), and therefore we now export layoutInCell=false (which results in the changed layout in MS Word).

Prior to 7.4, layoutInCell was not exported, and DOC import treats the absence of the flag to default layoutInCell to true, so things "automatically" worked.

Perhaps then the easiest thing to do is to check if there is an ADD_FLY_OFFSET compat flag, and only then export the layoutInCell property.
* DOCX: shouldn't matter since we export as compat15 - which forces layoutInCell
* RTF: seems we don't export or import layoutincell.

Steps to reproduce:
1.) Open tdf135061.odt from sw/qa/extras/uiwriter/data
2.) save in DOC format.
3a.) reload in MS Word - all shapes are crammed to the left side / smaller table
3b.) reload in LibreOffice - the table is much smaller 

Bisected to commit 98ecef56d0f87cd922ca560fead4e2533b30d57c
Author: Justin Luth on Mon Feb 7 20:41:19 2022 +0200
    tdf#79186 ww8export: save LayoutInCell property
Comment 1 Justin L 2023-10-06 14:18:28 UTC
This could get very messy, because LO seems to have a much more strict idea of what "Follow text flow" means than MS Word for shapes at least. And things change when opening the settings dialog and then pressing OK with "Follow text flow" enabled.

Just for clarity, FollowTextFlow(LO) and layoutInCell(MSO) are essentially equivalent.

tdf79186_noLayoutInCell.odt shows that at least textboxes need to be an exception.
Comment 2 Justin L 2023-10-06 19:26:09 UTC
(In reply to Justin L from comment #1)
> tdf79186_noLayoutInCell.odt shows that at least textboxes need to be an
> exception.
see https://gerrit.libreoffice.org/c/core/+/102258

Patch that I am NOT going to propose, but just for illustration is at https://gerrit.libreoffice.org/c/core/+/157662
Comment 3 Commit Notification 2024-08-24 12:30:09 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#157637 ODT->DOC: use layoutInCell for para-oriented fly

It will be available in 25.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.