mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-26 11:27:10 -06:00
A `DATE` or `TIME` field showed whatever was cached the last time the file was saved, so a letter written from a template went out carrying the date the template was saved. Word refreshes those two whenever it shows, prints or exports a document; WordCraft only did so on an explicit Update Field(s), on insert, or when printing with "Update fields before printing" on. Headless `convert` to PDF was the worst of it: nothing hints the date is old. Refresh them where a document is read instead, in a new `io::opened` beside `ensure_nonempty` -- the two things a freshly-read document needs -- so `text`, PDF, rendering and the window all show the same, current value. The model's stored result is the one source they share; patching each output path would have needed a clock in two places and still missed the next one. Narrow on purpose. Only `DATE` and `TIME`: `CREATEDATE`, `SAVEDATE` and `PRINTDATE` record when something happened and are not "now", and `REF`, `TOC` and citations stay on explicit update, as in Word. A field carrying `w:fldLock` keeps its stored result, which is what the lock is for. Headers, footers and text boxes are covered too, not only the body. The field code is untouched, so saving writes the field back as it was, with a current cached result -- as Word writes one. Co-authored-by: Brandon Thomas <echelon@gmail.com>