Bug 135069 - FILEOPEN DOCX TOC style indent settings not imported correctly
Summary: FILEOPEN DOCX TOC style indent settings not imported correctly
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, filter:docx, regression
Depends on:
Blocks: DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2020-07-23 08:07 UTC by NISZ LibreOffice Team
Modified: 2020-11-09 16:10 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
Example file from Word with TOC paragraph styles (31.01 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-07-23 08:07 UTC, NISZ LibreOffice Team
Details
Screenshot of the original document side by side in Word and Writer (158.05 KB, image/png)
2020-07-23 08:08 UTC, NISZ LibreOffice Team
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2020-07-23 08:07:54 UTC
Created attachment 163437 [details]
Example file from Word with TOC paragraph styles

Attached user made document has a TOC and there are custom styles (TJ 1-9) defined for it. 
On the first level TOC entries is “TJ 1” style applied, on the second level it’s “TJ 2”. These have 0 before/after/hanging indent set.
When opened in Writer the before/after/first line indents get crazy values, making the first level TOC text unreadable.

More observations: “TJ 1” style is based on “Tartalom fejezetcím” style. Which is based on “Címsor 2” style, that has 19.32 cm hanging indent – this shows up in Writer; also 1 cm left indent which does not.
“Címsor 2” is based on “Címsor 1” which has 0 left and right indent, 0.75 cm hanging. “Címsor 1” is based on “Normal” which has 0 left and right indent and no hanging indent. 
I don’t see where the 15.5 cm before and -4,82 after indents are inherited in Writer, but the 19,32 first line indent is from the “Címsor 2” style. See also bug #132752

Also the “TJ 1-9” styles do not show up in the Styles sidebar at all.

Steps to reproduce:
    1. Open attached document

Actual results:
First level TOC entries unreadable due to spacing settings.

Expected results:
Readable TOC.

LibreOffice details:
Version: 7.1.0.0.alpha0+ (x64)
Build ID: b1c83b68bfbf3477fa6a8f4c79c53f6f9ab31f8e
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: default; VCL: win
Locale: hu-HU (hu_HU); UI: en-US
Calc: CL

Also in:
Verzió: 6.4.0.3 (x86)
Build az.: b0a288ab3d2d4774cb44b62f04d5d28733ac6df8
CPU szálak: 4; OS: Windows 6.3 Build 9600; Felületmegjelenítés: GL; VCL: win; 
Területi beállítások: en-US (hu_HU); Felület nyelve: hu-HU
Calc: CL

Does not happen yet (styles seem not to be applied to TOC) in:
Verzió: 6.3.0.4 (x86)
Build az.: 057fc023c990d676a43019934386b85b21a9ee99
CPU szálak: 4; OS: Windows 6.3; Felületmegjelenítés: GL; VCL: win; 
Területi beállítások: hu-HU (hu_HU); Felület nyelve: hu-HU
Calc: CL

Bibisected using bibisect-win64-6.4 to:
URL: https://cgit.freedesktop.org/libreoffice/core/commit/?id=b47a8f091ad8f9048a6b7962e9cde5d04ea0d665
author	Justin Luth <justin.luth@collabora.com>	2019-08-01 15:50:00 +0300
committer	Justin Luth <justin_luth@sil.org>	2019-08-01 19:28:54 +0200
tdf#126544 writerfilter: check parent style exists before assigning

Adding CC to: Justin Luth
It might be possible that this has just uncovered something pre-existing.
Comment 1 NISZ LibreOffice Team 2020-07-23 08:08:14 UTC
Created attachment 163438 [details]
Screenshot of the original document side by side in Word and Writer
Comment 2 Xisco Faulí 2020-07-23 16:08:20 UTC
Reproduced in

Version: 7.1.0.0.alpha0+
Build ID: d8270636a57e7dc68ede51308c380e2098f765d7
CPU threads: 4; OS: Linux 4.19; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 3 Justin L 2020-07-24 09:41:45 UTC
I think that the problem is that w:styleId="Tartalomfejezetcm" tries to set indent before text to be larger than the page width (LO UI limits it to 15.5cm)
and so I'm guessing that LO spills the excess amount into a negative indent after text. (15.5+4.83 = 20.33)
          <w:ind w:left="11520" w:hanging="10953"/>

MS Word 2003 reports that Tartalomfejezetcm has a left indent of 1cm, and a hanging of 19.32 (=20.32). If I apply the Tartalomfejezetcm style to the line instead of TOC 1 (TJ1), then Word goes really bizarre. (Word 2016 does the same thing - the text is tried to be placed one character per line at position 20.32 I guess - which is offscreen.)

For some reason, Word explicitly states TOC 1 has indent of 0, first of 0. Is it doing something special to prevent inheritance for the TOC styles? W:ind certainly is not defined by the style itself. And yet with the UI I can re-inherit from Tartalomfejezetcm and then Word goes berserk as well.

So it seems there are some illegal things in this document (Word's UI does not allow such a large left indent for example.)
Comment 4 NISZ LibreOffice Team 2020-08-24 12:30:01 UTC Comment hidden (obsolete)
Comment 5 NISZ LibreOffice Team 2020-08-24 12:45:57 UTC
(In reply to NISZ LibreOffice Team from comment #4)
> (In reply to Justin L from comment #3)
> > So it seems there are some illegal things in this document (Word's UI does
> > not allow such a large left indent for example.)
> 
> It seems to depend on the paragraph location too:
> - For Normal paragraph in document body on an A4 page it is 14,7 cm
> (Hanging+Left+Right)
> - In the TOC in this example document it is 26,6 cm. Although the TOC starts
> to look quite funny after that.

Correction:
- For direct formatting the limit is 14,7 cm
- For paragraph style the limit is 26,6 cm
For an A4 page.
For A3 the paragraph style limit is the same, but direct formatting goes up to 23,4 cm.