Skip to content

Add update_fields option to write word/settings.xml - #48

Open
ajay20015 wants to merge 3 commits into
PumasAI:mainfrom
ajay20015:aja/settings-xml-support
Open

Add update_fields option to write word/settings.xml#48
ajay20015 wants to merge 3 commits into
PumasAI:mainfrom
ajay20015:aja/settings-xml-support

Conversation

@ajay20015

Copy link
Copy Markdown

Adds an update_fields::Bool field to Document (default false). When true, save writes word/settings.xml containing
<w:updateFields w:val="true"/>, so Word recomputes every field (e.g. a hand-built TOC's PAGEREF page numbers) the first time the document is opened.

Fixes #47 .

Wired the same way styles.xml already is: a SettingsRel singleton through resolve_rel!, added to gather_rels only when update_fields is set, plus a content_types override for application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml.

Adding the field removed Document's implicit 2-arg constructor (Document(body, styles)), which one existing test used directly. Added that constructor back explicitly, defaulting update_fields to false.

relpath after walkdir returns native separators, so the test's
hardcoded forward-slash keys ("word/settings.xml", etc.) never
matched on Windows.
@ajay20015
ajay20015 force-pushed the aja/settings-xml-support branch from f53e3d4 to fc22631 Compare July 26, 2026 13:17
@ajay20015
ajay20015 marked this pull request as ready for review July 26, 2026 13:53
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.

Document has no way to force Word to recompute fields on open

1 participant