Bug 170208 - table/content without cell margin shifted left of the page margin
Summary: table/content without cell margin shifted left of the page margin
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: Justin L
URL:
Whiteboard: target:26.8.0 target:26.2.0.2 target:...
Keywords: bibisected, filter:docx
Depends on:
Blocks:
 
Reported: 2026-01-02 19:02 UTC by Justin L
Modified: 2026-01-19 16:34 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
forum-en-21352.docx: no tblInd, empty tcBorders, tcMar(0) (7.33 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2026-01-06 16:23 UTC, Justin L
Details
170208_generatedTblInd.docx: hand-tweaked to exaggerate unexpected indent from left (4.86 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2026-01-06 17:54 UTC, Justin L
Details
170208_generatedTblInd.pdf: how it looks in Word 2010 and then 2024 (39.19 KB, application/pdf)
2026-01-06 18:08 UTC, Justin L
Details
converted/import-compare.zip: PDF overlay. RED=fixed, BLUE=before fixes, BLACK=Word 2024 (880.39 KB, application/zip)
2026-01-12 18:36 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2026-01-02 19:02:55 UTC
The problem is that the table is too far to the left. In MS Word, the table has no margin, and the border starts at the page/body margin.

Ultimately this is probably inherited from OOo. The particular document I am focusing on did not load well at all in OOo, but already in 3.6.7 the table borders are shown left of the table. A large (DEF_BORDER_DIST) cell margin is seen here - and is the same size as the over-shift to the left.

The margin disappeared in 4.0, but the shift was still there.

The shift disappeared in 5.4 with commit 9a31d1c83e08600507689dc18f6f0973bc7e4389
Author:     Vitaliy Anderson on Mon Apr 17 13:11:53 2017 +0200
    tdf#106742: OOXML import/export: treat "tblInd" properly.

and returned with 6.3.6 commit d978f5d40102a098f1faf1e98aa39ad122284299
Author:     Michael Stahl on Tue Feb 11 11:57:35 2020 +0100
    related: tdf#106742 sw: DOCX import/export: fix default of table indent

It again disappeared in 7.5 with commit/788cc6ff3b186ceb8f265e53b5482f808f6536f4
author		Vasily Melenchuk on Mon Jan 09 07:54:51 2023 +0000
    "tdf#148578: Do not apply table shift for RTF"

and returns again in 25.8.3 with commit a80d7ba9c01c8c5c95bf01960d969b82dc7edffc
Author: Aron Budea on Mon Sep 29 14:59:18 2025 +0930
    tdf#168598 Fix for tdf#148578 should only apply to RTF
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191587

I expect the key to solving this is to notice that the cell margins end up being zero, instead of a default value of DEF_BORDER_DIST.

Seem with many examples. The ones I noted were:
fdo34995-1 attachment 44099 [details] (survey.docx)
fdo36552-3 attachment 46135 [details] (3 columns 2 rows.docx)
fdo40287-1 attachment 50449 [details] (note.docx)
fdo42668-1 attachment 53248 [details] (LibreOffice_Writer_crash.docx)
fdo47768-1 attachment 58926 [details] (SampleFile.docx)
fdo49229-2 attachment 60705 [details] (tabla_normal 2.docx)
fdo52191-3 attachment 64309 [details] (Untitled 1.docx)
fdo52222-1 attachment 64343 [details] (Ausbildungsnachweis0312.docx)
fdo61667-2 attachment 76793 [details] (copy_Mexico-Americano_hospital info.docx) ***
fdo74770-1 attachment 93741 [details] (Job_Description_HR3.docx)
Comment 1 Justin L 2026-01-03 14:02:12 UTC
(In reply to Justin L from comment #0)
> I expect the key to solving this is to notice that the cell margins end up
> being zero, instead of a default value of DEF_BORDER_DIST (0.19cm).

That changed in LO 4.1 with commit 60ec497e0e91354a616978be531d15d3efa3f559
Author:     Miklos Vajna on Fri Jan 4 14:49:05 2013 +0100
  n#793262 DOCX: import w:tcMar inside w:tc

This was found by Collabora's mso-test
Comment 2 Commit Notification 2026-01-06 02:27:53 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#170208 docx import: shift table by cell margin, not style margin

It will be available in 26.8.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 3 Justin L 2026-01-06 16:23:59 UTC
Created attachment 204943 [details]
forum-en-21352.docx: no tblInd, empty tcBorders, tcMar(0)

The fix in comment 2 only solves some of the documents, including the one I attached here - which was the main document I based the bug report on.
Also fixed: fdo34995-1(tcMar 0), fdo49229-2(tblInd -.05cm), fdo52222-1(tblInd -.12cm), 

Others, though now better, are not completely fixed. There seems to be some mystery at play here, because I get slightly different 'indent from left' results depending on the version of MS Word I use.

I see nothing in the specs or in the Errata documentation that indicates that a missing tblInd gets some default or some calculated value.

MS Word 2010 often gives me an unexpected table 'indent from left' of 0.08cm (where the table's 'default cell margins' are 0.02cm and the cell margins are 0.10cm), while Word 2024 has an unexpected 'indent from left' of 0.10cm
examples: fdo36552-3, fdo40287-1(0.19/0.17), fdo42668-1, fdo47768-1, fdo52222-1, 

So what do they have in common?
-none of them define a tblInd (although some of the fixed ones don't either - but they tended to have tcMar 0.)
-none of them have a settings.xml file (but I don't think that is the key)
-all of them define a non-empty w:tcBorders along with a tcMar

Based on some experimentation, it seems that it simply takes the value of tcMar and uses that as the undefined tblInd (Word 2010 always subtracting some complicated formula using the left and right tblCellMar from the tcMar).
In other words (at least for Word 2024) the indent and the cell margin cancel themselves out (and look like how compat15 would show it).
Comment 4 Justin L 2026-01-06 16:27:21 UTC
(In reply to Justin L from comment #0)
> fdo61667-2 attachment 76793 [details] (copy_Mexico-Americano_hospital info.docx)
> fdo74770-1 attachment 93741 [details] (Job_Description_HR3.docx)

These two were actually fixed by bearon's patch. (They don't have different tcMar cell margins)
Comment 5 Justin L 2026-01-06 17:54:42 UTC
Created attachment 204945 [details]
170208_generatedTblInd.docx: hand-tweaked to exaggerate unexpected indent from left

(In reply to Justin L from comment #3)
> There seems to be some mystery at play here,
> because I get slightly different 'indent from left'
> results depending on the version of MS Word I use.

This document clearly shows the differences between Word 2024 and 2010. It also clearly demonstrates that Word just manufactures it's own tblInd when none is provided.
Comment 6 Justin L 2026-01-06 18:08:21 UTC
Created attachment 204946 [details]
170208_generatedTblInd.pdf: how it looks in Word 2010 and then 2024
Comment 7 Commit Notification 2026-01-06 23:50:16 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#170208 docx import: conjure up a tblInd if none is provided

It will be available in 26.8.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 Justin L 2026-01-12 14:42:22 UTC
patch 7 should have fixed the remaining documents. Backports are in progress.
Comment 9 Commit Notification 2026-01-12 17:22:22 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/587c9ea7239d2c715975294d0b1d94b06550e74e

tdf#170208 docx import: shift table by cell margin, not style margin

It will be available in 26.2.0.2.

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 10 Justin L 2026-01-12 18:36:22 UTC
Created attachment 205024 [details]
converted/import-compare.zip: PDF overlay. RED=fixed, BLUE=before fixes, BLACK=Word 2024

In this zip file, I compared the PDFs of:
-RED: Collabora Office Classic 25.04 with the patches included
-BLUE: with the two patches reverted
-BLACK: Microsoft Home and Business 2024.

If you focus on the table lines, you can see that the text and table lines now line up better.
Comment 11 Commit Notification 2026-01-12 22:45:56 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/459530b73eb5650b2c5651a513a2d1e3541e689c

tdf#170208 docx import: conjure up a tblInd if none is provided

It will be available in 26.2.0.2.

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 12 Commit Notification 2026-01-19 16:34:35 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/10de2a2a1d9fd1fe3bdf93228f9379f4efff110e

tdf#170208 docx import: shift table by cell margin, not style margin

It will be available in 25.8.5.

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 13 Commit Notification 2026-01-19 16:34:38 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

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

tdf#170208 docx import: conjure up a tblInd if none is provided

It will be available in 25.8.5.

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.