Repository navigation
fix(docx): end a page-margin section at a panel's cut - #963
Merged
Merged
Conversation
A page that DocumentSession.pageMargins sets against other top and bottom margins started no Word section where it started inside a panel: Word set it with the margins in force. Where the export cuts that panel at the row of its table the page starts with, the paragraph between the two parts now ends the section, breaking no page before itself, where the page above has room for it under the part. A section's margins are planned once it is written, while panels are cut once the document is: in a section whose margins vary, its panels' cuts are decided when it is written and made as decided. The copy of the header rows a part after a cut opens with holds no drawing: one the export anchors there at the section's end is the table's first page's.
A row holding a page reference leaves a panel uncut at that row's page and every page before it, and so does a header row holding a bookmark the export later takes out; the recipe, the matrix and the CHANGELOG now say so. The CHANGELOG states how ObsidianInvoice's twelve-fold line items stood before. NOT_REPEATED is built from DRAWINGS, and a test writes a section at a body table's split and one at a panel's cut in one document section.
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 page that
DocumentSession.pageMarginssets against other top and bottom margins than the page before it starts a Word section with them, where it starts between blocks of the body or among a body table's rows. A page that starts inside a panel started none and was named: Word set it with the margins in force. Since a panel whose table runs over pages is cut into a table a page, with a paragraph between the parts, there is a place for that section.Measured in Word 16 and LibreOffice 24.2 on a card (400×600 page, 1pt border, 6pt padding) whose table of 60 rows runs over three pages:
What is left is the cut's top border, which the report already names.
What changed
DocxPageMarginSectionsPanelCut(new): a cut the export makes in a panel at the row of its table a page starts with — how high the part's last row on the page above ends, the room the part needs under it, and where the section's properties go.plantakes the section's cuts, by the panel's table and the page each opens. A page that starts inside a panel cut there starts a section at the cut. The room is reckoned against the bottom margin Word sets the page above with — the margins in force, as for the hairline under a table. Where that page has room for the cut and not for the paragraph ending a section under the part as well, the page is named and the panel is cut as before.applyhands a cut's section properties to the cut, which writes them when it is made.DocxSemanticBackendcutsOpeningSectionsdecides the cuts of the section's panels when it is written, where its pages are set against more than one set of margins, andcutThePanelsAtTheirPagesmakes them as decided. A panel in a section of one set of margins, or one whose header or footer counts its own pages (which starts no Word section for a page's margins), is still decided once the document is written.decideTheCutsholds whatcutThePanelsAtTheirPagesdecided inline: it reads the rows in the table as written whole, which gives each later page the same row as the part left after the earlier cuts.DocxTableSplit:NOT_REPEATEDis built from the newDRAWINGSlist.splitInItsPanel: the copy of the header rows a part after a cut opens with holds no drawing. Where a cut is decided, the header rows hold none (rowStarting); the export anchors a shape there only at the section's end — a shape of the table's first page beside a header's text, or one a page with no other paragraph leaves in its first cell's — and decided early, the cut comes before that. Such a shape is its page's, and stays in the first part.page marginnote says the section starts where the panel is cut, in place of "starts inside this block".ObsidianInvoice
Its pages from 2 on have a larger foot. Its cut where page 2 starts now ends a section, and the pages after it are set with page 2's margins. With its line items repeated 3 to 11 times, every line stands on its page in Word and LibreOffice 24.2, as before; page 2 stands 0.1pt nearer in Word.
With them repeated 12 times, page 5 starts between its info cards and its footer divider. With page 1's margins in force on pages 2 to 4, page 5's differed, and it opened a section, which fixed the break. Its margins are now page 2's, so the editors place that break themselves, and both set it as they do the same invoice with one set of margins on every page:
keepNexton the paragraphs inside the cards' cell keeps their table with the paragraph after it. With those taken off, Word holds all 121 lines on page 4.Named, not fixed
Verification
ObsidianInvoice×2 to ×12 against the base, and ×12 with one set of margins on every page.DocxPanelOverPagesTest(+12, 34):DocxTableSplitTest(+1, 11): a panel's part after a cut copies its header rows without the drawing anchored in them, which the first part keeps. No export test reaches that route: section-end anchoring falls back to a cell's paragraph only on a page with no body paragraph, and every page a card opens on in the layouts tried had one.InvoicePanelOverPagesDocxTest(qa, +1, 3):ObsidianInvoice×3 and ×6 end one section, at the card's first cut, with page 1's bottom margin, the body page 2's; the parts are found after a paragraph that breaks the page or ends a section../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 2243, testing 5, render-pptx 142, templates 127, qa 1833../mvnw -f examples/pom.xml test→ BUILD SUCCESS, 93 tests.Lane: shared-engine (render-docx). No public API change.