Text data representation classes

The Text Editing framework data representation classes are responsible for:


MTextRepresentation is the abstract base class for the text data store classes. It provides the protocol for modifying both character and style data. The public functions call the corresponding Handle functions in concrete derived classes. Note that the difference between ReplaceText and TypeText is that TypeText propagates the typing styles to the replacement text.

MTextRepresentation also provides the interfaces for enabling synchronized access to the data, for creating the correct selection object for selecting stored data, and for issuing change notifications. Specific implementations of notification and synchronization are described below in "Text Editing framework notification mechanisms" and "Synchronizing data access."

TTextModel provides a text representation class based on TModel and encapsulates the data in an editable text document component.

TSimpleTextStore provides a text representation class for simple editable text elements--that is, text elements not based on the Document frameworks.

TEmbedderTextModel provides a text model that knows how to handle embedded components of other types. TEmbedderTextModel provides a storage model for embedded components that treats them as a character within the underlying text, identified by a special graphic style. TEmbedderTextModel provides the protocol for selecting and editing text ranges that contain embedded components.

TTextRepresentationReadEntry provides the interface for synchronizing read access to a text representation object.

TTextRepresentationWriteEntry provides the interface for synchronizing write access to a text representation object.

TTextNotification, derived from TNotification, is used by the text representation classes to issue notification of text changes to other interested objects--typically, to the associated text view and formatter. An additional notification class derived from TTextNotification, TInsertTextNotification, is created by the TypeText and ReplaceText functions.

Text Editing framework notification mechanisms

The text representation class issues notification of text modifications using TTextNotification or TInsertTextNotification objects. TTextNotification objects identify the selection object affected by the change and contain a time stamp noting the time the modification occurred. TInsertTextNotification objects also identify the number of characters inserted in the text.

You can use the notification's time stamp to determine if the notification is still valid by comparing it with the time stamp of the text representation object. The text representation object increments its time stamp whenever the text is modified. Use the MTextRepresentation::GetTextTimeStamp function to get the current time stamp.

TTextModel uses the Compound Document framework notification mechanism, delegating to TModel. TSimpleTextStore uses the default implementation provided by MTextRepresentation, issuing notification with a TNotifier object.

Synchronizing data access

To guarantee synchronized access to a text representation object, always use a TTextRepresentationReadEntry or TTextRepresentationWriteEntry object. You use these objects similarly to the way you use TDocumentComponentReadEntry and TDocumentComponentWriteEntry:

  1. Construct the entry object, passing a pointer to the text representation object in the constructor. The constructor calls the appropriate locking function, LockForReading or LockForWriting, on the text representation object.
  2. Call TTextRepresentationReadEntry::GetTextForReading or TTextRepresentationWriteEntry::GetTextForWriting to access the data.
  3. When you delete the entry object, it unlocks the text representation object.
The TTextModel locking functions use TDocumentComponentEntry objects to perform the locking. TSimpleTextStore does not implement the locking functions, which means that this class is not multithread safe.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker