Skip to content

feat: headers and footers - #202

Merged
anderix merged 2 commits into
mainfrom
165-headers-footers
Nov 24, 2026
Merged

anderix merged 2 commits into
mainfrom
165-headers-footers

Conversation

@anderix

@anderix anderix commented Nov 24, 2026

Copy link
Copy Markdown
Member

Closes #165

  • Core: TextDocument::set_header and set_footer give the first master page a style:header or style:footer, with an empty paragraph in the Header or Footer style where the document has it, or take it away. First and left variants are left untouched. band_path gives the band's path in the styles part.
  • Undo: a snapshot's content is now optional, and Editing::record_styles_part records an edit to the styles part alone.
  • FlowModel::in_styles_part makes every edit step record the styles part, so typing, the toolbar, links and fields work in a header and undo puts it back. Tested: typing_in_header_changes_styles_part_only, undo_restores_header (the undo test fails without in_styles_part).
  • xodt:
    • The header is drawn above the body and the footer below, each set off by a faint rule.
    • Clicking into one makes it the part typed into. One page editor serves all three parts; the first click switches and puts the caret at the start.
    • Format > Header and Format > Footer toggle the bands. Taking one away asks first when it holds text (turning_header_off_asks_when_not_empty), and each toggle is one undo step.
  • Checked in Xephyr: turning a header on, typing in it, taking it away (with the question), and Ctrl+Z bringing it back.
  • Recorded as a deferred minor: the Format menu is now taller than a 760-pixel window, so its last entries (Page setup, Header, Footer) are out of reach there. A taller window was needed to reach them.

…ike it, turned on and off from the Format menu
…arets follow undo into their part, and body-only things stay out of bands
@anderix

anderix commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Review fixes are in the second commit.

Critical

  • 1: turning a band on also gives the body's page layout a style:header-style or style:footer-style with header-footer-properties (min-height 0cm, spacing 0.25cm) where it has none, so odox's PDF prints it (a_header_turned_on_here_is_printed, red before the fix; turning_on_a_header_gives_its_page_layout_room_for_it).
  • 2: the body's master page is the one its first paragraph's or table's style names, following parents, else the first. master_page, master_path and page_layout all use it, and so does the PDF through master_page (the_body_master_page_is_the_one_its_first_paragraph_names). page_setup.rs's helper now reads the body's own layout; it had assumed Mpm1.

Important

  • 3: band models are tagged with a region (HEADER or FOOTER as a caret prefix). caret adds the tag, and restore_caret switches region and strips it (a_remembered_caret_takes_the_page_to_its_part).
  • 4, 5: comments, footnotes, endnotes and page breaks belong to the body. Their commands are dropped in a band, their menu entries are greyed (MenuState::in_band), and Ctrl+Enter, Ctrl+Alt+F and Ctrl+Alt+C are swallowed there.
  • 6: removal asks unless the band is one empty paragraph (a_header_with_a_picture_and_no_text_is_asked_about).

Minors

  • 7: display="false" bands aren't found or drawn, and turning one on clears the flag (a_header_not_displayed_is_none_until_turned_on).
  • 8: the word count reads the selection only in the body.
  • 9: the band keys are swallowed, as in 4 and 5.
  • 10: the region resets on open and close.
  • 12: a band goes after the master page's forms and style (a_band_goes_after_a_master_pages_forms_and_style).
  • 13: record_styles_part is used for the toggle.

Deferred: 11, popup ids keyed by path alone. Bands no longer get comments or notes from odox. Column drags and change decisions inside a header table aren't acted on.

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.

xodt: edit headers and footers

1 participant