Repository navigation
fix(docx): cut a panel at a page break in a section or panel inside it - #960
Merged
Merged
Conversation
- DocxPanelPieces cuts a container's children at page breaks among them and, at any depth, among those of the sections and panels its cell writes them in; Word and LibreOffice break no page inside a table cell. - writePanel cuts a panel in the flow by those pieces, a panel inside it written in the part each table holds; writeContainerBody writes a section's part, its edges where it starts and ends; what follows a break stands its container's spacing below the page's top. - A table after the first has no top padding, as the page sets the text there; a cut container's anchor is marked, and its notes said, once. - Tests: a section and a card inside a card cut there; spacing and edges at the cut; one bookmark and one note; nothing written twice; a card in a row's column not cut.
DemchaAV
marked this pull request as draft
October 25, 2026 12:06
DemchaAV
marked this pull request as ready for review
October 25, 2026 12:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A panel — a painted section or container — is written as a table of one cell, and Word breaks no page inside a table cell. The export cut a panel into two tables at a page break among its own children. A break one level down, in a section or a panel inside it, went through
writePageBreak, which writes its paragraph in the body: after the panel's table. A card holding a section with "Part A", a break and "Part B" came out with both parts in the card on the first page and the page breaking after the card, where the page sets "Part B" at the top of the second page, the card going on there.Measured in Word 16 and LibreOffice 24.2 (CI's build):
w:br w:type="page", a paragraph'sw:pageBreakBefore, in a table of the body and in one nested in a cell, all left the text after it on the first page. No break can be written in its place in the cell.What changed
DocxPanelPieces(new, package-private) cuts a container's children at page breaks among them and, at any depth, among the children of the sections and panels its cell writes them in: each piece a run ofParts, a child whole or the part of it between two breaks, marked where it opens and closes.writePanelcuts a panel in the flow by those pieces. A panel inside one is written in the part of it each table holds (panelWindows), its top padding where that part opens; every part draws its fill and its four borders, as the page draws each piece of a card. Inside a table cell, a row's column or a stack's column a panel is written whole, as before.writeContainerBodywrites the part of a section a piece holds, its top edge where it starts and its bottom edge where it ends.writePartswrites a piece's parts, owing the container's spacing above the first where it follows a break among the container's own children.writePanelPiecegives a table after the first no top padding, as the page sets the text there. This also changes a break among a panel's own children, which kept the padding: its text after the break stood 8pt low in Word for a card padded 8pt.writePlacedNodemarks a cut container's anchor once, where it starts, andwriteContainerChildrennames it once: written once a table, a bookmark round each part kept only the last, the link and the page reference going to the page after the break.Page breaksparagraph, the CHANGELOG.Verification
DocxPanelPiecesTest(new): a break among a panel's children cuts it in two; one inside a section inside a panel inside cuts all three, the parts opening and closing where they should; a break in a node its cell does not write as a container is not cut; a break ending a panel leaves an empty piece;followsABreakreads only a break among the container's own children.DocxPanelEdgeCasesTest(+6):word/document.xmlis unchanged, and so is the report../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 2195, testing 5, render-pptx 142, templates 127, qa 1830../mvnw -f examples/pom.xml test→ BUILD SUCCESS, 93 tests.Lane: shared-engine (render-docx). No public API change.