InsertPathElementAction Class Reference

An action which undoes the removal of an element into path data (hence replacing the deleted data). More...

#include <pathedit.h>

Inheritance diagram for InsertPathElementAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 InsertPathElementAction ()
 Constructor for the action to undo path modification.
 ~InsertPathElementAction ()
virtual ActionCode Execute ()
 This is a pure virtual method which should be redefined for all derived classes of Action.
void RecordPath (PathVerb *Verbs, PathFlags *Flags, DocCoord *Coords, NodePath *WhichPath)
 This function initialises the array pointers in this action. Note that the variables NumElements and InsertionPoint are initialised in the Init function.

Static Public Member Functions

static ActionCode Init (Operation *pOp, ActionList *pActionList, INT32 NumChangedElements, INT32 ChangedIndex, Action **NewAction)
 This is the function which creates an instance of this action. If there is no room in the undo buffer (which is determined by the base class Init function called within) the function will either return AC_NO_RECORD which means the operation can continue, but no undo information needs to be stored, or AC_OK which means the operation should continue AND record undo information. If the function returns AC_FAIL, there was not enough memory to record the undo information, and the user has decided not to continue with the operation.

Protected Attributes

INT32 NumElements
INT32 InsertionPoint
NodePathChangedPath
PathVerbChangedVerbs
PathFlagsChangedFlags
DocCoordChangedCoords

Detailed Description

An action which undoes the removal of an element into path data (hence replacing the deleted data).

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
See also:
-

Definition at line 704 of file pathedit.h.


Constructor & Destructor Documentation

InsertPathElementAction::InsertPathElementAction  ) 
 

Constructor for the action to undo path modification.

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

Errors: -

See also:
-

Definition at line 9004 of file pathedit.cpp.

09005 {
09006     ChangedVerbs = NULL;
09007     ChangedFlags = NULL;
09008     ChangedCoords = NULL;
09009 }

InsertPathElementAction::~InsertPathElementAction  ) 
 

Definition at line 9149 of file pathedit.cpp.

09150 {
09151     if (ChangedVerbs)
09152         CCFree(ChangedVerbs);
09153     if (ChangedCoords)
09154         CCFree(ChangedCoords);
09155     if (ChangedFlags)
09156         CCFree(ChangedFlags);
09157 }


Member Function Documentation

ActionCode InsertPathElementAction::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 from Action.

Definition at line 9093 of file pathedit.cpp.

09094 {
09095     // Here we're undoing the modify, so we have to write the list of changed array entries
09096     // back into the path. We also have to build undo information for the redo. Usefully,
09097     // We can use the existing arrays, swapping the data in the undo action for the data 
09098     // in the path, then passing the arrays on to the redo record. We have to make sure 
09099     // we don't try and de-allocate the arrays after we've done this, so we'll put a check in
09100     // the destructor for null pointers
09101     
09102     RemovePathElementAction* ModAction;
09103     
09104     ActionCode Act;
09105     Act = RemovePathElementAction::Init(pOperation, pOppositeActLst, NumElements, InsertionPoint, (Action**)(&ModAction));
09106     if (Act == AC_FAIL)
09107         return AC_FAIL;
09108 
09109     // Tell the operation where the path is
09110     if (ModAction!=NULL)
09111         ModAction->RecordPath(ChangedPath);
09112 
09113     // Force a re-draw of the place where the path used to be
09114     Document* pDoc = GetWorkingDoc();
09115     ERROR2IF( pDoc == NULL, AC_FAIL, "There was no current document when undoing modifypath" );
09116     Spread* pSpread = ChangedPath->FindParentSpread();
09117     DocRect Invalid = ChangedPath->GetUnionBlobBoundingRect();
09118     pDoc->ForceRedraw( pSpread, Invalid, FALSE, ChangedPath );
09119 
09120     // See if we can open the path up
09121     if (!ChangedPath->InkPath.InsertSection(InsertionPoint,
09122                                             NumElements))   // WARNING! This routine will claim memory
09123         return AC_FAIL;                                     // in a way the undo system can't track, so it
09124                                                             // won't be able to warn the user that memory is
09125                                                             // tight and would they prefer not to do this operation
09126 
09127     // Get pointers to all the arrays of the path
09128     PathVerb* Verbs = ChangedPath->InkPath.GetVerbArray();
09129     DocCoord* Coords = ChangedPath->InkPath.GetCoordArray();
09130     PathFlags* Flags = ChangedPath->InkPath.GetFlagArray();
09131 
09132     // Now insert the data from the arrays in the action record
09133 
09134     for (INT32 i=0;i<NumElements;i++)
09135     {
09136         Verbs[i+InsertionPoint] = ChangedVerbs[i];
09137         Coords[i+InsertionPoint] = ChangedCoords[i];
09138         Flags[i+InsertionPoint] = ChangedFlags[i];
09139     }
09140 
09141     ChangedPath->InvalidateBoundingRect();
09142 
09143     Invalid = ChangedPath->GetUnionBlobBoundingRect();
09144     pDoc->ForceRedraw( pSpread, Invalid, FALSE, ChangedPath );
09145 
09146     return Act;
09147 }

ActionCode InsertPathElementAction::Init Operation pOp,
ActionList pActionList,
INT32  NumChangedElements,
INT32  ChangedIndex,
Action **  NewAction
[static]
 

This is the function which creates an instance of this action. If there is no room in the undo buffer (which is determined by the base class Init function called within) the function will either return AC_NO_RECORD which means the operation can continue, but no undo information needs to be stored, or AC_OK which means the operation should continue AND record undo information. If the function returns AC_FAIL, there was not enough memory to record the undo information, and the user has decided not to continue with the operation.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/5/94
Parameters:
pOp is the pointer to the operation to which this action belongs [INPUTS] pActionList is the action list to which this action should be added NumChangedElements is the number of elements in the path that are going to change. This tells the action how much memory the total action is going to take
NewAction is a pointer to a pointer to an action, allowing the function to return [OUTPUTS] a pointer to the created action
Returns:
ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL

Errors: -

See also:
Action::Init()

Definition at line 9043 of file pathedit.cpp.

09048 {
09049     UINT32 ActSize = sizeof(InsertPathElementAction) +
09050                     NumChangedElements * (sizeof(PathVerb)+sizeof(PathFlags)+sizeof(DocCoord));
09051 
09052     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(InsertPathElementAction), NewAction);
09053     if ((Ac == AC_OK) && (*NewAction != NULL))
09054     {
09055         ((InsertPathElementAction*)*NewAction)->NumElements = NumChangedElements;
09056         ((InsertPathElementAction*)*NewAction)->InsertionPoint = ChangedIndex;
09057     }
09058 
09059     return Ac;
09060 }

void InsertPathElementAction::RecordPath PathVerb Verbs,
PathFlags Flags,
DocCoord Coords,
NodePath WhichPath
 

This function initialises the array pointers in this action. Note that the variables NumElements and InsertionPoint are initialised in the Init function.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
Verbs is a pointer to an array of path verbs [INPUTS] Flags is a pointer to an array of path flags Coords is a pointer to an array of DocCoords WhichPath is the path that's being operated on
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 9084 of file pathedit.cpp.

09086 {
09087     ChangedPath = WhichPath;
09088     ChangedVerbs = Verbs;
09089     ChangedFlags = Flags;
09090     ChangedCoords = Coords;
09091 }


Member Data Documentation

DocCoord* InsertPathElementAction::ChangedCoords [protected]
 

Definition at line 728 of file pathedit.h.

PathFlags* InsertPathElementAction::ChangedFlags [protected]
 

Definition at line 727 of file pathedit.h.

NodePath* InsertPathElementAction::ChangedPath [protected]
 

Definition at line 724 of file pathedit.h.

PathVerb* InsertPathElementAction::ChangedVerbs [protected]
 

Definition at line 726 of file pathedit.h.

INT32 InsertPathElementAction::InsertionPoint [protected]
 

Definition at line 723 of file pathedit.h.

INT32 InsertPathElementAction::NumElements [protected]
 

Definition at line 722 of file pathedit.h.


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