Professional Documents
Culture Documents
Solution
If there is a valid text selection, use ITextEditSuite::Delete to delete selected text (after testing
ITextEditSuite::CanEditText to determine whether the operation is allowed).
Before performing the modification, check the model to ensure it is not locked
(ITextModel::IsModelLocked).
Sample code
SnpManipulateTextModel::DeleteText
Solution
Put the replaced data into a reference counted K2::shared_ptr with type WideString, and pass it into the
InsertCmd, so the memory occupied by the data is purged when no one is referencing it. For more
information, see K2SmartPtr.h.
Before performing the modification, check the model to ensure it is not locked
(ITextModel::IsModelLocked).
Sample code
SnpManipulateTextModel::ReplaceText
Solution
To copy text within and between stories, use the command provided by the
ITextUtils::QueryCopyStoryCommand utility facade. Variants of this API allow common use cases of text
copy to be handled; for example, copying a range from source to a range in the destination and copying
the complete source story to the end of the destination story.