Table of Contents

Class LayoutSession

Namespace
DocWright.Layout
Assembly
DocWright.Layout.dll

A layout that is kept, so laying a document out again after an edit costs the edit rather than the document.

public sealed class LayoutSession
Inheritance
LayoutSession
Inherited Members

Remarks

The session resolves the document again on every call (resolution is a few milliseconds) and lays it out again, but every paragraph whose resolved content and measuring conditions equal ones it measured before reuses that measurement, which is most of a layout's cost. The result is the layout a fresh StyleResolver and LayoutEngine would produce for the document as it now is, primitive for primitive: the session decides what to reuse by comparing content, never by trusting a caller's account of what changed, so a wrong or missing hint cannot make a page stale.

Pages the new layout reproduces exactly are handed back as the previous LayoutPage instances, so a consumer can tell by reference which pages to send again; LayoutUpdate names the range.

A session is not thread-safe: one caller at a time, with the document not changing during a call. Different sessions are independent. Memory is bounded by the last layout: a measurement the latest layout did not use is dropped when it ends.

Constructors

LayoutSession(FontEngine, LayoutSessionOptions?)

Initializes a session over a font engine.

Properties

Current

Gets the latest layout, or null before the first call.

Methods

Layout(WordDocument, IConversionDiagnostics?)

Lays a document out from the start and keeps the result.

Relayout(WordDocument, IReadOnlyCollection<long>?, IConversionDiagnostics?)

Lays a document out again after it changed, reusing what did not change, and says which pages are new.