Skip to content

feat: date, page number and page count fields - #201

Merged
anderix merged 2 commits into
mainfrom
170-fields
Nov 24, 2026
Merged

anderix merged 2 commits into
mainfrom
170-fields

Conversation

@anderix

@anderix anderix commented Nov 24, 2026

Copy link
Copy Markdown
Member

Closes #170

  • edit/field.rs provides insert_field(content, path, at, Field::{Date { fixed }, PageNumber, PageCount}, today). Each field is written as LibreOffice writes it: text:date with text:date-value (and text:fixed="true" for a fixed date), text:page-number text:select-page="current", and text:page-count.
  • follow_dates writes today into the dates that follow the day. The shell calls it before each save.
  • doc::date_shown gives what a following date shows today, in its own data style. The PDF bands use it too.
  • xodt has a Format > Field submenu with Date, Date (fixed), Page number and Page count.
  • The window shades every field faintly, and draws a following date as today's local date (jiff) without changing the tree. odox_ui::today() is now local time, not UTC.
  • PDF:
    • The model marks page fields in their paragraphs.
    • A document whose paragraphs hold them is laid out once to find the page each lands on and the page count, then laid out again with the values filled in, runs shifted to match.
    • Tested: page_number_in_body_filled_per_page_in_pdf, page_count_in_pdf.
  • Known limitation, recorded as a ruling: text typed at a field's place goes in before it. A field adds no characters to the paragraph's text model, so one offset stands on both sides of it.

…eld, shaded in the window and filled page by page in the PDF
…Office's adjustments and numerals, until the pages settle, and following dates saved in their own style
@anderix

anderix commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Review fixes are in the second commit.

Important

  • 1, 2: Piece now carries fields: each line's piece names the page fields whose text begins in that line, a table row gathers its cells' fields, and a split keeps them on the part above. Pages are found per field (a_page_field_in_a_table_cell_shows_its_page, a_field_shows_the_page_it_is_on_not_where_its_paragraph_began).

  • 3: the layout repeats until the pages and the count stop changing, at most four times (FILLS). There is no dedicated test for this one: a document where filling in a number adds a page is hard to build reliably.

  • 4: text:select-page previous and next, text:page-adjust and style:num-format are read. A number moved off the document shows nothing (previous_page_and_roman_numerals_as_libreoffice_writes_them).

  • 5: an empty field gets a run (an_empty_page_field_at_the_start_is_filled).

  • 6: following dates in the PDF body print today (a_following_date_in_the_body_shows_today).

  • 7: follow_dates now:

    • touches only a text document's body;
    • compares the date part, so a LibreOffice date of today keeps its time;
    • writes the text through the field's own data style.

    Tests: a_date_saved_today_keeps_its_time_and_one_from_another_day_its_style, a_spreadsheets_dates_are_left_alone.

Minors

  • 8: doc comments moved back.
  • 10: the DESIGN paragraph rewritten to say what is true.
  • 11: imports merged, Flow::today private, split keeps the fields.
  • 9 (cost of the second pass) is deferred.

Every new test fails on the reviewed code.

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: insert date, page number and page count fields

1 participant