Table of Contents

Class TableOfContentsEditingExtensions

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

A table of contents inserted and rebuilt, and fields updated, as undoable edits (Word's References > Table of Contents, Update Table and F9), as Word writes them (WQ-0097, tools/Probe-WordTableOfContents.ps1).

public static class TableOfContentsEditingExtensions
Inheritance
TableOfContentsEditingExtensions
Inherited Members

Remarks

A table of contents is one TOC field whose result is a paragraph per heading: style TOCn, a right tab with a dot leader at the text width, a hyperlink to a _Toc bookmark round the heading's text, and a PAGEREF field to that bookmark. Its page numbers are what PageReference says; layout draws every PAGEREF from the bookmark's page whatever the cached result.

Fields

MaxTableOfContentsEntries

The most entries one table of contents lists: the headings past it are left out.

NoEntriesText

What Word writes as the result of a table of contents that finds no heading.

Methods

InsertTableOfContents(WordDocument, DocumentPosition, TableOfContentsOptions?, FieldUpdateOptions?)

Inserts a table of contents at a position, listing the body's headings of the levels asked for, as one undoable edit. Each heading gets a _Toc bookmark round its text (an existing one is reused); the TOCn styles are added as Word defines them when the document has none.

UpdateField(WordDocument, DocumentPosition, FieldUpdateOptions?)

Updates the one field at a position, as one undoable edit: the innermost field whose extent holds the position (a reference inside a table of contents entry is that reference, not the table). A table of contents is rebuilt; any other field gets its evaluated result, as UpdateFields(WordDocument, DocumentSpan, FieldUpdateOptions?) gives it; nothing else changes.

UpdateFields(WordDocument, DocumentSpan, FieldUpdateOptions?)

Updates every field whose extent meets a span, as one undoable edit (Word's F9): a table of contents is rebuilt from the headings as they are now (their bookmarks reused); any other field gets its evaluated result; PAGEREF takes PageReference; PAGE and NUMPAGES are left to layout; a field that cannot be evaluated keeps its result.