Document Model
- 2 minutes to read
A document model defines the logical structure of a document, which reflects its logical organization and hierarchically groups the logical entities in a document. It is illustrated in the following scheme.
The root of a document model is the object exposing the Document interface. For the current document loaded in RichEditControl, it can be accessed via the RichEditControl.Document property. The Document interface provides a comprehensive set of properties and methods required to manipulate text within a control. In other words, it is the starting point for using XtraRichEdit API.
The document is divided into logical Document.Sections. Each section in a SectionCollection defines its own page settings, such as SectionPage.PaperKind, page orientation (the SectionPage.Landscape property) and its margins. The Section.Page and Section.Margins properties enable you to access these settings.
To insert a section at an arbitrary position, use the Document.InsertSection method.
The section consists of paragraphs. The Paragraph class represents the paragraph entity in the document model. You can access a collection of paragraphs in a document via the SubDocument.Paragraphs property. The Section.Paragraphs property of a section gives you a collection of paragraphs in a particular section of a document.
To modify paragraph formatting, you can use either the Paragraph object or the ParagraphProperties interface. The interface is more convenient to use, since it can be easily accessed for a particular document range via the SubDocument.BeginUpdateParagraphs method. Do not forget to call the SubDocument.EndUpdateParagraphs method to properly finalize modification.
To insert a paragraph at an arbitrary position, use the SubDocument.InsertParagraph method.
The paragraph consists of runs—groups of characters with a uniform format. This is an internal entity, not available via API. You should manage the Positions and Ranges instead.
NOTE
For a specified Document
Headers and Footers are implemented as SubDocuments and stand apart form the main document.
The document model also includes entities that do not comprise a hierarchy, such as lists , Styles, Tables, inline objects represented as Inline Objects (Pictures).
Numbered and bulleted lists are represented by specific collections of paragraphs. To format lists, the ToggleSimpleNumberingListCommand, ToggleBulletedListCommand and ToggleMultiLevelListCommand commands are used.
Special codes within the document ranges give rise to Document Fields, Hyperlinks and Bookmarks and Ranges with Permissions.