void OpUndo::Do(OpDescriptor*) { // Remember our document, because in debug builds we need to access it after End() // has been called, and End() deletes the operation. Document *pDoc = pOurDoc; // #ifdef _DEBUG // // Ensure that the size of the operation history is valid before the undo // pDoc->GetOpHistory().DebugSizeCheck(); // #endif pDoc->GetOpHistory().UndoPrev(); // Undo the previous operation End(); // if there are no more actions to undo and the operation history has not been reduced // then mark the document as un-modified. if ( (!(pDoc->GetOpHistory().CanUndo())) && (!(pDoc->GetOpHistory().IsReduced())) ) { pDoc->SetModified(FALSE); } #ifdef _DEBUG // Ensure that the size of the operation history is valid after the undo pDoc->GetOpHistory().DebugSizeCheck(); #endif }
void OpRedo::Do(OpDescriptor*) { // ENSURE(FALSE,"Someone's trying to Redo!"); // Remember our document, because in debug builds we need to access it after End() // has been called, and End() deletes the operation. Document *pDoc = pOurDoc; pDoc->GetOpHistory().RedoNext(); End(); #ifdef _DEBUG // Ensure that the size of the operation history is valid pDoc->GetOpHistory().DebugSizeCheck(); #endif }
OpState OpRedo::GetState(String_256* UIDescription, OpDescriptor*) { OpState OpSt; // Undo always works on the selected document... Document *pDocument = Document::GetSelected(); if (pDocument) { OperationHistory *pOpHist = &(pDocument->GetOpHistory()); // Is there an Operation History? if (pOpHist) { // The Redo operation can only be invoked if there are any operations to redo. if (pOpHist->CanRedo()) { // Temporary String used for Operation Name String_256 OpName; // Get the name of operation to be undone pOpHist->GetRedoOpName(&OpName); //Concatenate The Menu Description with the operation name String Space = _T(" "); *UIDescription += Space; *UIDescription += OpName; return OpSt; } } } //ELSE set to state to disabled OpSt.Greyed = TRUE; // Load reason why operation is disabled String_256 DisableReason(_R(IDS_REDO_DISABLED)); *UIDescription = DisableReason; return(OpSt); }