Action Class Reference

This class represents an Action which is an individual job which is executed to accomplish an operation. An operation contains lists of actions to perform Undo, Redo and Smart Duplication. More...

#include <ops.h>

Inheritance diagram for Action:

ListItem CCObject SimpleCCObject ActionApplyPlugInToBitmap ActionColourChange ActionHideColours ActionPageResize ActionSetDefaultGrid AddPressurePointsAction AddTimeStampPointsAction ApplyAction BaseTextAction BuildMouldAction ChangeBitmapPtrAction ChangeBlendAction ChangeBlenderAction ChangeBlendStepsAction ChangeBrushAction ChangeBrushDefAction ChangeContourAttributeProfileAction ChangeContourColourTypeAction ChangeContourObjectProfileAction ChangeContourStepsAction ChangeContourToInnerAction ChangeContourToOuterAction ChangeContourWidthAction ChangeEffectResAction ChangeFeatherEffectAction ChangeFeatherEffectProfileAction ChangeFeatherProfileAction ChangeFillProfileAction ChangeLyrAttribAction ChangeShapeDataAction ChangeShapePathAction ChangeShapePointAction ChangeTranspFillProfileAction CopyObjectsToClipboardAction DeactivateBrushDefAction EndRebuildMouldAction FactorOutCommonChildAttrAct HideNodeAction InitBlendAction InitBlendersAction InitNodeBlendPathAction InsertFloaterAction InsertPathElementAction InvalidateArbitaryAction InvalidateBoundsAction InvalidateRectAction InvalidateRegionAction LayerColourAction LayerStateAction LocaliseCommonAttrAct MarkEditListAction ModifyElementAction ModifyFilledAction ModifyFlagsAction ModifyPathAction PositionCaretAction PrePostTextAction RecalcBoundsAction RecordBoundsAction RecordChangeCodesAction RecordEnvelopeAction RecordGeometryAction RecordPerspectiveAction RedoAction2 RedoAction3 RedoColAction RedrawBoundsAction RegenerateContourAction RegenerateFeatherContourAction RemapBlendAction RemoveFloaterAction RemovePathElementAction RemovePressurePointsAction RemoveTimeStampPointsAction RestoreFillRampAction RestoreSelectionsAction SaveDetachAction SavePathArraysAction SelectDeselectAction SetTimeStampUpdateTypeAction ShowNodeAction StartRebuildMouldAction StorePathIndentAction ToggleAutoKerningAction ToggleInsetPathAction TransformNodeAction UnApplyAction UndoAction2 UndoAction3 UndoColAction UpdateBrushAction UpdateCachedKeyholePathAction List of all members.

Public Member Functions

 Action ()
 Action constructor.
virtual ~Action ()
 Action destructor.
virtual void Slaughter ()
 destructor which gets called when an operation is deleted
virtual ActionCode Execute ()
 This is a pure virtual method which should be redefined for all derived classes of Action.
virtual BOOL IsADiscardableAction ()
DocumentGetWorkingDoc ()
ViewGetWorkingView ()
DocViewGetWorkingDocView ()
UINT32 GetSize ()
 Find out which document this action is working on. Returns the View that is associated with this action. Note that the majority of actions don't care what view they work on - most of them are document-based, and cause all views attached to a document to be updated. Returns the DocView that is associated with this action. This will return NULL if the View the action is attached to is not actually a DocView (e.g. it may be a PrintView). Note that the majority of actions don't care what view they work on - most of them are document-based, and cause all views attached to a document to be updated. For finding the total size of the action.
virtual void Dump ()
 Shows debug information on the action. Override to display information specific to your action.
BOOL TransferToOtherOp (Operation *pOtherOp, ActionList *pAddActions, ActionList *pOtherActions)
 Adds this action to the end of the specified action list.

Static Public Member Functions

static ActionCode Init (Operation *pOp, ActionList *pActionList, UINT32 Size, CCRuntimeClass *ActionClass, Action **NewAction)
 To check that there is sufficient room for the action in the operation history, and if there is, then to add the action to the operations action list.

Protected Attributes

OperationpOperation
ActionListpOppositeActLst
UINT32 Size

Friends

class OperationHistory

Detailed Description

This class represents an Action which is an individual job which is executed to accomplish an operation. An operation contains lists of actions to perform Undo, Redo and Smart Duplication.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/93
See also:
Operation

Definition at line 559 of file ops.h.


Constructor & Destructor Documentation

Action::Action  ) 
 

Action constructor.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 2322 of file ops.cpp.

02322               :ListItem()
02323 {
02324 } 

Action::~Action  )  [virtual]
 

Action destructor.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
Action::Slaughter

Definition at line 2341 of file ops.cpp.

02342 {                                  
02343     //if (IsUserName("Simon"))
02344     //  TRACE( _T("Action being deleted\n"));   
02345 }  


Member Function Documentation

void Action::Dump  )  [virtual]
 

Shows debug information on the action. Override to display information specific to your action.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/8/95
Parameters:
- [INPUTS]
Outputs debugging information to debug display [OUTPUTS]
Returns:
-

Errors: -

See also:
Operation::Dump

Definition at line 2681 of file ops.cpp.

02682 {
02683 #if DEBUG_TREE
02684     TRACEALL( _T("        Action %s (Size = %d bytes)\n"), GetRuntimeClass()->GetClassName(), GetSize() );
02685 #endif
02686 }

ActionCode Action::Execute  )  [virtual]
 

This is a pure virtual method which should be redefined for all derived classes of Action.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/8/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: If this method is ever called then an ENSURE failure will occur.

See also:
-

Reimplemented in UndoColAction, RedoColAction, RedoAction2, RedoAction3, UndoAction2, UndoAction3, ChangeBrushDefAction, DeactivateBrushDefAction, ActionHideColours, ActionColourChange, CopyObjectsToClipboardAction, InvalidateArbitaryAction, LayerStateAction, ChangeLyrAttribAction, RecordGeometryAction, SaveDetachAction, InvalidateRectAction, RedrawBoundsAction, BuildMouldAction, StartRebuildMouldAction, EndRebuildMouldAction, RecordEnvelopeAction, RecordPerspectiveAction, InitNodeBlendPathAction, UpdateCachedKeyholePathAction, FactorOutCommonChildAttrAct, LocaliseCommonAttrAct, InitBlendAction, ChangeBitmapPtrAction, RecordChangeCodesAction, ChangeFeatherProfileAction, ChangeFeatherEffectProfileAction, ChangeFeatherEffectAction, RegenerateFeatherContourAction, RestoreFillRampAction, InvalidateRegionAction, InvalidateRegionIfBgRedrawAction, HideNodeAction, ShowNodeAction, UnApplyAction, ApplyAction, RestoreSelectionsAction, SelectDeselectAction, TransformNodeAction, ActionSetDefaultGrid, ActionPageResize, ModifyPathAction, RemovePathElementAction, InsertPathElementAction, ModifyElementAction, ModifyFlagsAction, ModifyFilledAction, RecalcBoundsAction, RecordBoundsAction, SavePathArraysAction, ActionApplyPlugInToBitmap, LayerColourAction, ChangeShapeDataAction, ChangeShapePointAction, ChangeShapePathAction, StoreCharCodeAction, StoreKernCodeAction, ReversePathAction, MatrixFitToPathAction, MatrixRemoveFromPathAction, ChangeBlendStepsAction, RemapBlendAction, InitBlendersAction, ChangeBlendAction, ChangeBlenderAction, InvalidateBoundsAction, ChangeFillProfileAction, ChangeTranspFillProfileAction, InsertFloaterAction, RemoveFloaterAction, RegenerateContourAction, ChangeContourWidthAction, ChangeContourToOuterAction, ChangeContourToInnerAction, ChangeContourStepsAction, ChangeContourAttributeProfileAction, ChangeContourColourTypeAction, ChangeContourObjectProfileAction, ToggleInsetPathAction, ChangeBrushAction, RemoveTimeStampPointsAction, AddTimeStampPointsAction, UpdateBrushAction, SetTimeStampUpdateTypeAction, RemovePressurePointsAction, AddPressurePointsAction, ChangeEffectResAction, MarkEditListAction, PrePostTextAction, PositionCaretAction, ToggleAutoKerningAction, and StorePathIndentAction.

Definition at line 2384 of file ops.cpp.

02385 {
02386     ENSURE(FALSE, "Calling pure virtual method of abstract class Action");    
02387     return (AC_FAIL); // The function needs to return a value, even though it never will !. 
02388 } 

UINT32 Action::GetSize  ) 
 

Find out which document this action is working on. Returns the View that is associated with this action. Note that the majority of actions don't care what view they work on - most of them are document-based, and cause all views attached to a document to be updated. Returns the DocView that is associated with this action. This will return NULL if the View the action is attached to is not actually a DocView (e.g. it may be a PrintView). Note that the majority of actions don't care what view they work on - most of them are document-based, and cause all views attached to a document to be updated. For finding the total size of the action.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The size of the action in bytes

Errors: -

See also:
-

Definition at line 2659 of file ops.cpp.

02660 {
02661     return (Size); 
02662 }          

Document* Action::GetWorkingDoc  )  [inline]
 

Definition at line 582 of file ops.h.

00582 { return pOperation->GetWorkingDoc(); }

DocView* Action::GetWorkingDocView  )  [inline]
 

Definition at line 584 of file ops.h.

00584 { return pOperation->GetWorkingDocView(); }

View* Action::GetWorkingView  )  [inline]
 

Definition at line 583 of file ops.h.

00583 { return pOperation->GetWorkingView(); }

ActionCode Action::Init Operation pOp,
ActionList pActionList,
UINT32  ActionSize,
CCRuntimeClass ActionClass,
Action **  NewAction
[static]
 

To check that there is sufficient room for the action in the operation history, and if there is, then to add the action to the operations action list.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/93
Parameters:
pOp,: The operation to which the action should be added [INPUTS]
pActionList: The action list in the operation object

Size: The size of the action in bytes. This should be the total size of the action (including any objects pointed to by the action).

Parameters:
NewAction,: A pointer to the action if it could be allocated. This [OUTPUTS] will be NULL if we are unwinding (AC_OK gets returned)
Returns:
AC_FAIL: There was not enough room in the operation history for the action and the user did not wish to continue. Usually End() should be called in this situation.
AC_NORECORD: There was not enough room in the operation history for the action, but the user requested that he wished to continue without undo.

Currently AC_RECORD is never returned, as we never fail an operation just because we exceed the max size of the operation history !. See code for a reason why

AC_OK : The action was successfully initialised and added to the operation. OR we are unwinding. In this situation NewAction will be NULL.

Returns:
Errors: -
See also:
-

Definition at line 2439 of file ops.cpp.

02445 {  
02446     
02447     ERROR3IF(!(pOp->IsKindOf(CC_RUNTIME_CLASS(UndoableOperation))), 
02448         "Trying to create an action for a non-undoable operation"); 
02449 
02450     // Update the hour glass
02451     ContinueSlowJob(); 
02452 
02453 //  OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(pOp->GetRuntimeClass()); 
02454                                             
02455     OperationHistory& OpHist = pOp->GetWorkingDoc()->GetOpHistory(); 
02456             
02457     //if (Action::LastDiscardableAction != NULL) 
02458     //{                                          
02459     //  delete (LastDiscardableAction);             // LastDescardable action
02460     //  Action::LastDiscardableAction = NULL; 
02461     //}  
02462  
02463 
02464     // If we are unwinding an operation during Undo or Redo then 
02465     // we don't want to create an action as it will already exist on the oposite action
02466     // list. 
02467     
02468     // When unwinding a Do however things are a little different. Whilst we don't need
02469     // need to generatate Redo actions for redoing purposes, we do need them to tidy up 
02470     // the dying Operation. eg. A ShowNodeAction may need to delete its hidden node, and its
02471     // Slaughter method must be called to acheive this. However if we fail to allocate an 
02472     // action in this circumstance we don't want to return an AC_FAIL. Leaking memory is 
02473     // preferable to having nowhere to go. 
02474 
02475     if (pOp->GetOpFlgs().UnwindingActions && (pOp->OpStatus!=DO || pOp->GetOpFlgs().KeepOnEnd))
02476     {
02477         (*NewAction) = NULL; 
02478         return (AC_OK); 
02479     
02480     }
02481     
02482     
02483     //  TRACE( _T("Size of operation history = %ld\n"), OpHist.GetSize()); 
02484 
02485 
02486     // Try to allocate memory for the action, deleting undo if we get desperate
02487     ALLOC_WITH_FAIL((*NewAction),(Action*)(ActionClass->CreateObject()),pOp);         
02488     
02489     // oh no it's all gone horribly wrong, I wouldn't like to be in your shoes
02490     if ((*NewAction) == NULL)
02491     {
02492         // If we are unwinding at this point then we don't fail the action (See note above)
02493         if ((pOp->GetOpFlgs().UnwindingActions))
02494         {
02495             ERROR3IF(!(pOp->OpStatus == DO), "OpStatus should be Do");
02496             return (AC_OK);  
02497         }
02498         else
02499         {      
02500             return (AC_FAIL);
02501         }
02502     }
02503     //if (IsUserName("Simon"))
02504     //{
02505     //  TRACE( _T("Adding action %s, NumBytes = %lu\n"),(*NewAction)->GetRuntimeClass()->m_lpszClassName, ActionSize);  
02506     //} 
02507 
02508 
02509     // If fail and discard then there is no need to prompt the user more than once
02510     if (!(pOp->GetOpFlgs().Failed))
02511     {                                                
02512         // Check that there is enough room in the operation history for the action
02513         if ((OpHist.GetSize() + ActionSize) > OpHist.GetMaxSize())    
02514         {                      
02515             //BOOL NoRoom = FALSE; 
02516             // There is not enough room so first of all check if we can make room 
02517             if (OpHist.GetMaxSize() > ActionSize) 
02518             {                          
02519                 // See if we can make room by deleting UNDO records
02520                 //if (OpHist.ReduceSize((OpHist.GetMaxSize() - ActionSize),TRUE) == FALSE)
02521                 //  NoRoom = TRUE;
02522                 // The outcome does not matter
02523                 OpHist.ReduceSize((OpHist.GetMaxSize() - ActionSize),TRUE, TRUE);
02524             }
02525             else
02526             {
02527                 // Very big action
02528                 OpHist.ReduceSize(0,TRUE, TRUE);
02529             }                    
02530             // We used to give the user the option of either continuing and loosing all undo/redo
02531             // or have them abort their current operation. I didn't think this was a very good idea
02532             // so I have removed the code. Now we let the operation history grow to what
02533             // ever size it wants to, but keep the Maximum size the same. The operation history
02534             // will shrink towards the maximum size whenever there are undo operations which can be deleted.
02535             
02536             // I found that in practice we were reaching this NoRoom situation when the user was undoing
02537             // almost back to the start. If the user redoes then this shrinks the OpHist 
02538             // because there are undo ops to discard, if the user does then this also shrinks the OpHist because
02539             // all redo ops are discarded. 
02540             
02541             /*
02542             else
02543                 NoRoom = TRUE; 
02544             if (NoRoom)
02545             {   
02546                     
02547                 // We cannot make enough room in the operation history for the action
02548                 UINT32 _R(IDS_MSG) = (pOp->OpStatus == UNDO) ? 
02549                     (UINT32)_R(IDS_CANNOT_REDO_WARNING): (UINT32)_R(IDS_CANNOT_UNDO_WARNING);    
02550                                     
02551                 if (InformWarning(_R(IDS_MSG),
02552                                   _R(IDS_CONTINUE),   
02553                                   _R(IDS_CANCEL)) == 2) 
02554                 {      
02555                     // The user does not want to continue, so inform the action's operation that 
02556                     // when the operation ends the actions previously added to its action list 
02557                     // will be executed to bring the document back to the state it was in before the
02558                     // operation was* started.
02559                     pOp->FailAndExecute();   
02560                     LastDiscardableAction = *NewAction; 
02561                     return (AC_FAIL);  
02562                 }
02563                 else
02564                     // The user does want to continue, so inform the operation that when it ends 
02565                     // it should be deleted. 
02566                     pOp->FailAndDiscard();     
02567                 
02568             }
02569             */
02570         }
02571     }
02572     // Add the action to the operation's action list.        
02573     
02574     // Note that actions are added to the operation's action list even after a fail and discard 
02575     // error.  The reason for this is that if memory runs out whilst trying to execute an operation
02576     // after such an error, we need to be able to unwind all actions which have been performed. If 
02577     // we do not do this then all sorts of chaos will occur. 
02578     
02579     pActionList->AddTail(*NewAction);    
02580     (*NewAction)->pOperation = pOp;            // Record the operation to which the action is attached. 
02581     
02582     // Store a pointer to the opposite ActionList to that which the Action is atatched 
02583     (*NewAction)->pOppositeActLst = (pOp->GetUndoActionList() == pActionList) ? 
02584         (pOp->GetRedoActionList()) : (pOp->GetUndoActionList());
02585           
02586     (*NewAction)->Size = ActionSize;           // Record the size of the action           
02587                                              
02588     // Even though the operation has not yet been added to the operation history and maybe
02589     // never will, we increase the current size of the operation history to accomodate the 
02590     // action. If the operation fails then the Size of the operation history will be reduced 
02591     // by the same ammount in the action list's execute methods. 
02592          
02593     OpHist.IncSize(ActionSize);                                                                     
02594     
02595     return (AC_OK); // success                
02596 }                                     

virtual BOOL Action::IsADiscardableAction  )  [inline, virtual]
 

Definition at line 579 of file ops.h.

00579 { return FALSE; }  

void Action::Slaughter void   )  [virtual]
 

destructor which gets called when an operation is deleted

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
Action::Slaughter

Reimplemented in ActionHideColours, FactorOutCommonChildAttrAct, LocaliseCommonAttrAct, ShowNodeAction, RestoreSelectionsAction, and TransformNodeAction.

Definition at line 2362 of file ops.cpp.

02363 {               
02364     delete (this); // Call the destructor 
02365 }   

BOOL Action::TransferToOtherOp Operation pOtherOp,
ActionList pAddActions,
ActionList pOtherActions
 

Adds this action to the end of the specified action list.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/1/96
Parameters:
pOtherOp - points to the operation to add this action to. [INPUTS] pAddActions - points to the action list to add this action to. pOtherAction - points to the other action list.
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation::MergeWithPrevious

Definition at line 2703 of file ops.cpp.

02704 {
02705     ERROR2IF((pOtherOp==NULL) || (pAddActions==NULL) || (pOtherActions==NULL), FALSE, "NULL parameter");
02706 
02707     pOperation = pOtherOp;
02708     pOppositeActLst = pOtherActions;
02709     
02710     pAddActions->AddTail(this);
02711 
02712     return TRUE;
02713 }


Friends And Related Function Documentation

friend class OperationHistory [friend]
 

Definition at line 563 of file ops.h.


Member Data Documentation

Operation* Action::pOperation [protected]
 

Definition at line 595 of file ops.h.

ActionList* Action::pOppositeActLst [protected]
 

Definition at line 600 of file ops.h.

UINT32 Action::Size [protected]
 

Definition at line 605 of file ops.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:49:49 2007 for Camelot by  doxygen 1.4.4