Bug 157572 - FILEOPEN: DOCX: Incorrect position of text frames inside pseudo-table because of wrong vAnchor default
Summary: FILEOPEN: DOCX: Incorrect position of text frames inside pseudo-table because...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:24.2.0 target:7.6.3
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2023-10-03 11:40 UTC by Xisco Faulí
Modified: 2023-10-05 19:39 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Comparsion MSO vs LibreOffice 24.2 master (357.85 KB, image/png)
2023-10-03 11:40 UTC, Xisco Faulí
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2023-10-03 11:40:24 UTC
Created attachment 189974 [details]
Comparsion MSO vs LibreOffice 24.2 master

Steps to reproduce:
1. Open attachment 66643 [details] from bug 54516
2. Go to page 2

-> The header is in the wrong table cell. See comparison

Reproduced in

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 0c4913e03e8427a576138601958f2dbf13b8c37b
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded

[Bug found by office-interoperability-tools]
Comment 1 Xisco Faulí 2023-10-03 11:41:16 UTC
Regression introduced by:

author	Justin Luth <justin.luth@collabora.com>	2023-03-11 13:16:56 -0500
committer	Justin Luth <jluth@mail.com>	2023-03-14 12:02:24 +0000
commit 630732bfd8ed531e9d412a36a083f33763def054 (patch)
tree 54073ddad4ba516dd98792c8847c93d16f2e0752
parent b1696d2a3e2015b60fc04a785e6a9f7925f4232e (diff)
tdf#112287 tdf#154129 writerfilter framePr: fix vAnchor default

Bisected with: bibisect-linux64-7.6

Adding Cc: to Justin Luth
Comment 2 Justin L 2023-10-03 15:49:22 UTC
There is no table here. These are all just lines and boxes and whatnot. This document has long been a complete mess.

But it is a good question - why some lines move and some don't. I'm struggling to make a minimal reproducer out of this document.

Prior to 7.0, this bug's focus on page 2 looked similar to today. It was "fixed" by 7.0 commit f5636817e7677a3081263df9004940a7d5ac54af
Author: Tibor Nagy on Wed May 6 11:15:35 2020 +0200
    tdf#112287 DOCX frame import: fix default vAnchor
    
    Vertical frame alignment was calculated from above
    margin instead of the bottom one, resulting bad
    positions, when vAnchor wasn't defined.

One nice thing - there are no framePr entries in the styles. So everything is spelled out in document.xml. I believe the line I am looking for is <w:framePr w:w="1100" w:wrap="auto" w:hAnchor="margin" w:x="881" w:y="4681"/> In any case, none of these framePr's have any defined nVAnchor or nVAlign, but all should have a valid w:y.

So they SHOULD all be vertically positioned according to the page margin. And that is exactly what MS Word 2010 does as well, but my commit changed LO to use the paragraph.

So, the textboxes are aligned to the anchor paragraph, and the line shapes are aligned to the entire page - the same as MS Word. REGRESSION seems to be accurate.


RABBIT TRAIL: -------------------------------------------------------
There also seems to be a difference in the paragraph the textboxes are anchored to. In MS Word, they are anchored to the top (of two) paragraphs, while in LO they are anchored to the last paragraph. (In Word, changing to "relative to page" doesn't change the position, but it does in LO.) 

So, checking the anchoring to the "top paragraph on page 2" goes all the way back to 6.3 when the page break was first restored, which I assume was with
6.3 commit f6f53f76e15f5eecc5b6ce56e471c53cebfea8ad
Author: Justin Luth on Wed Apr 24 22:20:51 2019 +0300
    tdf#123636 writerfilter: handle deferred breaks on frames
Comment 3 Justin L 2023-10-03 17:25:24 UTC
from 17.3.1.11 framePr (Text Frame Properties), we find:
vAnchor (Frame Vertical Positioning Base) Specifies the base object from which the horizontal positioning in the y attribute should be calculated.

A text frame can be horizontally positioned relative to:
* The horizontal edge of the page before any runs of text (the top edge for top-to-bottom sections, the bottom for bottom-to-top sections)
* The horizontal edge of the text margin before any runs of text (the top edge for top-to-bottom sections, the bottom for bottom-to-top sections)
* The horizontal edge of the page before any runs of text (the top edge for top-to-bottom sections, the bottom for bottom-to-top sections) [identical to #1???]

If this attribute is omitted, then its value shall be assumed to be page.

HOWEVER, errata [MS-OE376].pdf in 2.1.48 Part 4 Section 2.3.1.11, framePr (Text Frame Properties) indicates:
The standard states that the default value for the vAnchor attribute is page.
HOWEVER Word uses a default value of text for this attribute (and for hAnchor).

HOWEVER, when I save this document, it writes out vAnchor for "page" and "paragraph - aka text", but does not write out vAnchor for "margin". So BOTH pieces of documentation are wrong?


The detailed description of the three choices is:
"margin" (Relative To Margin): Specifies that the parent object shall be vertically anchored to the text margins.
This shall be used to specify that any vertical positioning values shall be calculated with respect to the location of the text margin.

"page" (Relative To Page): Specifies that the parent object shall be vertically
anchored to the page edge.
This shall be used to specify that any vertical positioning values shall be calculated with respect to the location of the edge of the page.

"text" (Relative To Vertical Text Extents): Specifies that the parent object shall be vertically anchored to the text extents.
This shall be used to specify that any vertical positioning values shall be calculated with respect to the location of the top edge of the text in the anchor paragraph.


In LO we have:
text::RelOrientation::PAGE_PRINT_AREA = margin
text::RelOrientation::PAGE_FRAME = page
text::RelOrientation::FRAME = text
Comment 4 Justin L 2023-10-03 20:33:31 UTC
proposed fix at https://gerrit.libreoffice.org/c/core/+/157527
Comment 5 Commit Notification 2023-10-04 14:36:50 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#157572 tdf#112287 tdf#154129 writerfilter framePr: fix vAnchor default

It will be available in 24.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.
Comment 6 Commit Notification 2023-10-04 16:42:05 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/44401e14ff0aab5bc9505c2ec3b78ce91eaf8f4f

related tdf#157572 writerfilter framePr: no vAlign if w:y defined

It will be available in 24.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.
Comment 7 Commit Notification 2023-10-04 18:43:20 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5760d7876dae55d351e80b990dc064440fa46a73

related tdf#157572 writerfilter framePr: no vAlign if vAnchor=text

It will be available in 24.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.
Comment 8 Commit Notification 2023-10-04 18:44:22 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

related tdf#157572 docx export framePr: no w:x if zero or xAlign

It will be available in 24.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.
Comment 9 Commit Notification 2023-10-05 06:42:20 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

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

tdf#157572 tdf#112287 tdf#154129 writerfilter framePr: fix vAnchor default

It will be available in 7.6.3.

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.