00001 // $Id: plugin.cpp 751 2006-03-31 15:43:49Z alex $ 00002 // 00003 // File which implements plug-in related items. At present this includes 00004 // implementations of:- 00005 // PlugInItem 00006 // PlugInPath 00007 // PlugInPathList 00008 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00009 ================================XARAHEADERSTART=========================== 00010 00011 Xara LX, a vector drawing and manipulation program. 00012 Copyright (C) 1993-2006 Xara Group Ltd. 00013 Copyright on certain contributions may be held in joint with their 00014 respective authors. See AUTHORS file for details. 00015 00016 LICENSE TO USE AND MODIFY SOFTWARE 00017 ---------------------------------- 00018 00019 This file is part of Xara LX. 00020 00021 Xara LX is free software; you can redistribute it and/or modify it 00022 under the terms of the GNU General Public License version 2 as published 00023 by the Free Software Foundation. 00024 00025 Xara LX and its component source files are distributed in the hope 00026 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00027 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00028 See the GNU General Public License for more details. 00029 00030 You should have received a copy of the GNU General Public License along 00031 with Xara LX (see the file GPL in the root directory of the 00032 distribution); if not, write to the Free Software Foundation, Inc., 51 00033 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00034 00035 00036 ADDITIONAL RIGHTS 00037 ----------------- 00038 00039 Conditional upon your continuing compliance with the GNU General Public 00040 License described above, Xara Group Ltd grants to you certain additional 00041 rights. 00042 00043 The additional rights are to use, modify, and distribute the software 00044 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00045 library and any other such library that any version of Xara LX relased 00046 by Xara Group Ltd requires in order to compile and execute, including 00047 the static linking of that library to XaraLX. In the case of the 00048 "CDraw" library, you may satisfy obligation under the GNU General Public 00049 License to provide source code by providing a binary copy of the library 00050 concerned and a copy of the license accompanying it. 00051 00052 Nothing in this section restricts any of the rights you have under 00053 the GNU General Public License. 00054 00055 00056 SCOPE OF LICENSE 00057 ---------------- 00058 00059 This license applies to this program (XaraLX) and its constituent source 00060 files only, and does not necessarily apply to other Xara products which may 00061 in part share the same code base, and are subject to their own licensing 00062 terms. 00063 00064 This license does not apply to files in the wxXtra directory, which 00065 are built into a separate library, and are subject to the wxWindows 00066 license contained within that directory in the file "WXXTRA-LICENSE". 00067 00068 This license does not apply to the binary libraries (if any) within 00069 the "libs" directory, which are subject to a separate license contained 00070 within that directory in the file "LIBS-LICENSE". 00071 00072 00073 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00074 ---------------------------------------------- 00075 00076 Subject to the terms of the GNU Public License (see above), you are 00077 free to do whatever you like with your modifications. However, you may 00078 (at your option) wish contribute them to Xara's source tree. You can 00079 find details of how to do this at: 00080 http://www.xaraxtreme.org/developers/ 00081 00082 Prior to contributing your modifications, you will need to complete our 00083 contributor agreement. This can be found at: 00084 http://www.xaraxtreme.org/developers/contribute/ 00085 00086 Please note that Xara will not accept modifications which modify any of 00087 the text between the start and end of this header (marked 00088 XARAHEADERSTART and XARAHEADEREND). 00089 00090 00091 MARKS 00092 ----- 00093 00094 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00095 designs are registered or unregistered trademarks, design-marks, and/or 00096 service marks of Xara Group Ltd. All rights in these marks are reserved. 00097 00098 00099 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00100 http://www.xara.com/ 00101 00102 =================================XARAHEADEREND============================ 00103 */ 00104 00105 #include "camtypes.h" 00106 00107 #include "plugin.h" 00108 00109 // Place any IMPLEMENT type statements here 00110 CC_IMPLEMENT_DYNAMIC(PlugInItem, ListItem) 00111 CC_IMPLEMENT_DYNAMIC(PlugInPath, ListItem) 00112 CC_IMPLEMENT_DYNAMIC(PlugInPathList, List) 00113 00114 // We want better memory tracking 00115 #define new CAM_DEBUG_NEW 00116 00117 /************************************************************************************** 00118 00119 > PlugInItem::PlugInItem() 00120 00121 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00122 Created: 10/12/96 00123 Purpose: Constructor for a PlugInItem. 00124 00125 **************************************************************************************/ 00126 00127 PlugInItem::PlugInItem() 00128 { 00129 // Set up the class variables to known states 00130 m_PathNameID = -1; 00131 m_ModuleName.Empty(); 00132 m_FilterName.Empty(); 00133 m_FamilyName.Empty(); 00134 m_PlugInName.Empty(); 00135 } 00136 00137 /************************************************************************************** 00138 00139 > virtual BOOL PlugInItem::About() 00140 00141 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00142 Created: 11/12/96 00143 Returns: True if works ok, False otherwise. 00144 Purpose: Find out about a plug-in. 00145 00146 **************************************************************************************/ 00147 00148 BOOL PlugInItem::About() 00149 { 00150 ERROR3("PlugInItem::About baseclass invoked!"); 00151 return TRUE; 00152 } 00153 00154 /************************************************************************************** 00155 00156 > virtual BOOL PlugInItem::Apply(KernelBitmap *pInputBitmap, Document* pDocument, 00157 KernelBitmap **ppOutputBitmap = NULL) 00158 00159 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00160 Created: 17/12/96 00161 Inputs: pInputBitmap the bitmap to apply the effect to 00162 pDocument document the bitmap is in 00163 Outputs: ppOutputBitmap if specified, a pointer to the output bitmap generated 00164 Returns: True if works ok, False otherwise. 00165 Purpose: Applies a plug-in's bitmap effect to the specified bitmap. 00166 00167 **************************************************************************************/ 00168 00169 BOOL PlugInItem::Apply(KernelBitmap *pInputBitmap, Document* pDocument, 00170 KernelBitmap **ppOutputBitmap) 00171 { 00172 ERROR3("PlugInItem::Apply baseclass invoked!"); 00173 return TRUE; 00174 } 00175 00176 /************************************************************************************** 00177 00178 > virtual BOOL PlugInItem::ApplyLastFilter(KernelBitmap *pInputBitmap, Document* pDocument, 00179 KernelBitmap **ppOutputBitmap = NULL) 00180 00181 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00182 Created: 17/12/96 00183 Inputs: pInputBitmap the bitmap to apply the effect to 00184 pDocument document the bitmap is in 00185 Outputs: ppOutputBitmap if specified, a pointer to the output bitmap generated 00186 Returns: True if works ok, False otherwise. 00187 Purpose: Applies a plug-in's bitmap effect to the specified bitmap using the last 00188 applied parameters. Assumes that Apply for this plug-in has been called 00189 already. 00190 00191 **************************************************************************************/ 00192 00193 BOOL PlugInItem::ApplyLastFilter(KernelBitmap *pInputBitmap, Document* pDocument, 00194 KernelBitmap **ppOutputBitmap) 00195 { 00196 ERROR3("PlugInItem::ApplyLastFilter baseclass invoked!"); 00197 return TRUE; 00198 } 00199 00200 /************************************************************************************** 00201 00202 > virtual BOOL PlugInItem::IsBitmapModeOk(INT32 ColourDepth) 00203 00204 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00205 Created: 6/1/97 00206 Inputs: ColourDepth the colour depth or bits per pixel of the bitmap 00207 GreyScale only relevent if bitmap is 8bpp, True if greyscale 00208 Returns: True if the bitmap is compatible and False otherwise. 00209 Purpose: Checks to see if a plug-in can cope with the specified colour depth. 00210 00211 **************************************************************************************/ 00212 00213 BOOL PlugInItem::IsBitmapModeOk(INT32 ColourDepth, BOOL GreyScale) 00214 { 00215 return FALSE; 00216 } 00217 00218 /************************************************************************************** 00219 **************************************************************************************/ 00220 00221 /************************************************************************************** 00222 00223 > PlugInPath::PlugInPath( const PathName& NewPath, INT32 ID, BOOL IsHidden = FALSE) 00224 00225 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00226 Created: 9/12/96 00227 Inputs: Path - the pathname to put in the list. 00228 ID - the ID a plug-in item uses to associate itself with a pathname 00229 IsHidden - the pathname is not one added by the user (Defaults to FALSE) 00230 Purpose: Create a new plug-in pathname list item from the given pathname. 00231 SeeAlso: PlugInPathList; 00232 00233 **************************************************************************************/ 00234 00235 PlugInPath::PlugInPath( const PathName& NewPath, INT32 ID, BOOL IsHidden) 00236 { 00237 // Initialise our class variables to these specified values. 00238 m_Path = NewPath; 00239 m_PathNameID = ID; 00240 m_IsHidden = IsHidden; 00241 } 00242 00243 /************************************************************************************** 00244 **************************************************************************************/ 00245 00246 /************************************************************************************** 00247 00248 > PlugInPathList::~PlugInPathList() 00249 00250 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00251 Created: 10/12/96 00252 Inputs: - 00253 Outputs: - 00254 Returns: - 00255 Purpose: Constructor for the list of pathnames to parse plug-ins for. 00256 SeeAlso: PlugInPath 00257 00258 **************************************************************************************/ 00259 00260 PlugInPathList::PlugInPathList() 00261 { 00262 m_IDCounter = 0; 00263 } 00264 00265 /************************************************************************************** 00266 00267 > PlugInPathList::~PlugInPathList() 00268 00269 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00270 Created: 9/12/96 00271 Inputs: - 00272 Outputs: - 00273 Returns: - 00274 Purpose: Destroy the list of pathnames to parse plug-ins for. 00275 SeeAlso: PlugInPath 00276 00277 **************************************************************************************/ 00278 00279 PlugInPathList::~PlugInPathList() 00280 { 00281 // Destroy the list of pathnames which we may have 00282 /* PlugInPath* pPath = (PlugInPath *)GetHead(); 00283 while (pPath) 00284 { 00285 delete pPath; 00286 00287 // Try the next pathname in the list 00288 pPath = (PlugInPath *)GetNext(pPath); 00289 } */ 00290 00291 DeleteAll(); 00292 } 00293 00294 /************************************************************************************** 00295 00296 > PlugInPath * PlugInPathList::GetFirstPath() 00297 00298 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00299 Created: 9/1/97 00300 Returns: Pointer to the first PlugInPath or NULL if there are none. 00301 Purpose: Finds the first pathname in the list of plug-in pathnames. 00302 When searching the pathname list, you MUST use these form of the list 00303 classes GetHead/GetNext as otherwise you will get unknown effects. 00304 SeeAlso: GetNextPath 00305 00306 **************************************************************************************/ 00307 00308 PlugInPath * PlugInPathList::GetFirstPath() 00309 { 00310 // Get the real first item, if there is one 00311 PlugInPath * pPath = (PlugInPath * ) GetHead(); 00312 // While there is an item and it is hidden then search for the next one in the list 00313 while (pPath && pPath->IsHidden()) 00314 { 00315 pPath = (PlugInPath * ) GetNext(pPath); 00316 } 00317 00318 return pPath; 00319 } 00320 00321 /************************************************************************************** 00322 00323 > PlugInPath * PlugInPathList::GetNextPath(const PlugInPath * pCurrentItem) 00324 00325 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00326 Created: 9/1/97 00327 Returns: Pointer to the first PlugInPath or NULL if there are none. 00328 Purpose: Finds the next pathname in the list of plug-in pathnames. 00329 When searching the pathname list, you MUST use these form of the list 00330 classes GetHead/GetNext as otherwise you will get unknown effects. 00331 SeeAlso: GetNextPath 00332 00333 **************************************************************************************/ 00334 00335 PlugInPath * PlugInPathList::GetNextPath(const PlugInPath * pCurrentItem) 00336 { 00337 ERROR3IF(pCurrentItem == NULL,"GetNextPath has been given a null current item"); 00338 if (pCurrentItem == NULL) 00339 return NULL; 00340 00341 // Get the real next item, if there is one 00342 PlugInPath * pPath = (PlugInPath * ) GetNext(pCurrentItem); 00343 // While there is an item and it is hidden then search for the next one in the list 00344 while (pPath && pPath->IsHidden()) 00345 { 00346 pPath = (PlugInPath * ) GetNext(pPath); 00347 } 00348 00349 return pPath; 00350 } 00351 00352 /************************************************************************************** 00353 00354 > BOOL PlugInPathList::RemoveHiddenItems() 00355 00356 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00357 Created: 9/1/97 00358 Returns: True if completed succesfully, False otherwise. 00359 Purpose: Removes all hidden items, i.e. ones not added by the user, from the list 00360 of pathnames. 00361 00362 **************************************************************************************/ 00363 00364 BOOL PlugInPathList::RemoveHiddenItems() 00365 { 00366 // Go through all the paths in the list and remove all those with the hidden 00367 // attribute set. 00368 PlugInPath* pPath = (PlugInPath *)GetHead(); 00369 while (pPath) 00370 { 00371 if (pPath->IsHidden()) 00372 { 00373 // The item is hidden so remove it 00374 // First, find the next item, if there is one 00375 PlugInPath* pNextPath = (PlugInPath *)GetNext(pPath); 00376 00377 RemoveItem(pPath); 00378 // remove item returns NULL if problem 00379 if (pPath == NULL) 00380 return FALSE; 00381 00382 // remove the old path item from memory 00383 delete pPath; 00384 // move to considering the next item 00385 pPath = pNextPath; 00386 } 00387 else 00388 { 00389 // Try the next pathname in the list 00390 pPath = (PlugInPath *)GetNext(pPath); 00391 } 00392 } 00393 00394 return TRUE; 00395 } 00396 00397 /************************************************************************************** 00398 00399 > PlugInPath * PlugInPathList::AddPathName( const PathName& NewPath, BOOL IsHidden = FALSE) 00400 00401 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00402 Created: 9/12/96 00403 Inputs: NewPath - the new pathname to put in the list. 00404 IsHidden - the pathname is not one added by the user (Defaults to FALSE) 00405 Returns: Pointer to the newly added pathname, or 00406 NULL if out of memory => ERROR1 00407 Purpose: Add a new pathname to the list of plug-in pathnames. 00408 Hidden pathnames are ones not added by the user but are the sub-directories 00409 of the user added ones. 00410 Errors: Out of memory => ERROR1 00411 SeeAlso: PlugInPath 00412 00413 **************************************************************************************/ 00414 00415 PlugInPath * PlugInPathList::AddPathName( const PathName& NewPath, BOOL IsHidden ) 00416 { 00417 PlugInPath *pPlugPath = new PlugInPath(NewPath, m_IDCounter, IsHidden); 00418 00419 // Increment our counter which a plug-in uses to associate itself with a pathname 00420 m_IDCounter++; 00421 00422 // Check for out of memory 00423 if (pPlugPath == NULL) 00424 return NULL; 00425 00426 // Add to the list and return success 00427 AddTail(pPlugPath); 00428 return pPlugPath; 00429 } 00430 00431 /************************************************************************************** 00432 00433 > BOOL PlugInPathList::DeletePathName( const PathName& OldPath) 00434 00435 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00436 Created: 9/12/96 00437 Inputs: OldPath - the pathname to delete from the list. 00438 Returns: True if deleted ok, False otherwise. 00439 Purpose: Delete a pathname from the list of plug-in pathnames. 00440 SeeAlso: PlugInPath 00441 00442 **************************************************************************************/ 00443 00444 BOOL PlugInPathList::DeletePathName( const PathName& OldPath ) 00445 { 00446 String_256 OldPathStr = OldPath.GetPath(); 00447 PlugInPath* pPath = (PlugInPath *)GetHead(); 00448 while (pPath) 00449 { 00450 PathName Path = pPath->GetPathName(); 00451 if (Path.GetPath() == OldPathStr) 00452 { 00453 RemoveItem(pPath); 00454 // remove item returns NULL if problem 00455 if (pPath == NULL) 00456 return FALSE; 00457 delete pPath; 00458 return TRUE; 00459 } 00460 00461 // Try the next pathname in the list 00462 pPath = (PlugInPath *)GetNext(pPath); 00463 } 00464 00465 // Failed to find the path in the list 00466 return FALSE; 00467 } 00468 00469 /************************************************************************************** 00470 **************************************************************************************/ 00471