Skip to content

fix(docx): name every page a page-margin note is about - #954

Merged
DemchaAV merged 1 commit into
2.5-devfrom
fix/docx-page-margin-notes-every-page
Oct 24, 2026
Merged

DemchaAV merged 1 commit into
2.5-devfrom
fix/docx-page-margin-notes-every-page

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Why

A DOCX export names in its report (page margin) each page whose top and bottom margins it does not write as a Word section. Two of those notes were untrue for a real template.

  • A note about several pages named the first of them only. Word sets the later pages with the margins in force too, and they went unnamed. ObsidianInvoice with its line items run onto three pages starts pages 2 and 3 inside the panel holding them; its note named page 2, and page 3's margins were lost without a word. The same held for a run of pages whose side margins differ, and for a section of a document of several whose page count a Word section would split.
  • A note about a page carried no page. The report's contract (DocxExportReport) says a note about no one node names what it is about, page N or section N, page N. The notes on a section written where a page starts, on a page after one whose content reaches its foot, on a page no block starts and on a page's side margins carried their section's path instead, which a document of one section has none of. MerchantInvoice, PaymentsInvoice and WorkspaceInvoice give such a note wherever a page with their later bottom margin starts between blocks.

What changed

  • DocxPageMarginSections.plan
    • A block several pages start inside keeps one note, rewritten (report.set) to name each of them, compared against the same margins in force: "the top and bottom margins of pages 2 and 3 differ from page 1's, which Word sets them with: each starts inside this block, where the export starts no Word section". A block named for a page before a written section is still named again after it.
    • A section whose header or footer counts its own pages, in a document of several, names every page whose margins differ from page 1's, not only the first.
    • The notes about a page carry pagePath(section, page): page N, or section N, page N in a document of several sections. The note on the section whose page count would split stays on the section, and a block's note on the block.
  • nameTheSides names each page of a run whose side margins differ: "the side margins of pages 2 and 3 differ from the document's and are not written".
  • Page lists read "pages 2 and 3", "pages 2, 3 and 5", and three or more in a row "pages 2 to 4" (pages, notSetWith).
  • Contract (DocxExportReport Javadoc, recipe, CHANGELOG): a note about a page zone, or about a node of one, has no path or, in a document of several sections, names its section, as the notes written for zones do.
  • Ledger: pageGeometry names the case where no block of the body starts a page.

Verification

  • DocxPageMarginSectionsTest (4 new, 4 changed):

    • a panel four pages start inside has one note naming pages 2 to 4;
    • pages 2, 3 and 5 starting inside one panel, page 4 set as page 1 is, are named so;
    • a note about a page names the page, for a written section and for side margins, and section 2, page 2 in a document of several;
    • the room note after a page full to its foot names page 2;
    • the side margins of pages 2 and 3 are named together;
    • a section of several whose footer counts its pages names pages 2 on;
    • a table with a page reference in a row that would move, run onto three pages, names pages 2 and 3.
  • Fail-closed: 10 sabotages, each run alone, all caught. They break:

    • the block's one note, named apart or not extended;
    • the page lists, two pages in a row and the last joining word;
    • the side-margin run;
    • the section that counts its pages;
    • the page path, without its section and left as the section's on a written section, on side margins and on a room note.

    The "no block of the body starts page N" note has no test: no document shape found reaches it.

  • ObsidianInvoice with its line items run onto three pages, through the export: its one note names pages 2 and 3. Merchant, Payments and Workspace are unchanged.

  • Corpus: 62 of 62 DOCX are byte for byte the same, and the 1384 notes are unchanged: none of its documents has margins that change from page to page.

  • Gate:

    • ./mvnw -B -ntp clean verify -pl <core, render-pdf, render-docx, render-pptx, templates, testing, qa, coverage> -am → BUILD SUCCESS: core 823, render-pdf 339, render-docx 2141, testing 5, render-pptx 142, templates 127, qa 1830.
    • The JDK 17 knowledge checks pass, with the API surfaces unchanged, and core javadoc has 0 warnings.
    • ./mvnw -f examples/pom.xml test → BUILD SUCCESS, 93 tests.

Lane: shared-engine (render-docx). The report's record is unchanged; its notes' text and paths change only for documents with margins that change from page to page.

- A note about several pages named the first of them only, and the
  later ones, which Word sets with the margins in force too, went
  unnamed: ObsidianInvoice with its line items run onto three pages
  named page 2, not page 3. The note on a block several pages start
  inside, on a run of pages whose side margins differ, and on a section
  of several whose page count a Word section would split now names each
  page, as "pages 2 and 3", "pages 2, 3 and 5", "pages 2 to 4".
- A page-margin note about a page names it, page N or section N, page
  N, as the report's contract says: the notes on a section written
  where a page starts, on a page after one whose content reaches its
  foot, on a page no block starts and on a page's side margins carried
  their section's path, none in a document of one section.
- The contract's page zones, as written: a note about one, or about a
  node of one, has no path or names its section in a document of
  several.
@DemchaAV
DemchaAV merged commit 2817d24 into 2.5-dev Oct 24, 2026
13 checks passed
@DemchaAV
DemchaAV deleted the fix/docx-page-margin-notes-every-page branch October 24, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant