Bug 155229 - FILEOPEN DOCX/DOC/RTF Table with row heights set as "At least" gets smaller row heights (MSO atLeast 10 is larger than MSO exact 10)
Summary: FILEOPEN DOCX/DOC/RTF Table with row heights set as "At least" gets smaller r...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Oliver Specht (CIB)
URL:
Whiteboard: target:25.2.0
Keywords: filter:doc, filter:docx, filter:rtf
Depends on:
Blocks: DOCX-Tables DOC-Tables RTF-Tables
  Show dependency treegraph
 
Reported: 2023-05-10 10:33 UTC by Gabor Kelemen (allotropia)
Modified: 2024-11-29 10:46 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from Word 2013 (16.01 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-05-10 10:33 UTC, Gabor Kelemen (allotropia)
Details
The example file saved as DOC (79.00 KB, application/msword)
2023-05-10 10:34 UTC, Gabor Kelemen (allotropia)
Details
The example file saved as RTF (195.48 KB, application/msword)
2023-05-10 10:35 UTC, Gabor Kelemen (allotropia)
Details
The DOCX example file in Word 2016 and Writer (100.78 KB, image/png)
2023-05-10 10:36 UTC, Gabor Kelemen (allotropia)
Details
The DOC example file in Word 2016 and Writer (98.85 KB, image/png)
2023-05-10 10:38 UTC, Gabor Kelemen (allotropia)
Details
The RTF example file in Word 2016 and Writer (110.10 KB, image/png)
2023-05-10 10:40 UTC, Gabor Kelemen (allotropia)
Details
The docx file saved as PDF with Word and Writer, compared in DiffPDF (77.36 KB, image/png)
2023-05-10 10:43 UTC, Gabor Kelemen (allotropia)
Details
The example docx with row heights changed to exact values (16.15 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-05-10 11:32 UTC, Gabor Kelemen (allotropia)
Details
The modified example file in Word and Writer - layout matches (149.45 KB, image/png)
2023-05-10 11:38 UTC, Gabor Kelemen (allotropia)
Details
155229_exact0.51cm.docx: 1 page document that becomes 2 pages with w:hRule="atLeast" (16.27 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-07-06 15:36 UTC, Justin L
Details
155229_atLeast0.51cm.docx: 2 page document in MSO (14.56 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-07-06 15:41 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2023-05-10 10:33:27 UTC
Created attachment 187178 [details]
Example file from Word 2013

Attached example document contains a table with several rows where the row height is defined as "At least" 1.5 cm (numbers 34 - 36) and 0.6 cm (numbers 37-42). The rest is set as "Exactly" x cm.
When imported in Writer the row height of those with "At least" value is a bit smaller than originally, compounding as much to have the last row of the table on the same page instead of breaking to the second page like in Word.
This happens in DOCX/DOC/RTF formats as well.

1. Open attached document
-> the row numbered 67 is at the bottom of the first page instead of at the top of the second.

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 440c23ee678442fc64aa9fcca13b137738e10a04
CPU threads: 14; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: threaded

and all the way back to 3.5
Comment 1 Gabor Kelemen (allotropia) 2023-05-10 10:34:06 UTC
Created attachment 187179 [details]
The example file saved as DOC
Comment 2 Gabor Kelemen (allotropia) 2023-05-10 10:35:05 UTC
Created attachment 187180 [details]
The example file saved as RTF
Comment 3 Gabor Kelemen (allotropia) 2023-05-10 10:36:51 UTC
Created attachment 187181 [details]
The DOCX example file in Word 2016 and Writer
Comment 4 Gabor Kelemen (allotropia) 2023-05-10 10:38:10 UTC
Created attachment 187182 [details]
The DOC example file in Word 2016 and Writer
Comment 5 Gabor Kelemen (allotropia) 2023-05-10 10:40:19 UTC
Created attachment 187183 [details]
The RTF example file in Word 2016 and Writer
Comment 6 Gabor Kelemen (allotropia) 2023-05-10 10:43:09 UTC
Created attachment 187184 [details]
The docx file saved as PDF with Word and Writer, compared in DiffPDF

The DiffPDF tool shows that there is a compounding difference between row heights until the row 42, then the distance between the row borders is not growing anymore.
Comment 7 Gabor Kelemen (allotropia) 2023-05-10 11:32:42 UTC
Created attachment 187185 [details]
The example docx with row heights changed to exact values

If I change the At least values to "Exactly" then the layout matches.
Comment 8 Gabor Kelemen (allotropia) 2023-05-10 11:38:49 UTC
Created attachment 187186 [details]
The modified example file in Word and Writer - layout matches

I had to grow the last rows height by 0.2 cm before this, but with Exact row heights the layout matches.
Comment 9 Buovjaga 2023-05-16 16:08:44 UTC
Confirmed. Also confirmed the correct rendering in office.com.

Arch Linux 64-bit, X11
Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 41d96a72fc0e0a9fa35b6ac88a389473f8baedaf
CPU threads: 8; OS: Linux 6.3; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 16 May 2023
Comment 10 Gabor Kelemen (allotropia) 2023-07-03 18:59:51 UTC
*** Bug 156129 has been marked as a duplicate of this bug. ***
Comment 11 Justin L 2023-07-06 15:36:22 UTC
Created attachment 188236 [details]
155229_exact0.51cm.docx: 1 page document that becomes 2 pages with w:hRule="atLeast"

Satya discovered that in Microsoft Office, "atLeast" heights are actually larger than "exact" heights - at least in their layout.

Simply changing w:hRule="exact" to w:hRule="atLeast" will cause this 1-page document to become two pages in MSO. (I used MSO 2010 - the difference can easily be seen in the UI by simply selecting the table and changing the row heights from exact to at least.)
Comment 12 Justin L 2023-07-06 15:41:24 UTC
Created attachment 188237 [details]
155229_atLeast0.51cm.docx: 2 page document in MSO

This is the identical document, with "exact" changed to "atLeast".

The MSO documentation of course indicates that they OUGHT to be the same size. So this must be an MSO implementation detail. Thus it will be rather hard to guess what algorithm difference they use to determine the layout row height in these two cases. (Guessing wrong will lead to regressions in the other direction of having rows be too large, or round-tripping with a bigger TWIP result.)
Comment 13 Oliver Specht (CIB) 2024-06-26 11:50:08 UTC
In the 'atLeast' case the row height means the space between the borders. 
With 'exact' the border is ignored and painted into the cell.
Only the bottom border of the last has an influence on the table height.
Comment 14 Gabor Kelemen (allotropia) 2024-07-22 15:35:17 UTC
Proposed patch in https://gerrit.libreoffice.org/c/core/+/169611
Comment 15 Commit Notification 2024-08-30 13:48:06 UTC
Oliver Specht committed a patch related to this issue.
It has been pushed to "master":

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

tdf#155229 Calculate row height incl. border if 'atLeast' is set

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.
Comment 16 Gabor Kelemen (allotropia) 2024-08-30 14:00:24 UTC
Tested locally, all example files (in RTF/DOC/DOCX formats as well) here look the same as in Word.