Bug 168927 - All tables are treated as RTL when a specific *.dot template is opened in LibreOffice
Summary: All tables are treated as RTL when a specific *.dot template is opened in Lib...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
25.8.1.1 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: DOCX-RTL
  Show dependency treegraph
 
Reported: 2025-10-17 21:54 UTC by Paul
Modified: 2025-10-18 19:22 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul 2025-10-17 21:54:17 UTC
Description:
The following public Microsoft Word template contains some tables: https://www.mdpi.com/files/word-templates/nanomaterials-template.dot

When I open this template with Microsoft Word, it looks alright. When I open it in LibreOffice Writer, the tables appear as Right-to-Left and are saved as RTL.

I've done some research, and it appears that the template is partially at fault: at the end of the document, inside <w:sectPr> element, there's a <w:bidi/> element. However, I believe that, according to the standard, this BiDi should only apply to the last section, and certainly not to all tables inside the document.

Can confirm that removal of <w:bidi/> from the last section's <w:sectPr> makes all the tables LTR, as they should be.

Steps to Reproduce:
1. Download https://www.mdpi.com/files/word-templates/nanomaterials-template.dot
2. Open it in Writer.
3. Observe the tables within the document.

Actual Results:
The tables appear as Right-to-Left. E.g., in Table 1, the leftmost column is "Title 3" and the rightmost is "Title 1"; the cursor movement between the cells is also inverted, but not inside the cells. In other words, LibreOffice, for some reason, thinks this table is RTL, or should be displayed as RTL.

If I save this template as a *.docx file, LibreOffice inserts <w:bidiVisual w:val="true"/> for each table, consequently even MS Word starts to treat the tables as RTL. If I save this template as an *.odt file and reopen it in LibreOffice, the tables continue to be treated as RTL too.

Expected Results:
LTR tables.


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 25.8.1.1 (X86_64) / LibreOffice Community
Build ID: 580(Build:1)
CPU threads: 16; OS: Linux 6.16; UI render: default; VCL: gtk3
Locale: en-GB (en_US.UTF-8); UI: en-US
Debian package version: 4:25.8.1-1
Calc: threaded

Tl;dr: <w:bidi/> element inside the last section's <w:sectPr> is erroneously applied to all tables inside the document.
Comment 1 Regina Henschel 2025-10-18 14:58:34 UTC
The problem is, that the template uses the right-to-left mark in the section property to position the line numbering on the right margin. It seems Word has no other means to put the line numbering to the right.

To "repair" the document, set the writing direction to "left-to-right" in the page style and the line numbering position to "right" in Tools>Line numbering.

I see in Word, that even in a right-to-left section, the table layout (=ordering of columns) is left-to-right. You need to explicitly set it to right-to-left in the table properties if you want the start column on the right side. The table will get a <w:bidiVisual/> child element then.

Perhaps LibreOffice can set text::WritingMode2::LR_TB as default in any case on import and later overwrite it, if a "bidiVisual" exists?

I think, ignoring the <w:bidi/> element cannot be the solution, because it might be used for other purposes than positioning of line numbering.

I confirm, that there is an import problem.

BTW, the template is not a dot (MS binary), but a dotx document.

Tested with Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: d60ff8c8bd4e3ebf8f84f53448ead3c838332ea9
CPU threads: 32; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: threaded

and

Microsoft® Word for Microsoft 365 MSO (Version 2509 Build 16.0.19231.20138) 64-bit
Comment 2 Paul 2025-10-18 19:22:44 UTC
Had to double check the line numbering. Thing is, I have MS Word 2010, and when I open a non-modified template in it, I can't see any line numbers at all. I did not notice this behavior before. A modified template (with that BiDi removed) shows line numbers on the left, and so does any document based on this template, but saved by LibreOffice.

To be honest, I lack expertise in OpenXML formats, so I don't quite understand why that BiDi should affect table layout throughout the document, but not the text (which is obviously LTR). Is the "last section" referring to something reserved for page setup (like line numbering and other options), instead of literally the last section (e.g., the last paragraph of text) of the document?

I can indeed fix the document both my way and the way you described, but later when save it back into *.docx, the line numbers are, of course, shown on the left. And it seems I need a version of word with RTL support installed to fix this without XML editing. Not sure whether we can do anything about it, if *.docx itself lacks options for line number positioning.