Bug 157707 - FILEOPEN DOCX (compat14): layoutInCell(false) still offsets from table, not from underlying paragraph (comment 4)
Summary: FILEOPEN DOCX (compat14): layoutInCell(false) still offsets from table, not f...
Status: RESOLVED DUPLICATE of bug 133522
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: lowest minor
Assignee: Not Assigned
URL:
Whiteboard: compatibilityMode14
Keywords: filter:docx
Depends on:
Blocks: 157637
  Show dependency treegraph
 
Reported: 2023-10-11 16:45 UTC by Justin L
Modified: 2024-01-20 20:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
layoutInCell_line.docx: minimal example - made in LibreOffice (5.84 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-10-11 16:50 UTC, Justin L
Details
notLayoutInCell_line.docx: modified by MSO 2010 - curve should be under first column (14.86 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-10-11 17:52 UTC, Justin L
Details
notLayoutInCell_line_mso2010.pdf: how layoutInCell=false ought to look (3.67 KB, application/pdf)
2023-10-11 17:54 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-11 16:45:33 UTC
UIWriter's unit test tdf104492.docx specifies
<mc:AlternateContent>
  <mc:Choice Requires="wps">
    <w:drawing>
      <wp:anchor layoutInCell="1">
but the imported line has FollowTextFlow = false
Comment 1 Justin L 2023-10-11 16:50:21 UTC
Created attachment 190150 [details]
layoutInCell_line.docx: minimal example - made in LibreOffice

The layout in LO and MSO is currently identical.
That is actually a bad thing because LO is indicating that this is not following text flow. However it should, and MSO does mark it as "layout in cell".

If it was not "layout in cell", then the curve should be seen under the first column, not the second column.

Steps to reproduce: 
1. open layoutInCell_line.docx
2. go to the "Positions and Size" of the curve. It should be "Keep inside text boundaries"
Comment 2 Justin L 2023-10-11 17:16:51 UTC
Ahh, this is a coding exception since LO handles "layoutInCell" differently in this case. (LO wants to force the entire shape into the cell, not just affect the anchor offset.)
    if (m_pImpl->m_nWrap == text::WrapTextMode_THROUGH && m_pImpl->m_nHoriRelation == text::RelOrientation::FRAME)
    {
        // text::RelOrientation::FRAME is OOXML's "column", which behaves as if
        // layout-in-cell would be always off.
        m_pImpl->m_bLayoutInCell = false;
    }
Comment 3 Justin L 2023-10-11 17:43:56 UTC
Forced on export via:
if (pFrameFormat->GetSurround().GetValue() == text::WrapTextMode_THROUGH
    && pFrameFormat->....GetRelationOrient() == text::RelOrientation::FRAME)
{
// "In front of text" and horizontal positioning relative to Column is ignored
// on import, add it back here.
     bLclInTabCell = true;
}
Comment 4 Justin L 2023-10-11 17:52:56 UTC
Created attachment 190156 [details]
notLayoutInCell_line.docx: modified by MSO 2010 - curve should be under first column

Previous comments have shown code that just hard-codes true (on export) or false(on import) values to layoutInCell. However, that isn't a great idea because as this document shows, it should make a difference in layout.

The layout is the topic of bug 157637. This version of the file just shows that we can't just willy-nilly start forcing certain layoutInCell values.

Currently, this hard-coding makes it impossible for us to fix the layout when layoutInCell==false.
Comment 5 Justin L 2023-10-11 17:54:12 UTC
Created attachment 190157 [details]
notLayoutInCell_line_mso2010.pdf: how layoutInCell=false ought to look
Comment 6 Buovjaga 2023-10-25 11:10:26 UTC
Confirm

Arch Linux 64-bit, X11
Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 9704f61982360ce35983a61cca3fd00bbdf51ab6
CPU threads: 8; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 25 October 2023
Comment 7 Justin L 2024-01-20 18:07:19 UTC
ooxmlexport21's tdf153909_followTextFlow.docx is another example.

So we have a dilemma where the offset needs to be calculated based on layoutInCell=true, but that we can't force the shape to be inside the cell (and thus have turned off FollowTextFlow).

The result is that when LO round-trips file, it looks the same in LO, but in 
MS Word the contents have shifted around (at least for old versions of MS Word).

NOT fixing this layout might be the best response, since compat15 tends to always ignore a false value of layoutInCell.
Comment 8 Justin L 2024-01-20 20:53:35 UTC
Setting to very low importance. IIUC, these will all be documents created before Word 2013.

Note that layoutInCell does two different things. The big problem with it is that it (only sometimes) forces the fly inside of the cell boundaries. Secondly, it says whether the fly should offset from the cell margins, or from the paragraph-that-the-table-is-connected-to's margins.
Comment 9 Justin L 2024-01-20 20:58:36 UTC

*** This bug has been marked as a duplicate of bug 133522 ***