Bug 106742 - FILEOPEN: DOC(X) table with minus left spacing in MSO Word 2013+
Summary: FILEOPEN: DOC(X) table with minus left spacing in MSO Word 2013+
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: Vitaliy
QA Contact:
URL:
Whiteboard: target:5.4.0
Keywords:
Depends on:
Blocks: DOCX-Tables
  Show dependency treegraph
 
Reported: 2017-03-24 09:47 UTC by Thomas Lendo
Modified: 2017-04-26 20:39 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
MSO Word 2013 file with table (spacing to content 0.3 cm) (17.75 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-03-24 09:47 UTC, Thomas Lendo
Details
Screenshot showing the difference (55.09 KB, image/png)
2017-03-24 09:50 UTC, Thomas Lendo
Details
ooxml export unit test (13.39 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-04-05 09:02 UTC, Vitaliy
Details
Table made with MSO Word XP in LibO 5.4.0.0.alpha0+ (17.13 KB, image/png)
2017-04-26 20:35 UTC, Thomas Lendo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Lendo 2017-03-24 09:47:26 UTC
Created attachment 132116 [details]
MSO Word 2013 file with table (spacing to content 0.3 cm)

When opening an MS Office Word file, the tables in this document have a minus left spacing. This numeric value is the same as the table spacing to content.

I assume that the left beginning of the table content is for LibO the same as the left beginning of page content. But for MSO the table begins at page borders, not where the table content begins.

Steps to reproduce:

- Open the attached file with LibO (or create a new Word file, insert a table, save it and open it with LibO).
- Click into the table.
- Open the table properties dialog with Table > Properties...

Actual result:

Spacing "Left" (tab: Table) has the same value (in its negative form) as the Spacing to Contents "Left" value (tab: Borders).

You can test it if you change the content spacing in MSO to another value and then opening it in LibO -> same result with new value.

Expected result:

Like in MSO, the table borders should begin where the page content begins. Spacing "Left" (tab: Table) should be "0 cm".


Tested with
MSO 2013,
LibO 5.3.1.2
Build ID: e80a0e0fd1875e1696614d24c32df0f95f03deb2
CPU Threads: 8; OS Version: Windows 6.2; UI Render: default; Layout Engine: new; Locale: de-DE (de_DE); Calc: CL
and LibO 5.3.1.2
Comment 1 Thomas Lendo 2017-03-24 09:50:09 UTC
Created attachment 132117 [details]
Screenshot showing the difference
Comment 2 Xisco Faulí 2017-03-24 10:17:15 UTC
Confirmed in

Version: 5.4.0.0.alpha0+
Build ID: 1670cc25bc2771e87f7956a4b0dd634abaa4128b
CPU threads: 4; OS: Linux 4.8; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group

and

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 3 Vitaliy 2017-04-05 09:02:51 UTC
Created attachment 132343 [details]
ooxml export unit test

Open the attachment in Word 2013+ please. If you change cell margin at the table, the border will be shifted. But if you save the document again this will stop working - if you try to change cell margin, cell padding will be changed instead of margin.



I've found this info:

https://social.technet.microsoft.com/Forums/ie/en-US/0a6529f8-b980-4240-87ad-ee4fac85020b/word-2016-cant-override-default-table-cell-margins?forum=Office2016ITPro

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_mobile/word-2016-impossible-to-adjust-margins-within/4ba072e2-8a9d-4533-84fe-49f190003392



https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_mac/ms-word-for-mac-formatting-issues/1fccba17-5cdd-4cba-a626-c2239cbb7d2b

>In Word 2013, this was changed so that the table border aligns with
>the margin and the text is indented. Word 2016 for both Mac and Windows
>both follow this new rendering. This will not be changed. The only way to
>have the table appear in the old style is to save the file in an earlier
>version of Word.

>For anyone creating templates or documents with tables that have to work
>in a mixed 2011/2016 environment, the solution is to set the cell margins at 0
>then use paragraph indenting to create the space between the text
>and the table border. This renders the same in all versions of Word.



I see 2 ways to solve the problem:

1. Change behavior as in Word 2013+. But all newer documents saved as docx will become incompatible with older versions of Word.

2. Another option is to try to detect version of software that generated document. That will allow to see document as author intended. But this will however lead to users of older Words see different results with newer documents, and newer Word will show older documents differently, too.
Comment 4 Heiko Tietze 2017-04-08 08:56:54 UTC
Stuart, what do you think about the suggestions?
Comment 5 Thomas Lendo 2017-04-10 11:28:49 UTC
Thank you, Vitaliy, for your investigation.

I would prefer option 1 and would handle it like Word 2013+ because new documents saved in Word 2013+ as docx are incompatible with older versions of Word too. This would be the cleaner and forward-looking implementation. It's also easier to explain that behavior to LibO users because it's how new Word versions works too.
Comment 6 Commit Notification 2017-04-17 11:15:40 UTC
Vitaliy Anderson committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9a31d1c83e08600507689dc18f6f0973bc7e4389

tdf#106742: OOXML import/export: treat "tblInd" properly.

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Thomas Lendo 2017-04-21 21:59:58 UTC
I tested the attached example documents in this bug and it seems to be fixed. I will test it on Windows soon.

@Vitaliy: Still working on it or finished?

Version: 5.4.0.0.alpha0+
Build ID: 091a92cedd02dd486076a76f1cddde026f359d0c
CPU threads: 2; OS: Linux 3.13; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86@71-TDF, Branch:master, Time: 2017-04-20_05:55:01
Comment 8 Dominik Kopp 2017-04-22 13:53:03 UTC
I can confirm as well that normal tables are now better positioned.
Comment 9 Vitaliy 2017-04-24 12:22:51 UTC
Thomas, I've finished working on this. Please test the patch. If it's ok, close this bug :)
Comment 10 Thomas Lendo 2017-04-26 20:35:06 UTC
Created attachment 132875 [details]
Table made with MSO Word XP in LibO 5.4.0.0.alpha0+

I also tested a table made with MSO Word XP (aka Word 2002 aka Word 10) in LibO 5.4.0.0.alpha0+ and it looked identical.
Comment 11 Thomas Lendo 2017-04-26 20:39:45 UTC
I successfully tested the files attached to this bug and other files made with MSO Word 2013 on Windows 10.

Set bug to RESOLVED FIXED.

Version: 5.4.0.0.alpha0+
Build ID: 1167df7df59e37fddef0c40c4d27cb2e82e10922
CPU threads: 2; OS: Linux 3.13; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86@71-TDF, Branch:master, Time: 2017-04-26_14:55:28
Locale: de-DE (de_DE.UTF-8); Calc: group

Vitaliy, thank you very much for your fast and accurate  work!