ngiter.cpp

Go to the documentation of this file.
00001 // $Id: ngiter.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: /wxCamelot/Kernel/ngiter.cpp 7     20/07/05 15:39 Luke $
00100     Classes to iterate through the objects in the document and over Attribute gallery
00101     groups and items.
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 //#include "ngcore.h"
00107 #include "ngitem.h"
00108 #include "ngiter.h"
00109 #include "ngsentry.h"
00110 
00111 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "node.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 
00114 #if 0
00115 #ifdef _DEBUG
00116 #undef THIS_FILE
00117 static char BASED_CODE THIS_FILE[] = __FILE__;
00118 #endif
00119 #endif
00120 
00121 DECLARE_SOURCE("$Revision: 1282 $");
00122 
00123 // This definition must appear after the above CC_IMPLEMENT_ definitions.
00124 // Declare smart memory handling in Debug builds
00125 #define new CAM_DEBUG_NEW
00126 
00127 
00128 // These global objects implement the various Sources for NodeScans.
00129 SelectDocSource     theSelectedDocument;
00130 SelectObjSource     theSelectedObjects;
00131 NotSelectSource     theUnselectedObjects;
00132 SetSentinelSource   theSetSentinel;
00133 
00134 
00135 /********************************************************************************************
00136 >   BOOL NodeScan::Scan()
00137 
00138     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00139     Created:    27/7/99
00140     Returns:    TRUE if scan terminated successfully, FALSE if the NodeScan
00141                 cancelled the scan.
00142     Purpose:    Scans through the 'selected' document's tree extracting Nodes and calling
00143                 the polymorphic Do function with them.
00144 ********************************************************************************************/
00145 
00146 BOOL NodeScan::Scan()
00147 {
00148     // Call Pre() before the scan.
00149     if (!Pre()) return FALSE;
00150 
00151     // Perform the appropriate type of scan.
00152     for (Node* pNode = m_pSource->GetFirst();
00153          pNode != 0;
00154          pNode = m_pSource->GetNext(pNode))
00155     {
00156         // NB. Post() not called if scan fails.
00157         if (!Do(pNode)) return FALSE;
00158     }
00159 
00160     // Call Post() after a successful scan.
00161     return Post();
00162 }
00163 
00164 
00165 
00166 /********************************************************************************************
00167 >   virtual BOOL NodeScan::Pre()
00168 
00169     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00170     Created:    27/7/99
00171     Returns:    TRUE to successfully start scan, FALSE on error.
00172     Purpose:    Default override called by NodeScan::Scan prior to scanning the document.
00173 ********************************************************************************************/
00174 
00175 BOOL NodeScan::Pre()
00176 {
00177     return TRUE;
00178 }
00179 
00180 
00181 
00182 /********************************************************************************************
00183 >   virtual BOOL NodeScan::Post()
00184 
00185     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00186     Created:    27/7/99
00187     Returns:    TRUE to successfully finish scan, FALSE on error.
00188     Purpose:    Default override called by NodeScan::Scan prior to scanning the document.
00189 ********************************************************************************************/
00190 
00191 BOOL NodeScan::Post()
00192 {
00193     return TRUE;
00194 }
00195 
00196 
00197 
00198 /********************************************************************************************
00199 >   NodeScan::NodeScan(NodeScan::Source* ps)
00200 
00201     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00202     Created:    27/7/99
00203     Inputs:     The source of objects over which to scan, eg. theSelectedDocument or
00204                 theSelectedObjects.
00205     Purpose:    Constructs an NodeScan object.
00206     SeeAlso:    NodeScan::Source; DocTreeSource; RangeSource
00207 ********************************************************************************************/
00208 
00209 NodeScan::NodeScan(NodeScan::Source* ps)
00210   : m_pSource(ps)
00211 {
00212     // Empty.
00213 }
00214 
00215 
00216 
00217 /********************************************************************************************
00218 >   virtual NodeScan::~NodeScan()
00219 
00220     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00221     Created:    27/7/99
00222     Purpose:    Destroys an NodeScan object.
00223 ********************************************************************************************/
00224 
00225 NodeScan::~NodeScan()
00226 {
00227     // Empty.
00228 }
00229 
00230 
00231 
00232 /********************************************************************************************
00233 >   UndoableNodeScan::UndoableNodeScan(UndoableOperation* pOp, NodeScan::Source* ps)
00234 
00235     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00236     Created:    27/7/99
00237     Inputs:     pOp     ---     the UndoableOperation that defines the context for the
00238                                 scans implemented by derived classes.
00239     Purpose:    Constructs an UndoableNodeScan object.
00240     SeeAlso:    NodeScan
00241 ********************************************************************************************/
00242 
00243 UndoableNodeScan::UndoableNodeScan(UndoableOperation* pOp, NodeScan::Source* ps)
00244   : NodeScan(ps),
00245     m_pOp(pOp)
00246 {
00247     // Empty.
00248 }
00249 
00250 
00251 
00252 /********************************************************************************************
00253 >   DocTreeSource::DocTreeSource(BaseDocument* pDoc = 0)
00254 
00255     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00256     Created:    27/7/99
00257     Inputs:     pDoc        ---     the document whose tree is to be scanned, if any
00258     Purpose:    Constructs a DocTreeSource object.
00259     SeeAlso:    NodeScan::Source; NodeScan
00260 ********************************************************************************************/
00261 
00262 DocTreeSource::DocTreeSource(BaseDocument* pDoc)
00263   : m_pDoc(pDoc)
00264 {
00265     // Empty.
00266 }
00267 
00268 
00269 
00270 /********************************************************************************************
00271 >   virtual Node* DocTreeSource::GetFirst()
00272 
00273     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00274     Created:    27/7/99
00275     Returns:    The first non-hidden node in a depth-first traversal of the tree, or null.
00276     Purpose:    Identical to Node::DocFindFirstDepthFirst but skips over hidden nodes.
00277                 NB. the first node in the document tree is guaranteed to never be
00278                 hidden.
00279     SeeAlso:    NodeScan::Source; DocTreeSource::GetNext
00280 ********************************************************************************************/
00281 
00282 Node* DocTreeSource::GetFirst()
00283 {
00284     ERROR3IF(m_pDoc == 0, "DocTreeSource::GetFirst: no document");
00285 
00286     Node* pNode = m_pDoc->GetFirstNode();
00287     if (pNode != 0 && !pNode->IsSetCandidate()) pNode = GetNext(pNode);
00288     return pNode;
00289 }
00290 
00291 
00292 
00293 /********************************************************************************************
00294 >   virtual Node* DocTreeSource::GetNext(Node* pNode)
00295 
00296     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00297     Created:    27/7/99
00298     Inputs:     pNode   ---     the previous node returned by _GetNext
00299     Returns:    The next non-hidden node in a depth-first traversal of the tree, or null.
00300     Purpose:    Identical to Node::DocFindNextDepthFirst but skips over hidden nodes.
00301                 To be precise, it doesn't follow child links for NodeHiddens.
00302     SeeAlso:    NodeScan::Source; DocTreeSource::GetFirst
00303 
00304     Notes:      Karim 14/12/2000
00305                 Modified so that we also skip NodeMoulds in the tree,
00306                 as the user must not be allowed to select moulded objects.
00307                 This is achieved by effectively hiding them from the NameGallery's scans.
00308                 ps, TODO:   Rather than test specifically for NodeMould,
00309                             use a similar mechanism to IsSetCandidate().
00310 ********************************************************************************************/
00311 
00312 Node* DocTreeSource::GetNext(Node* pNode)
00313 {
00314     do {
00315         if (pNode->FindNext() == 0)
00316             pNode = pNode->FindParent();
00317         else
00318         {
00319             pNode = pNode->FindNext();
00320             while ( !pNode->IsNodeHidden() &&
00321                     !pNode->IsANodeMould() && pNode->FindFirstChild() != 0 )
00322                 pNode = pNode->FindFirstChild();
00323         }
00324     } while (pNode != 0 && !pNode->IsSetCandidate());
00325 
00326     return pNode;
00327 }
00328 
00329 
00330 
00331 /********************************************************************************************
00332 >   virtual Node* SelectDocSource::GetFirst()
00333 
00334     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00335     Created:    27/7/99
00336     Purpose:    Customises DocTreeSource::_GetFirst to use the 'selected' documemt's tree.
00337     SeeAlso:    NodeScan::Source; DocTreeSource; DocTreeSource::GetFirst
00338 ********************************************************************************************/
00339 
00340 Node* SelectDocSource::GetFirst()
00341 {
00342     m_pDoc = Document::GetSelected();
00343     return m_pDoc != 0 ? DocTreeSource::GetFirst() : 0;
00344 }
00345 
00346 
00347 
00348 /********************************************************************************************
00349 >   RangeSource::RangeSource(Range* pRange = 0)
00350 
00351     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00352     Created:    27/7/99
00353     Inputs:     pRange  ---   the range to be scanned, if any.
00354     Purpose:    Constructs a RangeSource object.
00355     SeeAlso:    NodeScan::Source; NodeScan
00356 ********************************************************************************************/
00357 
00358 RangeSource::RangeSource(Range* pRange)
00359   : m_pRange(pRange)
00360 {
00361     // Empty.
00362 }
00363 
00364 
00365 
00366 /********************************************************************************************
00367 >   virtual Node* RangeSource::GetFirst()
00368 
00369     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00370     Created:    27/7/99
00371     Returns:    The first object in the selection to scan over, or null if there isn't one.
00372     SeeAlso:    RangeSource::GetNext; NodeScan::Source; NodeScan
00373 ********************************************************************************************/
00374 
00375 Node* RangeSource::GetFirst()
00376 {
00377     ERROR3IF(m_pRange == 0, "RangeSource::GetFirst: no range");
00378     
00379     Node* pNode = m_pRange->FindFirst();
00380     if (pNode != 0 && !pNode->IsSetCandidate()) pNode = GetNext(pNode);
00381     return pNode;
00382 }
00383 
00384 
00385 
00386 /********************************************************************************************
00387 >   virtual Node* RangeSource::GetNext(Node* pLastNode)
00388 
00389     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00390     Created:    27/7/99
00391     Returns:    The next object in the selection to scan over, or null if there isn't one.
00392     SeeAlso:    RangeSource::GetFirst; NodeScan::Source; NodeScan
00393 ********************************************************************************************/
00394 
00395 Node* RangeSource::GetNext(Node* pNode)
00396 {
00397     for (pNode = m_pRange->FindNext(pNode);
00398          pNode != 0 && !pNode->IsSetCandidate();
00399          pNode = m_pRange->FindNext(pNode))
00400             /* empty */ ;
00401 
00402     return pNode;
00403 }
00404 
00405 
00406 
00407 /********************************************************************************************
00408 >   virtual Node* SelectObjSource::GetFirst()
00409 
00410     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00411     Created:    27/7/99
00412     Returns:    The first object in the selection to scan over, or null if there isn't one.
00413     SeeAlso:    RangeSource::_GetFirst; RangeSource; NodeScan::Source; NodeScan
00414 ********************************************************************************************/
00415 
00416 Node* SelectObjSource::GetFirst()
00417 {
00418     m_pRange = GetApplication()->FindSelection();
00419     return RangeSource::GetFirst();
00420 }
00421 
00422 
00423 
00424 /********************************************************************************************
00425 >   virtual Node* NotSelectSource::GetFirst()
00426 
00427     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00428     Created:    27/7/99
00429     Returns:    The first unselected node in a depth-first traversal of the tree, or null.
00430     Purpose:    Identical to Node::DocFindFirstDepthFirst but skips over hidden nodes.
00431                 NB. the first node in the document tree is guaranteed to never be
00432                 hidden.
00433     SeeAlso:    NodeScan::Source; NotSelectSource::GetNext
00434 ********************************************************************************************/
00435 
00436 Node* NotSelectSource::GetFirst()
00437 {
00438     Node* pNode = SelectDocSource::GetFirst();
00439     if (pNode != 0 && pNode->IsSelected()) pNode = GetNext(pNode);
00440     return pNode;
00441 }
00442 
00443 
00444 
00445 /********************************************************************************************
00446 >   virtual Node* NotSelectSource::GetNext(Node* pNode)
00447 
00448     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00449     Created:    27/7/99
00450     Inputs:     pNode   ---     the previous node returned by _GetNext
00451     Returns:    The next non-hidden node in a depth-first traversal of the tree, or null.
00452     Purpose:    Identical to Node::DocFindNextDepthFirst but skips over hidden nodes.
00453                 To be precise, it doesn't follow child links for NodeHiddens.
00454     SeeAlso:    NodeScan::Source; NotSelectSource::GetFirst
00455 ********************************************************************************************/
00456 
00457 Node* NotSelectSource::GetNext(Node* pNode)
00458 {
00459     do {
00460         if (pNode->FindNext() == 0)
00461             pNode = pNode->FindParent();
00462         else
00463         {
00464             pNode = pNode->FindNext();
00465             while (!pNode->IsNodeHidden() && pNode->FindFirstChild() != 0)
00466                 pNode = pNode->FindFirstChild();
00467         }
00468     } while (pNode != 0 && (!pNode->IsSetCandidate() || pNode->IsSelected()));
00469 
00470     return pNode;
00471 }
00472 
00473 
00474 
00475 /********************************************************************************************
00476 >   SingleNodeSource::SingleNodeSource(Node* pNode)
00477 
00478     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00479     Created:    27/7/99
00480     Inputs:     pNode   ---     the node to "scan" over
00481     Returns:    Scan over a single Node.
00482     SeeAlso:    NodeScan::Source; NodeScan
00483 ********************************************************************************************/
00484 
00485 SingleNodeSource::SingleNodeSource(Node* pNode)
00486   : m_pNode(pNode)
00487 {
00488     // Empty.
00489 }
00490 
00491 
00492 
00493 /********************************************************************************************
00494 >   virtual Node* SingleNodeSource::GetFirst()
00495 
00496     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00497     Created:    27/7/99
00498     Returns:    A single object.
00499     SeeAlso:    NodeScan::Source; NodeScan; SingleNodeSource::GetNext
00500 ********************************************************************************************/
00501 
00502 Node* SingleNodeSource::GetFirst()
00503 {
00504     return m_pNode;
00505 }
00506 
00507 
00508 
00509 /********************************************************************************************
00510 >   virtual Node* SingleNodeSource::GetNext(Node* pLastNode)
00511 
00512     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00513     Created:    27/7/99
00514     Returns:    Null - the sole object has already been returned by _GetFirst.
00515     SeeAlso:    NodeScan::Source; NodeScan; SingleNodeSource::GetFirst
00516 ********************************************************************************************/
00517 
00518 Node* SingleNodeSource::GetNext(Node*)
00519 {
00520     return 0;
00521 }
00522 
00523 
00524 
00525 /********************************************************************************************
00526 >   virtual Node* SetSentinelSource::GetFirst()
00527 
00528     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00529     Created:    27/7/99
00530     Returns:    The 'selected' document's NodeSetSentinel.
00531     SeeAlso:    SingleNodeSource; NodeScan::Source; NodeScan
00532 ********************************************************************************************/
00533 
00534 Node* SetSentinelSource::GetFirst()
00535 {
00536     m_pNode = Document::GetSelected()->GetSetSentinel();
00537     return SingleNodeSource::GetFirst();
00538 }
00539 
00540 
00541 
00542 /********************************************************************************************
00543 >   virtual SGNameGroup* NameGroupIter::ForEach()
00544 
00545     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00546     Created:    27/7/99
00547     Returns:    Null if all Do() calls succeed, a pointer to the failing group if a Do()
00548                 call fails.
00549     Purpose:    Calls NameGroupIter::Do for every group in the name gallery.
00550     SeeAlso:    NodeScan
00551 ********************************************************************************************/
00552 
00553 SGNameGroup* NameGroupIter::ForEach()
00554 {
00555     PORTNOTETRACE("other","NameGroupIter::ForEach - do nothing");
00556 #ifndef EXCLUDE_FROM_XARALX
00557     SGNameGroup* pGroup = NameGallery::Instance()->GetFirstGroup();
00558     while (pGroup != 0)
00559     {
00560         SGNameGroup* pNextGroup = (SGNameGroup*) pGroup->GetNext();
00561         if (!Do(pGroup)) return pGroup;
00562         pGroup = pNextGroup;
00563     }
00564 #endif
00565     return NULL;
00566 }
00567 
00568 
00569 
00570 /********************************************************************************************
00571 >   NameItemIter::NameItemIter(NameItemIter::Mask mask = NameItemIter::ALL_ITEMS)
00572 
00573     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00574     Created:    27/7/99
00575     Inputs:     mask    ---     what to iterate over (ALL_ITEMS, ALL_NAMES, 
00576                                 HIGHLIGHTED_ITEMS, HIGHLIGHTED_NAMES)
00577     Purpose:    Constructs a NameItemIter.
00578     SeeAlso:    NameGroupIter; NameIterOp
00579 ********************************************************************************************/
00580 
00581 NameItemIter::NameItemIter(NameItemIter::Mask mask)
00582   : m_eMask(mask)
00583 {
00584     // Empty.
00585 }
00586 
00587 
00588 /********************************************************************************************
00589 >   virtual SGNameItem* NameItemIter::ForEach()
00590 
00591     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00592     Created:    27/7/99
00593     Returns:    Null if all Do() calls succeed, a pointer to the failing item if a Do()
00594                 call fails.
00595     Purpose:    Calls NameItemIter::Do for every item in the name gallery.
00596     SeeAlso:    NodeScan
00597 ********************************************************************************************/
00598 
00599 SGNameItem* NameItemIter::ForEach()
00600 {
00601     PORTNOTETRACE("other","NameItemIter::ForEach - do nothing");
00602 #ifndef EXCLUDE_FROM_XARALX
00603     // Just the items in 'Used Names'?
00604     if (INT32(m_eMask) & 1)
00605         return ForEachItem(NameGallery::Instance()->GetUsedNames());
00606 
00607     // Items in all the groups.
00608     SGNameGroup* pGroup = NameGallery::Instance()->GetFirstGroup();
00609     while (pGroup != 0)
00610     {
00611         SGNameGroup* pNextGroup = (SGNameGroup*) pGroup->GetNext();
00612         SGNameItem* pStopItem = ForEachItem(pGroup);
00613         if (pStopItem != 0) return pStopItem;
00614         pGroup = pNextGroup;
00615     }
00616 #endif
00617     // No item stopped the iteration.
00618     return NULL;
00619 }
00620 
00621 
00622 
00623 /********************************************************************************************
00624 >   SGNameItem* NameItemIter::ForEachItem(SGNameGroup* pGroup)
00625 
00626     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00627     Created:    27/7/99
00628     Returns:    Null if all Do() calls succeed, a pointer to the failing item if a Do()
00629                 call fails.
00630     Purpose:    Calls NameItemIter::Do for every item in the given group.
00631     SeeAlso:    NameIterItem::ForEach
00632 ********************************************************************************************/
00633 
00634 SGNameItem* NameItemIter::ForEachItem(SGNameGroup* pGroup)
00635 {
00636     if (pGroup == 0) return 0;
00637 
00638     SGNameItem* pItem = (SGNameItem*) pGroup->GetChild();
00639     while (pItem != 0)
00640     {
00641         // NB. careful to fetch next item in iteration before calling Do() in case
00642         // Do() deletes the item and we lose its next link.
00643         SGNameItem* pNextItem = (SGNameItem*) pItem->GetNext();
00644         if (((INT32(m_eMask) & 2) == 0 || pItem->IsSelected()) && !Do(pItem))
00645             return pItem;
00646         pItem = pNextItem;
00647     }
00648 
00649     return 0;
00650 }
00651 
00652 
00653 
00654 /********************************************************************************************
00655 >   NameIterOp::NameIterOp(Node* pNode, UndoableOperation* pOp = 0,
00656                            NameItemIter::Mask mask = NameItemIter::HIGHLIGHTED_NAMES)
00657 
00658     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00659     Created:    27/7/99
00660     Inputs:     pNode   ---     the node to iterate gallery items over.
00661                 pOp     ---     if supplied by a derived class, the operation context in
00662                                 which this iteration is working on objects.
00663     Purpose:    Specialisation of NameItemIter base class to iterate over highlighted Name
00664                 gallery 'Used Names' items and perform undoable operations on the nodes
00665                 that are members of their sets.
00666     SeeAlso:    NameItemIter
00667 ********************************************************************************************/
00668 
00669 NameIterOp::NameIterOp(Node* pNode, UndoableOperation* pOp, NameItemIter::Mask mask)
00670   : NameItemIter(mask),
00671     m_pNode(pNode),
00672     m_pOp(pOp)
00673 {
00674     // Empty.
00675 }

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