ngsetop.cpp

Go to the documentation of this file.
00001 // $Id: ngsetop.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 /*
00099     $Header: /Camelot/kernel/ngsetop.cpp 16    19/12/00 9:37 Matt $
00100     Operations to manipulate sets and names of objects.
00101 */
00102 
00103 #include "camtypes.h"
00104 
00105 #include "ngcore.h"
00106 #include "ngdialog.h"
00107 #include "ngitem.h"
00108 #include "ngprop.h"
00109 #include "ngscan.h"
00110 #include "ngsentry.h"
00111 #include "ngsetop.h"
00112 
00113 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "nodeattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 #include "keypress.h"
00116 //#include "nodetext.h"     // text tool bodges :(
00117 
00118 //#include "cxfrech.h"      // Wix ObjectName attributes - in camtypes.h [AUTOMATICALLY REMOVED]
00119 //#include "attrval.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00120 #include "userattr.h"
00121 #include "tmpltatr.h"
00122 
00123 #include "impexpop.h"
00124 #include "bitfilt.h"
00125 
00126 #include "ophist.h"
00127 
00128 //#include "mario.h"
00129 //#include "justin3.h"
00130 
00131 #ifdef _DEBUG
00132 #undef THIS_FILE
00133 static char BASED_CODE THIS_FILE[] = __FILE__;
00134 #endif
00135 
00136 DECLARE_SOURCE("$Revision: 1282 $");
00137 
00138 CC_IMPLEMENT_DYNCREATE(OpSelectSet,             Operation);
00139 CC_IMPLEMENT_DYNCREATE(OpSelectUnionSets,       Operation);
00140 CC_IMPLEMENT_DYNCREATE(OpSelectIntersectSets,   Operation);
00141 CC_IMPLEMENT_DYNCREATE(OpApplyNamesToSel,       SelOperation);
00142 CC_IMPLEMENT_DYNCREATE(OpApplyNamesToOne,       UndoableOperation);
00143 CC_IMPLEMENT_DYNCREATE(OpApplyNameToNone,       UndoableOperation);
00144 CC_IMPLEMENT_DYNCREATE(OpDeleteNamesFromAll,    UndoableOperation);
00145 CC_IMPLEMENT_DYNCREATE(OpRenameAll,             UndoableOperation);
00146 CC_IMPLEMENT_DYNCREATE(OpRemoveNamesFromSel,    SelOperation);
00147 CC_IMPLEMENT_DYNCREATE(OpRedefineNamesAsSel,    SelOperation);
00148 CC_IMPLEMENT_DYNCREATE(OpExportSets,            Operation);
00149 CC_IMPLEMENT_DYNCREATE(OpChangeSetProperty,     UndoableOperation);
00150 CC_IMPLEMENT_DYNCREATE(OpChangeBarProperty,     UndoableOperation);
00151 CC_IMPLEMENT_DYNCREATE(OpChangeBarExtends,      UndoableOperation);
00152 
00153 // This definition must appear after the above CC_IMPLEMENT_ definitions.
00154 #define new CAM_DEBUG_NEW
00155 
00156 
00157 /********************************************************************************************
00158 >   virtual void OpSelectSet::DoWithParam(OpDescriptor*, OpParam* pParam)
00159 
00160     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00161     Created:    09/7/99
00162     Inputs:     pParam->Param1  ---  the (SGNameItem*) set to change the selection of
00163                 pParam->Param2  ---  the SelectScan::Change code (TOGGLE, DESELECT,
00164                                      SELECT or SELECT_EXCLUSIVE).
00165     Purpose:    Performs the OPTOKEN_SELECT_SET operation.  
00166     SeeAlso:    SelectScan; Operation
00167 ********************************************************************************************/
00168 
00169 void OpSelectSet::DoWithParam(OpDescriptor*, OpParam* pParam)
00170 {
00171     SelectScan((SGNameItem*)(void *) pParam->Param1, (SelectScan::Change) (INT32) pParam->Param2).Scan();
00172     End();
00173 }
00174 
00175 
00176 
00177 /********************************************************************************************
00178 >   static OpState OpSelectUnionSets::GetState(String_256*, OpDescriptor*)
00179 
00180     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00181     Created:    09/7/99
00182     Purpose:    Returns the UI state of this operation.
00183 ********************************************************************************************/
00184 
00185 OpState OpSelectUnionSets::GetState(String_256*, OpDescriptor*)
00186 {
00187     INT32 nTotal;
00188     NameGallery::Instance()->GetHighlightCount(&nTotal, 0);
00189     return OpState(FALSE, nTotal < 1);
00190 }
00191 
00192 
00193 
00194 /********************************************************************************************
00195 >   virtual void OpSelectUnionSets::Do(OpDescriptor*)
00196 
00197     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00198     Created:    09/7/99
00199     Purpose:    Performs the OPTOKEN_SELECT_UNION_SETS operation.  
00200     SeeAlso:    SelectUnionScan; OpSelectSet; OpSelectIntersectSets; Operation
00201 ********************************************************************************************/
00202 
00203 void OpSelectUnionSets::Do(OpDescriptor*)
00204 {
00205     SelectUnionScan::Change option = SelectUnionScan::SELECT_EXCLUSIVE;
00206     if( KeyPress::IsGalleryCtrlPressed() )
00207         option = SelectUnionScan::DESELECT;
00208     SelectUnionScan( option ).Scan();
00209     End();
00210 }
00211 
00212 
00213 
00214 /********************************************************************************************
00215 >   static OpState OpSelectIntersectSets::GetState(String_256*, OpDescriptor*)
00216 
00217     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00218     Created:    09/7/99
00219     Purpose:    Returns the UI state of this operation.
00220 ********************************************************************************************/
00221 
00222 OpState OpSelectIntersectSets::GetState(String_256*, OpDescriptor*)
00223 {
00224     INT32 nTotal;
00225     NameGallery::Instance()->GetHighlightCount(&nTotal, 0);
00226     return OpState(FALSE, nTotal < 2);
00227 }
00228 
00229 
00230 
00231 /********************************************************************************************
00232 >   virtual void OpSelectIntersectSets::Do(OpDescriptor*)
00233 
00234     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00235     Created:    09/7/99
00236     Purpose:    Performs the OPTOKEN_SELECT_INTERSECT_SETS operation.  
00237     SeeAlso:    SelectIntersectScan; OpSelect; OpSelectUnionSets; Operation
00238 ********************************************************************************************/
00239 
00240 void OpSelectIntersectSets::Do(OpDescriptor*)
00241 {
00242     SelectUnionScan option = SelectUnionScan::SELECT_EXCLUSIVE;
00243     if( KeyPress::IsGalleryCtrlPressed() )
00244         option = SelectUnionScan::DESELECT;
00245     SelectUnionScan( option ).Scan();
00246     End();
00247 }
00248 
00249 
00250 
00251 /********************************************************************************************
00252 >   static OpState OpApplyNamesToSel::GetState(String_256*, OpDescriptor*)
00253 
00254     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00255     Created:    09/7/99
00256     Purpose:    Returns the UI state of OPTOKEN_APPLY_NAMES_TO_SEL,
00257                 OPTOKEN_REMOVE_NAMES_FROM_SEL and OPTOKEN_REDEFINE_NAMES_AS_SEL.
00258 ********************************************************************************************/
00259 
00260 OpState OpApplyNamesToSel::GetState(String_256*, OpDescriptor*)
00261 {
00262     INT32 nTotal, nNames;
00263     NameGallery::Instance()->GetHighlightCount(&nTotal, &nNames);
00264     return OpState(FALSE, GetApplication()->FindSelection()->IsEmpty()
00265                        || nNames < 1 || nTotal > nNames);
00266 }
00267 
00268 
00269 
00270 /********************************************************************************************
00271 >   virtual void OpApplyNamesToSel::Do(OpDescriptor*)
00272 
00273     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00274     Created:    09/7/99
00275     Purpose:    Performs the OPTOKEN_APPLY_NAMES_TO_SEL operation.
00276 ********************************************************************************************/
00277 
00278 void OpApplyNamesToSel::Do(OpDescriptor*)
00279 {
00280     AllowOpScan aosSel(this, &theSelectedObjects),
00281                 aosSentinel(this, &theSetSentinel);
00282 
00283     if (!aosSel.Scan() ||
00284         !aosSentinel.Scan() ||
00285         !DoStartSelOp(TRUE, TRUE) ||
00286         !ApplyScan(this, &theSelectedObjects).Scan() ||
00287         !ApplyScan(this, &theSetSentinel).Scan() ||
00288         !aosSel.Update() ||
00289         !aosSentinel.Update())
00290     {
00291         FailAndExecute();
00292     }
00293 
00294     End();
00295 } 
00296 
00297 
00298 
00299 /********************************************************************************************
00300 >   virtual void OpApplyNamesToSel::DoWithParam(OpDescriptor*, OpParam* pParam)
00301 
00302     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00303     Created:    09/7/99
00304     Inputs:     pParam->Param1      ---     StringBase* to the name to apply to the
00305                                             selected objects
00306     Purpose:    Performs OPTOKEN_APPLY_NAME_TO_SEL for a single parameterised name.
00307     Returns:    TRUE if successful.
00308 ********************************************************************************************/
00309 
00310 void OpApplyNamesToSel::DoWithParam(OpDescriptor*, OpParam* pParam)
00311 {
00312     ERROR3IF(pParam->Param1 == 0, "OpApplyNamesToSel::DoWithParam: null argument");
00313     const StringBase& strName = *((const StringBase*)(void *) pParam->Param1);
00314 
00315     AllowOpScan aosSel(this, &theSelectedObjects),
00316                 aosSentinel(this, &theSetSentinel);
00317 
00318     if (!aosSel.Scan() ||
00319         !aosSentinel.Scan() ||
00320         !DoStartSelOp(TRUE, TRUE) ||
00321         !ApplySingleScan(this, &theSelectedObjects, strName).Scan() ||
00322         !ApplySingleScan(this, &theSetSentinel, strName).Scan() ||
00323         !ApplyPropScan(this, strName).Scan() ||
00324         !aosSel.Update() ||
00325         !aosSentinel.Update())
00326     {
00327         FailAndExecute();
00328     }
00329 
00330     End();
00331 }
00332 
00333 
00334 
00335 /********************************************************************************************
00336 >   static OpState OpApplyNamesToOne::GetState(String_256*, OpDescriptor*)
00337 
00338     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00339     Created:    09/7/99
00340     Purpose:    Returns the UI state of OPTOKEN_APPLY_NAMES_TO_ONE,
00341                 OPTOKEN_DELETE_NAMES_FROM_ALL, and OPTOKEN_RENAME_ALL.
00342 ********************************************************************************************/
00343 
00344 OpState OpApplyNamesToOne::GetState(String_256*, OpDescriptor*)
00345 {
00346     INT32 nTotal, nNames;
00347     NameGallery::Instance()->GetHighlightCount(&nTotal, &nNames);
00348     return OpState(FALSE, nNames < 1 || nTotal > nNames);
00349 }
00350 
00351 
00352 
00353 /********************************************************************************************
00354 >   void OpApplyNamesToOne::DoWithParam(OpDescriptor*, OpParam* pParam)
00355 
00356     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00357     Created:    09/7/99
00358     Inputs:     pParam->Param1  --- pointer to the Node to apply to, cast to a INT32
00359     Purpose:    Performs the OPTOKEN_APPLY_NAMES_TO_ONE operation which applies the
00360                 highlighted names to the given object.  
00361     SeeAlso:    GalleryNameDragInfo
00362 ********************************************************************************************/
00363 
00364 void OpApplyNamesToOne::DoWithParam(OpDescriptor*, OpParam* pParam)
00365 {
00366     ERROR3IF(pParam->Param1 == 0, "OpApplyNamesToOne::DoWithParam: null argument");
00367     Node* pNode = (Node*)(void *) pParam->Param1;
00368     
00369     SingleNodeSource theObject(pNode);
00370     AllowOpScan aosObj(this, &theObject),
00371                 aosSentinel(this, &theSetSentinel);
00372 
00373     if (!aosObj.Scan() ||
00374         !aosSentinel.Scan() ||
00375         !ApplyScan(this, &theObject).Scan() ||
00376         !ApplyScan(this, &theSetSentinel).Scan() ||
00377         !aosObj.Update() ||
00378         !aosSentinel.Update())
00379     {
00380         FailAndExecute();
00381     }
00382 
00383     End();
00384 }
00385 
00386 
00387 
00388 /********************************************************************************************
00389 >   void OpApplyNameToNone::DoWithParam(OpDescriptor*, OpParam* pParam)
00390 
00391     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00392     Created:    09/7/99
00393     Inputs:     pParam->Param1      ---     StringBase* to the name to apply to the
00394                                             selected objects
00395     Purpose:    Performs the OPTOKEN_APPLY_NAME_TO_NONE operation which applies the
00396                 given name to no objects (ie. just to the NodeSetSentinel object).
00397     SeeAlso:    NameObjectsDlg::DoCommit
00398 ********************************************************************************************/
00399 
00400 void OpApplyNameToNone::DoWithParam(OpDescriptor*, OpParam* pParam)
00401 {
00402     ERROR3IF(pParam->Param1 == 0, "OpApplyNameToNone::DoWithParam: null argument");
00403     const StringBase& strName = *((const StringBase*)(void *) pParam->Param1);
00404 
00405     AllowOpScan aosSentinel(this, &theSetSentinel);
00406 
00407     if (!aosSentinel.Scan() ||
00408         !ApplySingleScan(this, &theSetSentinel, strName).Scan() ||
00409         !ApplyPropScan(this, strName).Scan() ||
00410         !aosSentinel.Update())
00411     {
00412         FailAndExecute();
00413     }
00414 
00415     End();
00416 }
00417 
00418 
00419 
00420 /********************************************************************************************
00421 >   virtual void OpDeleteNamesFromAll::Do(OpDescriptor*)
00422 
00423     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00424     Created:    09/7/99
00425     Purpose:    Performs the OPTOKEN_DELETE_NAMES_FROM_ALL operation.  Removes all the
00426                 Wix ObjectName attributes that are members of the given Document's
00427                 named sets.
00428 ********************************************************************************************/
00429 
00430 void OpDeleteNamesFromAll::Do(OpDescriptor*)
00431 {
00432     AllowOpScan aosDoc(this, &theSelectedDocument);
00433 
00434     if (!aosDoc.Scan() ||
00435         !HidePropScan(this).Scan() ||
00436         !HideScan(this, &theSelectedDocument).Scan() ||
00437         !aosDoc.Update())
00438     {
00439         FailAndExecute();
00440     }
00441 
00442     End();
00443 } 
00444 
00445 
00446 
00447 // renames all of the attribute nodes in the tree (& sentinel) from Str to NewStr (sjk 17/8/00)
00448 void RenameSetInstance(const String_256 & str, const String_256 & NewStr, UndoableOperation *pOp, Spread * pSpread)
00449 {
00450     // cant convert to the same thing its pointless
00451     if (str.CompareTo(NewStr) == 0)
00452         return;
00453 
00454     if (pOp == NULL || pSpread == NULL)
00455         return;
00456 
00457     SliceHelper::PurgeUseOfSetName(str, pOp, &NewStr);
00458     Node * pTop = (Node *) pSpread; // search from the spread first
00459     BOOL again = TRUE;
00460     Node * pNodeSetSentinel = pOp->GetWorkingDoc()->GetSetSentinel(); // the sentinel 
00461 
00462     // scan the tree to replace these nodes with the new node name
00463     Node * pNode = SliceHelper::FindNextNameNode(pTop, pTop);
00464     do
00465     {
00466         while (pNode)
00467         {
00468             if (str.CompareTo(((TemplateAttribute *)pNode)->GetParam()) == 0)
00469             {
00470                 // is the new attrib already on this parent?
00471                 // test siblings for the new attrib if it is already there don't add another
00472                 BOOL FoundLikeSibling = FALSE;
00473                 Node * pSib;
00474                 for (   pSib = pNode->FindParent()->FindFirstChild(CC_RUNTIME_CLASS(TemplateAttribute));
00475                         pSib != NULL;
00476                         pSib = pSib->FindNext(CC_RUNTIME_CLASS(TemplateAttribute)) )
00477                         {
00478                             if (NewStr.CompareTo(((TemplateAttribute *)pSib)->GetParam()) == 0)
00479                                 FoundLikeSibling = TRUE;
00480                         }
00481 
00482                 // add the new attrib where the old one was
00483                 TemplateAttribute* pta = NULL;
00484                 if (!FoundLikeSibling)
00485                 {
00486                     ALLOC_WITH_FAIL(pta, (new TemplateAttribute(TA_NAME, ((TemplateAttribute *)pNode)->GetQuestion(), NewStr)), pOp);
00487                     if (pta)
00488                     {
00489                         pta->AttachNode(pNode, PREV);
00490                         // Create an action to hide the new attribute when we Undo.
00491                         HideNodeAction* pHideAct;
00492                         if (AC_FAIL == HideNodeAction::Init(pOp, pOp->GetUndoActions(),
00493                                                             pta, TRUE, (Action**) &pHideAct))
00494                         {
00495                             delete pta;
00496                             pta = NULL;
00497                         }               
00498                     }
00499                 }
00500 
00501                 Node * pDelMe = pNode;
00502                 pNode = SliceHelper::FindNextNameNode(pNode, pTop);
00503 
00504                 // hide this node - the old attrib
00505                 pOp->DoHideNode(pDelMe, FALSE);
00506             }
00507             else
00508                 pNode = SliceHelper::FindNextNameNode(pNode, pTop);
00509         }
00510 
00511         again = pTop != pNodeSetSentinel;
00512         pTop = pNodeSetSentinel;
00513         pNode = SliceHelper::FindNextNameNode(pTop, pTop);
00514     } while (again);
00515 
00516 
00517 
00518     // Matt 18/12/2000
00519     // Nearly done renaming - don't forget that we need to hide the old NodeSetProperty !!!
00520     BOOL propertyrenamed = FALSE;
00521     NodeSetProperty * pNodeSetProperty = (NodeSetProperty *) pNodeSetSentinel->FindFirstChild(CC_RUNTIME_CLASS(NodeSetProperty));
00522     while (pNodeSetProperty && !propertyrenamed)
00523     {
00524         if ((pNodeSetProperty->GetName() == str) && (!pNodeSetProperty->IsNodeHidden()))
00525         {
00526             propertyrenamed = TRUE;
00527             pOp->DoHideNode(pNodeSetProperty, FALSE);
00528         }
00529         pNodeSetProperty = (NodeSetProperty *) pNodeSetProperty->FindNext(CC_RUNTIME_CLASS(NodeSetProperty));
00530     }
00531 }
00532 
00533 
00534 
00535 
00536 
00537 
00538 
00539 /********************************************************************************************
00540 >   virtual void OpRenameAll::DoWithParam(OpDescriptor*, OpParam* pParam)
00541 
00542     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00543     Created:    09/7/99
00544     Inputs:     pParam->Param1   ---    StringBase* to the new name
00545     Purpose:    Performs the OPTOKEN_RENAME_ALL operation.  
00546 ********************************************************************************************/
00547 void OpRenameAll::DoWithParam(OpDescriptor*, OpParam* pParam)
00548 {
00549     ERROR3IF(pParam->Param1 == 0, "OpRenameAll::DoWithParam: null argument");
00550     const StringBase& strNewName = *((const StringBase*) (void *) pParam->Param1);
00551     Spread * pSpread = Document::GetSelectedSpread();
00552     if (pSpread == NULL)
00553     {
00554         FailAndExecute();
00555         End();
00556         return;
00557     }
00558 
00559     // If we are only renaming one item then preserve it's properties, otherwise
00560     // if we are renaming lots to be the same name then make default properties.
00561     NodeSetProperty* pCopyPropNode = 0;
00562     NamedExportProp* pNewExport = 0;
00563 //  Node * pNodeSetSentinel = GetWorkingDoc()->GetSetSentinel(); // the sentinel 
00564 
00565     INT32 nNames;
00566     NameGallery::Instance()->GetHighlightCount(0, &nNames);
00567     if (nNames == 1)
00568     {
00569         // Find the NodeSetProperty associated with the first highlighted item
00570         // in the 'Used Names' display group.
00571         String_256 str;
00572         NameGallery::Instance()->GetUsedNames()->FindNextSelectedItem()->GetNameText(&str);
00573         pCopyPropNode = GetWorkingDoc()->GetSetSentinel()->FindPropertyNode(str);
00574         if (pCopyPropNode != 0)
00575         {
00576             // Try to create an export property for the new name now so we can compare
00577             // it with that of the old name and work out what can be preserved.
00578             ALLOC_WITH_FAIL(pNewExport,
00579                             (NamedExportProp*) SGNameProp::CreateDefault(strNewName,
00580                                                                 NamedExportProp::nIndex),
00581                             this);
00582             if (pNewExport == 0)
00583             {
00584                 FailAndExecute();
00585                 End();
00586                 return;
00587             }
00588 
00589             // Look up the old properties.
00590             NamedExportProp* pOldExport =
00591                     (NamedExportProp*) pCopyPropNode->GetProperty(NamedExportProp::nIndex);
00592             ERROR3IF(pOldExport == 0, "OpRenameAll::DoWithParam: no export property");
00593 
00594             // Preserve the filter, options and location of the old property.
00595             pNewExport->SetFilter(pOldExport->GetFilter());
00596             pNewExport->SetOptions(pOldExport->GetOptions());
00597 
00598             String_256 strPath(pOldExport->GetPath().GetLocation(TRUE));
00599             strPath += pNewExport->GetPath().GetFileName(TRUE);
00600             pNewExport->SetPath(PathName(strPath));
00601         }       
00602     }
00603 
00604     SGNameItem* pNameGalleryItem = (SGNameItem*) NameGallery::Instance()->GetUsedNames()->GetChild();
00605 //  SGNameItem* pRenameMe = NULL;
00606     while (pNameGalleryItem)
00607     {
00608         if (pNameGalleryItem->IsSelected())
00609         {
00610             String_256 str;
00611             pNameGalleryItem->GetNameText(&str);
00612             // remove any references to str (the old set name)
00613             // and replace them (undoably of corse) with strNewName (sjk)
00614             RenameSetInstance(str, *((const String_256 *) (void *) pParam->Param1), this, pSpread);
00615         }
00616 
00617         pNameGalleryItem = (SGNameItem *) pNameGalleryItem->GetNext();
00618     }
00619     
00620     
00621     // Now perform the actual renaming.
00622     AllowOpScan aosDoc(this, &theSelectedDocument);
00623 
00624     BOOL ok = aosDoc.Scan();
00625 
00626     if (ok)
00627         ok = ApplyPropScan(this, strNewName, pCopyPropNode).Scan();
00628 
00629     if (ok)
00630         ok = HidePropScan(this).Scan();
00631 
00632 //  if (ok)
00633 //      ok = HideScan(this, &theSelectedDocument).Scan();
00634 
00635     // update the locations of everything now as we dont want any extends going on
00636     NameGallery * pNameGallery = NameGallery::Instance();
00637     pNameGallery->FastUpdateNamedSetSizes(); // make sure we are using the most up-to-date data
00638 
00639     if (ok)
00640         ok = aosDoc.Update();
00641 
00642     if (!ok)
00643     {
00644         FailAndExecute();
00645         End();
00646         return;
00647     }
00648 
00649     // If we preserved an export property then reset it to the default for its new name.
00650     if (pNewExport != 0)
00651     {
00652         // Change to the new property (without undo) and deallocate the old.
00653         pCopyPropNode = GetWorkingDoc()->GetSetSentinel()->FindPropertyNode(strNewName);
00654         if (pCopyPropNode != 0) delete pCopyPropNode->SetProperty(pNewExport);
00655     }
00656     
00657     End();
00658 }
00659 
00660 
00661 
00662 /********************************************************************************************
00663 >   virtual void OpRemoveNamesFromSel::Do(OpDescriptor*)
00664 
00665     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00666     Created:    09/7/99
00667     Inputs:     pOpDesc     ---     See base class
00668     Purpose:    Performs the OPTOKEN_REMOVE_NAMES_FROM_SEL operation.
00669 ********************************************************************************************/
00670 
00671 void OpRemoveNamesFromSel::Do(OpDescriptor*)
00672 {
00673     AllowOpScan aosSel(this, &theSelectedObjects);
00674 
00675     if (!aosSel.Scan() ||
00676         !DoStartSelOp(TRUE, TRUE) ||
00677         !HideScan(this, &theSelectedObjects).Scan() ||
00678         !aosSel.Update())
00679     {
00680         FailAndExecute();
00681     }
00682 
00683     End();
00684 } 
00685 
00686 
00687 
00688 /********************************************************************************************
00689 >   virtual void OpRedefineNamesAsSel::Do(OpDescriptor*)
00690 
00691     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00692     Created:    09/7/99
00693     Purpose:    Performs the OpRedefineNamesAsSel operation.  Hides all the Wix
00694                 ObjectName attributes that are members of the given Document's
00695                 given attribute set and applies them only to the selected objects.
00696     Inputs:     pOpDesc     ---     See base class
00697     SeeAlso:    class OpRedefineNamesAsSel::Param; OpApplyAttribToSelected::DoWithParam;
00698                 OpRedefineNamesAsSel::DoApply
00699 ********************************************************************************************/
00700 
00701 void OpRedefineNamesAsSel::Do(OpDescriptor*)
00702 {
00703     AllowOpScan aosSel(this, &theSelectedObjects),
00704                 aosUnsel(this, &theUnselectedObjects),
00705                 aosSentinel(this, &theSetSentinel);
00706 
00707     if (!aosSel.Scan() ||
00708         !aosUnsel.Scan() ||
00709         !aosSentinel.Scan() ||
00710         !DoStartSelOp(TRUE, TRUE) ||
00711         !HideScan(this, &theSelectedDocument).Scan() ||
00712         !ApplyScan(this, &theSelectedObjects).Scan() ||
00713         !ApplyScan(this, &theSetSentinel).Scan() ||
00714         !aosSel.Update() ||
00715         !aosUnsel.Update() ||
00716         !aosSentinel.Update())
00717     {
00718         FailAndExecute();
00719     }
00720 
00721     End();
00722 }   
00723 
00724 
00725 
00726 /********************************************************************************************
00727 >   static OpState OpExportSets::GetState(String_256*, OpDescriptor*)
00728 
00729     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00730     Created:    09/7/99
00731     Purpose:    Returns the UI state of this operation.
00732 ********************************************************************************************/
00733 
00734 OpState OpExportSets::GetState(String_256*, OpDescriptor*)
00735 {
00736     INT32 nTotal, nNames;
00737     NameGallery::Instance()->GetHighlightCount(&nTotal, &nNames);
00738     return OpState(FALSE, nNames < 1);
00739 }
00740 
00741 
00742 
00743 /********************************************************************************************
00744 >   virtual void OpExportSets::Do(OpDescriptor*)
00745 
00746     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00747     Created:    09/7/99
00748     Purpose:    Performs the OPTOKEN_EXPORT_SETS operation.  
00749     SeeAlso:    OpSelectIntersectSets; Operation
00750 ********************************************************************************************/
00751 
00752 void OpExportSets::Do(OpDescriptor*)
00753 {
00754     // Iterate over all highlighted set items in the gallery, re-exporting the
00755     // export targets.
00756     if (ExportHighlightedIter(this).ForEach() != 0) InformError();
00757     End();
00758 }
00759 
00760 
00761 
00762 /***********************************************************************************************
00763 >   OpExportSets::ExportHighlightedIter::ExportHighlightedIter(OpExportSets* pOp)
00764 
00765     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00766     Created:    27/8/99
00767     Inputs:     pOp     ---     required context for the exporting.
00768     Purpose:    Constructs an ExportHighlightedIter.
00769     SeeAlso:    OpExportSets; NameItemIter
00770 ***********************************************************************************************/
00771 
00772 OpExportSets::ExportHighlightedIter::ExportHighlightedIter(OpExportSets* pOp)
00773   : NameItemIter(NameItemIter::HIGHLIGHTED_NAMES),
00774     m_pOp(pOp)
00775 {
00776     // Save the selection.
00777     OpMenuExport::SaveSelection();
00778 }
00779 
00780 
00781 
00782 /***********************************************************************************************
00783 >   virtual OpExportSets::ExportHighlightedIter::~ExportHighlightedIter()
00784 
00785     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00786     Created:    27/8/99
00787     Purpose:    Destroys an ExportHighlightedIter.
00788 ***********************************************************************************************/
00789 
00790 OpExportSets::ExportHighlightedIter::~ExportHighlightedIter()
00791 {
00792     // Restore the selection.
00793     OpMenuExport::RestoreSelection();
00794 
00795     // Warn about any unexportable names.
00796     if (!m_strExtErrors.IsEmpty())
00797     {
00798         // Some implied extensions weren't recognised so warn about them.
00799         String_256 str;
00800         m_strExtErrors.toUpper();
00801         str.MakeMsg(_R(IDS_NAMEGAL_EXT_ERROR), &m_strExtErrors);
00802         Error::SetError(0, str, 0);
00803         InformWarning();
00804     }
00805 }
00806 
00807 
00808 
00809 /***********************************************************************************************
00810 >   virtual BOOL OpExportSets::ExportHighlightedIter::Do(SGNameItem* pItem)
00811 
00812     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00813     Created:    27/8/99
00814     Purpose:    Called for each SGNameItem that is highlighted in the Name Gallery.
00815 ***********************************************************************************************/
00816 
00817 BOOL OpExportSets::ExportHighlightedIter::Do(SGNameItem* pItem)
00818 {
00819     // Skip if the set contains no objects.
00820     if (pItem->IsEmpty()) return TRUE;
00821     
00822     // Skip if the export property is not (yet) set up.
00823     NamedExportProp* pProp = (NamedExportProp*) pItem->GetProperty(NamedExportProp::nIndex);
00824     ERROR3IF(pProp == 0, "ExportHighlightedIter::Do: no export property");
00825 
00826     // if the user has not set the options themselves yet prompt them for a location
00827     if (pProp->IsVirgin())
00828     {
00829         if ( !pProp->ExportPropertiesToLocationDlg(pItem) )
00830             return FALSE;
00831 
00832         // pItem may have been altered in the above call
00833         // and we need to refer to the new state
00834         pProp = (NamedExportProp*) pItem->GetProperty(NamedExportProp::nIndex);
00835     }
00836 
00837     if (pProp->GetFilter() == 0 || !pProp->GetPath().IsValid())
00838     {
00839         // Build up a warning message over the course of the iteration.
00840         String_256 str;
00841         pItem->GetNameText(&str);
00842         PathName pth(str);
00843 
00844         if (!m_strExtErrors.IsEmpty()) m_strExtErrors += String(_R(IDS_NAMEGAL_EXT_COMMA));
00845         m_strExtErrors += pth.GetType();
00846         return TRUE;
00847     }
00848 
00849     // Clear out the selection and just select the given set.
00850     if (!SelectScan(pItem, SelectScan::SELECT_EXCLUSIVE, TRUE).Scan()) return FALSE;
00851 
00852     // Fix-up the bevel gubbins etc.
00853     OpMenuExport::NormaliseSelection();
00854 
00855     // Try to open a file.
00856     CCDiskFile theFile;
00857     if (!theFile.open(pProp->GetPath().GetPath(), ios::in | ios::out | ios::binary))
00858         return FALSE;
00859 
00860     // TODO: express-export the selection using the stored options.
00861     BOOL fOk = FALSE;
00862     if (pProp->GetFilter()->IS_KIND_OF(BaseBitmapFilter))
00863     {
00864         // never assume that the colours are the same so invalidate the palette
00865         // or indeed the thing may have changed size so flush the lot of cached data
00866         pProp->GetOptions()->BitmapSourceHasChanged();
00867         // do the export dance
00868         fOk = ((BaseBitmapFilter*) pProp->GetFilter())->DoExportWithOptions(
00869                                             m_pOp,
00870                                             &theFile,
00871                                             &pProp->GetPath(),
00872                                             m_pOp->GetWorkingDoc(),
00873                                             pProp->GetOptions());
00874     }
00875     
00876     // Tidy up and continue iterating if successful.
00877     theFile.close();
00878     return fOk;
00879 }
00880 
00881 
00882 
00883 /***********************************************************************************************
00884 >   virtual void OpChangeSetProperty::DoWithParam(OpDescriptor*, OpParam* pParam)
00885 
00886     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00887     Created:    27/8/99
00888     Inputs:     pParam->Param1      ---     the name of the set the property appertains to
00889                 pParam->Param2      ---     the SGNameProp* to set in the tree
00890     Purpose:    Runs the OPTOKEN_CHANGE_SET_PROPERTY operation.
00891     SeeAlso:    SGNameProp::Change
00892 ***********************************************************************************************/
00893 
00894 void OpChangeSetProperty::DoWithParam(OpDescriptor*, OpParam* pParam)
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 }
00966 
00967 
00968 
00969 /***********************************************************************************************
00970 >   virtual void OpChangeBarProperty::DoWithParam(OpDescriptor*, OpParam* pParam)
00971 
00972     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00973     Created:    27/8/99
00974     Inputs:     pParam->Param2      ---     pointer to the OpChangeBarPropParam
00975     Purpose:    Runs the OPTOKEN_CHANGE_BAR_PROPERTY operation.
00976     SeeAlso:    NodeBarProperty::MakeChange; OpChangeBarPropParam
00977 ***********************************************************************************************/
00978 
00979 void OpChangeBarProperty::DoWithParam(OpDescriptor*, OpParam* pParam)
00980 {
00981     // Extract the parameter.
00982     ERROR3IF(pParam == 0, "OpChangeBarProperty::DoWithParam: no parameter");
00983     OpChangeBarPropParam* pInput = (OpChangeBarPropParam*) (pParam);
00984     NodeBarProperty* pProp = pInput->m_Prop; //(NodeBarProperty*) (pParam->Param1);
00985     ERROR3IF(pInput == 0 || pProp == 0, "OpChangeBarProperty::DoWithParam: no property");
00986 
00987     // Set this to a special value to indicate it's as yet unused.
00988     m_BarIndex = -1;
00989     m_MakingLive = FALSE; // is the live stretch being turned back on?
00990 
00991     // Try to duplicate the old bar properties.
00992     if (!DoChangeBarProperty(this, pInput->m_nIndex, pProp, pInput->m_pbdtInfo, &m_MakingLive))
00993     {
00994         FailAndExecute();
00995         End();
00996         return;
00997     }
00998 
00999     // does this to record what the op was that triggered the extending stuff
01000     // most ops don't do it like this. Instead they go through AllowOp
01001     // but his doesn't need to go through AllowOp and doesn't call that
01002     // so it calls this instead. sjk
01003     NameGallery* pNameGallery = NameGallery::Instance();
01004     if (pNameGallery != 0)
01005     {
01006         // set up for a bar wiggling
01007         pNameGallery->PreTriggerEdit(this, 0, (Node*) 0);
01008 
01009         // make sure this bar does know it has been touched
01010         pNameGallery->m_TouchedBar = pInput->m_nIndex;
01011         m_BarIndex = pInput->m_nIndex;
01012     }
01013 
01014     // Success.
01015     End();
01016 }
01017 
01018 BOOL OpChangeBarProperty::DoChangeBarProperty(UndoableOperation * pOp, INT32 Index, NodeBarProperty* pProp, const BarDataType * pBarData, BOOL * pMadeLive)
01019 {
01020     if (pMadeLive)
01021         *pMadeLive = FALSE;
01022 
01023     if (!pOp || !pProp || !pBarData)
01024         return FALSE;
01025 
01026     // Try to duplicate the old bar properties.
01027     NodeBarProperty* pCopy;
01028     ALLOC_WITH_FAIL(pCopy, ((NodeBarProperty*) pProp->SimpleCopy()), pOp);
01029     if (pCopy == 0)
01030     {
01031         return FALSE;
01032     }
01033 
01034     // Try to attach the duplicate bar properties in the right place.
01035     pCopy->AttachNode(pOp->GetWorkingDoc()->GetSetSentinel(), LASTCHILD);
01036     HideNodeAction* pHideAct;
01037     if (AC_FAIL == HideNodeAction::Init(pOp, pOp->GetUndoActions(), pCopy,
01038                                         TRUE, (Action**) &pHideAct))
01039     {
01040         delete pCopy;
01041         return FALSE;
01042     }
01043 
01044     // Write the new data into the duplicate.
01045     if (Index >= (INT32)pCopy->HowMany())
01046         pCopy->Add(*pBarData);
01047     else
01048     {
01049         BOOL MakingLive = !pCopy->Bar(Index).IsLive && pBarData->IsLive;
01050         BarDataType* pCopyData = &pCopy->Bar(Index);
01051         *pCopyData = *pBarData;
01052         if (pMadeLive)
01053             *pMadeLive = MakingLive;
01054     }
01055 
01056     // Try to hide the old bar properties.
01057     if (!pOp->DoHideNode(pProp, TRUE, 0, TRUE))
01058     {
01059         return FALSE;
01060     }
01061     
01062     return TRUE;
01063 }
01064 
01065 
01066 
01067 /***********************************************************************************************
01068 >   virtual void OpChangeBarExtends::DoWithParam(OpDescriptor*, OpParam* pParam)
01069 
01070     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
01071     Created:    27/8/99
01072     Inputs:     pParam->Param1      ---     (INT32) ID of the bars to change
01073                 pParam->Param2      ---     (BYTE) the new stretching mode to set
01074     Purpose:    Runs the OPTOKEN_CHANGE_BAR_EXTENDS operation.
01075     SeeAlso:    NodeBarProperty::MakeChange
01076 ***********************************************************************************************/
01077 
01078 void OpChangeBarExtends::DoWithParam(OpDescriptor*, OpParam* pParam)
01079 {
01080     // Extract the parameters.
01081     ERROR3IF(pParam == 0, "OpChangeBarExtends::DoWithParam: no parameter");
01082     INT32 idBars = (INT32) pParam->Param1;
01083     BYTE nMode = (BYTE) pParam->Param2;
01084     SGUsedNames* pNames = NameGallery::Instance()->GetUsedNames();
01085     ERROR3IF(pNames == 0, "OpChangeBarExtends::DoWithParam: no set names");
01086     NodeSetSentinel* pSentry = GetWorkingDoc()->GetSetSentinel();
01087 
01088     // Iterate over all SGUsedNames, looking for matching bar IDs.
01089     for (SGNameItem* pItem = (SGNameItem*) pNames->GetChild();
01090          pItem != 0;
01091          pItem = (SGNameItem*) pItem->GetNext())
01092             if (pItem->m_BarNumber == idBars)
01093             {
01094                 // We've found a bar whose ID matches.  Undoably change its extending
01095                 // mode to that passed in.
01096                 String_256 strName;
01097                 pItem->GetNameText(&strName);
01098                 NodeSetProperty* pOldSetNode = pSentry->FindPropertyNode(strName);
01099                 ERROR3IF(pOldSetNode == 0,
01100                             "OpChangeBarExtends::DoWithParam: can't find NodeSetProperty");
01101 
01102                 // Try to duplicate the old set properties.
01103                 NodeSetProperty* pNewSetNode;
01104                 ALLOC_WITH_FAIL(pNewSetNode,
01105                                 ((NodeSetProperty*) pOldSetNode->SimpleCopy()),
01106                                 this);
01107                 if (pNewSetNode == 0)
01108                 {
01109                     FailAndExecute();
01110                     End();
01111                     return;
01112                 }
01113 
01114                 // Write the stretching flag into the duplicate.
01115                 NamedStretchProp* pProp =
01116                         (NamedStretchProp*) pNewSetNode->GetProperty(NamedStretchProp::nIndex);
01117                 ERROR3IF(pProp == 0, "OpChangeBarExtends::DoWithParam: no property");
01118                 pProp->SetStretchType(nMode);
01119 
01120                 // Mark the duplicate property as no longer "virgin".
01121                 pProp->SetDirty();
01122 
01123                 // Insert the new properties in their place.
01124                 pNewSetNode->AttachNode(pSentry, LASTCHILD);
01125                 HideNodeAction* pHideAct;
01126                 if (AC_FAIL == HideNodeAction::Init(this, GetUndoActions(), pNewSetNode,
01127                                                     TRUE, (Action**) &pHideAct))
01128                 {
01129                     delete pNewSetNode;
01130                     FailAndExecute();
01131                     End();
01132                     return;
01133                 }
01134 
01135                 //  Finally, hide the old properties.
01136                 if (!DoHideNode(pOldSetNode, TRUE, 0, TRUE))
01137                 {
01138                     FailAndExecute();
01139                     End();
01140                     return;
01141                 }
01142             }
01143 
01144     // Success.
01145     End();
01146 }
01147 
01148 
01149 
01150 /********************************************************************************************
01151 >   BOOL InitNamingSystem()
01152 
01153     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
01154     Created:    09/7/99
01155     Purpose:    Initialises the various operations and other components of the
01156                 Attribute gallery with the exception of the gallery and its embedded
01157                 gagdets, which are initialised with the other galleries in sginit.cpp
01158     Returns:    TRUE if successful.
01159 ********************************************************************************************/
01160 
01161 BOOL InitNamingSystem()
01162 {
01163 /*
01164     RegisterOpDescriptor's arguments:-
01165 
01166     toolID                              : Tool ID (from which the Module ID can be found)
01167     txID                                : String Resource ID
01168     RuntimeClass                        : The operation's runtime class
01169     tok,                                : pointer to the token string
01170     gs,                                 : pointer to the GetState function
01171     helpId = 0                          : help identifier 
01172     bubbleID = 0                        : string resource for bubble help
01173     resourceID = 0                      : resource ID
01174     controlID = 0                       : control ID within that resource within that tool
01175     GroupBarID = SYSTEMBAR_ILLEGAL      : The system bar group this op desc belongs to
01176     ReceiveMessages = FALSE *!!*        : Does this respond to system messages?
01177                                         : NOTE ** MUST be TRUE for ops connected to buttons?
01178     Smart = FALSE                       : A smart duplicate operation ?
01179     Clean = TRUE  *!!*                  : Does the operation change the document
01180     pVertOpDesc   *!!*                  : this op desc's vertical alter ego, if any
01181     OneOpenInstID = 0                   : When not 0 only one live instance
01182                                           of the operation is permitted, and
01183                                           OneOpenInstID is the string resource
01184                                           ID describing why.This will be useful
01185                                           for 1 open instance dialogs.
01186     AutoStateFlags = 0                  : Flags which indicate conditions when
01187                                           the operation should automatically be
01188                                           greyed/ticked, GREY_WHEN_NO_CURRENT_DOC and
01189                                           GREY_WHEN_NO_SELECTION, DONT_GREY_WHEN_SELECT_INSIDE
01190                                           This cuts down the number calls to GetState
01191 
01192     NB. The Clean argument defaults to FALSE for UndoableOperation::RegisterOpDescriptor.
01193     Also sote that UndoableOperation::RegisterOpdescriptor doesn't take the pVertOpDesc
01194     argument.  Oh sweet Camelot!
01195 */
01196     return OpSelectSet::RegisterOpDescriptor(
01197                 0,
01198                 _R(IDS_NAMEOP_SELECT_SET),
01199                 CC_RUNTIME_CLASS(OpSelectSet),
01200                 OPTOKEN_SELECT_SET,
01201                 0,
01202                 0,
01203                 _R(IDBBL_NAMEOP_SELECT_SET),
01204                 0,
01205                 0,
01206                 SYSTEMBAR_ILLEGAL,
01207                 FALSE,
01208                 FALSE,
01209                 TRUE,
01210                 0,
01211                 0,
01212                 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01213 
01214         && OpSelectUnionSets::RegisterOpDescriptor(
01215                 0,
01216                 _R(IDS_NAMEOP_SELECT_UNION_SETS),
01217                 CC_RUNTIME_CLASS(OpSelectUnionSets),
01218                 OPTOKEN_SELECT_UNION_SETS,
01219                 OpSelectUnionSets::GetState,
01220                 0,
01221                 _R(IDBBL_NAMEOP_SELECT_UNION_SETS))
01222         
01223         && OpSelectIntersectSets::RegisterOpDescriptor(
01224                 0,
01225                 _R(IDS_NAMEOP_SELECT_INTERSECT_SETS),
01226                 CC_RUNTIME_CLASS(OpSelectIntersectSets),
01227                 OPTOKEN_SELECT_INTERSECT_SETS,
01228                 OpSelectIntersectSets::GetState,
01229                 0,
01230                 _R(IDBBL_NAMEOP_SELECT_INTERSECT_SETS))
01231         
01232         && OpApplyNamesToSel::RegisterOpDescriptor(
01233                 0,
01234                 _R(IDS_NAMEOP_APPLY_NAMES_TO_SEL),
01235                 CC_RUNTIME_CLASS(OpApplyNamesToSel),
01236                 OPTOKEN_APPLY_NAMES_TO_SEL,
01237                 OpApplyNamesToSel::GetState,
01238                 0,
01239                 _R(IDBBL_NAMEOP_APPLY_NAMES_TO_SEL))
01240         
01241         && OpApplyNamesToSel::RegisterOpDescriptor(
01242                 0,
01243                 _R(IDS_NAMEOP_APPLY_NAME_TO_SEL),
01244                 CC_RUNTIME_CLASS(OpApplyNamesToSel),
01245                 OPTOKEN_APPLY_NAME_TO_SEL,
01246                 0,
01247                 _R(IDBBL_NAMEOP_APPLY_NAME_TO_SEL),
01248                 0,
01249                 0,
01250                 0,
01251                 SYSTEMBAR_ILLEGAL,
01252                 FALSE,
01253                 FALSE,
01254                 FALSE,
01255                 0,
01256                 GREY_WHEN_NO_SELECTION | DONT_GREY_WHEN_SELECT_INSIDE)
01257 
01258         && OpApplyNamesToOne::RegisterOpDescriptor(
01259                 0,
01260                 _R(IDS_NAMEOP_APPLY_NAMES_TO_ONE),
01261                 CC_RUNTIME_CLASS(OpApplyNamesToOne),
01262                 OPTOKEN_APPLY_NAMES_TO_ONE,
01263                 OpApplyNamesToOne::GetState,
01264                 0,
01265                 _R(IDBBL_NAMEOP_APPLY_NAMES_TO_ONE))
01266 
01267         && OpApplyNameToNone::RegisterOpDescriptor(
01268                 0,
01269                 _R(IDS_NAMEOP_APPLY_NAME_TO_NONE),
01270                 CC_RUNTIME_CLASS(OpApplyNameToNone),
01271                 OPTOKEN_APPLY_NAME_TO_NONE,
01272                 0,
01273                 _R(IDBBL_NAMEOP_APPLY_NAME_TO_NONE),
01274                 0,
01275                 0,
01276                 0,
01277                 SYSTEMBAR_ILLEGAL,
01278                 FALSE,
01279                 FALSE,
01280                 FALSE,
01281                 0,
01282                 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01283         
01284         && OpDeleteNamesFromAll::RegisterOpDescriptor(
01285                 0,
01286                 _R(IDS_NAMEOP_DELETE_NAMES_FROM_ALL),
01287                 CC_RUNTIME_CLASS(OpDeleteNamesFromAll),
01288                 OPTOKEN_DELETE_NAMES_FROM_ALL,
01289                 OpApplyNamesToOne::GetState,
01290                 0,
01291                 _R(IDBBL_NAMEOP_DELETE_NAMES_FROM_ALL))
01292 
01293         && OpRenameAll::RegisterOpDescriptor(
01294                 0,
01295                 _R(IDS_NAMEOP_RENAME_ALL),
01296                 CC_RUNTIME_CLASS(OpRenameAll),
01297                 OPTOKEN_RENAME_ALL,
01298                 OpApplyNamesToOne::GetState,
01299                 0,
01300                 _R(IDBBL_NAMEOP_RENAME_ALL))
01301 
01302         && OpRemoveNamesFromSel::RegisterOpDescriptor(
01303                 0,
01304                 _R(IDS_NAMEOP_REMOVE_NAMES_FROM_SEL),
01305                 CC_RUNTIME_CLASS(OpRemoveNamesFromSel),
01306                 OPTOKEN_REMOVE_NAMES_FROM_SEL,
01307                 OpApplyNamesToSel::GetState,
01308                 0,
01309                 _R(IDBBL_NAMEOP_REMOVE_NAMES_FROM_SEL))
01310 
01311         && OpRedefineNamesAsSel::RegisterOpDescriptor(
01312                 0,
01313                 _R(IDS_NAMEOP_REDEFINE_NAMES_AS_SEL),
01314                 CC_RUNTIME_CLASS(OpRedefineNamesAsSel),
01315                 OPTOKEN_REDEFINE_NAMES_AS_SEL,
01316                 OpApplyNamesToSel::GetState,
01317                 0,
01318                 _R(IDBBL_NAMEOP_REDEFINE_NAMES_AS_SEL))
01319         
01320         && OpExportSets::RegisterOpDescriptor(
01321                 0,
01322                 _R(IDS_NAMEOP_EXPORT_SETS),
01323                 CC_RUNTIME_CLASS(OpExportSets),
01324                 OPTOKEN_EXPORT_SETS,
01325                 OpExportSets::GetState,
01326                 0,
01327                 _R(IDBBL_NAMEOP_EXPORT_SETS))
01328 
01329         && OpChangeSetProperty::RegisterOpDescriptor(
01330                 0,
01331                 _R(IDS_NAMEOP_CHANGE_SET_PROPERTY),
01332                 CC_RUNTIME_CLASS(OpChangeSetProperty),
01333                 OPTOKEN_CHANGE_SET_PROPERTY,
01334                 0,
01335                 _R(IDBBL_NAMEOP_CHANGE_SET_PROPERTY),
01336                 0,
01337                 0,
01338                 0,
01339                 SYSTEMBAR_ILLEGAL,
01340                 FALSE,
01341                 FALSE,
01342                 FALSE,
01343                 0,
01344                 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01345         
01346         && OpChangeBarProperty::RegisterOpDescriptor(
01347                 0,
01348                 _R(IDS_NAMEOP_CHANGE_BAR_PROPERTY),
01349                 CC_RUNTIME_CLASS(OpChangeBarProperty),
01350                 OPTOKEN_CHANGE_BAR_PROPERTY,
01351                 0,
01352                 _R(IDBBL_NAMEOP_CHANGE_BAR_PROPERTY),
01353                 0,
01354                 0,
01355                 0,
01356                 SYSTEMBAR_ILLEGAL,
01357                 FALSE,
01358                 FALSE,
01359                 FALSE,
01360                 0,
01361                 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01362         
01363         && OpChangeBarExtends::RegisterOpDescriptor(
01364                 0,
01365                 _R(IDS_NAMEOP_CHANGE_BAR_EXTENDS),
01366                 CC_RUNTIME_CLASS(OpChangeBarExtends),
01367                 OPTOKEN_CHANGE_BAR_EXTENDS,
01368                 0,
01369                 _R(IDBBL_NAMEOP_CHANGE_BAR_EXTENDS),
01370                 0,
01371                 0,
01372                 0,
01373                 SYSTEMBAR_ILLEGAL,
01374                 FALSE,
01375                 FALSE,
01376                 FALSE,
01377                 0,
01378                 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01379         
01380         && NameObjectsDlg::Init()
01381 
01382         && NameObjectsDlg::RegisterOpDescriptor(
01383                 0,
01384                 _R(IDS_NAMEOP_NAME_OBJECTS_DLG),
01385                 CC_RUNTIME_CLASS(NameObjectsDlg),
01386                 OPTOKEN_NAME_OBJECTS_DLG,
01387                 0,
01388                 0,
01389                 _R(IDBBL_NAMEOP_NAME_OBJECTS_DLG),
01390                 0,
01391                 0,
01392                 SYSTEMBAR_ILLEGAL,
01393                 TRUE,                   // send kernel messages
01394                 FALSE,
01395                 TRUE,
01396                 0,
01397                 _R(IDS_NAMEDLG_ONE_INSTANCE),
01398                 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01399 
01400         && RenameObjectsDlg::RegisterOpDescriptor(
01401                 0,
01402                 _R(IDS_NAMEOP_RENAME_OBJECTS_DLG),
01403                 CC_RUNTIME_CLASS(RenameObjectsDlg),
01404                 OPTOKEN_RENAME_OBJECTS_DLG,
01405                 OpApplyNamesToOne::GetState,
01406                 0,
01407                 _R(IDBBL_NAMEOP_RENAME_OBJECTS_DLG));
01408 }

Generated on Sat Nov 10 03:45:53 2007 for Camelot by  doxygen 1.4.4