00001 // $Id: filtrmgr.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 #include "camtypes.h" 00100 #include "filtrmgr.h" 00101 00102 //#include "filters.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00103 #include "fileform.h" 00104 00105 #if defined(DEBUG_THIS) 00106 #include "plgnfltr.h" 00107 #endif 00108 00109 DECLARE_SOURCE("$Revision: 1282 $"); 00110 00111 CC_IMPLEMENT_MEMDUMP(FilterManager, CC_CLASS_MEMDUMP) 00112 CC_IMPLEMENT_MEMDUMP(FileFormat, CC_CLASS_MEMDUMP) 00113 CC_IMPLEMENT_MEMDUMP(FilterList, List) 00114 CC_IMPLEMENT_MEMDUMP(FormatEntry, CC_CLASS_MEMDUMP) 00115 CC_IMPLEMENT_MEMDUMP(FilterEntry, CC_CLASS_MEMDUMP) 00116 00117 // Declare smart memory handling in Debug builds 00118 #define new CAM_DEBUG_NEW 00119 00120 /******************************************************************************************** 00121 00122 > FilterManager::FilterManager() 00123 00124 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00125 Created: 22/02/94 00126 Purpose: Set the Filter object up to be in a clean state. 00127 SeeAlso: Filter; Filter::~Filter; OILFilter 00128 00129 ********************************************************************************************/ 00130 FilterManager::FilterManager() : 00131 FILTERID_START(FILTERID_ALDUS_END + 1), 00132 FORMATID_START(1) 00133 { 00134 m_NextFilterID = FILTERID_START; 00135 m_NextFormatID = FORMATID_START; 00136 } 00137 00138 00139 /******************************************************************************************** 00140 00141 > FilterID FilterManager::GetNewFilterID() 00142 00143 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00144 Created: 10/12/96 00145 Returns: A FilterID unique to this FilterManager for each call to the function 00146 Purpose: Support function providing an unique ID for each newly registered Filter 00147 00148 ********************************************************************************************/ 00149 UINT32 FilterManager::GetNewFilterID() 00150 { 00151 ERROR3IF(!m_NextFilterID, "Creating duff FilterID"); 00152 00153 return m_NextFilterID++; 00154 } 00155 00156 00157 /******************************************************************************************** 00158 00159 > FilterID FilterManager::RegisterFilter( const Filter* const pFilter, 00160 const DESTRUCTION_METHOD DestructMethod) 00161 00162 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00163 Created: 15/12/94 00164 Inputs: pFilter: pointer to the filter to register 00165 Returns: FilterID that uniquely identifies the given filter within the scope of this 00166 FilterManager and allows for fast retrieval of the filter. 00167 Purpose: Permits the filter to be used by the FilterManager. 00168 For an import filter to be present on the Import dialog the filter should 00169 associate itself with the requisite FileFormats via AssociateFilterWithFormat() 00170 00171 ********************************************************************************************/ 00172 00173 UINT32 FilterManager::RegisterFilter( Filter* const pFilter, 00174 const DESTRUCTION_METHOD DestructMethod) 00175 { 00176 //DestructMethod; // This line just read "DestructMethod;" - what's that meant to do then? 00177 UINT32 newID = Filter::RegisterFilter(pFilter); 00178 00179 return newID; 00180 } 00181 00182 00183 00184 /******************************************************************************************** 00185 00186 > BOOL FilterManager::Init() 00187 00188 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00189 Created: 22/12/96 00190 Returns: TRUE if initialised ok, FALSE if not. 00191 Purpose: Initializes the filter manager 00192 Currently just does some tests 00193 00194 ********************************************************************************************/ 00195 00196 BOOL FilterManager::Init() 00197 { 00198 #if defined(DEBUG_THIS) 00199 00200 String_256 MyFormatName = _T("myFormat"); 00201 String_256 MyFormatDesc = _T("Format (*.frm)"); 00202 XtraFileFormat* pFormat = new XtraFileFormat(MyFormatName, MyFormatDesc); 00203 FileFormatID myFormatID = RegisterFileFormat((FileFormat*)pFormat, FilterManager::DM_DELETE_WHEN_DONE); 00204 MyFormatDesc = _T(".fm1"); 00205 pFormat->AddExtension(MyFormatDesc); 00206 MyFormatDesc = _T(".fm2"); 00207 pFormat->AddExtension(MyFormatDesc); 00208 MyFormatDesc = _T(".fm3"); 00209 pFormat->AddExtension(MyFormatDesc); 00210 MyFormatDesc = _T(".fm2"); 00211 pFormat->AddExtension(MyFormatDesc); 00212 MyFormatDesc = _T(".one long mother of an extension well beyond thirty-two"); 00213 pFormat->AddExtension(MyFormatDesc); 00214 00215 #endif 00216 00217 // All ok 00218 return TRUE; 00219 } 00220 00221 00222 /******************************************************************************************** 00223 00224 > BOOL FilterManager::DeInit() 00225 00226 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00227 Created: 22/12/96 00228 Purpose: Destroy all the FileFormat objects, maybe 00229 00230 ********************************************************************************************/ 00231 00232 BOOL FilterManager::DeInit() 00233 { 00234 for (UINT32 index = 0; index < GetLastFormatID(); index++) 00235 { 00236 FormatEntry* pEntry = GetFormats()[index]; 00237 ERROR2IF(pEntry == NULL, FALSE, "pEntry NULL"); 00238 00239 FileFormat* pFormat = pEntry->GetFormat(); 00240 ERROR2IF(pFormat == NULL, FALSE, "pFormat NULL"); 00241 00242 if (pEntry->GetDestructionMethod() == DM_DELETE_WHEN_DONE) 00243 { 00244 delete pFormat; 00245 } 00246 delete pEntry; 00247 GetFormats()[index] = NULL; 00248 } 00249 00250 // All ok 00251 return TRUE; 00252 } 00253 00254 00255 00256 #define ADD_FILTER(Classname, FilterIDConst) \ 00257 /* Create, initialise and install the Generic import filter */ \ 00258 pFilter = new Classname; \ 00259 if (pFilter == NULL) return FALSE; \ 00260 \ 00261 if (!pFilter->Init()) \ 00262 { \ 00263 /* Error occured - report it and stop trying to initialise filters. */ \ 00264 InformError(); \ 00265 return TRUE; \ 00266 } \ 00267 \ 00268 FilterIDConst = RegisterFilter(pFilter, DM_DELETE_WHEN_DONE); \ 00269 if (FilterIDConst == NULL) \ 00270 { \ 00271 return FALSE; \ 00272 } \ 00273 00274 00275 /******************************************************************************************** 00276 00277 > Filter* FilterManager::FindFilterFromID(const UINT32 FilterID) const 00278 00279 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00280 Created: 10/12/96 00281 Purpose: Provides the Filter given its ID 00282 00283 ********************************************************************************************/ 00284 Filter* FilterManager::FindFilterFromID(const UINT32 FilterID) const 00285 { 00286 Filter* pFilter = Filter::GetFirst(); 00287 while (pFilter != NULL) 00288 { 00289 if (pFilter->FilterID == FilterID) 00290 { 00291 break; 00292 } 00293 pFilter = Filter::GetNext(pFilter); 00294 } 00295 return pFilter; 00296 } 00297 00298 00300 00301 /******************************************************************************************** 00302 00303 > FormatArray& FilterManager::GetFormats() 00304 00305 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00306 Created: 10/12/96 00307 Returns: A reference to the FormatArray 00308 Purpose: Support function providing access to the FileFormats 00309 00310 ********************************************************************************************/ 00311 FormatArray& FilterManager::GetFormats() 00312 { 00313 return m_Formats; 00314 } 00315 00316 /******************************************************************************************** 00317 00318 > FileFormatID FilterManager::GetNewFormatID() 00319 00320 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00321 Created: 10/12/96 00322 Returns: A FileFormatID unique to this FilterManager for each call to the function 00323 Purpose: Support function providing an unique ID for each newly registered FileFormat 00324 00325 ********************************************************************************************/ 00326 FileFormatID FilterManager::GetNewFormatID() 00327 { 00328 return m_NextFormatID++; 00329 } 00330 00331 00332 /******************************************************************************************** 00333 00334 > FileFormatID FilterManager::RegisterFileFormat(const FileFormat* pFormat, 00335 const DESTRUCTION_METHOD dm) 00336 00337 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00338 Created: 10/12/96 00339 Inputs: pFormat: A pointer to the FileFormat to register 00340 Returns: A FileFormatID by which the given FileFormat can be uniquely identified and 00341 quickly retrieved. 00342 Purpose: Registers the given FileFormat with this FilterManager 00343 00344 ********************************************************************************************/ 00345 FileFormatID FilterManager::RegisterFileFormat( FileFormat* const pFormat, 00346 const DESTRUCTION_METHOD DestructMethod) 00347 { 00348 ERROR2IF(pFormat == NULL, 0, "NULL Args"); 00349 00350 // Look for one we might already have 00351 FileFormatID IDToReturn = FindFormatIDFromName(pFormat->GetName()); 00352 if (IDToReturn == 0) 00353 { 00354 // Have to add a new one 00355 IDToReturn = GetNewFormatID(); 00356 FormatEntry* pFormatEntry = new FormatEntry(IDToReturn, pFormat, DestructMethod); 00357 if (pFormatEntry == NULL) 00358 { 00359 goto AddFormatError; 00360 } 00361 00362 if (!GetFormats().Add(pFormatEntry)) 00363 { 00364 delete pFormatEntry; 00365 goto AddFormatError; 00366 } 00367 } 00368 else 00369 { 00370 // Use the duplicate then 00371 } 00372 00373 return IDToReturn; 00374 00375 AddFormatError: 00376 00377 return 0; 00378 } 00379 00380 00381 /******************************************************************************************** 00382 00383 > BOOL FilterManager::AssociateFilterWithFormat( const FilterID FilterID, 00384 const FileFormatID FileFormatID) 00385 00386 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00387 Created: 10/12/96 00388 Inputs: FilterID: The FilterID (returned by RegisterFilter()) of the filter to 00389 associate with the given FileFormatID 00390 FileFormatID: Like FilterID 00391 Purpose: Tells this FilterManager that the given filter wishes to be considered when 00392 doing things with the given format. 00393 00394 ********************************************************************************************/ 00395 BOOL FilterManager::AssociateFilterWithFormat( const UINT32 FilterID, 00396 const FileFormatID FileFormatID) 00397 { 00398 BOOL Successful = TRUE; // value to return 00399 00400 Filter* pFilter = FindFilterFromID(FilterID); 00401 FormatEntry* pFormatEntry = FindFormatEntryFromID(FileFormatID); 00402 00403 if (pFilter != NULL && pFormatEntry != NULL) 00404 { 00405 // We found both the filter & format so create a new association entry 00406 Successful = pFormatEntry->GetFilters().AddFilter(pFilter, FilterID); 00407 } 00408 else 00409 { 00410 Successful = FALSE; 00411 } 00412 00413 return Successful; 00414 } 00415 00416 00417 /******************************************************************************************** 00418 00419 > FileFormatID FilterManager::FindFormatIDFromName(const StringBase& FormatName) const 00420 00421 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00422 Created: 10/12/96 00423 Purpose: Relief function returning the FileFormat ID instead of the FileFormat per se 00424 See Also: Other overloaded function 00425 00426 ********************************************************************************************/ 00427 FileFormatID FilterManager::FindFormatIDFromName(const StringBase& FormatName) const 00428 { 00429 FileFormatID FoundID = 0; 00430 FormatEntry* pFoundEntry = FindFormatEntryFromName(FormatName); 00431 00432 if (pFoundEntry != NULL) 00433 { 00434 FoundID = pFoundEntry->GetID(); 00435 } 00436 else 00437 { 00438 FoundID = 0; 00439 } 00440 00441 return FoundID; 00442 } 00443 00444 /******************************************************************************************** 00445 00446 > FileFormat* FilterManager::FindFormatFromName(const StringBase& FormatName) const 00447 00448 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00449 Created: 10/12/96 00450 Inputs: FormatName: The name of a FileFormat given in the FileFormat's constructor 00451 which has subsequently been Added to this FilterManager. 00452 Returns: A pointer to the FileFormat with the name given or NULL if none was found 00453 Purpose: Finds the one & only FileFormat with the given FormatName 00454 Used by Xtra's mainly 00455 00456 ********************************************************************************************/ 00457 FileFormat* FilterManager::FindFormatFromName(const StringBase& FormatName) const 00458 { 00459 FormatEntry* pEntry = FindFormatEntryFromName(FormatName); 00460 if (pEntry != NULL) 00461 { 00462 return pEntry->GetFormat(); 00463 } 00464 return NULL; 00465 } 00466 00467 00468 /******************************************************************************************** 00469 00470 > FileFormat* FilterManager::FindFormatFromID(const FileFormatID FormatID) const 00471 00472 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00473 Created: 10/12/96 00474 Purpose: Provides the FileFormat given its ID 00475 See Also: FindFormatEntryFromID 00476 00477 ********************************************************************************************/ 00478 FileFormat* FilterManager::FindFormatFromID(const FileFormatID FormatID) const 00479 { 00480 FileFormat* pReturnedFormat; 00481 00482 FormatEntry* pEntry = FindFormatEntryFromID(FormatID); 00483 if (pEntry != NULL) 00484 { 00485 pReturnedFormat = pEntry->GetFormat(); 00486 } 00487 else 00488 { 00489 pReturnedFormat = NULL; 00490 } 00491 00492 return pReturnedFormat; 00493 } 00494 00495 00496 /******************************************************************************************** 00497 00498 > FormatEntry* FilterManager::FindFormatEntryFromID(const FileFormatID) const 00499 00500 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00501 Created: 10/12/96 00502 Purpose: Internally does the actual finding by ID 00503 See Also: FindFormatFromID 00504 00505 ********************************************************************************************/ 00506 FormatEntry* FilterManager::FindFormatEntryFromID(const FileFormatID FormatID) const 00507 { 00508 ERROR2IF(FormatID == 0 || FormatID > GetLastFormatID(), NULL, 00509 "Invalid FileFormatID"); 00510 00511 return GetFormats()[FormatID - 1]; 00512 } 00513 00514 00515 /******************************************************************************************** 00516 00517 > FormatEntry* FilterManager::FindFormatEntryFromName(const StringBase& FormatName) const 00518 00519 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00520 Created: 10/12/96 00521 Inputs: FormatName: The name of a FileFormat given in the FileFormat's constructor 00522 which has subsequently been Added to this FilterManager. 00523 Returns: A pointer to the FileFormat with the name given or NULL if none was found 00524 Purpose: Finds the one & only FileFormat with the given FormatName 00525 Used by Xtra's mainly 00526 00527 ********************************************************************************************/ 00528 FormatEntry* FilterManager::FindFormatEntryFromName(const StringBase& FormatName) const 00529 { 00530 for (UINT32 index = 0; index < GetLastFormatID(); ++index) 00531 { 00532 FormatEntry* pFormatEntry = GetFormats()[index]; 00533 if (pFormatEntry != NULL) 00534 { 00535 FileFormat* pFormat = pFormatEntry->GetFormat(); 00536 if (pFormat->GetName() == FormatName) 00537 { 00538 return pFormatEntry; 00539 } 00540 } 00541 else 00542 { 00543 // we'll ignore this one 00544 } 00545 } 00546 00547 return NULL; 00548 } 00549 00550 00551 00552 /******************************************************************************************** 00553 00554 > Filter* FilterManager::FindMatchedFilter(SearchCriteria) 00555 00556 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00557 Created: 10/12/96 00558 Purpose: To find a filter with the given SearchCriteria 00559 Notes: Returns the first matching filter within the context of the given 00560 SearchCriteria (the SearchContext is contained within the SearchCriteria) 00561 00562 ********************************************************************************************/ 00563 Filter* FilterManager::FindFilter(FilterSearchCriteria& Criteria) const 00564 { 00565 return NULL; 00566 } 00567 00568 00569 /******************************************************************************************** 00570 00571 > FilterList* FilterManager::ListMatchingFilters(FilterSearchCriteria& Criteria) 00572 00573 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00574 Created: 10/12/96 00575 Purpose: Creates a list of filters matching the given FilterSearchCriteria 00576 Returns: A list of filters matching the given FilterSearchCriteria. The list IsEmpty 00577 if no filters matched 00578 NULL if failed 00579 Notes: The returned list should be deleted when finished with. 00580 00581 ********************************************************************************************/ 00582 FilterList* FilterManager::ListMatchingFilters(FilterSearchCriteria& Criteria) 00583 { 00584 FilterList* pList = new FilterList; 00585 00586 return pList; 00587 } 00588 00589 00590 00591 /******************************************************************************************** 00592 00593 > FormatEntry::FormatEntry(const FileFormatID ID, const FileFormat* pFormat, 00594 const FilterManager::DESTRUCTION_METHOD DestructMethod) 00595 00596 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00597 Created: 10/12/96 00598 Inputs: ID: The FileFormat's ID 00599 pFormat: A pointer to the FileFormat 00600 DestructMethod: Whether or not the FileFormat should be deleted when this 00601 FormatEntry is. 00602 Purpose: Provides an entry for the FilterManager's database of FileFormats 00603 00604 ********************************************************************************************/ 00605 FormatEntry::FormatEntry(const FileFormatID ID, FileFormat* const pFormat, 00606 const FilterManager::DESTRUCTION_METHOD DestructMethod) 00607 { 00608 m_pFormat = pFormat; 00609 m_FormatID = ID; 00610 m_DestructMethod = DestructMethod; 00611 } 00612 00613 00614 00615 /******************************************************************************************** 00616 00617 > FormatEntry::~FormatEntry() 00618 00619 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> 00620 Created: 10/12/96 00621 Purpose: Default constructor deleting associated FilterEntry items 00622 00623 ********************************************************************************************/ 00624 FormatEntry::~FormatEntry() 00625 { 00626 GetFilters().DeleteAll(); 00627 } 00628 00629 00630 /******************************************************************************************** 00631 00632 > FilterList::FilterList() 00633 00634 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim) 00635 Created: 28/03/94 00636 Purpose: Initialises a list 00637 00638 ********************************************************************************************/ 00639 FilterList::FilterList() 00640 { 00641 } 00642 00643 00644 /******************************************************************************************** 00645 00646 > FilterEntry::FilterEntry(Filter* pFilter, FilterID ID) 00647 00648 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim) 00649 Created: 28/03/94 00650 Inputs: pFilter: the filter contained within this FilterItem 00651 ID - a unique ID for the given filter 00652 Purpose: Initialises a list item for a Filter 00653 00654 ********************************************************************************************/ 00655 FilterEntry::FilterEntry(Filter* const pFilter, const UINT32 ID) 00656 { 00657 ERROR3IF(pFilter == NULL || !ID, "FilterListItem - pFilter NULL"); 00658 00659 m_pFilter = pFilter; 00660 m_FilterID = ID; 00661 } 00662 00663 00664 /******************************************************************************************** 00665 00666 > BOOL FilterList::AddFilter(Filter* const pFilter, const FilterID ID) 00667 00668 Author: Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim) 00669 Created: 28/03/94 00670 Inputs: pEntry: the FilterEntry to add to the list. 00671 Returns: TRUE if the filter was added to the list ok; FALSE if not. 00672 Purpose: Add a new item to the compatible filter list, which points to the given 00673 filter, and stores the given compatibility rating in the list entry. 00674 The list is kept in sorted order, i.e. the list item is added to the list 00675 according to its compatibility rating; the higher the rating, the closer 00676 it is to the head of the list. 00677 Errors: Out of memory. 00678 SeeAlso: ComaptibleFilterList; CompatibleFilter 00679 00680 ********************************************************************************************/ 00681 BOOL FilterList::AddFilter(Filter* const pFilter, const UINT32 ID) 00682 { 00683 // Make a new list item for this filter. 00684 FilterEntry* pEntry = new FilterEntry(pFilter, ID); 00685 if (pEntry == NULL) 00686 { 00687 return FALSE; 00688 } 00689 00690 AddTail(pEntry); // can't fail 00691 00692 // All ok 00693 return TRUE; 00694 }