Bug 128290 - FILESAVE: DOCX Table in exported DOCX resizes columns in MSO - option "Automatically resize to fit contents"
Summary: FILESAVE: DOCX Table in exported DOCX resizes columns in MSO - option "Automa...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: medium normal
Assignee: Louis Meyrat
URL:
Whiteboard: target:6.5.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicDebug
: 128047 (view as bug list)
Depends on:
Blocks: DOCX-Tables
  Show dependency treegraph
 
Reported: 2019-10-21 10:21 UTC by Matthew Kogan
Modified: 2020-11-05 08:01 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Table column width test.odt (9.46 KB, application/vnd.oasis.opendocument.text)
2019-10-22 09:51 UTC, Matthew Kogan
Details
A sample DOCX created in Word with two tables to compare (14.85 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-11-27 11:51 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Kogan 2019-10-21 10:21:55 UTC
Description:
When an exported DOCX file is opened in Word, the columns are automatically resized to fit the contents. This behaviour is switchable in Word, so should be switched off in the exported file unless the equivalent behaviour has been switched on in Writer.

Steps to Reproduce:
1. Insert a table with two columns of equal width;
2. Type one short word in the first column, and one very long word in the second column, so that it wraps to the next line;
3. Save the document to DOCX;
4. Open the DOCX file in Word;

Actual Results:
The second column is wider than the first, so the long word does not wrap to the next line.

Expected Results:
Both columns should be the same width, as they were in Writer.


Reproducible: Always


User Profile Reset: No



Additional Info:
Unticking "Automatically resize to fit contents" on the "Table Options" dialog in Word makes the columns the same width again.
Comment 1 Xisco Faulí 2019-10-22 09:44:10 UTC Comment hidden (obsolete)
Comment 2 Matthew Kogan 2019-10-22 09:51:09 UTC
Created attachment 155228 [details]
Table column width test.odt

Sample document attached.
Comment 3 Xisco Faulí 2019-10-22 12:22:34 UTC
Reproduced in

Version: 6.4.0.0.alpha1+
Build ID: de4839e66d3d195315729b95cc144cdab96b6e74
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded

and

Version 4.1.0.0.alpha0+ (Build ID: ff140bb6b8b109f14c270ff059f0b8d71dab5d6)
Comment 4 Timur 2019-11-27 11:30:16 UTC
As written in this fine report, seen when LO-saved DOCX opened in MSO.
Not seen with LO-saved DOC.
Was also seen in LO 3.3 (where OOXML save was added) and worse.
Comment 5 Mike Kaganski 2019-11-27 11:51:02 UTC
Created attachment 156142 [details]
A sample DOCX created in Word with two tables to compare

We need to write <w:tblLayout w:type="fixed"/> into w:tblPr element of tables, as seen in the sample document, where the two otherwise identical tables are only differ by the said property said in Word 2016.
Comment 6 Mike Kaganski 2019-11-27 11:54:46 UTC
The pable properties are set in sw/source/filter/ww8/docxattributeoutput.cxx (DocxAttributeOutput::TableDefinition), and sw/source/filter/ww8/docxtablestyleexport.cxx (DocxTableStyleExport::Impl::tableStyleTablePr).
Comment 7 Louis Meyrat 2020-01-07 13:49:27 UTC
Hi!
I'd like to take this easyhack as my first libreoffice task. I am able to reproduce the bug, and thanks to @Matthew Kogan and @Mike Kaganski 's pointers, this shouldn't take too long.
Wish me luck !
Comment 8 Louis Meyrat 2020-01-13 09:31:58 UTC
As stated in https://bugs.documentfoundation.org/show_bug.cgi?id=113604 , there is no equivalent feature in LibreOffice yet. 
So I simply added <w:tblLayout w:type="fixed"/> to all exported docx tables. It solves the problem for all the cases I could think of.
Comment 9 Mike Kaganski 2020-01-13 09:47:13 UTC
(In reply to Louis Meyrat from comment #8)
> As stated in https://bugs.documentfoundation.org/show_bug.cgi?id=113604 ,
> there is no equivalent feature in LibreOffice yet. 
> So I simply added <w:tblLayout w:type="fixed"/> to all exported docx tables.
> It solves the problem for all the cases I could think of.

Nice! Thanks for working on this.
Have you a gerrit change to look at? Please put me into reviewers. Thanks!
Comment 10 Louis Meyrat 2020-01-13 10:06:25 UTC
Sure ! I am setting up gerrit right now
Comment 11 Commit Notification 2020-01-19 22:31:39 UTC
Louis Meyrat committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/8be3ae254f5b2ff76d9861ad4b9b5b5de5d14bb4

tdf#128290 add tblLayout element to docx export

It will be available in 6.5.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 12 Timur 2020-03-12 12:46:31 UTC
Looks good in MSO. Thanks.
Comment 13 NISZ LibreOffice Team 2020-03-17 10:36:03 UTC
*** Bug 128047 has been marked as a duplicate of this bug. ***
Comment 14 Timur 2020-03-17 10:58:36 UTC Comment hidden (obsolete)