drmacro / wordinator

Generate high-quality DOCX files using a simplified XML format (simple word processing XML).
Apache License 2.0
37 stars 8 forks source link

Generate of ToC with explicit ToC entries does not honor bookmarkRef attribute in SWPX markup #151

Open drmacro opened 3 months ago

drmacro commented 3 months ago

When a element specifies bookmarkRef, the attribute is ignored and no page number reference is generated.

In addition, the dirty="yes" setting should not be set when there are explicit ToC entries as Word will overwrite them if you respond "yes" to the open-time prompt to update fields.

drmacro commented 3 months ago

This appears to be a bit more complicated than I had thought.

There is clearly a particular combination of elements with an ToC paragraph that Word recognizes as a ToC entry with a page reference such that when you say "update field" on the ToC it gives you the option of updating just the page numbers and not the ToC entries themselves.

It looks like it might be that the entire content of the paragraph must be within a single hyperlink but still experimenting with that.

drmacro commented 3 months ago

As far as I can tell, the only variable is the styles for the target paragraphs: When they are ToC-generating styles, then you get the option to update just the page numbers. When they are not, you do not.

drmacro commented 3 months ago

Have updated the code so it only sets dirty="on" when there are no child elements.

This means that if you want the ToC to be autogenerated, do not include any literal elements and be sure you have the "Update on open" setting turned on in Word.

ekimbernow commented 1 month ago

Does this update to the behavior of the "dirty" setting satisfy the requirement?