OpRemoveAttributeFromSelection Class Reference

Delete a Node from the tree. More...

#include <opnode.h>

Inheritance diagram for OpRemoveAttributeFromSelection:

SelOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

virtual void DoWithParam (OpDescriptor *pOp, OpParam *pParam)
 Performs the OpRemoveAttributeFromSelection operation. It removes all attributes with the given AttributeIdentifier from the selected objects.
virtual void GetOpName (String_256 *pOpName)
 The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies.

Static Public Member Functions

static BOOL Declare ()
 Declares the OpDescriptor for OpRemoveAttributeFromSelection. Should be called on start up.
static OpState GetState (String_256 *Description, OpDescriptor *)
 For finding OpRemoveAttributeFromSelection state.

Protected Member Functions

NodeAttributeFindAttributeOfClassID (Node *const pNode, AttributeIdentifier AttrID)
 Support function to find an attribute of the given class.
BOOL DoRemove (NodeAttribute *const pOldAttr)
 Support function to remove the attribute.

Detailed Description

Delete a Node from the tree.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/11/96

Definition at line 144 of file opnode.h.


Member Function Documentation

BOOL OpRemoveAttributeFromSelection::Declare  )  [static]
 

Declares the OpDescriptor for OpRemoveAttributeFromSelection. Should be called on start up.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Will - I wish I hadn't)
Date:
09/07/97
Returns:
TRUE if the operation could be successfully initialised FALSE if no more memory could be allocated

Definition at line 139 of file opnode.cpp.

00140 {
00141     
00142     // Register the opdescriptors for the OpRemoveAttributeFromSelection operation
00143 
00144     return (RegisterOpDescriptor(   0,
00145                                     _R(IDS_DELETEATTROP),
00146                                     CC_RUNTIME_CLASS(OpRemoveAttributeFromSelection),
00147                                     OPTOKEN_DELETEATTR,
00148                                     OpRemoveAttributeFromSelection::GetState,
00149                                     0,  /* help ID */
00150                                     0,
00151                                     0,
00152                                     0,
00153                                     SYSTEMBAR_ILLEGAL,          // For now !
00154                                     FALSE,                      // Receive messages
00155                                     FALSE,
00156                                     FALSE,
00157                                     0,
00158                                     0 // (GREY_WHEN_NO_CURRENT_DOC | GREY_WHEN_NO_SELECTION)
00159            )); 
00160 }               

BOOL OpRemoveAttributeFromSelection::DoRemove NodeAttribute *const   pOldAttr  )  [protected]
 

Support function to remove the attribute.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
08//07/97
Parameters:
pOldAttr : The attribute to go [INPUTS]
Returns:
TRUE if successful FALSE if the operation should be aborted (TIDYUP THEN CALL End()!)

Definition at line 335 of file opnode.cpp.

00336 {
00337     ENSURE_NOT_NULL(pOldAttr);      // well use a reference then!
00338 
00339     BOOL Ok = TRUE;
00340 
00341     Node* CurrentNode = pOldAttr->FindParent();
00342     ERROR3IF(CurrentNode == NULL, "Can't find parent node in Replace Attr");
00343 
00344     // Now we have done with the old attribute, so lets hide it, so
00345     // the changes can be undone
00346     Ok = DoHideNode(pOldAttr, 
00347                     TRUE,       // Include the subtree size (not that there is one)
00348                     NULL,       // the hidden node
00349                     TRUE);      // make sure the attribute's HidingNode function is called
00350 
00351     return Ok;
00352 }

void OpRemoveAttributeFromSelection::DoWithParam OpDescriptor pOpDesc,
OpParam pOpParam
[virtual]
 

Performs the OpRemoveAttributeFromSelection operation. It removes all attributes with the given AttributeIdentifier from the selected objects.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Will - I wish I hadn't)
Date:
09/07/97
Parameters:
pOpDesc,: See base class [INPUTS] pOpParam: A RemoveAttributeParam containing the AttributeIdentifier of the attributes to remove.

Reimplemented from Operation.

Definition at line 222 of file opnode.cpp.

00223 {    
00224     VOID_ENSURE_NOT_NULL(pOpParam);
00225     ENSURE_KIND(pOpParam, RemoveAttributeParam);
00226 
00227     const RemoveAttributeParam* const pRemoveParam = (RemoveAttributeParam*)pOpParam;
00228 
00229     // Objects used to mark changed nodes, so that parents will update after attr replacement
00230     ObjChangeFlags cFlags;
00231     cFlags.Attribute    = TRUE;
00232     ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
00233 
00234     BOOL Ok = TRUE;
00235 
00236     Ok = DoStartSelOp(FALSE, FALSE, FALSE, FALSE);  // FALSE's == don't render the blobs
00237 
00238     // Obtain the current selection
00239     SelRange* const pSelRange = GetApplication()->FindSelection();
00240     Ok = (pSelRange != NULL);
00241 
00242     if (Ok)
00243     {
00244 
00245         if (Ok)
00246         {
00247             Range CurrentSelection(*pSelRange);
00248             // Mark nodes that will allow this to happen, 
00249             // and error if no nodes will let it happen
00250     
00251             Ok = CurrentSelection.AllowOp(&ObjChange);
00252         }
00253     }
00254 
00255     if (Ok)
00256     {
00257         AttributeIdentifier AttrIDToDelete = pRemoveParam->GetAttrIDToDelete();
00258 
00259         Node* pNode = pSelRange->FindFirst();
00260         while (pNode != NULL && Ok)
00261         {
00262             NodeAttribute* const pAttr = FindAttributeOfClassID(pNode, AttrIDToDelete);
00263             if (pAttr != NULL)
00264             {
00265                 Ok = DoRemove(pAttr);
00266             }
00267 
00268             pNode = pSelRange->FindNext(pNode);
00269         }
00270     }
00271 
00272     if (Ok)
00273     {
00274         // Update all parents of this
00275         ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
00276         Ok = UpdateChangedNodes(&ObjChange);
00277     }
00278 
00279     if (!Ok)
00280     {
00281         FailAndExecute();
00282     }
00283 
00284     End(); // End of operation
00285 } 

NodeAttribute * OpRemoveAttributeFromSelection::FindAttributeOfClassID Node *const   pNode,
AttributeIdentifier  AttrID
[protected]
 

Support function to find an attribute of the given class.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
08//07/97
Parameters:
pNode : The attribute to go [INPUTS] AttrID: The AttributeIdentifier of the attribute to find
Returns:
An attribute of the given class or NULL if none found

Definition at line 304 of file opnode.cpp.

00305 {
00306     NodeAttribute* pAttr = NodeAttribute::FindFirstAppliedAttr(pNode);
00307 
00308     while (pAttr)
00309     {
00310         if (pAttr->GetAttributeClassID() == AttrID)
00311             return pAttr;
00312 
00313         pAttr = NodeAttribute::FindPrevAppliedAttr(pAttr);
00314     }
00315 
00316     return NULL;
00317 }

void OpRemoveAttributeFromSelection::GetOpName String_256 OpName  )  [virtual]
 

The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Will - I wish I hadn't)
Date:
09/07/97
Parameters:
The undo string for the operation [OUTPUTS]

Reimplemented from Operation.

Definition at line 200 of file opnode.cpp.

00201 { 
00202     *OpName += String_256(_R(IDS_ATTR_CHANGE));
00203 }  

OpState OpRemoveAttributeFromSelection::GetState String_256 Description,
OpDescriptor OpDesc
[static]
 

For finding OpRemoveAttributeFromSelection state.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Will - I wish I hadn't)
Date:
09/07/97
Returns:
The state of the OpRemoveAttributeFromSelection operation
Notes: Always available cos it ain't in no menu

Definition at line 177 of file opnode.cpp.

00178 {
00179     OpState OpSt;
00180 
00181     OpSt.Greyed = ( FALSE );  
00182                                                 
00183     return(OpSt);   
00184 }


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