Class: TStyleRunsGroup

Declaration: StyleRunsGroup.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MCollectible

Inherited By:

None.

Purpose:

A TStyleRunsGroup object encapsulates all of the style information and modifications for the text that created it. TStyleRunsGroup is a concrete class that contains a collection of TStyleRuns objects. A TStyleRuns object maintains the styles of a particular kind as they are applied to the text; see descriptions of TStyleKind and TStyleRuns. Whenever a TStandardText object is modified, one or more of the member functions HandleDelete, HandleInsertGap, and HandleCopyStyles is called on the corresponding TStyleRunsGroup object. These member functions iterate through each TStyleRuns object in the collection, calling the corresponding member function on each. A style run is the term used to describe a maximal contiguous range of text with the same style information.

Instantiation:

Always allocate on the heap.

Deriving Classes:

Derive classes from TStyleRunsGroup in order to override the current behavior.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Other Considerations:

None.

Member Function: TStyleRunsGroup::~TStyleRunsGroup

virtual ~ TStyleRunsGroup ()

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: TStyleRunsGroup::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:

None.

Member Function: TStyleRunsGroup::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 exception TTextException::kInvalidVersionNumber when the streamed in version number cannot be handled.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleRunsGroup::HasStyles

virtual bool HasStyles () const

Interface Category:

API.

Purpose:

Determines if the TStyleRunsGroup object contains any style information.

Calling Context:

Called to find out if there is any style information applied to the text that the TStyleRunsGroup corresponds to.

Parameters:

Return Value:

Returns true if the TStyleRunsGroup object contains any style information. Returns false otherwise.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleRunsGroup::GetStyleKinds

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

Interface Category:

API.

Purpose:

Gets the complete set of style kinds that the TStyleRunsGroup contains. Use this member function when you need to get all of the styles in a particular range, regardless of style kind. For instance, if you need to get all of the styles at a given index, use this member function to get all of the style kinds, then iterate through the returnSet calling StylesAt for each kind.

Calling Context:

Called to get the complete set of style kinds that are applied to the text that the TStyleRunsGroup applies to.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Do not delete or modify the TStyleKind objects in the resulting set. The set can be deleted, but not the contents.

Member Function: TStyleRunsGroup::GetLength

virtual TTextCount GetLength (const TStyleKind & styleKind) const

Interface Category:

API.

Purpose:

Determines the length of the style runs for the given style kind. As an example, consider a TStandardText object of length 10 that has character-based styles applied to the characters at index 4 and 5. There will be three style runs, the first from index 0 to 3 containing no styles, the second from index 4 to 5 containing the character-based styles, and the third from index 6 to 9 containing no styles. The total length of these style runs is 10, so GetLength returns 10 even though only 2 characters have styles applied to them.

Calling Context:

Called to get the total length of the style runs for the given style kind.

Parameters:

Return Value:

Returns the total length of the style runs for the given style kind.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleRunsGroup::HandleDelete

virtual void HandleDelete (const TText & textToBeModified, TTextOffset beginOffset, TTextCount length)

Interface Category:

API.

Purpose:

Updates the style runs when characters are going to be deleted from the text. This member function iterates over the collection of TStyleRuns, calling HandleDelete on each.

Calling Context:

Called when characters are going to be removed from the corresponding TText object.

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 corresponding TText object, 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: TStyleRunsGroup::HandleInsertGap

virtual void HandleInsertGap (const TText & modifiedText, TTextOffset beginOffset, TTextCount length)

Interface Category:

API.

Purpose:

Updates the style runs when new characters have been inserted into the text. This member function iterates over the collection of TStyleRuns, calling HandleInsertGap on each.

Calling Context:

Called when new characters have been inserted into the corresponding TText object.

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 corresponding TText object, 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: TStyleRunsGroup::HandleCopyStyles

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

Interface Category:

API.

Purpose:

Copies the styles from a specified range of a given TText object into the TStyleRunsGroup corresponding to another TText object. 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 HandleInsertGap has been called.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleRunsGroup::AddStyles

  1. virtual void AddStyles (const TStyle & newStyle, const TTextRange & range, const TText & thisText)
  2. virtual void AddStyles (const TStyleSet & newStyles, const TTextRange & range, const TText & thisText, const TStyleKind & styleKind)

Interface Category:

API.

Purpose:

  1. Adds the specified style to the corresponding TStyleRuns object within the specified text range. The member function GetKind is called on the style and on each TStyleRuns object in the collection to determine which TStyleRuns object can manage the given style. If no corresponding TStyleRuns object is found, the member function CreateStyleRuns is polymorphically called on the style kind to create the corresponding TStyleRuns object. The style is added to the new TStyleRuns object, and the new TStyleRuns object is added to the collection managed by TStyleRunsGroup.
  2. Adds the styles of the specified kind to the corresponding TStyleRuns object within the specified text range. A style set can consist of styles of different kinds, so the style kind must be supplied to indicate which styles in the set to add.

Calling Context:

  1. Called directly to add a single style.
  2. Called directly to add styles of a particular kind from a given style set.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleRunsGroup::CopyStyles

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

Interface Category:

API.

Purpose:

Copies the styles from a specified range of a given TText object into the TStyleRunsGroup corresponding to another TText object. 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: TStyleRunsGroup::RemoveStyles

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

Interface Category:

API.

Purpose:

  1. Removes the specified style from the specified range of text.
  2. Removes the styles of the specified kind that are in the given style from the specified range of text. A style set can consist of styles of different kinds, so the style kind must be supplied to indicate which styles in the set to remove.
  3. Removes the styles of the specified name, category, and kind from the specified range of text.
  4. Removes the styles of the specified kind from the specified range of text

Calling Context:

  1. Called directly to remove the specified style.
  2. Called directly to remove the specified styles.
  3. Called directly to remove the specified styles.
  4. Called directly to remove the specified styles.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleRunsGroup::ReplaceStyles

  1. virtual void ReplaceStyles (const TStyle & newStyle, const TTextRange & range, const TText & thisText)
  2. virtual void ReplaceStyles (const TStyleSet & newStyles, const TTextRange & range, const TStyleKind & styleKind, const TText & thisText)

Interface Category:

API.

Purpose:

ReplaceStyles is equivalent to removing the current styles of the specified kind from the specified range, and then adding the specified styles to the specified range.
  1. Replaces existing styles with the specified style.
  2. Replaces existing styles with the specified styles. A style set can consist of styles of different kinds, so the style kind must be supplied to indicate which styles are to be removed and which styles in the set are to be added.

Calling Context:

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

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleRunsGroup::StylesAt

  1. virtual TTextIndex StylesAt (TTextIndex indexOfInterest, TStyleSet & returnSet, TTextRange & currentRange, const TStyleKind & styleKind, const TText & thisText) const
  2. virtual TTextIndex StylesAt (TTextIndex indexOfInterest, TStyleSet & returnSet, const TStyleKind & styleKind, const TText & thisText) const

Interface Category:

API.

Purpose:

Fills in the given style set with the styles of a specified kind that are applied to a specified index of the text. When needed, callers can 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 and the maximal contiguous text range that contains the same style information and the index of interest.
  2. Called directly to get the styles for a specified index.

Parameters:

Return Value:

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

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleRunsGroup::GetStyleBounds

virtual void GetStyleBounds (TTextIndex indexOfInterest, TTextRange & currentRange, const TStyleKind & styleKind, const TText & thisText) 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:

None.

Member Function: TStyleRunsGroup::StylesExist

virtual bool StylesExist (const TStyleSet & theSet, const TTextRange & theRange, const TStyleKind & styleKind) 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. Returns false otherwise.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TStyleRunsGroup::StylesContinuous

virtual bool StylesContinuous (const TStyleSet & theSet, const TTextRange & theRange) 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: TStyleRunsGroup::GetStylesInRange

virtual void GetStylesInRange (TSetOf < TStyle > & returnSet, const TStyleKind & styleKind, const TTextRange & range) 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. When two styles with the same name and different values exist, both styles are included in the resulting union. This is why a collection of TStyle pointers is returned instead of a TStyleSet. More than one style with the same name is not allowed in the same TStyleSet.

Calling Context:

Called directly to get the maximal set of styles of a 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: TStyleRunsGroup::GetContinuousStyles

virtual void GetContinuousStyles (TStyleSet & returnSet, const TStyleKind & styleKind, const TTextRange & range) const

Interface Category:

API.

Purpose:

Gets the maximal set of continuous styles of a 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 a 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: TStyleRunsGroup::TStyleRunsGroup

TStyleRunsGroup ()

Interface Category:

API.

Purpose:

Default constructor.

Calling Context:

Called directly to create a TStyleRunsGroup object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.