Question
After observing a story, how can I get the parameters of the insert or delete commands for the story
void MyStoryObserver::AutoAttach()
{
do
{
InterfacePtr<ISubject> subject(this, IID_ISUBJECT);
if (subject != nil)
{
if (subject->IsAttached(ISubject::kBothAttachments, this, IID_ITEXTMODEL, IID_MYSTORY_OBSERVER) == kFalse)
{
subject->AttachObserver(ISubject::kBothAttachments, this, IID_ITEXTMODEL, IID_MYSTORY_OBSERVER);
}
}
} while (kFalse);
}
void MyStoryObserver::Update(
const ClassID& theChange,
ISubject* theSubject,
const PMIID& protocol,
void* changedBy)
{
if (protocol == IID_ITEXTMODEL)
{
ClassID changeClassID = theChange.Get();
UIDRef storyUIDRef(::GetUIDRef(this));
InterfacePtr<IDocument> iDocument(storyUIDRef.GetDataBase(), storyUIDRef.GetDataBase()->GetRootUID(), UseDefaultIID());
if (iDocument == nil) {
return;
}
do
{
if (changeClassID == kInsertTextCmdBoss
|| changeClassID == kDeleteTextCmdBoss
)
{
ICommand* theCmd = static_cast<ICommand*>(changedBy);
if (theCmd && theCmd->GetCommandState() == ICommand::kDone)
{
// How can I get the insertion position and the length of the inserted content in the insert command, as well as the deletion position and the content length in the delete command?
}
}
} while (kFalse);
}
}
