ActionList Class Reference

An ActionList is a list object which holds actions which can be executed. It is used by Operation objects to hold UNDO, REDO and Smart duplicate actions. More...

#include <ops.h>

Inheritance diagram for ActionList:

List CCObject SimpleCCObject List of all members.

Public Member Functions

 ActionList ()
 ~ActionList ()
 ActionList destructor, deletes the action list and all actions it contains. NOTE that REDO action lists must be deleted backwrds.
BOOL ExecuteForwards (BOOL AllButLast)
 This method executes all actions in the action list forwards. If there is no failure then all actions are deleted If an action fails whilst executing no actions are deleted and FALSE is returned.
BOOL ExecuteBackwards (BOOL AllButLast, BOOL bIgnoreSelectActions=FALSE)
 This method executes all actions in the action list backwards. If there is no failure then all actions are deleted If an action fails whilst executing no actions are deleted and FALSE is returned.
ActionFindActionOfClass (CCRuntimeClass *ClassOfActionToFind, Action *LastAction=NULL)
 To search the action list for the first action with runtime class ClassOfActionToFind.

Detailed Description

An ActionList is a list object which holds actions which can be executed. It is used by Operation objects to hold UNDO, REDO and Smart duplicate actions.

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

Action

Definition at line 196 of file ops.h.


Constructor & Destructor Documentation

ActionList::ActionList  ) 
 

ActionList::~ActionList  ) 
 

ActionList destructor, deletes the action list and all actions it contains. NOTE that REDO action lists must be deleted backwrds.

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

Errors: -

See also:
ActionList::SlaughterBackwards;

Definition at line 219 of file ops.cpp.

00220 {   
00221 /*
00222     ListItem* Current = GetHead();          // First action     
00223     while (Current != NULL)                 // While there are more actions to delete
00224     {
00225         ((Action*)RemoveHead())->Slaughter();  // Delete the action 
00226         Current = GetHead();                   // Get next action
00227         ContinueSlowJob(); 
00228     }
00229 */
00230     ListItem* Current = GetTail();          // Last action     
00231     while (Current != NULL)                 // While there are more actions to delete
00232     {
00233         ((Action*)RemoveTail())->Slaughter();  // Delete the action 
00234         Current = GetTail();                   // Get next action
00235         ContinueSlowJob(); 
00236     }
00237 
00238 } 


Member Function Documentation

BOOL ActionList::ExecuteBackwards BOOL  AllButLast,
BOOL  bIgnoreSelectActions = FALSE
 

This method executes all actions in the action list backwards. If there is no failure then all actions are deleted If an action fails whilst executing no actions are deleted and FALSE is returned.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/7/93
Parameters:
AllButLast,: When FALSE execute all actions in the action list. [INPUTS] When TRUE execute all actions except the last
- [OUTPUTS]
Returns:
TRUE if the action list was successfully executed FALSE if it was not

Errors: -

See also:
ActionList::ExecuteForwards

Definition at line 338 of file ops.cpp.

00339 {        
00340     ListItem* CurrentAction = GetTail();   
00341 
00342     if (AllButLast && (CurrentAction != NULL))   
00343         CurrentAction = CurrentAction->Previous; // Don't execute the last action 
00344        
00345 //TRACE( _T("Before Undo\n"));
00346 //((Action*)CurrentAction)->GetWorkingDoc()->FindFirstSpread()->DST();
00347 
00348     BOOL Failed = FALSE;                                       
00349     while ((CurrentAction != NULL) && (!Failed)) // For each action in the list
00350     {
00351         // Attempt to execute action 
00352         if (!(bIgnoreSelectActions &&
00353             CurrentAction->IsKindOf(CC_RUNTIME_CLASS(RestoreSelectionsAction)))
00354            )
00355             Failed = (((Action*)CurrentAction)->Execute() == AC_FAIL);
00356 
00357 //((Action*)CurrentAction)->Dump();
00358 //((Action*)CurrentAction)->GetWorkingDoc()->FindFirstSpread()->DST();
00359 
00360         // Get next action 
00361         CurrentAction = CurrentAction->Previous; 
00362     }    
00363     
00364     if (!Failed)     
00365     { 
00366         // Successfully executed action list so all actions are deleted. 
00367         Action* HeadItem = (Action *) GetHead(); 
00368 
00369         Document *pDoc = HeadItem->GetWorkingDoc();
00370         ERROR2IF(pDoc == NULL, FALSE, "No document attached to action in Action::ExecuteBackwards");
00371         OperationHistory& OpHistory = pDoc->GetOpHistory();
00372 
00373         // Loop while there are still actions to delete
00374         while (HeadItem != NULL)
00375         {                      
00376             // Reduce the size of the operation history by the size of the action being deleted
00377             OpHistory.DecSize(((Action*)HeadItem)->GetSize()); 
00378 
00379             // Delete the action 
00380             delete (RemoveItem(HeadItem));
00381 
00382             // Get next action  
00383             HeadItem = (Action *) GetHead(); 
00384         }
00385         
00386     }
00387     
00388     return (!Failed); 
00389 }

BOOL ActionList::ExecuteForwards BOOL  AllButLast  ) 
 

This method executes all actions in the action list forwards. If there is no failure then all actions are deleted If an action fails whilst executing no actions are deleted and FALSE is returned.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/7/93
Parameters:
AllButLast,: When FALSE execute all actions in the action list. [INPUTS] When TRUE execute all actions except the last
- [OUTPUTS]
Returns:
TRUE if the action list was successfully executed FALSE if it was not

Errors: -

See also:
-

Definition at line 265 of file ops.cpp.

00266 {                                          
00267     ListItem* CurrentAction = GetHead();  
00268     ListItem* LastAction = GetTail(); 
00269     
00270     // If we are to execute all actions but the last then the last action to
00271     // execute is prev(tail)
00272     if ((LastAction != NULL) && (AllButLast))
00273         LastAction = LastAction->Previous; 
00274        
00275 //TRACE( _T("Before Redo\n"));
00276 //((Action*)CurrentAction)->GetWorkingDoc()->FindFirstSpread()->DST();
00277 
00278     BOOL Failed = FALSE; 
00279     while ((CurrentAction != LastAction) && (!Failed))  // For each action in the list
00280     {    
00281         // Execute the action                   
00282         Failed = (((Action*)CurrentAction)->Execute() == AC_FAIL); 
00283 
00284 //((Action*)CurrentAction)->Dump();
00285 //((Action*)CurrentAction)->GetWorkingDoc()->FindFirstSpread()->DST();
00286 
00287         CurrentAction = CurrentAction->Next;    
00288     }                   
00289     
00290     if (!Failed)
00291     {
00292         // Successfully executed action list so all actions are deleted. 
00293         Action* HeadItem = (Action *) GetHead(); 
00294 
00295         Document *pDoc = HeadItem->GetWorkingDoc();
00296         ERROR2IF(pDoc == NULL, FALSE, "No document attached to action in Action::ExecuteForwards");
00297         OperationHistory& OpHistory = pDoc->GetOpHistory();
00298 
00299         while (HeadItem != NULL)
00300         {         
00301             // Reduce the size of the operation history by the size of the action 
00302             // being deleted. 
00303             OpHistory.DecSize(HeadItem->GetSize()); 
00304 
00305             // Remove the action from the action list 
00306             delete (RemoveItem(HeadItem));
00307 
00308             // Get next action 
00309             HeadItem = (Action *) GetHead(); 
00310         }
00311     }
00312     
00313     return (!Failed);
00314 }    

Action * ActionList::FindActionOfClass CCRuntimeClass ClassOfActionToFind,
Action LastAction = NULL
 

To search the action list for the first action with runtime class ClassOfActionToFind.

Action* ActionList::FindActionOfClass(CCRuntimeClass* ClassOfActionToFind, Action* LastAction = NULL);

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/11/94
Parameters:
ClassOfActionToFind,: the runtime class of the action we are to search for [INPUTS] LastAction: if you need to search for more than one occurence of a particular action then specifying the LastAction parameter will cause the search to begin after this Action. If this parameter is not specified then the search will start at the head of the action list.
- [OUTPUTS]
Returns:
A pointer to the first action with runtime class ClassOfActionToFind, or NULL if no such action was found.

Errors: -

See also:

Definition at line 418 of file ops.cpp.

00420 {
00421     Action* Current = LastAction;   // Will be NULL if LastAction is not specified
00422     do
00423     {
00424         if (Current == NULL)
00425         {
00426             Current = (Action*)GetHead(); 
00427         }
00428         else
00429         {
00430             Current = (Action*)GetNext(Current);
00431         }
00432         if ((Current != NULL) && (Current->GetRuntimeClass() == ClassOfActionToFind))
00433         {
00434             return Current;
00435         }
00436     } while (Current != NULL); 
00437     return NULL;    
00438 } 


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