Skip to content

fix(builder): ODT layout parity with DOCX (inherited spacing, space after a page break) #298

Done

Description

@vaceslav

Found by porting a real-world template end to end (#292; epic #261, phase 4). The template matched the original in pages, words and fonts through a Stirling-PDF (LibreOffice) PDF path.

F10 — ODT: a derived paragraph style that sets one spacing loses the other · cosmetic, easy to hit

A style based on another that sets only SpaceBefore is written with only fo:margin-top. LibreOffice reads the top
and bottom margin of a style as one item, so the inherited fo:margin-bottom becomes 0. Measured: label to value
13.3 pt in the ODT against 15.3 pt in the DOCX, until the derived style restated both values.

Proposed change: when a style sets either spacing, the ODT writer writes both, resolved through BasedOn. The same
probably holds for start, end and first-line indent (not measured).

F11 — ODT: space above a heading at the top of a page after a manual page break · cosmetic

After PageBreak() a heading with 28 pt space before starts 28 pt lower in the ODT than in the DOCX. LibreOffice drops
that space for a DOCX and keeps it for an ODT.

Proposed change: write LibreOffice's compatibility settings into settings.xml so both formats lay out alike, or
document the difference in the support matrix. Which setting it is has to be confirmed; I did not test one.

Activity

  1. added
    enhancement
    builder
    on Nov 26, 2026
  2. vaceslav commented on Dec 1, 2026

    @vaceslav
    ContributorAuthor

    Done on feature/builder (9bb5d0e..73571a9).

    F10. A derived paragraph style that sets only one of space before and space after now gets the other written from its parent chain. LibreOffice reads both as one item and lost the inherited value: 15.6 pt in ODT against 25.6 pt in DOCX, now equal. Start, end and first-line indents were measured and are already inherited correctly.

    F11. This is not a compatibility setting. In a spike, AddParaTableSpacingAtStart in settings.xml changed nothing in six cases, and the two settings sets differ in no flag about this. The cause is LibreOffice's DOCX import: it writes margin-top 0 on the paragraph after a page break. The ODT writer now applies the same rule as a pass over the block tree, which removes the space before from:

    • the first paragraph, table (space before) or rule after a break;
    • the first block of every branch of a conditional there.

    The pass does not go into loops (every copy would lose the space) or table cells (LibreOffice ignores a break there). The final review of the first version found exactly these four shapes (loop, cell, table/rule, else); the rework covers each with a test against the DOCX rendered by LibreOffice.

    Known limits (documented):

  3. vaceslav commented on Dec 2, 2026

    @vaceslav
    ContributorAuthor

    Done on feature/builder, merged to main in #316 and released in builder 0.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    builderenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions