#include <bmplist.h>
Inheritance diagram for GlobalBitmapList:
Public Member Functions | |
GlobalBitmapList () | |
GlobalBitmapList constructor. | |
~GlobalBitmapList () | |
GlobalBitmapList destructor. | |
BOOL | AddItem (OILBitmap *NewBitmap) |
Adds an item to the tail of the GlobalBitmaplist. | |
void | MakeNameUnique (String_256 *) |
Ensures a bitmap name is unique. | |
ListItem * | GetFirstBitmapName (String_256 *) |
Find the names of the bitmaps in the list. | |
ListItem * | GetNextBitmapName (ListItem *, String_256 *) |
Find the names of the bitmaps in the list. | |
OILBitmap * | GetBitmapFromName (String_256 *) |
Finds a bitmap with a particular name. | |
OILBitmap * | FindDuplicateBitmap (OILBitmap *pBitmap) |
Looks to see if an identical bitmap is already in the bitmap list. | |
void | DeleteAllUnusedBitmaps () |
Called when a document is deleted, to delete all the unused bitmaps. | |
BOOL | IsBitmapOnClipBoard (OILBitmap *pOILBmp) |
Check to see if a bitmap is used on the clipboard. | |
BOOL | IsUsedInDocument (Document *pDoc, OILBitmap *pOILBmp) |
Checks if the specified OIL bitmap is in the bitmap list of the specified document. | |
INT32 | GetDocumentBitmapCount (Document *pDoc) |
Find how many bitmaps are being used by this document. | |
INT32 | GetDocumentBitmapSize (Document *pDoc) |
Find the total size of the bitmaps being used by this document. | |
Static Public Member Functions | |
static BOOL | Init () |
Initialise the GlobalBitmapList. | |
static BOOL | DeInit () |
DeInitialise the GlobalBitmapList. |
Definition at line 185 of file bmplist.h.
|
GlobalBitmapList constructor.
Definition at line 161 of file bmplist.cpp.
|
|
GlobalBitmapList destructor.
Definition at line 178 of file bmplist.cpp.
|
|
Adds an item to the tail of the GlobalBitmaplist.
Definition at line 260 of file bmplist.cpp. 00261 { 00262 ERROR3IF(Item == NULL, "Trying to add NULL item to Global Bitmap List"); 00263 00264 if (Item == NULL) 00265 return FALSE; 00266 00267 // Is this Bitmap already in the list ? 00268 LISTPOS pos = FindPosition((ListItem*)Item); 00269 00270 if (pos == NOT_IN_LIST || pos == EMPTY_LIST) 00271 { 00272 // It's not in the list yet, so add it on the end 00273 AddTail((ListItem*)Item); 00274 return TRUE; 00275 } 00276 else 00277 { 00278 // It's already in the list, so just return 00279 return FALSE; 00280 } 00281 }
|
|
DeInitialise the GlobalBitmapList.
Definition at line 215 of file bmplist.cpp. 00216 { 00217 // First deinit the global bitmap list 00218 GlobalBitmapList* pBmpList = GetApplication()->GetGlobalBitmapList(); 00219 00220 ListItem* pItem = pBmpList->GetHead(); 00221 00222 while (pItem != NULL) 00223 { 00224 ListItem* pNext = pBmpList->GetNext(pItem); 00225 00226 OILBitmap* pBitmap = (OILBitmap*)pItem; 00227 00228 ERROR3IF(pBitmap->IsTemp(), "Warning. Found temp bitmap in global bitmap list"); 00229 00230 if (pBitmap == OILBitmap::Default) 00231 { 00232 // Don't delete the default bitmap, just remove it from the list 00233 pBitmap->RemoveFromGlobalList(); 00234 } 00235 else 00236 { 00237 delete pBitmap; // This will remove it from the list before deleting it 00238 } 00239 00240 pItem = pNext; 00241 } 00242 00243 // Now deinit the greyscale bitmap list 00244 // GreyscaleBitmapList::DeInit(); 00245 00246 return TRUE; 00247 }
|
|
Called when a document is deleted, to delete all the unused bitmaps.
Definition at line 609 of file bmplist.cpp. 00610 { 00611 InternalClipboard::AttrsHaveChanged(); 00612 // As we now have two clipboards, we need to sort out both 00613 InternalClipboard::Swap(); // Swap to alternative clipboard 00614 InternalClipboard::AttrsHaveChanged(); 00615 InternalClipboard::Swap(); // Swap back to orignal clipboard 00616 00617 ListItem* pItem = GetHead(); 00618 00619 while (pItem != NULL) 00620 { 00621 OILBitmap* pOILBmp = (OILBitmap*)pItem; 00622 00623 ERROR3IF(pOILBmp->IsAFractal(), "There's a fractal in the global list ! How'd that happen ?"); 00624 00625 BOOL IsUsed = FALSE; 00626 00627 if (pOILBmp == OILBitmap::Default) 00628 { 00629 IsUsed = TRUE; 00630 } 00631 // DY 16/3/2000, we don't want to delete bitmaps that are used by brushes when the 00632 // document they are in is deleted. 00633 if (pOILBmp->IsUsedByBrush()) 00634 { 00635 IsUsed = TRUE; 00636 } 00637 else 00638 { 00639 // Go though all the documents 00640 Document* pDoc = (Document*)GetApplication()->Documents.GetHead(); 00641 while (pDoc != NULL) 00642 { 00643 if (IsUsedInDocument(pDoc, pOILBmp)) 00644 { 00645 IsUsed = TRUE; 00646 break; 00647 } 00648 00649 // Move onto the next document 00650 pDoc = (Document*)GetApplication()->Documents.GetNext(pDoc); 00651 } 00652 00653 #if !defined(EXCLUDE_FROM_RALPH) 00654 // Now check the ClipBoard to see if the Bitmap is in there 00655 if (!IsUsed && IsBitmapOnClipBoard(pOILBmp)) 00656 { 00657 IsUsed = TRUE; 00658 //break; 00659 } 00660 00661 // Should do this but will ERROR2 on exit as the clipboard has no doc components 00662 // Should be ok as we now clear out the bitmap lists when the clipboard is cleared 00663 /*if (!IsUsed) 00664 { 00665 Document * pClipDoc = InternalClipboard::Instance(); 00666 if (pClipDoc && IsUsedInDocument(pClipDoc, pOILBmp)) 00667 { 00668 IsUsed = TRUE; 00669 } 00670 } */ 00671 00672 // As we now have two clipboards, we need to check both 00673 // Now check the ClipBoard to see if the Bitmap is in there 00674 if (!IsUsed) 00675 { 00676 InternalClipboard::Swap(); // Swap to alternative clipboard 00677 if (IsBitmapOnClipBoard(pOILBmp)) 00678 { 00679 IsUsed = TRUE; 00680 // break; 00681 } 00682 InternalClipboard::Swap(); // Swap back to orignal clipboard 00683 } 00684 00685 // Should do this but will ERROR2 on exit as the clipboard has no doc components 00686 // Should be ok as we now clear out the bitmap lists when the clipboard is cleared 00687 /*if (!IsUsed) 00688 { 00689 Document * pClipDoc = InternalClipboard::Other(); 00690 if (pClipDoc && IsUsedInDocument(pClipDoc, pOILBmp)) 00691 . { 00692 IsUsed = TRUE; 00693 } 00694 } */ 00695 #endif 00696 00697 } 00698 00699 // Get next item before we delete this item 00700 pItem = GetNext(pItem); 00701 00702 if (!IsUsed) 00703 { 00704 delete pOILBmp; // Delete if not used 00705 pOILBmp = NULL; 00706 } 00707 } 00708 }
|
|
Looks to see if an identical bitmap is already in the bitmap list.
Definition at line 421 of file bmplist.cpp. 00422 { 00423 ListItem* pItem = GetHead(); 00424 00425 while (pItem != NULL) 00426 { 00427 OILBitmap* pBmp = (OILBitmap*)pItem; 00428 00429 ERROR3IF(pBmp == pOILBitmap, "Why is this bitmap already in the list ?"); 00430 00431 if (pBmp != pOILBitmap && 00432 *pBmp == *pOILBitmap) 00433 { 00434 return pBmp; 00435 } 00436 00437 pItem = GetNext(pItem); 00438 } 00439 00440 return NULL; 00441 }
|
|
Finds a bitmap with a particular name.
Definition at line 352 of file bmplist.cpp. 00353 { 00354 ListItem* pItem = GetHead(); 00355 00356 while (pItem != NULL) 00357 { 00358 OILBitmap* pBmp = (OILBitmap*)pItem; 00359 00360 if (!pBmp->HasBeenDeleted()) 00361 { 00362 if (*BitmapName == pBmp->GetName()) 00363 return pBmp; 00364 } 00365 00366 pItem = GetNext(pItem); 00367 } 00368 00369 return NULL; 00370 }
|
|
Find how many bitmaps are being used by this document.
Definition at line 454 of file bmplist.cpp. 00455 { 00456 INT32 Count = 0; 00457 INT32 DefaultIsUsed = FALSE; 00458 00459 if (pDoc != NULL) 00460 { 00461 // Now get the actual bitmap list 00462 BitmapList* Bitmaps = pDoc->GetBitmapList(); 00463 00464 if (Bitmaps) 00465 { 00466 // Go through all the bitmaps in the list 00467 ListItem *Ptr = Bitmaps->GetHead(); 00468 while (Ptr != NULL) 00469 { 00470 KernelBitmap* Bmp = (KernelBitmap*)Ptr; 00471 00472 if (Bmp->IsDefaultBitmap() && !DefaultIsUsed) 00473 { 00474 if (Bmp->IsUsedInDocument(pDoc)) 00475 DefaultIsUsed = TRUE; 00476 } 00477 else if (Bmp->IsUsedInDocument(pDoc)) 00478 { 00479 Count++; 00480 } 00481 00482 Ptr = Bitmaps->GetNext(Ptr); 00483 } 00484 } 00485 } 00486 00487 if (DefaultIsUsed) Count++; 00488 00489 return Count; 00490 }
|
|
Find the total size of the bitmaps being used by this document.
Definition at line 502 of file bmplist.cpp. 00503 { 00504 INT32 Mem = 0; 00505 INT32 DefaultIsUsed = FALSE; 00506 00507 if (pDoc != NULL) 00508 { 00509 // Now get the actual bitmap list 00510 BitmapList* Bitmaps = pDoc->GetBitmapList(); 00511 00512 if (Bitmaps) 00513 { 00514 // Go through all the bitmaps in the list 00515 ListItem *Ptr = Bitmaps->GetHead(); 00516 while (Ptr != NULL) 00517 { 00518 KernelBitmap* Bmp = (KernelBitmap*)Ptr; 00519 00520 if (Bmp->IsDefaultBitmap() && !DefaultIsUsed) 00521 { 00522 if (Bmp->IsUsedInDocument(pDoc)) 00523 DefaultIsUsed = TRUE; 00524 } 00525 else if (Bmp->IsUsedInDocument(pDoc)) 00526 { 00527 Mem += Bmp->ActualBitmap->GetBitmapSize(); 00528 } 00529 00530 Ptr = Bitmaps->GetNext(Ptr); 00531 } 00532 } 00533 } 00534 00535 if (DefaultIsUsed) 00536 { 00537 Mem += OILBitmap::Default->GetBitmapSize(); 00538 } 00539 00540 return Mem; 00541 }
|
|
Find the names of the bitmaps in the list.
Definition at line 294 of file bmplist.cpp. 00295 { 00296 ListItem* First = GetHead(); 00297 00298 while (First != NULL) 00299 { 00300 if (!((OILBitmap*)First)->HasBeenDeleted()) 00301 { 00302 *BitmapName = ((OILBitmap*)First)->GetName(); 00303 return First; 00304 } 00305 00306 First = GetNext(First); 00307 } 00308 00309 return NULL; 00310 }
|
|
Find the names of the bitmaps in the list.
Definition at line 323 of file bmplist.cpp. 00324 { 00325 ListItem* Next = GetNext(Prev); 00326 00327 while (Next != NULL) 00328 { 00329 if (!((OILBitmap*)Next)->HasBeenDeleted()) 00330 { 00331 *BitmapName = ((OILBitmap*)Next)->GetName(); 00332 return Next; 00333 } 00334 00335 Next = GetNext(Next); 00336 } 00337 00338 return NULL; 00339 }
|
|
Initialise the GlobalBitmapList.
Reimplemented from SimpleCCObject. Definition at line 193 of file bmplist.cpp. 00194 { 00195 // GreyscaleBitmapList::Init(); 00196 00197 #if !defined(EXCLUDE_FROM_RALPH) 00198 return OpDeleteBitmap::Init(); 00199 #else 00200 return TRUE; 00201 #endif 00202 }
|
|
Check to see if a bitmap is used on the clipboard.
Definition at line 720 of file bmplist.cpp. 00721 { 00722 #if !defined(EXCLUDE_FROM_RALPH) 00723 00724 // Clear out any Cached attrs on the Clipboard 00725 Node* Subtree = (Node*) InternalClipboard::GetInsertionLayer(); 00726 if (!Subtree) return FALSE; 00727 00728 Range ClipRange(Subtree->FindFirstChild(), 00729 Subtree->FindLastChild(), 00730 RangeControl(TRUE,TRUE,TRUE,TRUE)); 00731 00732 // Go though all the nodes on the clipboard 00733 Node* Current = ClipRange.FindFirst(); 00734 while (Current != NULL) 00735 { 00736 // And search right down each subtree 00737 Node* pNodeToCheck = Current->FindFirstDepthFirst(); 00738 00739 while (pNodeToCheck != NULL) 00740 { 00741 // See if this node uses the bitmap 00742 INT32 Count = 0; 00743 00744 // Does this node have any bitmaps in it ? 00745 KernelBitmap* pKernelBmp = pNodeToCheck->EnumerateBitmaps(Count++); 00746 00747 while (pKernelBmp != NULL) 00748 { 00749 // Found a bitmap reference, but ... is it the one we want ? 00750 if (pKernelBmp->GetActualBitmap() == pOILBmp) 00751 { 00752 return TRUE; 00753 } 00754 00755 // Check whether this bitmap is an XPE master 00756 if (pKernelBmp->GetActualBitmap()) 00757 { 00758 PORTNOTE("other","Removed IXMLDOMDocumentPtr usage") 00759 #ifndef EXCLUDE_FROM_XARALX 00760 OILBitmap* pMaster = NULL; 00761 IXMLDOMDocumentPtr pInfo = NULL; 00762 pKernelBmp->GetActualBitmap()->GetXPEInfo(pMaster, pInfo); 00763 if (pMaster == pOILBmp) 00764 return TRUE; 00765 #endif 00766 } 00767 00768 pKernelBmp = pNodeToCheck->EnumerateBitmaps(Count++); 00769 } 00770 00771 pNodeToCheck = pNodeToCheck->FindNextDepthFirst(Current); 00772 } 00773 00774 Current = ClipRange.FindNext(Current); 00775 } 00776 00777 #endif 00778 00779 return FALSE; 00780 }
|
|
Checks if the specified OIL bitmap is in the bitmap list of the specified document.
Definition at line 558 of file bmplist.cpp. 00559 { 00560 ERROR2IF(pDoc == NULL || pOILBmp == NULL,FALSE,"GlobalBitmapList::IsUsedInDocument Bad params!"); 00561 00562 // Get the bitmap list for the specified document 00563 BitmapList* pBitmaps = pDoc->GetBitmapList(); 00564 if (pBitmaps) 00565 { 00566 ListItem* pKBmp = pBitmaps->GetHead(); 00567 00568 while (pKBmp) 00569 { 00570 KernelBitmap* pBmp = (KernelBitmap*)pKBmp; 00571 00572 if (pBmp->ActualBitmap == pOILBmp) 00573 { 00574 // Found a copy of the bitmap and so return TRUE 00575 return TRUE; 00576 } 00577 00578 PORTNOTETRACE("other","GlobalBitmapList::IsUsedInDocument - skip XPE master bit"); 00579 #ifndef EXCLUDE_FROM_XARALX 00580 // Check whether this bitmap is an XPE master 00581 if (pBmp->ActualBitmap) 00582 { 00583 OILBitmap* pMaster = NULL; 00584 IXMLDOMDocumentPtr pInfo = NULL; 00585 pBmp->ActualBitmap->GetXPEInfo(pMaster, pInfo); 00586 if (pMaster == pOILBmp) 00587 return TRUE; 00588 } 00589 #endif 00590 00591 pKBmp = pBitmaps->GetNext(pKBmp); 00592 } 00593 } 00594 00595 // Bitmap not found and so return FALSE 00596 return FALSE; 00597 }
|
|
Ensures a bitmap name is unique.
Definition at line 382 of file bmplist.cpp. 00383 { 00384 ListItem* Bitmap = GetHead(); 00385 00386 INT32 Number = 1; 00387 String_256 Name = *BitmapName; 00388 00389 while (Bitmap != NULL) 00390 { 00391 if ( Name == ((OILBitmap*)Bitmap)->GetName() ) 00392 { 00393 // This name already exists, so lets make it unique 00394 String_256 Str; 00395 camSnprintf( Str, 256, TEXT("%d"), Number++ ); 00396 Name = (*BitmapName); 00397 Name += Str; 00398 00399 Bitmap = GetHead(); // Start at the beginning again 00400 } 00401 else 00402 { 00403 Bitmap = GetNext(Bitmap); 00404 } 00405 } 00406 00407 *BitmapName = Name; 00408 }
|