feat(doc-codec): read and write a section's own page size and margins - #915
Merged
Conversation
PlcfSed/Sepx carry a section's own page width/height and left/right/top/bottom margins as SEP sprms (sprmSXaPage, sprmSYaPage, sprmSDxaLeft, sprmSDxaRight, sprmSDyaTop, sprmSDyaBottom), reusing the format-generic Prl/grpprl walker already built for paragraph and character sprms. A field the file leaves unstated falls back to Word's own new-document default (US Letter, one-inch margins), exactly as an individual unstated sprm already does elsewhere. sprmSDyaTop/sprmSDyaBottom's YAS operand has a minimum-margin (positive) and a fixed-margin (negative) form; both report the same absolute point size, since document-schema.js's Margins has no minimum/fixed distinction and this reader has no header/footer geometry to grow a minimum margin against. The writer always emits the positive form, matching what a real producer's own worked example does. writeDocContent now writes a real PlcfSed/Sepx for the one section it supports, appended after the Chpx/Papx pages in the WordDocument stream (not itself an FKP-paged structure, so it needs no page alignment) and referenced from a new Sed in the Table stream.
… forms Extends test-support/doc.ts's buildDoc with an optional sectionGrpprl, building a real PlcfSed/Sepx from hand-encoded sprm bytes independently of the writer under test, the same fixture-independence convention the file's existing sprm byte constants already follow. Covers: reading real, non-default page size and margins from a hand-built Sepx; falling back to Word's own new-document default when a file carries no PlcfSed at all; reading a fixed (negative YAS) top/bottom margin as the same absolute size a minimum (positive) one reports; and a full writeDocContent/ readDocContent round trip through non-default page geometry. Adds a prop/sep.js deep-import smoke entry alongside its prop/chp.js/prop/pap.js siblings.
…nd written Adds the read-side page-size/margins bullet and the write-side PlcfSed/Sepx note, and records LibreOffice verification: a non-default 600x800pt page with a 90/54/45/36pt left/right/top/bottom margin round-trips through LibreOffice's own fo:page-width/fo:page-height/fo:margin-* export to the exact point. Reframes the former "Section properties" scope row as "Section boundaries": the whole document is still always one section, but that one section's own page size and margins are no longer a placeholder.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Part of #85.
Reads and writes the one section this package supports' own real page size and margins, via PlcfSed/Sepx and the SEP sprm family (sprmSXaPage, sprmSYaPage, sprmSDxaLeft, sprmSDxaRight, sprmSDyaTop, sprmSDyaBottom) — reusing the same format-generic Prl/grpprl walker already built for paragraph and character sprms, confirmed field-by-field against the MS-DOC FibRgFcLcb97 spec page for fcPlcfSed's own byte offset. A document's whole-document default US Letter placeholder is now only a fallback for a field the file genuinely leaves unstated, not the whole story.
sprmSDyaTop/sprmSDyaBottom's YAS operand has a minimum-margin (positive) and fixed-margin (negative) form; both report the same absolute point size on read, since document-schema.js's
Marginshas no minimum/fixed distinction. The writer always emits the positive form, matching a real producer's own worked example in the spec.Verified via this package's own independent reader (write → read → equality, including the negative-YAS case) and against LibreOffice: a non-default 600x800pt page with a 90/54/45/36pt left/right/top/bottom margin round-trips through LibreOffice's own
fo:page-width/fo:page-height/fo:margin-*export to the exact point, with no discrepancy.