Class: TReplaceTextCommand

Declaration: TextCommandsCore.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TCommandOn

Inherited By:

None.

Purpose:

TReplaceTextCommand, derived from the template class TCommandOn<MTextSelection>, replaces the currently selected text in a text representation with the specified text. If the current text selection is an insertion point, no text is deleted and the specified text is inserted at that offset. If the specified text is empty, the selected text is deleted. Use TReplaceTextCommand to programmatically edit the text representation. TTypingCommand handles editing via user input.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

This class is designed to be used directly to programmatically edit a text representation. A different command, TTypingCommand, is used in response to editing by an end user.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Resource Use:

No special requirements.

Other Considerations:

None.

Member Function: TReplaceTextCommand::TReplaceTextCommand

  1. TReplaceTextCommand ()
  2. TReplaceTextCommand (const TReplaceTextCommand &)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Copy constructor.

Calling Context:

  1. Called by the stream-in operators. Call this function directly.
  2. Called to copy an object. Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

None.

Member Function: TReplaceTextCommand::~TReplaceTextCommand

virtual ~ TReplaceTextCommand ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Typically not called directly by clients.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

None.

Member Function: TReplaceTextCommand::SetText

virtual void SetText (const TText & text)

Interface Category:

API.

Purpose:

Specifies the text that this command will insert into the text representation. Call directly to set the replacement text before executing this command. Called from the Menu objects just after the command is created.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

None.

Member Function: TReplaceTextCommand::GetText

virtual const TText * GetText () const

Interface Category:

API.

Purpose:

Returns the text that this command is set to insert into the text representation.

Calling Context:

Call this function directly.

Parameters:

Return Value:

Returns a pointer to the text in this command.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

None.

Member Function: TReplaceTextCommand::operator>>=

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

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Call this function directly.

Parameters:

Return Value:

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

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

None.

Member Function: TReplaceTextCommand::operator<<=

virtual TStream & operator <<= (TStream &)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Call this function directly.

Parameters:

Return Value:

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

Exceptions:

Throws TInvalidVersionError if the object has detected an unsupportable version during the stream-in process.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

This function is protected.

Member Function: TReplaceTextCommand::operator=

TReplaceTextCommand & operator =(const TReplaceTextCommand &)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function directly.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

None.

Member Function: TReplaceTextCommand::HandleDoBegin

virtual void HandleDoBegin (MTextSelection &)

Interface Category:

API.

Purpose:

Executes this command. Gets the current selection from the text representation and stores this as the undo information of this command, then replaces the currently selected text with the new text. Updates the current selection.

Calling Context:

Called by the framework when the command is executed. Typically not called directly by clients. Note that the SetText member function needs to be called before HandleDoBegin, to specify the text that this command will insert.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

This protected function overrides the inherited TCommandOn function.

Member Function: TReplaceTextCommand::HandleUndo

virtual void HandleUndo (MTextSelection &)

Interface Category:

API.

Purpose:

Undoes the command. Replaces the text that was inserted in the text representation with the original text that it replaced. Also undoes the selection in the text representation to the original value.

Calling Context:

Called by the framework when the command is undone. Typically not called directly by clients.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

This protected function overrides the inherited TCommandOn function.

Member Function: TReplaceTextCommand::HandleRedo

virtual void HandleRedo (MTextSelection &)

Interface Category:

API.

Purpose:

Redoes the command after it has been undone. Also redoes the selection in the text representation.The information required to redo these actions is stored in this command,

Calling Context:

Called when the command is redone. Typically not called directly by clients.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

This command's functions assume that any required locks have already been acquired by the client.

Other Considerations:

This protected function overrides the inherited TCommandOn function.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.