Bug 32991 - FORMATTING: Tables Alignment lost when exporting to DOC and loading in MS Word
Summary: FORMATTING: Tables Alignment lost when exporting to DOC and loading in MS Word
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Justin L
Whiteboard: target:6.0.0
Keywords: filter:doc
Depends on:
Blocks: DOC
  Show dependency treegraph
Reported: 2011-01-11 04:06 UTC by Murz
Modified: 2020-12-03 14:22 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:

doc file with center aligned table (9.00 KB, application/msword)
2011-01-11 04:06 UTC, Murz
tablealign.odt (8.93 KB, application/vnd.oasis.opendocument.text)
2014-05-19 10:35 UTC, Murz
tablealign-lo- (9.50 KB, application/msword)
2014-05-19 10:35 UTC, Murz
tablealign-lo- (4.09 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2014-05-19 10:36 UTC, Murz
tablealign-oo-4.1.doc (9.50 KB, application/msword)
2014-05-19 10:36 UTC, Murz
native Word 2013 that correctly opens in both Word and LibreOffice (27.50 KB, application/msword)
2016-12-30 08:29 UTC, Luke
RTL_table_default.doc: sprmTJc==0, sprmTJc90==2 fails to open with table on right (24.00 KB, application/msword)
2017-08-26 01:43 UTC, Justin L

Note You need to log in before you can comment on or make changes to this bug.
Description Murz 2011-01-11 04:06:33 UTC
Created attachment 41874 [details]
doc file with center aligned table

How to reproduce:
1. Create new writer document.
2. Create the table 2x2.
3. Open table properties, set Aligment=Center, Width=70%, apply.
You will see the table center-aligned on page.
4. Save this file as doc (MS Word 97/2000/XP).
5. Open this file in Microsoft Word (2003, 2007 or other) - you will see this table aligned to left instead of center!
If you open this doc file in LibreOffice, you will see table centered, but in any MS Office Word application it show left-aligned.

Same problem with Right align.

This bug is absent on OpenOffice 3.0.0 but exists in 3.0.1 and later, the bug about this is here: http://www.openoffice.org/issues/show_bug.cgi?id=101472

Please fix this problem in LibreOffice, because it breaks all table formatting in documents when exporting to doc!
Comment 1 Thorsten Behrens (allotropia) 2011-01-13 01:01:33 UTC
This bug does not match the 3.3.0 blocker bug criteria.
Comment 2 Murz 2011-03-29 23:34:48 UTC Comment hidden (obsolete)
Comment 3 Björn Michaelsen 2011-12-23 11:34:48 UTC Comment hidden (obsolete, spam)
Comment 4 Murz 2011-12-30 02:51:54 UTC
Problem is still exists in LibreOffice 3.5 Beta 2, problem is exists with exporting to doc (MS Word 97/2000/XP/2003). With docx all works normally.

How to reproduce:
1. Create table with Alignment=center and width=70%. You will see table center-aligned on page.
2. Save the file as doc (MS Word 97/2000/XP/2003).
3. Open saved file in MS Word 97-2003. You will see table right-aligned, but must see center-aligned.
Comment 5 dE 2012-04-21 22:01:18 UTC Comment hidden (obsolete)
Comment 6 Jean-Baptiste Faure 2014-05-02 21:19:46 UTC Comment hidden (obsolete)
Comment 7 Paul 2014-05-15 01:43:45 UTC
I can confirm that the problem still occurs with DOC format and Libre Office
Comment 8 tommy27 2014-05-17 17:39:49 UTC Comment hidden (obsolete)
Comment 9 Murz 2014-05-19 10:34:59 UTC
I test this in LibreOffice version Version: Build ID: 420m0(Build:3) and this issue is reproducible when exporting to DOC:

When exporting to DOC - table is left-aligned, issue is here.

When exporting to DOCX - table is center-aligned, so all good.

Checking with Apache Openoffice 4.1.0 - when exporting to DOC - table is left-aligned, issue is here.
Comment 10 Murz 2014-05-19 10:35:34 UTC
Created attachment 99313 [details]

Source file
Comment 11 Murz 2014-05-19 10:35:49 UTC
Created attachment 99314 [details]
Comment 12 Murz 2014-05-19 10:36:02 UTC
Created attachment 99315 [details]
Comment 13 Murz 2014-05-19 10:36:19 UTC
Created attachment 99316 [details]
Comment 14 tommy27 2014-05-19 20:07:56 UTC
I've installed MS Word Viewer and I can reproduce the bug with LibO and
Build ID: a1dd961c3093f5f7624e4d1f2240e9120fd13f23
TinderBox: Win-x86@39, Branch:master, Time: 2014-05-06_11:47:48

tested under Win7x64
Comment 15 QA Administrators 2015-06-08 14:42:26 UTC Comment hidden (obsolete, spam)
Comment 16 Murz 2015-06-08 16:45:55 UTC
I have re-test this issue with version - it is still here.

When I export table to .doc - table alignment lost, when save to .docx - all ok.

Seems that this is issue only in .doc export module.

In OOo 3.3 this issue is reproducible too.
Comment 17 QA Administrators 2016-09-20 10:01:35 UTC Comment hidden (obsolete, spam)
Comment 18 Telesto 2016-11-24 15:58:39 UTC
Confirming with:
Build ID: f965a629fba10ecba7bad938a0c1c9c3db1e510d
CPU Threads: 4; OS Version: Windows 6.2; UI Render: default; Layout Engine: new; 
TinderBox: Win-x86@62-merge-TDF, Branch:MASTER, Time: 2016-11-23_00:13:10
Locale: nl-NL (nl_NL); Calc: CL
Comment 19 Luke 2016-12-30 08:29:16 UTC
Created attachment 130023 [details]
native Word 2013 that correctly opens in both Word and LibreOffice

There is an import bug here that is masking the initial export bug. If you open the first save in Word (attachment 99314 [details]), the center align is changed to left. The first save is already corrupted.
Comment 20 Justin L 2017-08-26 00:23:10 UTC
suggested fix at  https://gerrit.libreoffice.org/41584
Comment 21 Commit Notification 2017-08-26 01:16:29 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":


tdf#32991 DOCexport: MSO-compatible table justification

It will be available in 6.0.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:

Affected users are encouraged to test the fix and report feedback.
Comment 22 Justin L 2017-08-26 01:43:39 UTC
Created attachment 135801 [details]
RTL_table_default.doc: sprmTJc==0, sprmTJc90==2 fails to open with table on right

This section of ww8par2.cxx code mis-imports this into a left table:
    if ((m_nMinLeft && !m_bIsBiDi && text::HoriOrientation::LEFT == m_eOri) ||
        (m_nMinLeft != -108 && m_bIsBiDi && text::HoriOrientation::RIGHT == m_eOri)) // Word sets the first nCenter value to -108 when no indent is used
        m_eOri = text::HoriOrientation::LEFT_AND_WIDTH; //  absolutely positioned
Comment 23 Justin L 2017-08-26 01:46:34 UTC
useful unit test code:
CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT, getProperty<sal_Int16>(xTable, "HoriOrient"));
CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>(xTable, "WritingMode"));
Comment 24 Timur 2017-08-29 08:09:33 UTC
I'll set to Verified. Please backport. 
And please see cc'ed Bug 48882.
Comment 25 Justin L 2017-08-29 11:50:56 UTC
Not planning to backport since the documents don't round-trip anyway.

Bug 112074 was created to address the issues mentioned in comment 22 and comment 23. That should help a lot with round-tripping, but those shouldn't be backported either.
Comment 26 Finch. A 2020-12-03 11:29:07 UTC Comment hidden (spam)