bmpseq.cpp

Go to the documentation of this file.
00001 // $Id: bmpseq.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 
00100 
00101 #include "camtypes.h"
00102 #include "bmpseq.h"
00103 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "bmpcomp.h"
00106 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 
00108 
00109 // Place any IMPLEMENT type statements here
00110 CC_IMPLEMENT_MEMDUMP(BitmapSequenceInfo, CC_CLASS_MEMDUMP)
00111 CC_IMPLEMENT_MEMDUMP(BitmapSequence, CC_CLASS_MEMDUMP)
00112 
00113 
00114 // We want better memory tracking
00115 #define new CAM_DEBUG_NEW
00116 
00117 //#define DECLARE_PROCEDURE(p)      #define CURRENT_PROCEDURE_NAME  #p
00118 //#define DECLARE_PROCEDURE_END(p)  #undef CURRENT_PROCEDURE_NAME
00119 #define CURRENT_PROCEDURE_NAME          "bmpseq.cpp"
00120 
00121 #define ERROR2_CLASS(arg, classname)    ERROR2IF(arg == NULL || !arg->IS_KIND_OF(classname),    \
00122                                         FALSE, #arg " isn't");
00123 #define ERROR3IF_NOT_CLASS(arg, classname)      ERROR3IF(arg != NULL && \
00124                                                 !arg->IS_KIND_OF(classname), \
00125                                                 CURRENT_PROCEDURE_NAME " - " #arg " isn't");
00126 
00127 #define ERROR3IF_NULL_CLASS(arg, classname)     ERROR3IF(arg == NULL || \
00128                                                 !arg->IS_KIND_OF(classname), \
00129                                                 CURRENT_PROCEDURE_NAME " - " #arg " isn't");
00130 
00131 // Functions follow
00132 /********************************************************************************************
00133 
00134 >   void BitmapSequence::DeleteAll()
00135 
00136     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00137     Created:    09/07/96
00138     Purpose:    Deletes all the KernelBitmaps in the sequence
00139 
00140 ********************************************************************************************/
00141 void BitmapSequence::DeleteAll()
00142 {
00143     Bitmaps.DeleteAll();
00144 }
00145 
00146 
00147 /********************************************************************************************
00148 
00149 >   BOOL BitmapSequence::CopyFromDocumentList(Document* pDocument, const KernelBitmap* pStartBitmap, const UINT32 uNumberToCopy)
00150 
00151     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00152     Created:    09/07/96
00153     Inputs:     pDocument - the document to copy from
00154                 pStartBitmap - a pointer to a KernelBitmap in the document's bitmap list
00155                 providing a starting point from which to copy. 
00156                 uNumberToCopy - the number of bitmaps to copy
00157     Purpose:    Copies a sequence of bitmaps from the given document's bitmap list into
00158                 this BitmapSequence.
00159 
00160 ********************************************************************************************/
00161 BOOL BitmapSequence::CopyFromDocumentList(Document* pDocument, const KernelBitmap* pStartBitmap, const UINT32 uNumberToCopy)
00162 {
00163     if (pDocument == NULL)
00164     {
00165         pDocument = Document::GetSelected();
00166     }
00167     ERROR2IF(pDocument == NULL, FALSE, "pDocument == NULL")
00168     // The bitmap system relies on the Current Doc being correct,
00169     // so we'll set it to be on the safe side
00170     pDocument->SetCurrent();
00171 
00172     // Find this document's BitmapListComponent
00173     DocComponent* pDocBitmapList = pDocument->GetDocComponent(CC_RUNTIME_CLASS(BitmapListComponent));
00174     ERROR2IF(pDocBitmapList == NULL, FALSE, "Couldn't find document bitmap list");
00175 
00176     // Now get the actual bitmap list
00177     BitmapList* pBmpList = ((BitmapListComponent*)pDocBitmapList)->GetBitmapList();
00178 
00179     ListItem* pItem = (ListItem*)pStartBitmap;
00180     UINT32 uCurrentIndex = 1;
00181 
00182     while (uCurrentIndex <= uNumberToCopy)
00183     {
00184         KernelBitmap* pBmp = (KernelBitmap*)pItem;
00185         ERROR3IF_NULL_CLASS(pBmp, KernelBitmap);
00186 
00187         if (!AddBitmap(pBmp, INT32(uCurrentIndex)))
00188         {
00189             return FALSE;
00190         }
00191 
00192         pItem = pBmpList->GetNext(pItem);
00193         ++uCurrentIndex;
00194     }
00195     return TRUE;
00196 }
00197 
00198 
00199 /********************************************************************************************
00200 
00201 >   KernelBitmap* FindBitmap(const List* const pBitmapList, const KernelBitmap* const pStart, 
00202                 const KernelBitmap* const pBitmap)
00203 
00204     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00205     Created:    09/07/96
00206     Inputs:     pList - the list in which pListItem is
00207                 pListItem - the list item from which we wish to find the offset
00208                 uOffset - the number of the item further along the list which we wish to
00209                 retrieve
00210     Returns:    A pointer to the desired list item
00211                 NULL if gone off the end
00212     Purpose:    Finds the ListItem as the position uOffset items further down the list from
00213                 pListItem.
00214 
00215 ********************************************************************************************/
00216 KernelBitmap* FindBitmap(const List* const pBitmapList, const KernelBitmap* const pStart, 
00217                 const KernelBitmap* const pBitmap)
00218 {
00219     ERROR3IF_NULL_CLASS(pBitmap, KernelBitmap);
00220 
00221     if (pBitmapList == NULL)
00222     {
00223         return NULL;
00224     }
00225     const ListItem* pItem = pStart;
00226     const OILBitmap* pOILBmp = pBitmap->ActualBitmap;
00227 
00228     while (pItem != NULL)
00229     {
00230         KernelBitmap* pBmp = (KernelBitmap*)pItem;
00231         ERROR3IF_NOT_CLASS(pBmp, KernelBitmap);
00232 
00233         if (pBmp->ActualBitmap == pOILBmp || *pBmp->ActualBitmap == *pOILBmp)
00234         {
00235             return pBmp;
00236         }
00237         pItem = pBitmapList->GetNext(pItem);
00238     }
00239     return NULL;
00240 }
00241 
00242 
00243 /********************************************************************************************
00244 
00245 >   const ListItem* FindOffsetItem(const List* pList, const ListItem* pListItem, UINT32 uOffset)
00246 
00247     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00248     Created:    09/07/96
00249     Inputs:     pList - the list in which pListItem is
00250                 pListItem - the list item from which we wish to find the offset
00251                 uOffset - the number of the item further along the list which we wish to
00252                 retrieve
00253     Returns:    A pointer to the desired list item
00254                 NULL if gone off the end
00255     Purpose:    Finds the ListItem as the position uOffset items further down the list from
00256                 pListItem. Used by the search FindBitmapSubstring()
00257 
00258 ********************************************************************************************/
00259 const ListItem* FindOffsetItem(const List* pList, const ListItem* pListItem, UINT32 uOffset)
00260 {
00261     while (uOffset > 0 && pListItem != NULL)
00262     {
00263         pListItem = pList->GetNext(pListItem);
00264         --uOffset;
00265     }
00266     return pListItem;
00267 }
00268 
00269 
00270 /********************************************************************************************
00271 
00272 >   KernelBitmap* FindBitmapSubstring(List* pMainList, List* pSubList, 
00273                 const ListItem* pFirstMain, const ListItem* const pFirstSub,
00274                 const INT32 nSubLength)
00275 
00276     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00277     Created:    09/07/96
00278     Inputs:     pMainList - the KernelBitmap list in which we wish to find pSubList
00279                 pSubList - the KernelBitmap list we wish to find
00280                 pFirstMain - the KernelBitmap in pMainList from which we wish
00281                 to start searching
00282                 pFirstSub - the KernelBitmap in pSubList from which we wish to start
00283                 matching
00284     Purpose:    This is used internally by FindBitmapSubstring(...3 arguments...).
00285                 Call that instead.
00286     Notes:      Implements some well known string search algorithm whose name I can't
00287                 remember. Basically, it looks at the end of the search string for a match
00288                 and moves along in chunks if it can get away with it. Here it is from the STL
00289 
00290                 template <class charT>
00291                 size_t
00292                 basic_string<charT>::find (const basic_string<charT>& str, size_t pos) const
00293                                                                         _THROW_NONE
00294                 {
00295                     return find_str (str.data(), pos, str.length());
00296                 }
00297                 
00298                 /*template <class charT>
00299                 size_t
00300                 basic_string<charT>::find_str (const charT* s, size_t pos, size_t len) 
00301                                                const _THROW_NONE
00302                 {
00303                     size_t  count = pos;
00304                     size_t  shift;
00305                     size_t  place;
00306                     if ((length() == 0) || (len == 0))
00307                         return NPOS;
00308                     while (len <= (length()-count))
00309                     {
00310                         for (place = 0; place < len; ++place)
00311                         {
00312                             if (baggage_type::ne(   *(s+len-1-place),
00313                                                     *(data()+count+(len-1-place)))
00314                                                 )
00315                                 break;
00316                         }
00317                         if (place == len)
00318                             return count;
00319                         shift = find(*(s+len-1-place), count+(len-place));
00320                         if (shift == NPOS)
00321                             return NPOS;
00322                         count = shift-(len-place-1);
00323                     }
00324                     return NPOS;
00325 
00326 ********************************************************************************************/
00327 KernelBitmap* FindBitmapSubstring(List* pMainList, List* pSubList, 
00328                 const ListItem* pFirstMain, const ListItem* const pFirstSub,
00329                 const INT32 nSubLength)
00330 {
00331     ERROR3IF_NOT_CLASS(pMainList, List);
00332     ERROR3IF_NOT_CLASS(pSubList, List);
00333 
00334     if (pFirstMain == NULL || pFirstSub == NULL)
00335         return NULL;
00336 
00337     ERROR3IF_NOT_CLASS(pFirstMain, KernelBitmap);
00338     ERROR3IF_NOT_CLASS(pFirstSub, ImportBitmap);
00339 
00340     if (nSubLength <= 0)
00341     {
00342         ERROR3("FindBitmapSubstring - nSubLength <= 0");
00343         return NULL;
00344     }
00345     const ListItem* pCurrentMain = FindOffsetItem(pMainList, pFirstMain, nSubLength - 1);
00346     const ListItem* pCurrentSub;
00347     const ListItem* pLastSub = pSubList->GetTail();
00348     ERROR3IF(pLastSub == NULL, "FindBitmapSubstring - pLastSub == NULL");
00349 
00350     while (pCurrentMain != NULL)
00351     {
00352         pCurrentSub = pLastSub;
00353         INT32 nCurrentSubLength = 1;        // set as the new length of the substring to check
00354         while (nCurrentSubLength <= nSubLength)
00355         {
00356             KernelBitmap* pMainKernel = (KernelBitmap*)pCurrentMain;
00357             OILBitmap* pExistingOIL = pMainKernel->ActualBitmap;
00358             ERROR3IF_NULL_CLASS(pExistingOIL, OILBitmap);
00359             
00360             KernelBitmap* pSubKernel = ((ImportBitmap*)pCurrentSub)->pBmp;
00361             OILBitmap* pSubOIL = pSubKernel->ActualBitmap;
00362             ERROR3IF_NULL_CLASS(pSubOIL, OILBitmap);
00363 
00364             if (pExistingOIL != pSubOIL && !(*pExistingOIL == *pSubOIL))
00365                 break;
00366 
00367             pCurrentMain = pMainList->GetPrev(pCurrentMain);
00368             pCurrentSub = pSubList->GetPrev(pCurrentSub);
00369             ++nCurrentSubLength;
00370         }
00371 
00372         if (pCurrentSub == pSubList->GetPrev(pFirstSub))        // found the whole sub-list
00373         {
00374             return (KernelBitmap*)pCurrentMain;
00375         }
00376 
00377         // failed to find all the items in SubList so look for the sub-sublist where the
00378         // disparity was, starting at the next item in the main list.
00379         pCurrentMain = FindBitmapSubstring( pMainList, pSubList, 
00380                                 pMainList->GetNext(pCurrentMain), pCurrentSub, 
00381                                 nCurrentSubLength);
00382         if (pCurrentMain == NULL)
00383         {
00384             return NULL;
00385         }
00386         pCurrentMain = pMainList->GetPrev(pCurrentMain);
00387         pLastSub = pSubList->GetPrev(pCurrentSub);
00388     }
00389     return NULL;
00390 }
00391 
00392 
00393 /*
00394 INT32 FindSubString(INT32* pMainList, INT32* pSubList, const INT32 pFirstMain, INT32 pFirstSub, INT32 nSubLength)
00395 {
00396     if (pMainList[pFirstMain] == NULL)
00397         return 0;
00398 
00399     INT32 pLastMain = FindOffsetItem(pMainList, pFirstMain, nSubLength - 1);
00400     
00401     INT32 pLastSub = sizeof(search) / sizeof(INT32) - 2;
00402     while (1)
00403     {
00404         INT32 pCurrentMain = pLastMain;
00405         INT32 pCurrentSub = pLastSub;
00406         INT32 nCurrentSubLength = 1;
00407         while (nCurrentSubLength <= nSubLength)
00408         {
00409             if (pMainList[pCurrentMain] != pSubList[pCurrentSub])
00410                 break;
00411             --pCurrentMain;
00412             --pCurrentSub;
00413             ++nCurrentSubLength;
00414         }
00415         if (nCurrentSubLength > nSubLength)
00416         {
00417             return (pCurrentMain + 1);
00418         }
00419         INT32 pFoundMain = FindSubString(pMainList, pSubList, (pCurrentMain + 1), pCurrentSub, nCurrentSubLength);
00420         if (pFoundMain == NULL)
00421             return 0;
00422         pLastMain = pFoundMain;
00423 //      pLastSub = pCurrentSub;
00424     }
00425     return NULL;
00426 }
00427 
00428 INT32 Find(INT32* pMainList, const INT32 pFirstMain, const INT32 item)
00429 {
00430     INT32 pCurrent = pFirstMain;
00431     while (pMainList[pCurrent] != NULL)
00432     {
00433         if (item == pMainList[pCurrent])
00434         {
00435             return pCurrent;
00436         }
00437         ++pCurrent;
00438     }
00439     return NULL;
00440 }
00441 
00442 
00443 
00444 INT32 FindSubString(INT32* pMainList, INT32* pSubList, const INT32 pFirstMain)
00445 {
00446     return FindSubString(array, search, 1, 1, 3);
00447 }
00448 */
00449 
00450 /********************************************************************************************
00451 
00452 >   KernelBitmap* FindBitmapSubstring(List* pMainList, List* pSubList, 
00453                     ListItem* pFirstMain)
00454 
00455     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00456     Created:    09/07/96
00457     Inputs:     pMainList - the KernelBitmap list in which we wish to find pSubList
00458                 pSubList - the KernelBitmap list we wish to find
00459                 pFirstMain - the KernelBitmap in pMainList from which we wish
00460                 to start searching
00461     Returns:    A pointer to the first KernelBitmap in pMainList where the matched
00462                 sequence starts.
00463                 NULL if pSubList wasn't found
00464     Purpose:    Searches for a sequence (string) of bitmaps.
00465 
00466 ********************************************************************************************/
00467 KernelBitmap* FindBitmapSubstring(List* pMainList, List* pSubList, ListItem* pFirstMain)
00468 {
00469     return (FindBitmapSubstring(pMainList, pSubList, pFirstMain, pSubList->GetHead(), 
00470                                 pSubList->GetCount()));
00471 }
00472 
00473 
00474 /********************************************************************************************
00475 
00476 >   KernelBitmap* FindSimple(List* pMainList, List* pSubList, 
00477                             const ListItem* const pFirstMain)
00478 
00479     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00480     Created:    09/07/96
00481     Inputs:     pMainList - the KernelBitmap list in which we wish to find pSubList
00482                 pSubList - the KernelBitmap list we wish to find
00483                 pFirstMain - the KernelBitmap in pMainList from which we wish
00484                 to start searching
00485     Returns:    A pointer to the first KernelBitmap in pMainList where the matched
00486                 sequence starts.
00487                 NULL if pSubList wasn't found
00488     Purpose:    Searches for a sequence (string) of bitmaps. This may be faster than the
00489                 supposedly fast and complicated FindBitmapSubstring(). It was when I
00490                 profiled it.
00491 
00492 ********************************************************************************************/
00493 KernelBitmap* FindSimple(List* pMainList, List* pSubList, const ListItem* const pFirstMain)
00494 {
00495     ERROR2IF(pMainList == NULL, NULL, "pMainList == NULL");
00496     ERROR2IF(pSubList == NULL, NULL, "pSubList == NULL");
00497     ERROR2IF(pFirstMain == NULL, NULL, "pFirstMain == NULL");
00498 
00499     // Is the list we're looking for empty or longer than the list we're looking in?
00500     UINT32 uSubListLen = pSubList->GetCount();
00501     if (uSubListLen == 0 || uSubListLen > pMainList->GetCount())
00502     {
00503         return NULL;
00504     }
00505 
00506     // ...No. So go through the main list looking for the first item in our search list
00507     // and each time we find it check subsequent items in the main list for a match with
00508     // those remaining in our search list. If we found them all that's it, otherwise
00509     // continue looking for the first item in the main list.
00510 
00511     const ListItem* pStartMain = pFirstMain;
00512     const ListItem* const pFirstSub = pSubList->GetHead();
00513     for (;;)    // ever
00514     {
00515         // Find the first item of the sublist in the main list
00516         const ListItem* pFound = (ListItem*)FindBitmap(pMainList, (KernelBitmap*)pStartMain, 
00517                                                     ((ImportBitmap*)pFirstSub)->pBmp);
00518         if (pFound == NULL)     // the first search item isn't in the main list at all
00519         {
00520             return NULL;
00521         }
00522 
00523         const ListItem* pCurrentMain = pMainList->GetNext(pFound);
00524         const ListItem* pCurrentSub = pSubList->GetNext(pFirstSub);
00525         while (pCurrentSub != NULL)
00526         {
00527             ERROR3IF(pCurrentMain == NULL, "pCurrentMain == NULL");
00528 
00529             KernelBitmap* pMainKernel = (KernelBitmap*)pCurrentMain;
00530             OILBitmap* pExistingOIL = pMainKernel->ActualBitmap;
00531             ERROR3IF_NULL_CLASS(pExistingOIL, OILBitmap);
00532             
00533             KernelBitmap* pSubKernel = ((ImportBitmap*)pCurrentSub)->pBmp;
00534             OILBitmap* pSubOIL = pSubKernel->ActualBitmap;
00535             ERROR3IF_NULL_CLASS(pSubOIL, OILBitmap);
00536 
00537             if (pExistingOIL != pSubOIL && !(*pExistingOIL == *pSubOIL))
00538                 break;
00539 
00540             pCurrentMain = pMainList->GetNext(pCurrentMain);
00541             pCurrentSub = pSubList->GetNext(pCurrentSub);
00542         }
00543         
00544         if (pCurrentSub == NULL)        // we reached the end of our search list. All done.
00545         {
00546             return (KernelBitmap*)pFound;
00547         }
00548 
00549         // We didn't manage to find the whole search list, so go back looking for the
00550         // first item in the search list starting at the next item in the main list
00551         pStartMain = pMainList->GetNext(pStartMain);
00552     }
00553 }
00554 
00555 /********************************************************************************************
00556 
00557 >   BitmapSequenceInfo* BitmapSequence::GetSequenceInfo() const
00558 
00559     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00560     Created:    09/07/96
00561     Returns:    The BitmapSequenceInfo for this BitmapSequence
00562     Purpose:    Er...
00563 
00564 ********************************************************************************************/
00565 BitmapSequenceInfo* BitmapSequence::GetSequenceInfo() const
00566 {
00567     return m_pSequenceInfo;
00568 }
00569 
00570 
00571 /********************************************************************************************
00572 
00573 >   BOOL BitmapSequence::SetSequenceInfo(BitmapSequenceInfo* pNewInfo)
00574 
00575     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00576     Created:    09/07/96
00577     Inputs:     pNewInfo - a pointer
00578     Returns:    TRUE if set OK
00579                 FALSE otherwise
00580     Errors:     ERROR3's for invalid args
00581     Purpose:    To allow for future extensions
00582 
00583 ********************************************************************************************/
00584 BOOL BitmapSequence::SetSequenceInfo(BitmapSequenceInfo* pNewInfo)
00585 {
00586     ERROR3IF(pNewInfo != NULL && !pNewInfo->IS_KIND_OF(BitmapSequenceInfo), 
00587                 "BitmapSequence::SetSequenceInfo - pNewInfo isn't");
00588 
00589     m_pSequenceInfo = pNewInfo;
00590     return TRUE;
00591 }
00592 
00593 
00594 /********************************************************************************************
00595 
00596 >   UINT32 BitmapSequence::GetCount() const
00597 
00598     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00599     Created:    09/07/96
00600     Returns:    The number of bitmaps in this BitmapSequence
00601     Purpose:    You would probably want to know this
00602 
00603 ********************************************************************************************/
00604 UINT32 BitmapSequence::GetCount() const
00605 {   
00606     return Bitmaps.GetCount();
00607 }
00608 
00609 
00610 
00611 
00612 /********************************************************************************************
00613 
00614 >   KernelBitmap* BitmapSequence::FindInDocumentList(Document* pImportDocument)
00615 
00616     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00617     Created:    09/07/96
00618     Inputs:     pImportDocument - the document in which to search for this BitmapSequence
00619     Returns:    A pointer to the first KernelBitmap in pMainList where the matched
00620                 sequence starts.
00621                 NULL if pSubList wasn't found
00622     Purpose:    Searches for this BitmapSequence in pImportDocument's bitmap list
00623 
00624 ********************************************************************************************/
00625 KernelBitmap* BitmapSequence::FindInDocumentList(Document* pImportDocument)
00626 {
00627     ERROR2IF(pImportDocument == NULL, FALSE, "pImportDocument NULL");
00628     ERROR3IF(!pImportDocument->IS_KIND_OF(Document), "BitmapSequence::FindInDocumentList - pImportDocument isn't");
00629 
00630     // First we need to look at the Bitmap List in the document we are Importing
00631     // into, and if we find a KernelBitmap that points at a bitmap the same as the
00632     // one we have imported, then we'll just use that.
00633 
00634     // The bitmap system relies on the Current Doc being correct,
00635     // so we'll set it to be on the safe side
00636     pImportDocument->SetCurrent();
00637 
00638     // Find this document's BitmapListComponent
00639     DocComponent* pDocBitmapList = 
00640                         pImportDocument->GetDocComponent(CC_RUNTIME_CLASS(BitmapListComponent));
00641     ERROR2IF(pDocBitmapList == NULL, FALSE, "Couldn't find document bitmap list");
00642     List* pMainList = (List*)((BitmapListComponent*)pDocBitmapList)->GetBitmapList();
00643 
00644     KernelBitmap* pFound;       // the first item in the document list for the match
00645     // if there's only one bitmap do a simple search for it...
00646 /*  if (GetCount() == 1)
00647     {
00648         KernelBitmap* pStart = (KernelBitmap*)pMainList->GetHead();
00649         KernelBitmap* pBitmap = ((ImportBitmap*)((List*)&Bitmaps)->GetHead())->pBmp;
00650         pFound = FindBitmap(pMainList, pStart, pBitmap);
00651     }
00652     else        // do a hideous search
00653     {*/
00654         ListItem* pFirstMain = (ListItem*)pMainList->GetHead();
00655         List* pNewBitmaps = (List*)&Bitmaps;
00656         pFound = FindSimple(pMainList, pNewBitmaps, pFirstMain);
00657 //  }
00658 
00659     return pFound;
00660 }
00661 
00662 
00663 

Generated on Sat Nov 10 03:44:30 2007 for Camelot by  doxygen 1.4.4