Text Object Model
This section contains information about the programming elements used with the Text Object Model (TOM).
The TOM defines a substantial set of text manipulation interfaces. Text solutions such as Microsoft Word and rich edit controls support the TOM feature set. TOM was greatly influenced by WordBasic (the programming language used for Word) and it is easy to use from Microsoft Visual Basic for Applications (VBA). This compatibility has several advantages:
- Code can migrate fairly easily from one solution to another.
- One language can be used to share text information between different text engines.
- It reduces the need for documentation and code compared to the separate low-level Component Object Model (COM) and VBA interfaces.
However, it can be less efficient for C/C++ purposes than the use of more general lower level COM interfaces.
TOM is a straightforward set of interfaces to implement for its primary text solutions, Word and rich edit controls. However, for applications that place minor emphasis on text, it is better to provide TOM interfaces by transferring the text to an edit control that supports TOM. Since rich edit controls ship with Microsoft operating systems, they are the standard means of obtaining TOM functionality.
|About Text Object Model||
The top-level Text Object Model (TOM) object is defined by the ITextDocument interface, which has methods for creating and retrieving objects lower in the object hierarchy.
|Using The Text Object Model||
The code samples in this document show various aspects of using the Text Object Model (TOM).
The ITextDocument interface is the TOM top-level interface, which retrieves the active selection and range objects for any story in the document—whether active or not. It enables the application to:
When to Implement
Applications typically do not implement the ITextDocument interface. Microsoft text solutions, such as rich edit controls, implement ITextDocument as part of their TOM implementation.
When to Use
Applications can retrieve an ITextDocument pointer from a rich edit control. To do this, send an EM_GETOLEINTERFACE message to retrieve an IRichEditOle object from a rich edit control. Then, call the object's IUnknown::QueryInterface method to retrieve an ITextDocument pointer.
The ITextRange objects are powerful editing and data-binding tools that allow a program to select text in a story and then examine or change that text.
A text selection is a text range with selection highlighting.
Build date: 11/16/2013