https://bugs.documentfoundation.org/show_bug.cgi?id=161509
Bug ID: 161509 Summary: Built-in Microsoft Word style names are remapped on import but not on export Product: LibreOffice Version: 7.4.7.2 release Hardware: All OS: All Status: UNCONFIRMED Severity: normal Priority: medium Component: Writer Assignee: libreoffice-bugs@lists.freedesktop.org Reporter: d...@ecolingui.ca Description: See https://github.com/python-openxml/python-docx/issues/494#issuecomment-2160619976 for some context. LibreOffice will remap Microsoft Word's style names to its own when importing DOCX. For example, "heading 1" becomes "Heading 1". The full table appears to be in core/sw/source/writerfilter/dmapper/StyleSheetTable.cxx:1555 (StyleSheetTable::ConvertStyleName) The comment in that function implies that the names will be converted back on export. Unfortunately this is not entirely correct. They are remapped, but not to the right names, for instance, "Heading 1" remains "Heading 1" and not "heading 1". See core/sw/source/filter/ww8/styles.cxx (GetStiNames). Again the comment does not match the code, it says "keep in sync with StyleSheetTable::ConvertStyleName" but it is not in sync. Surprisingly for a Microsoft product, the names are case-sensitive. This doesn't cause any actual issues when loading the files in Word since the style definitions are copied into the document. However it causes unexpected errors when using third-party code such as the python-docx module that expect the Microsoft internal names for built-in styles. Steps to Reproduce: 1. Create a file in Microsoft Word with a "Heading 1" 2. Load the file in LibreOffice 3. Re-export the file as DOCX with LibreOffice Actual Results: word/styles.xml in the output has: <w:style w:type="paragraph" w:styleId="Heading1"> <w:name w:val="Heading 1"/> <w:basedOn w:val="Normal"/> Expected Results: It should have (as in the original Word file): <w:style w:type="paragraph" w:styleId="Heading1"> <w:name w:val="heading 1"/> <w:basedOn w:val="Normal"/> Reproducible: Always User Profile Reset: No Additional Info: Version: 7.4.7.2 / LibreOffice Community Build ID: 40(Build:2) CPU threads: 4; OS: Linux 6.1; UI render: default; VCL: gtk3 Locale: en-CA (en_CA.UTF-8); UI: en-US Debian package version: 4:7.4.7-1+deb12u2 Calc: threaded -- You are receiving this mail because: You are the assignee for the bug.