Table of Contents

Class FieldRegion

Namespace
DocWright.Dom.Fields
Assembly
DocWright.Dom.dll

A located field in a document: its instruction, its cached result, where it sits, and the three edits a consumer needs to make to it.

public sealed class FieldRegion
Inheritance
FieldRegion
Inherited Members

Remarks

Phase 14 kept field chains entirely internal, because updating fields in place was the only thing anyone needed to do with them. Mail merge needs to enumerate them without evaluating anything — a host builds a field-mapping UI from the list before a merge runs — and to remove or unwrap them afterwards, so the chain walk is surfaced here rather than reimplemented in the merge package. There is exactly one field-region walker in the tree and this is the public view of it.

A region is a snapshot taken at discovery. Editing one invalidates any other region that overlapped it, and editing the document invalidates all of them; re-discover rather than holding a list across mutations.

Properties

BeginChar

Gets the field's begin character (w:fldChar w:fldCharType="begin").

BeginParagraph

Gets the paragraph holding the field's begin character.

CachedResult

Gets the result Word last computed, which stands until something replaces it.

Depth

Gets the nesting depth, zero for a field that is not inside another field.

EndParagraph

Gets the paragraph holding the field's end character.

HasResultRegion

Gets whether the field has a separator, and therefore a result region. A field written without one has never been updated and has nothing cached.

Instruction

Gets the parsed instruction.

InstructionText

Gets the instruction region's text, with nested field results substituted.

IsWithinOneParagraph

Gets whether the field spans a single paragraph.

NestedFields

Gets the fields nested inside this one's instruction region.

ResultFormat

Gets the formatting replacement content should inherit: the first formatted run of the result region, or the begin character's own formatting when the result is empty.

Methods

Delete()

Removes the whole field, result included.

GetParagraphs()

Gets the paragraphs the field touches, in document order.

GetResultInlines()

Gets the inlines of the field's result region — what Word currently displays for it.

ReplaceWithText(string, CharacterFormat?)

Replaces the whole field — markup, instruction and result — with literal text.

ResolveInstruction(Func<FieldInstruction, string?>)

Rebuilds the instruction text, letting the caller decide what each nested field contributes.

SetResult(string, CharacterFormat?)

Replaces the field's result with literal text, leaving the field markup, its instruction and its w:ffData in place.

Unwrap()

Removes the field's markup and instruction but leaves its result behind as ordinary content, which is what "remove the field, keep the text" means.