UndoableOperation Class Reference

All Undoable operations should be derived from this class. More...

#include <undoop.h>

Inheritance diagram for UndoableOperation:

Operation MessageHandler ListItem CCObject SimpleCCObject BfxOp BlobbyOp OpApplyNamesToOne OpApplyNameToNone OpBackground OpChangeBarExtends OpChangeBarProperty OpChangeBrushDefinition OpChangeContourWidth OpChangeFeatherProfile OpChangeFeatherSize OpChangeLayerColour OpChangeSetProperty OpColourChange OpCreateNodeBitmap OpDeactivateBrush OpDeleteNamesFromAll OpDetachMould OpDragOrigin OpGrid OpGridResize OpGuideline OpHideColours OpInsertFloater OpLayerChange OpLayerGalChange OpMakeColourLocalToFrame OpMakeNodesShapes OpMouldLib OpRemoveFloater OpRenameAll OpSelectPathPoints OpShowState SelOperation TransOperation List of all members.

Public Member Functions

BOOL DoInvalidateNodesRegions (Range NodeRange, BOOL IncludeBlobs, BOOL UndoBlobs=FALSE, BOOL IfBgRedraw=FALSE, BOOL bForceRecache=TRUE)
 This low level Do function invalidates a region which is the union of the bounding rectangles of each node in the range. When the includeBlobs flag is TRUE the region which gets invalidated includes the objects blobs.
BOOL DoInvalidateNodeRegion (NodeRenderableBounded *Node, BOOL IncludeBlobs, BOOL UndoBlobs=FALSE, BOOL IfBgRedraw=FALSE, BOOL bForceRecache=TRUE)
 Invalidates the nodes bounding rectangle, or blob bounding rectangle.
BOOL DoInvalidateRegion (Spread *pSpread, const DocRect &InvalidRegion)
 Invalidates the region specified and adds the appropriate action to the action list for the current operation. If you are invalidating a region associated with a node in the tree then you should be using DoInvalidateNodeRegion() or DoInvalidateNodesRegion().
BOOL DoSaveCopyOfNode (NodeRenderable *Node)
 This fn saves a copy of the node in the operation history. When the operation is undone the copy is restored.
BOOL DoSaveCopyOfNodes (Range NodeRange)
 This fn takes a copy of the nodes in the range. The copies are restored when the operation is undone.
BOOL DoHideNode (Node *NodeToHide, BOOL IncludeSubtreeSize, NodeHidden **nodeHidden=NULL, BOOL TellSubtree=TRUE)
 This low level Do function hides the subtree with root NodeToHide.
BOOL DoHideNodes (Range NodeRange, BOOL IncludeSubtreeSize, BOOL TellSubtree=TRUE)
 This low level Do function hides a range of the subtrees.
BOOL DoHideComplexRange (Range &RangeToHide)
 This function is a pre process to DoHideNodes(). It calls each object in the range to hide themselves in a complex way. It may be that no objects in the selection require this facility, which means the RangeToHide object will be returned from this function unaffected. DoHideNodes() will then go through hidding all nodes in the range itself. If however a node responds to ComplexHide() and hides itself, the node will be removed from the range. This allows complex group nodes to control how they are hidden. Note, it is expected that ComplexHide() responders will hide nodes themselves This will have the automatic effect of removing them from the range. Hidden nodes do not appear in ranges.
BOOL DoInsertNewNode (NodeRenderableBounded *NewNode, Spread *pSpread, BOOL InvalidateRgn, BOOL ClearSelection=TRUE, BOOL SelectNewObject=TRUE, BOOL NormaliseAttributes=TRUE)
 Inserts the node as a last child of the active layer of the pSpread. If the NewNode is a NodeRenderableInk then the node becomes selected and all other nodes are deselected. If pSpread is NULL then the object is inserted on the selected spread.
BOOL DoInsertNewNode (NodeRenderableBounded *NewNode, Node *ContextNode, AttachNodeDirection Direction, BOOL InvalidateRegion, BOOL ClearSelection=TRUE, BOOL SelectNewObject=TRUE, BOOL NormaliseAttributes=TRUE)
 This high level do function attaches the node to ContextNode in the direction specified. If the NewNode is a NodeRenderableInk then the node becomes selected and all other nodes are deselected.
BOOL DoMoveNode (Node *MoveNode, Node *Destination, AttachNodeDirection Direction)
 This high level function moves NodeToMove from its current position in the tree, and attaches it to Destination in the direction specified by Direction.
BOOL DoMoveNodes (Range NodeRange, Node *Destination, AttachNodeDirection Direction)
 This high level function moves the range of nodes from their current position in the tree, and attaches them to the Destination node in the direction specified by Direction.
BOOL DoTransformNode (NodeRenderableInk *NodeToTransform, TransformBase *T)
 This high level Do function applies the transform Trans to the NodeToTransform.
BOOL DoTransformNodes (Range NodeRange, TransformBase *T)
 This high level Do function applies the transform Trans to each object in the range.
BOOL DoMakeShapes (Range NodeRange)
 This low level Do function calls the DoBecomeA virtual function on all SelectedNodes. It is the node's DoBecomeA function which is responsible for generating actions.
BOOL DoFlattenRange (Range NodeRange)
 Not implemented yet.
BOOL DoCopyNodesToClipboard (Range NodeRange)
 This Do function copies all nodes in the range to the internal clipboard. The objects are made attribute complete prior to being moved.
BOOL DoRemoveAttrTypeFromSubtree (Node *Subtree, CCRuntimeClass *NodeClass, Node *pExceptThis=NULL)
 Searches the subtree and every attribute which has type AttrType is hidden.
BOOL DoChangeSelection (NodePath *ThisNode, INT32 Index, BOOL NewState)
 This 'Do' function changes the selected state of a particular element in a path it creates all the necessary undo information so that the selection can be undone.
BOOL DoDeletePathSection (NodePath *ThisNode, INT32 Index, INT32 NumElements, BOOL RedrawPath=TRUE)
 This 'Do' function changes the selected state of a particular element in a path it creates all the necessary undo information so that the selection can be undone.
BOOL DoAlterPathElement (NodePath *ThisNode, INT32 Index, DocCoord NewCoord, PathFlags NewFlags, PathVerb NewVerb, BOOL RedrawPath=TRUE)
 This 'Do' function changes the selected element, recording undo information.
BOOL DoInsertPathElement (NodePath *ThisPath, INT32 Index, DocCoord NewCoord, PathFlags NewFlags, PathVerb NewVerb, BOOL RedrawPath=TRUE)
 This 'Do' function adds an element into a path, recording undo information.
BOOL DoReversePath (NodePath *ThisPath, BOOL RedrawPath=TRUE)
 This 'Do' function reverse a path, recording undo information.
BOOL DoSmoothNodePath (NodePath *pThisNode, double smoothacc)
 This function will smooth a node path given an accuracy. It will create a new node in the tree after the node specified and hide node passed if all is succesfull.
BOOL DoMakeNodeFromPath (NodePath *pParentNode, Path *pParentPath, AttachNodeDirection Direction, BOOL CopyAttributes)
 This functio will create a new nodepath and attach it in the specified direction to the context node specified. It will also copy attributes applied as children of the ConextNode to the new node if required.
BOOL DoLocaliseForAttrChange (NodeRenderableInk *Object, AttrTypeSet *pAffectedAttrTypes, ObjectSet *pLocalisedCompounds)
 This Do function must be called on an object prior to a set of attributes being applied to it. It globally localises those attributes which have a type in the pAffectedAttrTypes set.
BOOL DoLocaliseForAttrChange (NodeRenderableInk *Object, CCRuntimeClass *pAffectedAttrType, ObjectSet *pLocalisedCompounds)
 This Do function must be called on an object prior to an attribute being applied to it. If you are going to apply multiple attributes to the Object then it is more efficient to call the other version of this function which takes a set of attribute types.
BOOL DoLocaliseForAttrChange (Range *pRange, AttrTypeSet *pAffectedAttrTypes, BOOL ExcludeTextObjects=FALSE)
 This Do function must be called on a range prior to a set of attributes being applied to it. It globally localises those attributes which have a type in the pAffectedAttrTypes set.
BOOL DoLocaliseForAttrChange (Range *pRange, CCRuntimeClass *pAffectedAttrType)
 This Do function must be called on a range prior to an attribute being applied to it. If you are going to apply multiple attributes to the range then it is more efficient to call the other version of this function which takes a set of attribute types.
BOOL DoFactorOutAfterAttrChange (NodeRenderableInk *Object, AttrTypeSet *pAffectedAttrTypes)
 This Do function must be called on an object after attributes have being applied to it.
BOOL DoFactorOutAfterAttrChange (NodeRenderableInk *Object, CCRuntimeClass *pAffectedAttrType)
 This Do function must be called on an object after an attribute being applied to it. If you have applied multiple attributes to the Object then it is more efficient to call the other version of this function which takes a set of attribute types.
BOOL DoFactorOutAfterAttrChange (Range *pRange, AttrTypeSet *pAffectedAttrTypes)
 This Do function must be called on the range after attributes have being applied to it.
BOOL DoFactorOutAfterAttrChange (Range *pRange, CCRuntimeClass *pAffectedAttrType)
 This Do function must be called on the range after an attribute being applied to it. If you have applied multiple attributes to the range then it is more efficient to call the other version of this function which takes a set of attribute types.
BOOL DoFactorOutAfterAttrChange (ObjectSet *pLocalisedCompounds, AttrTypeSet *pAffectedAttrTypes)
 This Do function is designed to be called after all attributes in the pAffectedAttrTypes set have been localised on all compound nodes in the pLocalisedCompounds set.
BOOL DoFactorOutAfterAttrChange (ObjectSet *pLocalisedCompounds, CCRuntimeClass *pAffectedAttrType)
 This Do function is designed to be called after pAffectedAttrType has been localised on all compound nodes in the pLocalisedCompounds set.
BOOL DoFactorOutCommonChildAttributes (NodeRenderableInk *CompoundObject, BOOL Global=FALSE, AttrTypeSet *pAffectedAttrTypes=NULL)
 This function is an information gatherer for the DoFactorOutAfterDeletion function. See this function for a full description of its purpose. Whenever we delete a range of objects, if any objects in the range have compound parents then we must adjust the common attributes on these compounds. This function factors out all attributes which are common to all children of the compound object. All common attributes become first children of the compound object.
BOOL DoFactorOutCommonAttributes (NodeRenderableInk *pRootNode, BOOL bGlobal=FALSE, AttrTypeSet *pAffectedAttrTypes=NULL)
 Just a wrapper to get function name consistency and do the common IsCompound test to prevent DFOCCA from barfing...
BOOL DoLocaliseCommonAttributes (NodeRenderableInk *CompoundObject, BOOL CheckForDuplicates=FALSE, BOOL Global=FALSE, AttrTypeSet *pAffectedAttrTypes=NULL)
 This function is the opposite of DoFactorOutCommonChildAttributes it copies all attributes common to the compound object to each child object within the group which requires each attribute. The groups common attributes are deleted.
BOOL DoSelectNode (NodeRenderableInk *NodeToSelect, Spread *Parent=NULL)
 The function selects NodeToSelect. It also generates an action which will deselect the node when executed.
BOOL DoDeselectNode (NodeRenderableInk *NodeToDeselect, Spread *Parent=NULL)
 The function de-selects NodeToDeselect. It also generates an action which will select the node when executed.
 UndoableOperation ()
 Constructs a new undoable operation object:.
virtual ~UndoableOperation ()
 UndoableOperation destructor.
virtual void PerformMergeProcessing ()
 This function gets called from the Operation::EndOp method after the operation has ended successfuly and been added to the operation history. If the operation could potentially merge itself with the previous operation then perform this merging here.
void MergeWithPrevious ()
 Moves all the actions in this operation to the end of the previous action, then deletes this action.
virtual BOOL UpdateChangedNodes (ObjChangeParam *pParam, Spread *pSpread=NULL)
 This function overrides its namesake in Operation, calling the base function first and then adding a call to NameGallery::PostTriggerEdit if this Op admits it may change the bounds of nodes within the tree.
virtual BOOL NoStretchUpdateChangedNodes (ObjChangeParam *pParam, Document *pDoc)
 This is *not* an override of Operation::UpdateChangedNodes(..., Document*), although it performs *almost* exactly the same job. It is provided solely for NameGallery::PostTriggerEdit to call in order to get all affected nodes to update themselves correctly after a stretch. PostTriggerEdit is itself called in response to normal UpdateChangedNodes calls, so this avoids recursion problems.
virtual BOOL MayChangeNodeBounds () const
virtual BOOL GetStarted () const

Static Public Member Functions

static BOOL RegisterOpDescriptor (UINT32 toolID, UINT32 txID, CCRuntimeClass *RuntimeClass, TCHAR *tok, pfnGetState gs, UINT32 helpId=0, UINT32 bubbleID=0, UINT32 resourceID=0, UINT32 controlID=0, SystemBarType GroupBarID=SYSTEMBAR_ILLEGAL, BOOL ReceiveMessages=TRUE, BOOL Smart=FALSE, BOOL Clean=FALSE, UINT32 OneOpenInstID=0, UINT32 AutoStateFlags=0)
 This function should be called from the operations Init method. It creates an OpDescriptor for the operation.

Static Public Attributes

static BOOL MovingNode = FALSE

Private Member Functions

RangeIncludeParentTransformNodesInRange (Range *Rng)
 Transforms the node, checking if any parents need to transform too.

Private Attributes

BOOL WarnInsertObjsOntoLockedLayers

Detailed Description

All Undoable operations should be derived from this class.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/3/94
See also:
Operation

Definition at line 195 of file undoop.h.


Constructor & Destructor Documentation

UndoableOperation::UndoableOperation  ) 
 

Constructs a new undoable operation object:.

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

Errors: -

See also:
Operation::Operation

Definition at line 294 of file undoop.cpp.

00294                                     : Operation()
00295 {   
00296     // This var is a flag that ensures that this warning will only appear once for the lifetime of this op
00297     WarnInsertObjsOntoLockedLayers = TRUE;
00298 }

UndoableOperation::~UndoableOperation  )  [virtual]
 

UndoableOperation destructor.

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

Errors: -

See also:
-

Definition at line 317 of file undoop.cpp.

00318 {
00319 }


Member Function Documentation

BOOL UndoableOperation::DoAlterPathElement NodePath ThisPath,
INT32  Index,
DocCoord  NewCoord,
PathFlags  NewFlags,
PathVerb  NewVerb,
BOOL  RedrawPath = TRUE
 

This 'Do' function changes the selected element, recording undo information.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/7/94
Parameters:
ThisPath points at the NodePath whose state we want to change [INPUTS] Index is the element we want to change NewCoord is the new coordinate value NewFlags is the new flags value NewVerb is the new verb value RedrawPath - TRUE if the screen area of the path should be invalidated, FALSE if not
- [OUTPUTS]
Returns:
TRUE if succeeded, FALSE otherwise

Errors: -

See also:
-

Definition at line 2126 of file undoop.cpp.

02132 {
02133 #ifndef STANDALONE
02134 
02135     // Here we're changing an element, so we have to change the element in the path,
02136     // recording undo information at the same time.
02137     ModifyElementAction* ModAction = NULL;
02138     
02139     // Get pointers to all the arrays of the path
02140     PathVerb* Verbs = NULL;
02141     DocCoord* Coords = NULL;
02142     PathFlags* Flags = NULL;
02143     ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags);
02144 
02145     // Create an undo action for this action, which is a ModifyElementAction
02146     ActionCode Act;
02147     Act = ModifyElementAction::Init(this, 
02148                                     &UndoActions, 
02149                                     Verbs[Index],
02150                                     Flags[Index],
02151                                     Coords[Index],
02152                                     Index,
02153                                     ThisPath,
02154                                     (Action**)(&ModAction));
02155     if (Act == AC_FAIL)
02156         return FALSE;
02157 
02158     Document* pDocument = GetWorkingDoc();
02159     ERROR2IF(pDocument == NULL, FALSE, "There was no Document when deleteing path elements");
02160     Spread* pSpread = ThisPath->FindParentSpread();
02161     ERROR2IF(pSpread == NULL, FALSE, "Path had no parent spread");
02162 
02163     // Force a re-draw of the place where the path used to be
02164     if (RedrawPath)
02165     {
02166         DocRect Invalid = ThisPath->GetUnionBlobBoundingRect();
02167         // Mark the region as requiring object to recache any cached
02168         // data they may be holding because the Op may have changed it
02169         pDocument->ForceRedraw( pSpread, Invalid, FALSE, ThisPath );
02170     }
02171 
02172     // Update the coords
02173     Verbs[Index] = NewVerb;
02174     Flags[Index] = NewFlags;
02175     Coords[Index] = NewCoord;
02176 
02177     // The bounding rect may have changed
02178     ThisPath->InvalidateBoundingRect();
02179 
02180     // redraw the new area
02181     if (RedrawPath)
02182     {
02183         // redraw the new area
02184         DocRect Invalid = ThisPath->GetUnionBlobBoundingRect();
02185         // Mark the region as requiring object to recache any cached
02186         // data they may be holding because the Op may have changed it
02187         pDocument->ForceRedraw( pSpread, Invalid, FALSE, ThisPath );
02188     }
02189 
02190 #endif
02191     return TRUE;
02192 }

BOOL UndoableOperation::DoChangeSelection NodePath ThisNode,
INT32  Index,
BOOL  NewState
 

This 'Do' function changes the selected state of a particular element in a path it creates all the necessary undo information so that the selection can be undone.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/94
Parameters:
ThisNode points at the NodePath whose state we want to change [INPUTS] Index is the element we want to change NewState is the new state of selection we want to set
- [OUTPUTS]
Returns:
TRUE if succeeded, FALSE otherwise

Errors: -

See also:
-

Definition at line 1978 of file undoop.cpp.

01979 {
01980 #ifndef STANDALONE
01981 
01982     ModifyFlagsAction* UnAction;
01983     PathFlags* Flags = ThisNode->InkPath.GetFlagArray();
01984     if (Flags[Index].IsSelected != NewState)
01985     {
01986         ActionCode Act = ModifyFlagsAction::Init(this, 
01987                                                     &UndoActions,
01988                                                     Flags[Index],
01989                                                     Index,
01990                                                     ThisNode,
01991                                                     (Action**)&UnAction);
01992         if (Act == AC_FAIL)
01993             return FALSE;
01994         
01995         Flags[Index].IsSelected = NewState;
01996         return TRUE;
01997     }
01998 
01999 #endif
02000 
02001     return TRUE;
02002 }

BOOL UndoableOperation::DoCopyNodesToClipboard Range  NodeRange  ) 
 

This Do function copies all nodes in the range to the internal clipboard. The objects are made attribute complete prior to being moved.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/05/94
Parameters:
NodeRange,: The Range of nodes to copy [INPUTS]
Returns:
TRUE if successful FALSE if the operation should be aborted (TIDYUP THEN CALL End()!)
Before the copy begins StartComponentCopy is called on each DocComponent in the clipboard.

The nodes are then copied to the clipboard

CopyComponentData is then called on each node which has been copied to allow component data to be copied to the clipboard.

In the operations End method: If the operation has not failed then EndComponentCopy is called on each doc component do give them a chance to commit changes. If the operation has failed then AbortComponentCopy is called instead.

Returns:
Errors: -
See also:
NodeRenderableInk::MakeAttributeComplete

Definition at line 1830 of file undoop.cpp.

01831 {
01832     BOOL CopiedOK;
01833     BOOL ok;
01834 
01835     InternalClipboard* pInternalClip = InternalClipboard::Instance();
01836 
01837     // After the operation ends we will need to inform all DocComponents in the clipboard
01838     // of the outcome.
01839     InformDocComponentsOfOperationsOutcome(pInternalClip); 
01840 
01841 
01842     // Inform all DocComponents in the clipboard that a copy is about to take place
01843     CALL_WITH_FAIL(pInternalClip->StartComponentCopy(), this, ok)
01844     if (!ok)
01845     {
01846         // Start Component copy has failed so abort operation
01847         // Note that AbortComponentCopy will get called in the ops end method
01848         return FALSE;
01849     } 
01850 
01851     // Try to copy the selection to the clipboard
01852     CALL_WITH_FAIL(InternalClipboard::CopyObjects(NodeRange, this), this, CopiedOK)
01853 
01854     if (!CopiedOK)
01855     {
01856         return FALSE; 
01857     }
01858 
01859     // Now try and copy accross the component data
01860 
01861     CALL_WITH_FAIL(InternalClipboard::CopyComponentData(pOurDoc), this, CopiedOK)
01862 
01863     if (!CopiedOK)
01864     {
01865         return FALSE; 
01866     }
01867 
01868 
01869     // Create action, this action will do nothing for undo but it's twin redo action will
01870     // copy the selection to the clipboard.
01871     CopyObjectsToClipboardAction* UndoCopyObjectsToClipboardAction;                          
01872 
01873     if ( CopyObjectsToClipboardAction::Init(this, 
01874                                        &UndoActions, 
01875                                        NodeRange,  
01876                                       ( Action**)(&UndoCopyObjectsToClipboardAction)) == AC_FAIL)  
01877     {
01878         return FALSE;  // Failed to create action 
01879     } 
01880     return TRUE; // Success
01881 }

BOOL UndoableOperation::DoDeletePathSection NodePath ThisPath,
INT32  Index,
INT32  NumElements,
BOOL  RedrawPath = TRUE
 

This 'Do' function changes the selected state of a particular element in a path it creates all the necessary undo information so that the selection can be undone.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/94
Parameters:
ThisPath points at the NodePath whose state we want to change [INPUTS] Index is the element we want to change NumElements is the number of elements to be deleted RedrawPath - TRUE if the path ares should be redrawn, FALSE if the caller will do it
- [OUTPUTS]
Returns:
TRUE if succeeded, FALSE otherwise

Errors: -

See also:
-

Definition at line 2023 of file undoop.cpp.

02024 {
02025 #ifndef STANDALONE
02026 
02027     InsertPathElementAction* UnAction = NULL;
02028     ActionCode Act;
02029     Act = InsertPathElementAction::Init(this, &UndoActions, NumElements, Index,
02030                                             (Action**)(&UnAction));
02031     if (Act == AC_FAIL)
02032         return FALSE;
02033 
02034     Document* pDocument = GetWorkingDoc();
02035     ERROR2IF(pDocument == NULL, FALSE, "There was no Document when deleteing path elements");
02036     Spread* pSpread = ThisPath->FindParentSpread();
02037     ERROR2IF(pSpread == NULL, FALSE, "Path had no parent spread");
02038 
02039     // Force a re-draw of the place where the path used to be
02040     if (RedrawPath)
02041     {
02042         DocRect Invalid = ThisPath->GetUnionBlobBoundingRect();
02043         // Mark the region as requiring object to recache any cached
02044         // data they may be holding because the Op may have changed it
02045         pDocument->ForceRedraw(pSpread, Invalid, FALSE, ThisPath);
02046     }
02047 
02048     if ((Act != AC_NORECORD) && (UnAction != NULL))
02049     {
02050         // I have to claim some memory to store the elements I'm deleting...
02051         PathVerb* ChangedVerbs = NULL;
02052         DocCoord* ChangedCoords = NULL;
02053         PathFlags* ChangedFlags = NULL;
02054         ALLOC_WITH_FAIL(ChangedVerbs,(PathVerb*) CCMalloc(NumElements * sizeof(PathVerb)),this);
02055         ALLOC_WITH_FAIL(ChangedCoords,(DocCoord*) CCMalloc(NumElements * sizeof(DocCoord)),this);
02056         ALLOC_WITH_FAIL(ChangedFlags,(PathFlags*) CCMalloc(NumElements * sizeof(PathFlags)),this);
02057 
02058         if (!ChangedVerbs || !ChangedCoords || !ChangedFlags)
02059         {
02060             if (ChangedVerbs) CCFree(ChangedVerbs);
02061             if (ChangedCoords) CCFree(ChangedCoords);
02062             if (ChangedFlags) CCFree(ChangedFlags);
02063             return FALSE;
02064         }
02065 
02066         // Get pointers to all the arrays of the path
02067         PathVerb* Verbs = NULL;
02068         DocCoord* Coords = NULL;
02069         PathFlags* Flags = NULL;
02070         ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags);
02071 
02072         // Now copy the data from the path into the arrays
02073         for (INT32 i=0;i<NumElements;i++)
02074         {
02075             ChangedVerbs[i] = Verbs[Index+i];
02076             ChangedCoords[i] = Coords[Index+i];
02077             ChangedFlags[i] = Flags[Index+i];
02078         }
02079 
02080         // Now pass these arrays to the Insert action
02081         UnAction->RecordPath(ChangedVerbs, ChangedFlags, ChangedCoords, ThisPath);
02082     }
02083 
02084     // Now we've recorded the data we're about to delete, let's delete it
02085     ThisPath->InkPath.DeleteSection(Index, NumElements);
02086 
02087     if (RedrawPath)
02088     {
02089         DocRect Invalid = ThisPath->GetUnionBlobBoundingRect();
02090         // Accumulate this invalid region in a pending list until the Op
02091         // finishes
02092         // Mark the region as requiring object to recache any cached
02093         // data they may be holding because the Op may have changed it
02094         pDocument->ForceRedraw(pSpread, Invalid, FALSE, ThisPath);
02095     }
02096 
02097 #endif
02098     return TRUE;
02099 }

BOOL UndoableOperation::DoDeselectNode NodeRenderableInk NodeToDeselect,
Spread Parent = NULL
 

The function de-selects NodeToDeselect. It also generates an action which will select the node when executed.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/10/93
Parameters:
NodeToDeselect,: The node that is to be de-selected [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful FALSE if the operation should be aborted (TIDYUP THEN CALL End()!)

Errors: -

See also:
UndoableOperation::DoDeselectNode

Definition at line 1733 of file undoop.cpp.

01734 {   
01735     SelectDeselectAction* UndoSelectDeselectAction; 
01736     // Create an action to deselect the NodeToSelect when we undo. 
01737     if ( SelectDeselectAction::Init(this, 
01738                                     &UndoActions, 
01739                                     NodeToDeselect,
01740                                     Parent,
01741                                     (Action**)(&UndoSelectDeselectAction))
01742                                     != AC_FAIL)  
01743     {                   
01744         // We shall be able to select the object if we fail so deselect it. 
01745         NodeToDeselect->DeSelect(FALSE);  
01746         return (TRUE);      
01747     }               
01748     else
01749         return (FALSE); 
01750 } 

BOOL UndoableOperation::DoFactorOutAfterAttrChange ObjectSet pLocalisedCompounds,
CCRuntimeClass pAffectedAttrType
 

This Do function is designed to be called after pAffectedAttrType has been localised on all compound nodes in the pLocalisedCompounds set.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/5/95
Parameters:
pLocalisedCompounds,: A set of compound nodes which have localised their [INPUTS] pAffectedAttrType attributes.
pAffectedAttrType: The type of the attribute that have just been applied to the range.

Parameters:
- [OUTPUTS]
Returns:
TRUE if successful, FALSE if we run out of memory. Tidyup then call End()
The function globally factors out the attribute which has type pAffectedAttrType

Before calling the function you should have localised the attribute by calling DoLocaliseForAttrChange.

See also:
AttrTypeSet

NodeAttribute::GetAttributeType

UndoableOperation::DoLocaliseForAttrChange

Definition at line 3316 of file undoop.cpp.

03318 {
03319     ERROR3IF(!pLocalisedCompounds, "DoFactorOutAfterAttrChange called with a NULL compound set");  
03320     ERROR3IF(!pAffectedAttrType, "DoFactorOutAfterAttrChange called with a NULL attr type"); 
03321 
03322 
03323     // Scan the range
03324     ObjectItem* pObjItem = (ObjectItem*)(pLocalisedCompounds->GetHead());
03325     NodeRenderableInk* pCurrent;
03326 
03327     // We need an attribute type set
03328     AttrTypeSet Set; 
03329 
03330     // Add the attributes type to the set
03331     if (!(Set.AddToSet(pAffectedAttrType)))
03332     {
03333         return FALSE; 
03334     }
03335 
03336     while (pObjItem)
03337     {
03338         pCurrent = pObjItem->pObject;
03339         ERROR3IF(!(pCurrent->IsCompound()), "Set should only contain compound objects");
03340         if (pCurrent->IsCompound())
03341         {   
03342             if (!DoFactorOutCommonChildAttributes((NodeRenderableInk*)pCurrent, 
03343                                                      TRUE,     // Global
03344                                                      &Set))
03345             {
03346                 Set.DeleteAll();
03347                 return FALSE; 
03348             }
03349         }
03350         pObjItem = (ObjectItem*)pLocalisedCompounds->GetNext(pObjItem);
03351     }
03352 
03353     Set.DeleteAll(); 
03354     return TRUE; 
03355 }

BOOL UndoableOperation::DoFactorOutAfterAttrChange ObjectSet pLocalisedCompounds,
AttrTypeSet pAffectedAttrTypes
 

This Do function is designed to be called after all attributes in the pAffectedAttrTypes set have been localised on all compound nodes in the pLocalisedCompounds set.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/5/95
Parameters:
pLocalisedCompounds,: A set of compound nodes which have localised their [INPUTS] pAffectedAttrTypes attributes
pAffectedAttrTypes: The types of the attributes that have been applied to the range.

Parameters:
- [OUTPUTS]
Returns:
TRUE if successful, FALSE if we run out of memory. Tidyup then call End()
The function globally factors out the attributes which have a type which is in the pAffectedAttrTypes set.

Before calling the function you should have localised the attribute by calling DoLocaliseForAttrChange.

See also:
AttrTypeSet

NodeAttribute::GetAttributeType

UndoableOperation::DoLocaliseForAttrChange

Definition at line 3248 of file undoop.cpp.

03250 {
03251     ERROR3IF(!pLocalisedCompounds, "DoFactorOutAfterAttrChange called with a NULL compound set");  
03252     //ERROR3IF(!pAffectedAttrTypes, "DoFactorOutAfterAttrChange called with a NULL attr type set"); 
03253 
03254     // Scan the range
03255     ObjectItem* pObjItem = (ObjectItem*)(pLocalisedCompounds->GetHead());
03256     NodeRenderableInk* pCurrent;
03257 
03258     while (pObjItem)
03259     {
03260         pCurrent = pObjItem->pObject;
03261         ERROR3IF(!(pCurrent->IsCompound()), "Set should only contain compound objects");
03262         if (pCurrent->IsCompound())
03263         {   
03264             if (!DoFactorOutCommonChildAttributes((NodeRenderableInk*)pCurrent, 
03265                                                      TRUE,     // Global
03266                                                      pAffectedAttrTypes))
03267             {
03268                 return FALSE; 
03269             }
03270         }
03271         pObjItem = (ObjectItem*)pLocalisedCompounds->GetNext(pObjItem);
03272     }
03273 
03274     return TRUE; 
03275 
03276 }

BOOL UndoableOperation::DoFactorOutAfterAttrChange Range pRange,
CCRuntimeClass pAffectedAttrType
 

This Do function must be called on the range after an attribute being applied to it. If you have applied multiple attributes to the range then it is more efficient to call the other version of this function which takes a set of attribute types.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/5/95
Parameters:
pRange,: The objects that need their attributes factoring out [INPUTS]
pAffectedAttrType: The type of the attribute that have just been applied to the range.

Parameters:
- [OUTPUTS]
Returns:
TRUE if successful, FALSE if we run out of memory. Tidyup then call End()
The function globally factors out the attribute which has type pAffectedAttrType

Before calling the function you should have localised the attribute by calling DoLocaliseForAttrChange.

If an object in the range Discards its attribute children then its attributes are ignored when factoring (eg. the caret)

Note: When applying an attribute, we are not always going to apply it to the object itself, sometimes we need to apply it to the object's parent. Eg. when we apply a line based attribute to a text character the attributes will get applied to the parent TextLine.

In this situation we do not factor out the objects attributes, but its parents attributes instead.

Note: When applying attributes, we are not always going to apply the attributes to the object itself, sometimes we need to apply them to the object's parent. Eg. when we apply a line based attribute to a text character the attributes will get applied to the parent TextLine.

In this situation we do not factor out the object's attributes, but its parents attributes instead.

See also:
AttrTypeSet

NodeAttribute::GetAttributeType

UndoableOperation::DoLocaliseForAttrChange

Range::DoLocaliseForAttrChange

Range::DoFactorOutAfterAttrChange

Definition at line 2740 of file undoop.cpp.

02742 {
02743     ERROR3IF(pRange->Count() == 0, "Range::DoFactorOutAfterAttrChange called on an empty range");  
02744     // Scan the range
02745 
02746     // Iterate over the top of any liveeffects applied to the selection
02747     // Its important that this iteration matches those used in DoApplyAttribute functions
02748     // so that attributes are put in the places where mutation will find them
02749     ListRange* pLevel = EffectsStack::GetNewLevelRange(pRange, FALSE);  // We DO own this range
02750     Node* pCurrent = pLevel->FindFirst();
02751 
02752     // There is no need to factor out the attributes on a compound more than once, so we 
02753     // remember the last compound node which has had its attributes factored out 
02754     NodeRenderableInk* pFactoredOutCompound = NULL;
02755 
02756     Node* pParent;
02757     Node* pObject;                  
02758     while (pCurrent)
02759     {
02760         pObject = pCurrent;
02761         // Get the object that the attribute has been applied to
02762         ERROR3IF(!pAffectedAttrType, "AttrType is NULL");  
02763         pObject = ((NodeRenderableInk*)pObject)->GetObjectToApplyTo(pAffectedAttrType);
02764 
02765         // If the object can discard its attribute children then we should not try to factor
02766         // out its attributes
02767 
02768         {
02769 
02770             // We only need to factor out attributes on nodes which have a compound parent
02771             pParent = pObject->FindParent(); 
02772             ERROR3IF(pParent == NULL, "Range::DoFactorOutAfterAttrChange, node found without a parent"); 
02773         
02774             // Only factor out attribs if  the parent has not already had its attribs factored out
02775             if ((pParent->IsCompound()) && (pParent != pFactoredOutCompound))
02776             {
02777                 // Attempt to localise the compound
02778                 if (!DoFactorOutAfterAttrChange((NodeRenderableInk*)pObject, pAffectedAttrType))
02779                 {
02780                     delete pLevel;
02781                     return FALSE;
02782                 }
02783                  
02784                 pFactoredOutCompound = (NodeRenderableInk*)pParent;  // Remember that it's been localised
02785             }
02786         }
02787         pCurrent = pLevel->FindNext(pCurrent);
02788     }
02789 
02790     delete pLevel;
02791     return TRUE;
02792 }

BOOL UndoableOperation::DoFactorOutAfterAttrChange Range pRange,
AttrTypeSet pAffectedAttrTypes
 

This Do function must be called on the range after attributes have being applied to it.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/5/95
Parameters:
pRange,: The objects that need their attributes factoring out [INPUTS]
pAffectedAttrTypes: The types of the attributes that have just been applied to the range.

Parameters:
- [OUTPUTS]
Returns:
TRUE if successful, FALSE if we run out of memory. Tidyup then call End()
The function globally factors out those attributes which have a type in the pAffectedAttrTypes set.

Before calling the function you should have localised attributes by calling DoLocaliseForAttrChange.

If an object in the range Discards its attribute children then its attributes are ignored when factoring (eg. the caret)

Note: When applying attributes, we are not always going to apply the attributes to the object itself, sometimes we need to apply them to the object's parent. Eg. when we apply a line based attribute to a text character the attributes will get applied to the parent TextLine.

In this situation we do not factor out the objects attributes, but its parents attributes instead.

Warning ~~~~~~~

All attribute types in the AttrTypeSet must have been localised (and so need factoring out) on the same compound node. This means for example that the AttrType set cannot contain a Bold and a Line space attribute. If we need to do this in future then the routine will need to be changed.

See also:
AttrTypeSet

NodeAttribute::GetAttributeType

UndoableOperation::DoFactorOutAfterAttrChange

Range::DoLocaliseForAttrChange

Definition at line 2625 of file undoop.cpp.

02627 {
02628     ERROR3IF(pRange->Count() == 0, "Range::DoFactorOutAfterAttrChange called on an empty range");  
02629 
02630     // Iterate over the top of any liveeffects applied to the selection
02631     // Its important that this iteration matches those used in DoApplyAttribute functions
02632     // so that attributes are put in the places where mutation will find them
02633     ListRange* pLevel = EffectsStack::GetNewLevelRange(pRange, FALSE);  // We DO own this range
02634     Node* pCurrent = pLevel->FindFirst();
02635 
02636     // There is no need to factor out the attributes on a compound more than once, so we 
02637     // remember the last compound node which has had its attributes factored out 
02638     NodeRenderableInk* pFactoredOutCompound = NULL;
02639 
02640     Node* pParent;
02641     Node* pObject;
02642                         
02643     while (pCurrent)
02644     {
02645         // If the object can discard its attribute children then we should not try to factor
02646         // out its attributes
02647         CCRuntimeClass* AttrType;
02648         
02649         pObject = pCurrent;
02650         if (pAffectedAttrTypes && (!pAffectedAttrTypes->IsEmpty()))
02651         {
02652             AttrType = ((AttrTypeItem*)pAffectedAttrTypes->GetHead())->AttributeType;
02653             ERROR3IF(!AttrType, "AttrType set contains NULL attribute type");  
02654             pObject = ((NodeRenderableInk*)pObject)->GetObjectToApplyTo(AttrType);
02655         }
02656 
02657         // DY added test for NULL, which can occur with bevels
02658         if ((pObject != NULL))
02659         {
02660             // We only need to factor out attributes on nodes which have a compound parent
02661             pParent = pObject->FindParent(); 
02662             ERROR3IF(pParent == NULL, "Range::DoFactorOutAfterAttrChange, node found without a parent"); 
02663         
02664             // Only factor out attribs if  the parent has not already had its attribs factored out
02665             if ((pParent->IsCompound()) && (pParent != pFactoredOutCompound))
02666             {
02667                 // Attempt to localise the compound
02668                 if (!DoFactorOutAfterAttrChange((NodeRenderableInk*)pObject, pAffectedAttrTypes))
02669                 {
02670                     delete pLevel;
02671                     return FALSE;
02672                 }
02673                  
02674                 pFactoredOutCompound = (NodeRenderableInk*)pParent;  // Remember that it's been localised
02675             }
02676         }
02677         
02678         pCurrent = pLevel->FindNext(pCurrent);
02679     }
02680 
02681     delete pLevel;
02682     return TRUE;
02683 }

BOOL UndoableOperation::DoFactorOutAfterAttrChange NodeRenderableInk Object,
CCRuntimeClass pAffectedAttrType
 

This Do function must be called on an object after an attribute being applied to it. If you have applied multiple attributes to the Object then it is more efficient to call the other version of this function which takes a set of attribute types.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/5/95
Parameters:
Object,: The object that you have just applied attributes to [INPUTS]
pAffectedAttrType: The types of the attribute that have just been applied to the object.

Parameters:
- [OUTPUTS]
Returns:
TRUE if successful, FALSE if we run out of memory. Tidyup then call End()
The function globally factors out the attribute with type pAffectedAttrType

If the function is called on a object which does not have a compound parent then there will be no attributes to factor out so the function will simply return TRUE without having done anything.

Before calling the function you should have localised attributes by calling DoLocaliseForAttrChange.

If the object discards its attribute children then the routine does nothing (eg. the caret)

Note: When applying attributes, we are not always going to apply the attributes to the object itself, sometimes we need to apply them to the object's parent. Eg. when we apply a line based attribute to a text character the attributes will get applied to the parent TextLine.

In this situation we do not factor out the objects attributes, but its parents attributes instead.

See also:
AttrTypeSet

NodeAttribute::GetAttributeType

UndoableOperation::DoLocaliseForAttrChange

Range::DoLocaliseForAttrChange

Range::DoFactorOutAfterAttrChange

Definition at line 3170 of file undoop.cpp.

03172 {
03173     BOOL ok = TRUE;
03174 
03175     // Get object attr was applied to
03176     ERROR3IF(!pAffectedAttrType, "AttrType is NULL");  
03177     Object = Object->GetObjectToApplyTo(pAffectedAttrType);
03178 
03179     {   
03180 
03181         Node* pParent;
03182         pParent = Object->FindParent(); 
03183         ERROR3IF(!pParent, "UndoableOperation::DoFactorOutAfterAttrChange called on an object which has no parent"); 
03184 
03185         if (pParent->IsCompound())
03186         {
03187     
03188             // We need an attribute type set
03189             AttrTypeSet Set; 
03190 
03191             // Add the attributes type to the set
03192             if (!(Set.AddToSet(pAffectedAttrType)))
03193             {
03194                 ok = FALSE; 
03195             }
03196 
03197             if (ok)
03198             {
03199 
03200                 return (DoFactorOutCommonChildAttributes((NodeRenderableInk*)pParent, 
03201                                                          TRUE,     // Global
03202                                                          &Set));
03203             }
03204     
03205             Set.DeleteAll(); 
03206         }
03207     }
03208     return ok; 
03209 }

BOOL UndoableOperation::DoFactorOutAfterAttrChange NodeRenderableInk Object,
AttrTypeSet pAffectedAttrTypes
 

This Do function must be called on an object after attributes have being applied to it.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/5/95
Parameters:
Object,: The object that you have just applied attributes to [INPUTS]
pAffectedAttrTypes: The types of the attributes that have just been applied to the object.

Parameters:
- [OUTPUTS]
Returns:
TRUE if successful, FALSE if we run out of memory. Tidyup then call End()
The function globally factors out those attributes which have a type in the pAffectedAttrTypes set.

If the function is called on a object which does not have a compound parent then there will be no attributes to factor out so the function will simply return TRUE without having done anything.

Before calling the function you should have localised attributes by calling DoLocaliseForAttrChange.

If the object discards its attribute children then the routine does nothing (eg. the caret)

Note: When applying attributes, we are not always going to apply the attributes to the object itself, sometimes we need to apply them to the object's parent. Eg. when we apply a line based attribute to a text character the attributes will get applied to the parent TextLine.

In this situation we do not factor out the objects attributes, but its parents attributes instead.

Warning ~~~~~~~

All attribute types in the AttrTypeSet must have been localised (and so need factoring out) on the same compound node. This means for example that the AttrType set cannot contain a Bold and a Line space attribute. If we need to do this in future then the routine will need to be changed.

See also:
AttrTypeSet

NodeAttribute::GetAttributeType

UndoableOperation::DoLocaliseForAttrChange

Range::DoLocaliseForAttrChange

Range::DoFactorOutAfterAttrChange

Definition at line 3091 of file undoop.cpp.

03093 {
03094     CCRuntimeClass* AttrType;
03095 
03096     // Get object which attrib was applied to
03097     if (pAffectedAttrTypes && (!pAffectedAttrTypes->IsEmpty()))
03098     {
03099         AttrType = ((AttrTypeItem*)pAffectedAttrTypes->GetHead())->AttributeType;
03100         ERROR3IF(!AttrType, "AttrType set contains NULL attribute type");  
03101         Object = Object->GetObjectToApplyTo(AttrType);
03102     }
03103 
03104     {   
03105         Node* pParent;
03106         pParent = Object->FindParent(); 
03107         ERROR3IF(!pParent, "UndoableOperation::DoFactorOutAfterAttrChange called on an object which has no parent"); 
03108 
03109         if (pParent->IsCompound())
03110         {
03111             return (DoFactorOutCommonChildAttributes((NodeRenderableInk*)pParent, 
03112                                                      TRUE,     // Global
03113                                                      pAffectedAttrTypes));
03114         }
03115     }
03116     return TRUE;
03117 }

BOOL UndoableOperation::DoFactorOutCommonAttributes NodeRenderableInk pRootNode,
BOOL