Bug 164908 - FILEOPEN DOCX: heading 1 no longer centered (despite direct formatting)
Summary: FILEOPEN DOCX: heading 1 no longer centered (despite direct formatting)
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
24.2.4.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2025-01-29 02:18 UTC by Justin L
Modified: 2025-03-13 21:18 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
forum-mso-de-132466.docx: example file (153.12 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-01-29 02:18 UTC, Justin L
Details
forum-mso-de-132466.docx_mso.pdf: how it looks in Word 2019 (151.60 KB, application/pdf)
2025-01-29 02:20 UTC, Justin L
Details
forum-mso-de-132466min.docx: minimized version (147.66 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-02-21 15:25 UTC, Justin L
Details
Minimized example from Word 13, DE locale (37.70 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-03-13 21:18 UTC, Gabor Kelemen (allotropia)
Details
The minimized example in Word 2013 and Writer master (55.45 KB, image/png)
2025-03-13 21:18 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2025-01-29 02:18:51 UTC
Created attachment 198836 [details]
forum-mso-de-132466.docx: example file

One page 3, the heading "Chapter 1" is not centred (nor Chapter 2 etc.).

From 24.8 (backported to 24.2.4) commit ab1697cb4c17fd7a2fbf8d374ac95fc03b4d00be
Author: Michael Stahl on Fri May 3 12:12:24 2024 +0200
    tdf#160402 filter,writerfilter: import locale-dependent STYLEREF names

Something funny must be going on. Direct formatting of "center" is pretty clear.
  <w:pPr>
    <w:pStyle w:val="berschrift1"/>
    <w:jc w:val="center"/>
  <w:rPr>

w:style w:type="paragraph" w:styleId="berschrift1">
  <w:name w:val="heading 1"/>

Found by Collabora's mso-test
Comment 1 Justin L 2025-01-29 02:20:12 UTC
Created attachment 198837 [details]
forum-mso-de-132466.docx_mso.pdf: how it looks in Word 2019
Comment 2 Justin L 2025-02-21 15:25:43 UTC
Created attachment 199365 [details]
forum-mso-de-132466min.docx: minimized version

Round-tripping the original using MS Word 2010 (English) "fixes" the problem for LO. So I had to hand-modify the example to remove most of the body text.
Comment 3 Justin L 2025-02-21 17:13:00 UTC
The big difference? Before mstahl's commit, the paragraph style was "Heading 1".

It looks like something to do with the header. If I remove references to the header (which of course has a STYLEREF field in it), then it loads OK.
Comment 4 Justin L 2025-02-22 02:05:00 UTC
If I understand this right, mstahl just did a better job applying an existing bad idea.

It seems to go like this:
-the styleRef assigns the existing style to itself (for formatting)
-a clone of the style is made, and then the entire document is stepped through, and existing paragraphs are re-assigned to the clone-style.

Well, as part of "changing paragraph style", you lose any direct formatting.

My head is just spinning - all of this is too clever for me. Bye.
Comment 5 Gabor Kelemen (allotropia) 2025-03-13 21:18:33 UTC
Created attachment 199801 [details]
Minimized example from Word 13, DE locale

For this styleref thing to properly work, you need a matching Word UI and document locale. Unfortunately a German docx does break in an English Word :(.
Comment 6 Gabor Kelemen (allotropia) 2025-03-13 21:18:57 UTC
Created attachment 199802 [details]
The minimized example in Word 2013 and Writer master