OpChangeSetProperty Class Reference

#include <ngsetop.h>

Inheritance diagram for OpChangeSetProperty:

UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Private Member Functions

 CC_DECLARE_DYNCREATE (OpChangeSetProperty)
virtual void DoWithParam (OpDescriptor *, OpParam *pParam)
 Runs the OPTOKEN_CHANGE_SET_PROPERTY operation.

Detailed Description

Definition at line 386 of file ngsetop.h.


Member Function Documentation

OpChangeSetProperty::CC_DECLARE_DYNCREATE OpChangeSetProperty   )  [private]
 

void OpChangeSetProperty::DoWithParam OpDescriptor ,
OpParam pParam
[private, virtual]
 

Runs the OPTOKEN_CHANGE_SET_PROPERTY operation.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/8/99
Parameters:
pParam->Param1 --- the name of the set the property appertains to [INPUTS] pParam->Param2 --- the SGNameProp* to set in the tree
See also:
SGNameProp::Change

Reimplemented from Operation.

Definition at line 894 of file ngsetop.cpp.

00895 {
00896     // Extract the parameters.
00897     ERROR3IF(pParam == 0 || pParam->Param1 == 0, "OpChangeSetProperty::DoWithParam: no input");
00898     const StringBase& strName = *(((StringBase**) (void *) pParam->Param1)[0]);
00899     StringBase* pstrNewName = ((StringBase**) (void *) pParam->Param1)[1];
00900     SGNameProp* pProp = (SGNameProp*) (void *) pParam->Param2;
00901 
00902     // Find the equivalent old property, if any, and hide it.
00903     NodeSetSentinel* pSentry = GetWorkingDoc()->GetSetSentinel();
00904     NodeSetProperty* pOldSetNode = pSentry->FindPropertyNode(strName);
00905     ERROR3IF(pOldSetNode == 0, "OpChangeSetProperty::DoWithParam: can't find NodeSetProperty");
00906     if (pOldSetNode != 0 && !DoHideNode(pOldSetNode, TRUE, 0, TRUE))
00907     {
00908         FailAndExecute();
00909         End();
00910         return;
00911     }
00912 
00913     // Try to create a duplicate property holder node with the given (re)name.
00914     NodeSetProperty* pNewSetNode;
00915     ALLOC_WITH_FAIL(pNewSetNode,
00916                     (new NodeSetProperty(pstrNewName != 0 ? *pstrNewName : strName)),
00917                     this);
00918     if (pNewSetNode == 0)
00919     {
00920         FailAndExecute();
00921         End();
00922         return;
00923     }
00924 
00925     // Try to copy the old properties into it.
00926     NodeSetProperty* fOk=NULL; // we use this as a boolean because ALLOC_WITH_FAIL expects an allocation routine and thus pointers
00927     // so we return a dummy pointer (pNewSetNode) if we succeed as a flag
00928     ALLOC_WITH_FAIL(fOk, ((pNewSetNode->CopyProperties(pOldSetNode))?pNewSetNode:NULL), this);
00929     if (!fOk)
00930     {
00931         FailAndExecute();
00932         End();
00933         return;
00934     }
00935 
00936     // Set the new property within the duplicate.
00937     SGNameProp* pOldProp = pNewSetNode->SetProperty(pProp);
00938     if (pOldProp != 0) delete pOldProp;
00939 
00940     // Mark the new property as no longer "virgin".
00941     pProp->SetDirty();
00942 
00943     // Undoably insert the duplicate into the tree.
00944     ERROR3IF(pSentry->FindPropertyNode(pNewSetNode->GetName()) != 0,
00945                 "OpChangeSetProperty::DoWithParam: property node already exists");
00946     pNewSetNode->AttachNode(pSentry, LASTCHILD);
00947     HideNodeAction* pHideAct;
00948     if (AC_FAIL == HideNodeAction::Init(this, GetUndoActions(), pNewSetNode,
00949                                         TRUE, (Action**) &pHideAct))
00950     {
00951         delete pNewSetNode;
00952         FailAndExecute();
00953         End();
00954         return;
00955     }
00956 
00957     // Finally, if requested to then rename the strName set to be *pstrNewName.
00958     // Changing the type of an export property, for example, can mean renaming.
00959     if (pstrNewName != 0)
00960     {
00961         RenameSetInstance(strName, *pstrNewName, this, Document::GetSelectedSpread());
00962     }
00963 
00964     End();
00965 }


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