Class: TStandardText

Declaration: StandardText.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TText

Inherited By:

TTieredText

Purpose:

TStandardText is a concrete class that implements the full text protocol defined by class TText. Each standard text object contains both Unicode character codes and styling information. Common string manipulation functions, like insert and delete, are provided. Whenever you need a text object, you can create a TStandardText object. However, TText reference parameters are preferred over TStandardText reference parameters in the interfaces you provide to your clients. Only use TStandardText instead of TText in situations where a concrete class is required. In this way, other implementations of the text protocol can also exist and be used polymorphically as TText objects.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

This class is not designed for anything more than simple deriving. Developers can provide their own implementation of the text protocol by deriving directly from the abstract base class, TText. Classes that are derived either directly or indirectly from TText should not override Replace, Insert, and Delete. These member functions have been implemented in TText to use the following atomic member functions: HandleDeleteCharacters, HandleInsertCharacterGap, HandleCopyCharacters, HandleDeleteStyles, HandleInsertStylesGap, and HandleCopyStyles. These handle member functions should be overridden to provide the desired behavior.

Concurrency:

Not multithread safe.

Resource Use:

Due to the dynamic nature of the contents of text objects, the variable amount of characters and associated style information is always allocated on the heap. Large text objects allocate most of their storage on the heap even when the text object itself is allocated on the stack.

Member Function: TStandardText::TStandardText

  1. TStandardText ()
  2. TStandardText (TTextCount extraSpace)
  3. TStandardText (const TStandardText & that)
  4. TStandardText (const TStandardText & that, const TTextRange & thatRange, TTextCount extraSpace =0)
  5. TStandardText (const TText & that, const TTextRange & thatRange =TTextRange :: GetMaximumRange (), TTextCount extraSpace =0)
  6. TStandardText (const UniChar that [], TTextCount thatLength, TTextCount extraSpace =0)
  7. TStandardText (UniChar that, TTextCount extraSpace =0)
  8. TStandardText (const char nullTerminatedArray [], TTextCount extraSpace =0)
  9. TStandardText (const TUnicodeArray & that, TTextCount extraSpace =0)

Interface Category:

API.

Purpose:

  1. Default constructor. Constructs an empty text object.
  2. Constructs an empty text object with extra space.
  3. Copy constructor.
  4. Constructs a text object with the specified text string and extra space allocation.
  5. Constructs a text object with the specified text string and extra space allocation.
  6. Constructs a text object with the specified text string and extra space allocation.
  7. Constructs a text object with the specified text string and extra space allocation.
  8. Constructs a text object with the specified text string and extra space allocation.
  9. Constructs a text object with the specified text string and extra space allocation.

Calling Context:

  1. Called by the stream-in operators or to construct an empty text object.
  2. Called to construct a text object.
  3. Called to copy an object.
  4. Called to construct a text object.
  5. Called to construct a text object.
  6. Called to construct a text object.
  7. Called to construct a text object.
  8. Called to construct a text object.
  9. Called to construct a text object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Many of these constructors allocate only enough space for the text you pass in at instantiation. If you want to allocate more space, do so at construction time.

Member Function: TStandardText::~TStandardText

virtual ~ TStandardText ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::GetCharacterAt

virtual UniChar GetCharacterAt (TTextIndex index) const

Interface Category:

API.

Purpose:

Gets the character at a specified index.

Calling Context:

Called to get the character stored at a particular index.

Parameters:

Return Value:

The character at the specified index.

Exceptions:

Throws the exception TTextException::kInvalidIndex if the index is less than zero or beyond the current length of the text, passes all other exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Use a TCharacterIterator for fast sequential access. Even random access to more than a few characters will benefit from using a TCharacterIterator.

Member Function: TStandardText::SetCharacterAt

virtual void SetCharacterAt (TTextIndex index, const UniChar thatChar)

Interface Category:

API.

Purpose:

Sets the character at a specified index.

Calling Context:

Called to set the character stored at a specified index.

Parameters:

Return Value:

None.

Exceptions:

Throws the exception TTextException::kInvalidIndex if the index is less than zero or beyond the current length of the text, passes all other exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Use a TCharacterIterator for fast sequential access. Even random access to more than a few characters will benefit from using a TCharacterIterator.

Member Function: TStandardText::GetLength

virtual TTextCount GetLength () const

Interface Category:

API.

Purpose:

Gets the length of the text string encapsulated by this text object.

Calling Context:

Called to get the length of the text string encapsulated by this text object.

Parameters:

Return Value:

The length of the text string encapsulated by this text object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::IsContiguous

virtual bool IsContiguous () const

Interface Category:

API.

Purpose:

Queries whether the text in this text instance is stored contiguously.

Calling Context:

Called to query whether the text in this text instance is stored contiguously.

Parameters:

Return Value:

Returns true if the text is stored contiguously.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::PartialCopy

virtual TText * PartialCopy (const TTextRange & range, TTextCount extraSpace =0, TMemoryHeap * whichHeap =NIL) const

Interface Category:

API.

Purpose:

Creates a copy of any part of any text object polymorphically. Use this member function when polymorphic extraction of a range of text is required. This is a copy function that passes ownership of new storage to the client instead of an extract function with a client-provided text object as an output parameter. Otherwise, it is not possible to extract a range of text polymorphically.

Calling Context:

Called to get a polymorphic copy of any part of a text object.

Parameters:

Return Value:

A copy of the specified text range in a newly created text object is returned. The caller gets ownership of the storage for this new object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::Extract

  1. virtual TTextCount Extract (const TTextRange & thisRange, TText & that) const
  2. virtual TTextCount Extract (const TTextRange & thisRange, TUnicodeArray & that) const
  3. virtual TTextCount Extract (const TTextRange & thisRange, UniChar that [], TTextCount thatMaxCount) const
  4. virtual TTextCount Extract (const TTextRange & thisRange, char that [], TTextCount thatMaxCount) const

Interface Category:

API.

Purpose:

  1. Copies text in the specified text range of this text object into the output text object.
  2. Use ExtractCharacters instead if you are only interested in the character information, but you want the copied characters in another text object.
  3. Copies text in the specified text range of this text object into the output TUnicodeArray object.
  4. Copies text in the specified text range of this text object into the output UniChar array. The resulting UniChar array is NOT null terminated.
  5. Copies text in the specified text range of this text object into the output character array. The resulting character array is null terminated. This means that the size of the character array must be one byte more than the length of the text to be extracted. In other words, the length of the character array should be one more than thatMaxCount. Otherwise, the extraction may write off the end of the character array, resulting in heap corruption problems.

Calling Context:

  1. When copying text from one text object to another.
  2. When copying text from a text object into a TUnicodeArray object.
  3. When copying text from a text object into a UniChar array.
  4. When copying text from a text object into a character array.

Parameters:

Return Value:

The number of characters extracted; this can differ from the requested length.

Exceptions:

Throws the exception TTextException::kInvalidRange if the first index in the specified range is less than zero or beyond the current length of the text, if the text object to extract from is the same object as the text object to extract into, or if the current length of the text is less than zero. Passes all other exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

For more accurate extraction of 8-bit character data, use TTranscoder. When extracting into a character array, the resulting array is null terminated. This means that the length of the character array must be one more than thatMaxCount. When extracting into a UniChar array, the resulting array is NOT null terminated.

Member Function: TStandardText::ExtractCharacters

virtual TTextCount ExtractCharacters (const TTextRange & thisRange, TText & that) const

Interface Category:

API.

Purpose:

Copies only the characters in the specified text range of this text object into the output text object. Use Extract instead If you are interested in both the character and style information.

Calling Context:

Called to copy characters from one text object to another.

Parameters:

Return Value:

The number of characters extracted; this can differ from the requested length.

Exceptions:

Throws the exception TTextException::kInvalidRange if the first index in the specified range is less than zero or beyond the current length of the text, if the text object to extract from is the same object as the text object to extract into, or if the current length of the text is less than zero. Passes all other exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::IsStyled

virtual bool IsStyled () const

Interface Category:

API.

Purpose:

Determines if this text object has style information associated with it.

Calling Context:

Called directly to check for styles.

Parameters:

Return Value:

Returns true if there are any styles associated with this text object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Any of the style functions can still be called on text that is unstyled. Setter functions convert text from unstyled text to styled text and set the appropriate style information.

Member Function: TStandardText::StylesAt

  1. virtual TTextIndex StylesAt (TTextIndex indexOfInterest, TStyleSet & returnSet, const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ()) const
  2. virtual TTextIndex StylesAt (TTextIndex indexOfInterest, TStyleSet & returnSet, TTextRange & currentRunRange, const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ()) const

Interface Category:

API.

Purpose:

Fills in a given style set with the styles of the specified kind that are associated with the specified index. When needed, callers can also get the maximal contiguous text range with the same style information that contains the specified index.

Calling Context:

  1. Called directly to get the styles for a specified index.
  2. Called directly to get the styles for a specified index and the maximal contiguous text range that contains the same style information and the index of interest.

Parameters:

Return Value:

The starting index of the next style run. A style run is the term used to describe a maximal contiguous text range of text with the same style information.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Clients are not required to concern themselves with the underlying association of style information with the character codes. However, clients that take advantage of this knowledge can do some things more efficiently. For example, it is not necessary to make a StylesAt call for every character in a text object when iterating over style information. Rather, you can take advantage of style run information to make only one StylesAt call for each style run and then jump ahead to the next run (using the returned starting index for the next run). This member function is const in the semantic sense; the information available through the API is not changed. However, the internal state of the object may be changed. If information about a particular style kind is requested, then the corresponding TStyleRuns object may be created in order to cache the information.

Member Function: TStandardText::CopyStylesAt

  1. virtual TStyleSet * CopyStylesAt (TTextIndex indexOfInterest, const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind (), TMemoryHeap * whichHeap =NIL) const
  2. virtual TStyleSet * CopyStylesAt (TTextIndex indexOfInterest, TTextRange & currentRunRange, const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind (), TMemoryHeap * whichHeap =NIL) const

Interface Category:

API.

Purpose:

  1. Creates a new style set on the heap with a copy the styles of the specified kind that are associated with the specified index.
  2. Creates a new style set on the heap with a copy of the styles of the specified kind that are associated with the specified index. Also returns the maximal contiguous text range with the same style information that overlaps the specified index.

Calling Context:

  1. Called directly to copy the styles for a specified index.
  2. Called directly to copy the styles for a specified index and get the maximal contiguous text range that contains the same style information and the index of interest.

Parameters:

Return Value:

A copy of the styles of the specified kind at the specified index is returned. The caller gets ownership of the storage for this new object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This member function uses StylesAt to get the styles of interest. Therefore, this member function is const in the semantic sense; the information available through the API is not changed. However, the internal state of the object may be changed. If information about a particular style kind is requested, then the corresponding TStyleRuns object may be created in order to cache the information.

Member Function: TStandardText::StylesExist

virtual bool StylesExist (const TStyleSet & set, const TTextRange & range, const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ()) const

Interface Category:

API.

Purpose:

Determines if any of the characters within the specified text range are styled with all of the styles of the specified kind in the specified style set.

Calling Context:

Called directly to check for the existence of the specified styles anywhere within the specified text range.

Parameters:

Return Value:

Returns true if at least one character within the specified text range is styled with all the styles of the specified kind in the specified style set.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::StylesContinuous

virtual bool StylesContinuous (const TStyleSet & set, const TTextRange & range) const

Interface Category:

API.

Purpose:

Determines if every character within the specified text range is styled with all the styles in the specified style set.

Calling Context:

Called directly to check for the existence of the specified styles for every character within the specified text range.

Parameters:

Return Value:

Returns true if every character within the specified text range is styled with all the styles in the specified style set.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::AllStyles

virtual void AllStyles (TSetOf < TStyle > & returnSet, const TTextRange & range, const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ()) const

Interface Category:

API.

Purpose:

Gets the maximal set of styles of the specified kind for the specified text range. It is not required that styles in the returned set be continuous throughout the entire text range. It only matters that a style exist on at least one character in the text range for it to be included in this maximal set of styles.

Calling Context:

Called directly to get the maximal set of styles of the specified kind associated with a specified text range.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

The styles in the resulting set are owned by the text. Do not delete them.

Member Function: TStandardText::AllContinuousStyles

virtual void AllContinuousStyles (TStyleSet & returnSet, const TTextRange & range, const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ()) const

Interface Category:

API.

Purpose:

Gets the maximal set of continuous styles of the specified kind for the specified text range. It is required that styles in the returned set be continuous throughout the entire text range.

Calling Context:

Called directly to get the maximal set of continuous styles of the specified kind associated with a specified text range.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::AddStyles

  1. virtual void AddStyles (const TStyle & style, const TTextRange & range =TTextRange :: GetMaximumRange ())
  2. virtual void AddStyles (const TStyleSet & set, const TTextRange & range =TTextRange :: GetMaximumRange (), const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ())

Interface Category:

API.

Purpose:

  1. Adds the specified style to each character within the specified text range.
  2. Adds the styles of the specified kind in the specified style set to each character within the specified text range.

Calling Context:

  1. Called directly to add a single style.
  2. Called directly to add multiple styles at once.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Consistent with the style set invariant of only one style of the same category and name in a style set, new styles replace existing styles when the category and the name are the same. In the absence of category and name collisions, the new styles are simply added to what was there already.

Member Function: TStandardText::RemoveStyles

  1. virtual void RemoveStyles (const TStyle & style, const TTextRange & range =TTextRange :: GetMaximumRange ())
  2. virtual void RemoveStyles (const TStyleSet & set, const TTextRange & range =TTextRange :: GetMaximumRange (), const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ())
  3. virtual void RemoveStyles (const TStyleCategory & category, const TStyleName & name, const TTextRange & range =TTextRange :: GetMaximumRange (), const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ())
  4. virtual void RemoveStyles (const TStyleKind & styleKind, const TTextRange & range =TTextRange :: GetMaximumRange ())
  5. virtual void RemoveStyles ()

Interface Category:

API.

Purpose:

  1. Removes the specified style from each character within the specified text range.
  2. Removes the specified styles from each character within the specified text range.
  3. Removes the specified style from each character within the specified text range.
  4. Removes all of the styles of the specified kind from each character in the text object.
  5. Removes all styles from each character in the text object.

Calling Context:

  1. Called directly to remove the specified style.
  2. Called directly to remove the styles of the specified kind that are in the specified set of styles.
  3. Called directly to remove the style of the specified category, name, and kind.
  4. Called directly to remove the styles of the specified kind.
  5. Called directly to remove all styles.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

The input style or style set is used for comparison with the style information currently associated with text in the specified range. Only a category and name comparison is done. Styles are removed from the text that match the names of the input styles.

Member Function: TStandardText::ReplaceStyles

  1. virtual void ReplaceStyles (const TStyle & replacementStyle, const TTextRange & range =TTextRange :: GetMaximumRange ())
  2. virtual void ReplaceStyles (const TStyleSet & replacementSet, const TTextRange & range =TTextRange :: GetMaximumRange (), const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ())

Interface Category:

API.

Purpose:

  1. Replaces existing styles with the specified style. The styles of the same kind as the specified style are replaced. All other styles are not touched.
  2. Replaces the existing styles of the specified kind with the styles of the specified kind in the specified style set.

Calling Context:

  1. Called directly to replace existing styles with the specified style.
  2. Called directly to replace existing styles the specified set of styles.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::IsEqualStyles

virtual bool IsEqualStyles (const TText & that, const TTextRange & thatRange, const TTextRange & thisRange =TTextRange :: GetMaximumRange (), const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ()) const

Interface Category:

API.

Purpose:

Compares the style information of this text object with the input text object.

Calling Context:

Called to compare styles of the specified kind in a text range in one text object against styles of the specified kind in a different text range in another text object.

Parameters:

Return Value:

Returns true if the compared styles are equal.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This member function uses StylesAt to get the styles to be compared. Therefore, this member function is const in the semantic sense; the information available through the API is not changed. However, the internal state of the object may be changed. If information about a particular style kind is requested, then the corresponding TStyleRuns object may be created in order to cache the information.

Member Function: TStandardText::Hash

virtual long Hash () const

Interface Category:

API.

Purpose:

Generates a hash value.

Calling Context:

Called to generate a hash value.

Parameters:

Return Value:

The numeric value of the hash.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::operator+

TStandardText operator + (const TText & that) const

Interface Category:

API.

Purpose:

Creates a new text object on the stack consisting of a copy of the text object on the left-hand side with the text object on the right-hand side of the + operator appended to it.

Calling Context:

Called to create a local temporary for the result of appending one text object to another.

Parameters:

Return Value:

A new stack-based text object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::operator=

  1. virtual TText & operator =(const TText & that)
  2. virtual TStandardText & operator =(const TStandardText & that)

Interface Category:

API.

Purpose:

  1. Inherited assignment operator from class TText.
  2. Assignment operator.

Calling Context:

  1. Called when a TText object is polymorphically assigned to a TStandardText object.
  2. Called when one TStandardText object is assigned to another TStandardText object.

Parameters:

Return Value:

  1. Returns a TText reference to this text object.
  2. Returns a TStandardText reference to this text object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Currently, if this text object is styled and you assign an unstyled text object to it, after the assignment this text object is still considered a styled text object. For example, the function TStandardText::IsStyled returns true. This will be fixed in a later release.

Member Function: TStandardText::operator+=

  1. virtual TText & operator += (const TText & that)
  2. virtual TStandardText & operator += (const TStandardText & that)

Interface Category:

API.

Purpose:

Appends the contents of the input text object to the current contents of this text object.

Calling Context:

  1. Called when a TText object is polymorphically appended to a TStandardText object.
  2. Called when one TStandardText object is appended to another TStandardText object.

Parameters:

Return Value:

  1. Returns a TText reference to this text object.
  2. Returns a TStandardText reference to this text object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::operator>>=

virtual TStream & operator >>=(TStream & toStream) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

If you write a simple derived class of TStandardText that adds any instance data, you must override this virtual member function and provide your own streaming operator that calls this one first before streaming your own data.

Member Function: TStandardText::operator<<=

virtual TStream & operator <<= (TStream & fromStream)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws the exception TTextException::kInvalidVersionNumber when the version number that was streamed in is not supported. Passes all other exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

If you write a simple derived class of TStandardText that adds any instance data, you must override this virtual member function and provide your own streaming operator that calls this one first before streaming your own data.

Member Function: TStandardText::PartialStreamOut

virtual void PartialStreamOut (TStream & toStream, const TTextRange & range) const

Interface Category:

API.

Purpose:

Streams out a complete text object for the text contained within the specified text range.

Calling Context:

Called when you want to stream out only part of an existing text object. The standard streaming operators only work on the entire text object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::GetEmptyText

static const TText & GetEmptyText ()

Interface Category:

API.

Purpose:

Returns a const reference to an empty text object.

Calling Context:

Called to save the unnecessary construction of another text object when a const reference to an empty text object is needed.

Parameters:

Return Value:

Returns a const reference to an empty text object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Unfortunately, the construction of even the smallest things have enough of a cost to make this optimization worthwhile.

Member Function: TStandardText::HandleCopyStyles

virtual void HandleCopyStyles (const TText & that, TTextOffset thatOffset, TTextCount thatLength, TTextOffset thisOffset)

Interface Category:

API.

Purpose:

Copies the styles from a specified range of a given TText object into the text starting at the specified offset. This member function replaces the current styles with the styles to be copied. If there are no styles to be copied, then the specified range of the text that the styles are being copied into becomes unstyled. The behavior of HandleCopyStyles and CopyStyles can be different. For instance, for paragraph-based styles CopyStyles only copies the paragraph-based styles from the first paragraph of the specified range, while HandleCopyStyles copies the styles paragraph-by-paragraph.

Calling Context:

Called to copy the styles from one TText object into another. This member function should only be called when the corresponding text has been changed, so this member function is usually called directly after HandleInsertStylesGap has been called.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::HandleInsertStylesGap

virtual void HandleInsertStylesGap (TTextOffset beginOffset, TTextCount length)

Interface Category:

API.

Purpose:

Updates the style runs when new characters have been inserted into the text.

Calling Context:

Called when new characters have been inserted into the text.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This member function must be called after the new characters have been inserted into the text, because the characters can have an affect on how the style runs should be updated. For instance, if a paragraph marker is added, the paragraph-based style runs have to be updated to take this into account.

Member Function: TStandardText::HandleDeleteStyles

virtual void HandleDeleteStyles (TTextOffset beginOffset, TTextCount length)

Interface Category:

API.

Purpose:

Updates the style runs when characters are going to be deleted from the text.

Calling Context:

Called when characters are going to be removed from the text.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This member function must be called before the characters are actually removed from the text, because the characters can have an affect on how the style runs should be updated. For instance, if a paragraph marker is one of the characters being removed, the paragraph-based style runs have to be updated to take this into account.

Member Function: TStandardText::HandleCopyCharacters

  1. virtual void HandleCopyCharacters (const TText & that, TTextOffset thatOffset, TTextCount thatLength, TTextOffset thisOffset)
  2. virtual void HandleCopyCharacters (const UniChar that [], TTextCount thatLength, TTextOffset thisOffset)

Interface Category:

API.

Purpose:

Copies the characters from a specified range of a given TText object or UniChar array into the text starting at the specified offset.

Calling Context:

Called to copy the characters from a TText object or UniChar array into another TText object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

If the current characters in the text are not to be replaced, then HandleInsertCharacterGap must be called before this member function is used in order to create an opening in the text where the new characters are to be added.

Member Function: TStandardText::HandleInsertCharacterGap

virtual void HandleInsertCharacterGap (TTextOffset beginOffset, TTextCount length)

Interface Category:

API.

Purpose:

Opens up space in the text where new characters are to be added by calling the HandleCopyCharacters member function. For instance, to insert characters into text, call HandleInsertCharacterGap to create a gap where the new characters are to be added, then call HandleCopyCharacters to fill that gap in with the new characters.

Calling Context:

Called to open a gap in the text where new characters are to be inserted.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This member function must be followed by a call to HandleCopyCharacters in order to initialize the new character values. This member function does not initialize any of the values within the gap that it creates.

Member Function: TStandardText::HandleDeleteCharacters

virtual void HandleDeleteCharacters (TTextOffset beginOffset, TTextCount length)

Interface Category:

API.

Purpose:

Deletes the characters in the specified range of text, and collapses the character storage to completely remove the gap that is left when the characters are deleted.

Calling Context:

Called to delete the characters from a range of text.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::GetStyleBounds

virtual void GetStyleBounds (TTextIndex indexOfInterest, TTextRange & currentRunRange, const TStyleKind & styleKind =TCharacterStyleRuns :: GetStyleKind ()) const

Interface Category:

API.

Purpose:

For a specified style kind, this member function determines the maximal contiguous text range with the same style information that contains the specified index. For instance, for paragraph-based styles the resulting range is the range of the paragraph containing the specified index.

Calling Context:

Called directly to obtain boundary information about the styles of a specified kind at a specified index.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This member function is const in the semantic sense; the information available through the API is not changed. However, the internal state of the object may be changed. If information about a particular style kind is requested, then the corresponding TStyleRuns object may be created in order to cache the information.

Member Function: TStandardText::GetStyleKinds

virtual void GetStyleKinds (TSetOf < TStyleKind > & returnSet) const

Interface Category:

API.

Purpose:

Generates the complete set of the kinds of styles that are being applied to the text. This member function is used to get all of the styles in a particular range, regardless of kind. For instance, to get all of the styles at a given index, use this member function to get all of the kinds of styles, then iterate through the resulting set calling StylesAt for each kind.

Calling Context:

Called directly to get the complete set of the kinds of styles that are being applied to the text.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

The TStyleKind objects in the returned set are owned by the text. Do not modify or delete them.

Member Function: TStandardText::CopyStyles

virtual void CopyStyles (const TText & that, const TTextRange & thatRange, TTextOffset thisOffset)

Interface Category:

API.

Purpose:

Copies the styles from a specified range of a given TText object into the text starting at the specified offset. The behavior of HandleCopyStyles and CopyStyles can be different. For instance, for paragraph-based styles CopyStyles only copies the paragraph-based styles from the first paragraph of the specified range, while HandleCopyStyles copies the styles paragraph-by-paragraph.

Calling Context:

Called to copy the styles from one TText object into another.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStandardText::GetConstUniCharChunk

virtual const UniChar * GetConstUniCharChunk (TTextIndex indexOfInterest, TTextIndex & chunkStart, TTextCount & chunkLength) const

Interface Category:

API.

Purpose:

Returns a const pointer to the contiguous block of text storage containing the character at the specified index, and determines the starting index and the length of the storage that is returned. When the specified index is out of bounds, the return value is NIL and the length is 0. Note: There is currently a known bug in TStandardText::GetConstUniCharChunk which is preventing it from returning NIL when the specified index is outside the bounds of the text. This bug is expected to be fixed in the next release.

Calling Context:

Called only by character or text iterators.

Parameters:

Return Value:

Returns a const pointer to the contiguous block of text storage containing the character at the specified index, and fills in the values representing the starting index and the length of the storage that is returned. When the specified index is out of bounds, the return value is NIL and the length is 0.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This member function should only be used by character or text iterators. It is very dangerous, as it exposes the internal storage of the text.

Member Function: TStandardText::GetUniCharChunk

virtual void GetUniCharChunk (TTextIndex indexOfInterest, UniChar * & chunkPtr, TTextIndex & chunkStart, TTextCount & chunkLength)

Interface Category:

API.

Purpose:

Gets a pointer to the contiguous block of text storage containing the character at the specified index, and determines the starting index and the length of the resulting storage. When the specified index is out of bounds, the resulting pointer is NIL and the length is 0.

Calling Context:

This member function should only be used by character or text iterators.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This member function should only be used by character or text iterators. It is very dangerous, as it exposes the internal storage of the text.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.