Bug 166710 - FILEOPEN DOCX layoutincell: don't force top vertical alignment in cell just because it contains a fly
Summary: FILEOPEN DOCX layoutincell: don't force top vertical alignment in cell just b...
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: low minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:docx
Depends on:
Blocks: layoutInCell
  Show dependency treegraph
 
Reported: 2025-05-24 01:27 UTC by Justin L
Modified: 2025-05-24 05:42 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
tdf37153_squareWrap.docx: example document (29.01 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-05-24 01:27 UTC, Justin L
Details
tdf37153_squareWrap_Word2010.pdf: how it looks in MS Office (42.55 KB, application/pdf)
2025-05-24 01:48 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2025-05-24 01:27:48 UTC
Created attachment 200939 [details]
tdf37153_squareWrap.docx: example document

In DOC format, a cell that contains a floating object (a layout-in-cell fly) forces the cell contents to be top aligned. However, for DOCX format that doesn't apply (unless it has layout option doNotVertAlignCellWithSp).

Bug 37153 deals with this concept in regards to the layout flag.

Layout-in-cell (aka FollowTextFlow using LO terminology) was already supported in OOo, so this is an inherited problem. In OOo 3.3, our example document appears to be treated this as a doNotVertAlignCellWithSp. This is basically  what it looks today, although in between it has changed many times. 

The point is that it has never been correct.

There are two things that need to be corrected:
-   if ( bConsiderWrapOnObjPos ||     # sw/source/core/layout/tabfrm.cxx
+   if ( /* bConsiderWrapOnObjPos || */
and then properly place the image at the bottom of the cell.

The image is layout-in-cell. So it should usually be contained within the cell boundaries. An exception is when the fly is css::text::WrapTextMode_THROUGH ('Behind text' or 'In front of text' to use MS terms). But even in that case, the layout should ATTEMPT to keep everything inside the cell, and only escape after the anchor paragraph has been pushed to the top of the cell.

I noticed that Microsoft's UI tries really hard to suggest offset values that push the anchor paragraph to the top of the cell. I'm sure they did that to emulate how older Word versions were going to display it. In other words, when you make any changes to the wrapping, the Word application sets offset values that would match the layout of doNotVertAlignCellWithSp. However, if you override those values, you can see that there actually is no forcing of a top alignment anymore.

Steps to reproduce:
-open tdf37153_squareWrap.docx

In MS Word, the image is at the bottom of the cell, with the anchor paragraph just above it.
Currently, LO treats this non-wrap-through image as doNotVertAlignCellWithSp.
In the case of wrap-through flies (like ooxmlexport24's tdf37153_considerWrapOnObjPos.docx), the fly has escaped the cell boundaries and is underneath the cell.

Marking as low priority, because MOST documents will accidentally look OK.
Comment 1 Justin L 2025-05-24 01:48:25 UTC
Created attachment 200940 [details]
tdf37153_squareWrap_Word2010.pdf: how it looks in MS Office