Bug 166141 - FILEOPEN DOCX: Normal paragraph style gained 0.35cm "space after" when none is defined
Summary: FILEOPEN DOCX: Normal paragraph style gained 0.35cm "space after" when none i...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.6 all versions
Hardware: All All
: low minor
Assignee: Justin L
URL:
Whiteboard: target:26.2.0
Keywords: bibisected, bisected, regression
Depends on:
Blocks: DOCX-Paragraph
  Show dependency treegraph
 
Reported: 2025-04-11 13:01 UTC by Justin L
Modified: 2025-06-24 12:24 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
forum-mso-de-125863.docx: the example document (37.00 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-04-11 13:01 UTC, Justin L
Details
166141_minimal.docx: a minimal example of .35cm below paragraph spacing when none defined (29.47 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-06-23 13:21 UTC, Justin L
Details
166141_minimal2.docx: with attachedTemplate removed - so below spacing = 0.35cm (29.23 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-06-23 18:29 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2025-04-11 13:01:25 UTC
Created attachment 200295 [details]
forum-mso-de-125863.docx: the example document

In this document, the paragraphs should not be "separated" from each other. This is about as simple as you can get. There is no paragraph direct properties (no w:pPr) and no style assigned (so it should inherit from "Normal" - which looks fairly standard to me). 

<w:style w:type="paragraph" w:default="1" w:styleId="Standard">
  <w:name w:val="Normal"/>
  <w:pPr>
    <w:spacing w:line="264" w:lineRule="auto"/>   # no w:after="xxx"  defined
  </w:pPr>
</w:style>

There also are no DocDefaults <w:pPrDefault/> entries, so I'm not sure where the 0.35 cm of below spacing in the default paragraph style are coming from. It isn't a LO default for new ODT documents...

This started in LO 3.6.
Comment 1 Justin L 2025-06-23 13:21:32 UTC
Created attachment 201429 [details]
166141_minimal.docx: a minimal example of .35cm below paragraph spacing when none defined

It is related to settings.xml linkStyles.

if (m_pSettingsTable->GetLinkStyles())
    // If linked styles are enabled, set paragraph defaults from Word's default template
    xTextDefaults->setPropertyValue(getPropertyName(PROP_PARA_BOTTOM_MARGIN),
        uno::Any(sal_Int32(convertTwipToMm100(200))));

This was added by commit 8ba44dd1abbe31c1235f3b840bf27a61c3401236
Author: Miklos Vajna <vmiklos@suse.cz> on Wed Mar 14 17:12:35 2012 +0100
    n#751020 implement DOCX import of linked styles
    
    This is just initial support: the default template and paragraph
    properties are included.
Comment 2 Justin L 2025-06-23 18:24:56 UTC
17.15.1.55 linkStyles (Automatically Update Styles From Document Template)

This element specifies that styles in the given document shall be updated to match the styles in the attached template specified using the attachedTemplate element (§17.15.1.6) when the document is opened by a hosting application. This setting enables the styles contained in documents with attached templates to stay
synchronized with the styles used in the attached template.
If this element is omitted, then styles shall not be updated based on the document template regardless of its availability. If the attached template cannot be located or is not a valid file, then this setting should be silently ignored.

[Example: Consider a WordprocessingML document which should always update its styles with those defined in the document's attached template. This requirement would be specified using the following WordprocessingML in the document settings:
<w:settings>
  <w:linkStyles w:val="true" />
  <w:attachedTemplate r:id="rId10" />
…
</w:settings>


It seems like the key here is "If the attached template cannot be located or is not a valid file, then this setting should be silently ignored." If there is NO attachedTemplate listed, then YES - update using the builtin Word defaults.
Comment 3 Justin L 2025-06-23 18:29:39 UTC
Created attachment 201432 [details]
166141_minimal2.docx: with attachedTemplate removed - so below spacing = 0.35cm
Comment 4 Commit Notification 2025-06-24 12:24:09 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/bf326cd72905df985a1f150dbaabf4470fb5aabb

tdf#166141 writerfilter docx: linkStyles != 0.35cm bottom margin

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.