impbmp.cpp

Go to the documentation of this file.
00001 // $Id: impbmp.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 // Encapsulates a set of bitmaps exported to a file.
00100 
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 #include "impbmp.h"
00107 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 
00109 DECLARE_SOURCE("$Revision: 1282 $");
00110 
00111 CC_IMPLEMENT_MEMDUMP(ImportBitmap, ListItem)
00112 CC_IMPLEMENT_MEMDUMP(ImportBitmapList, List)
00113 CC_IMPLEMENT_MEMDUMP(ImportedBitmaps, CCObject)
00114 
00115 // Declare smart memory handling in Debug builds
00116 #define new CAM_DEBUG_NEW
00117 
00118 /********************************************************************************************
00119 
00120 >   ImportBitmap::ImportBitmap(KernelBitmap *pNewCol, INT32 NewRecordNumber)
00121 
00122     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00123     Created:    11/6/96
00124     Inputs:     pNewBmp         - the Bitmap to put in the list.
00125                 RecordNumber    - the number of the record that this Bitmap definition has been
00126                                   saved in.
00127     Purpose:    Create a new export Bitmap list item from the given indexed Bitmap.
00128     SeeAlso:    ImportBitmapList;
00129 
00130 ********************************************************************************************/
00131 
00132 ImportBitmap::ImportBitmap(KernelBitmap *pNewBmp, INT32 NewRecordNumber)
00133 {
00134     // Initialise our class variables to these specified values.
00135     pBmp = pNewBmp;
00136     RecordNumber = NewRecordNumber;
00137 }
00138 
00139 /********************************************************************************************
00140 
00141 >   ImportBitmapList::~ImportBitmapList()
00142 
00143     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00144     Created:    11/6/96
00145     Inputs:     -
00146     Outputs:    -
00147     Returns:    -
00148     Purpose:    Destroy the list of exported Bitmaps.
00149     SeeAlso:    ImportedBitmaps
00150 
00151 ********************************************************************************************/
00152 
00153 ImportBitmapList::~ImportBitmapList()
00154 {
00155     // Destroy the list of Bitmaps which we may have
00156     //ImportBitmap* pExportedBitmap = (ImportBitmap *)GetHead();
00157     //while (pExportedBitmap)
00158     //{
00159     //  delete pExportedBitmap;
00160 
00161         // Try the next Bitmap in the list
00162 //      pExportedBitmap = (ImportBitmap *)Bitmaps.GetNext(pExportedBitmap);
00163 //  }
00164     
00165     DeleteAll();
00166 }
00167 
00168 /********************************************************************************************
00169 
00170 >   ImportBitmap *ImportBitmapList::AddBitmap(KernelBitmap *pBmp, INT32 NewRecordNumber)
00171 
00172     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00173     Created:    11/6/96
00174     Inputs:     pNewBmp         - the Bitmap to put in the list.
00175                 RecordNumber    - the number of the record that this Bitmap definition has been
00176                                   saved in.
00177     Returns:    Pointer to the newly added Bitmap, or 
00178                 NULL if out of memory => ERROR1
00179     Purpose:    Add a new Bitmap to the list of exported Bitmaps.
00180     Errors:     Out of memory => ERROR1
00181     SeeAlso:    ImportBitmap
00182 
00183 ********************************************************************************************/
00184 
00185 ImportBitmap *ImportBitmapList::AddBitmap(KernelBitmap *pBmp, INT32 NewRecordNumber)
00186 {
00187     ImportBitmap *pNewBmp = new ImportBitmap(pBmp, NewRecordNumber);
00188 
00189     // Check for out of memory
00190     if (pNewBmp == NULL)
00191         return NULL;
00192 
00193     // Add to the list and return success
00194     AddTail(pNewBmp);
00195     return pNewBmp;
00196 }
00197 
00198 /********************************************************************************************
00199 
00200 >   ImportedBitmaps::ImportedBitmaps()
00201 
00202     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00203     Created:    23/5/96
00204     Inputs:     -
00205     Outputs:    -
00206     Returns:    -
00207     Purpose:    Construct the class which encapsulates a list of exported Bitmaps.
00208     SeeAlso:    ImportedBitmaps
00209 
00210 ********************************************************************************************/
00211 
00212 ImportedBitmaps::ImportedBitmaps()
00213 {
00214 }
00215 
00216 /********************************************************************************************
00217 
00218 >   ImportedBitmaps::~ImportedBitmaps()
00219 
00220     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00221     Created:    11/6/96
00222     Inputs:     -
00223     Outputs:    -
00224     Returns:    -
00225     Purpose:    Destroy the class which encapsulates a list of exported Bitmaps.
00226     SeeAlso:    ImportedBitmaps
00227 
00228 ********************************************************************************************/
00229 
00230 ImportedBitmaps::~ImportedBitmaps()
00231 {
00232     // Delete all the bitmaps in the list, as copies will have been made to
00233     // put in the tree
00234 
00235     ImportBitmap* pBitmap = (ImportBitmap *)Bitmaps.GetHead();
00236     while (pBitmap != NULL)
00237     {
00238         if (pBitmap->pBmp &&
00239             pBitmap->pBmp->GetParentBitmapList() == NULL)
00240         {
00241             // Only delete the bitmap if it has a NULL parent bitmap list,
00242             // because otherwise it means they are being used
00243             delete pBitmap->pBmp;
00244         }
00245 
00246         // Try the next Bitmap in the list
00247         pBitmap = (ImportBitmap *)Bitmaps.GetNext(pBitmap);
00248     }
00249 
00250 }
00251 
00252 /********************************************************************************************
00253 
00254 >   BOOL ImportedBitmaps::AddBitmap(KernelBitmap *pBmp, INT32 RecordNumber)
00255 
00256     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00257     Created:    11/6/96
00258     Inputs:     pNewBmp         - the Bitmap to put in the list.
00259                 RecordNumber    - the number of the record that this Bitmap definition has been
00260                                   saved in.
00261     Returns:    TRUE if the Bitmap could be added;
00262                 FALSE if not
00263     Purpose:    Add the specified Bitmap to the list of already exported Bitmaps.
00264     Errors:     -
00265     SeeAlso:    ImportBitmapList;
00266 
00267 ********************************************************************************************/
00268 
00269 BOOL ImportedBitmaps::AddBitmap(KernelBitmap *pBmp, INT32 RecordNumber)
00270 {
00271     // Add the Bitmap onto our list
00272     ImportBitmap * pNewBmp = Bitmaps.AddBitmap(pBmp, RecordNumber);
00273     if (pNewBmp)
00274         return TRUE;
00275     
00276     return FALSE;
00277 }
00278 
00279 /********************************************************************************************
00280 
00281 >   KernelBitmap *ImportedBitmaps::GetBitmap(INT32 ReqRecordNumber)
00282 
00283     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00284     Created:    11/6/96
00285     Inputs:     ReqRecordNumber - the record number to search the list for
00286     Returns:    Pointer to the KernelBitmap if successful;
00287                 NULL if not found.
00288     Purpose:    Searches for a previously imported bitmap definition. Used by the native/web
00289                 filter to convert a bitmap reference in a record to an KernelBitmap. This
00290                 must have already been imported in the file as the rule is that reference to
00291                 bitmaps can only be made if the bitmap definition has already been output.
00292     Errors:     -
00293     SeeAlso:    ImportedBitmaps; BitmapListComponent;
00294 
00295 ********************************************************************************************/
00296 
00297 KernelBitmap *ImportedBitmaps::GetBitmap(INT32 ReqRecordNumber)
00298 {
00299     // Work our way through the list of imported bitmaps until we find the required record number
00300     ImportBitmap* pBitmap = (ImportBitmap *)Bitmaps.GetHead();
00301     while (pBitmap != NULL)
00302     {
00303         if (pBitmap->RecordNumber == ReqRecordNumber)
00304             return pBitmap->pBmp;
00305 
00306         // Try the next Bitmap in the list
00307         pBitmap = (ImportBitmap *)Bitmaps.GetNext(pBitmap);
00308     }
00309 
00310     // Something went a bit wrong and we didn't find the requested record number
00311     // return NULL to the caller 
00312     return NULL;
00313 }
00314 

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