ContentEditor Class

Definition

Assembly Broadside.dll
Show inherited members (27)

The editor processor: run through RewriteContent(ContentEditor) or RewriteContent(ContentEditor), it sees every operator of the page's or form's own content with its byte range (CurrentOperator, GetOperator(Int32)) alongside the usual events, and removes, replaces, inserts before or after, or wraps operators. When the run ends the content is written again as one stream: untouched bytes are copied as they were, edits take the place of the operators they name.

public abstract class ContentEditor : ContentProcessor

Remarks

ISO 32000-2 §7.8.2: content is a sequence of operators, each preceded by its operands, so an operator's range (first operand through keyword) can be removed, replaced or surrounded without reading anything else again. A page's Contents array is read and rewritten as one stream, its parts joined by the line feed the interpreter reads between them (Table 31: the parts behave as if concatenated with at least one white-space character between them).

Operators are numbered from 0 in the order they appear in the stream being rewritten; operators of nested content (form XObjects, Type 3 glyphs, patterns, soft masks) are not numbered, and while their events arrive CurrentOperator is the operator of the rewritten stream that started them, such as the Do of a form. Edits may name any operator already numbered, during the run or in EndRun(ContentContext); they are applied together after the run.

Order of edits at one operator: text inserted before it is written in the order it was inserted, after the opening text of every wrap that starts there; text inserted after it in insertion order, before the closing text of every wrap that ends there. Wraps nest: one that covers more operators encloses one that covers fewer, and of two wraps over the same operators the later encloses the earlier. The last Remove(Int32) or Replace(Int32, ReadOnlySpan<Byte>) of an operator wins. Inserted and replacing text is separated from its neighbours by a line feed, and a removal that would join two tokens leaves a space between them, so the tokens on each side of an edit read as they did.

The bookkeeping is done by the rewrite itself, so an editor overrides any ContentProcessor member freely without calling the base. Run any other way (ProcessContent(ContentProcessor)), an editor numbers nothing and its edit methods throw. One editor serves one rewrite at a time and keeps its buffers for the next, so a reused editor allocates nothing per operator.

Tip: use kind:method, kind:property, kind:ctor. Press Esc to clear.

Constructors (1)

Properties (3)

Methods (6)