NewColour Class Reference

Represents a new colour object to be added to a document after a file has beeen imported. It holds information on whether the colour name will need to be mangled. More...

#include <impcol.h>

Inheritance diagram for NewColour:

ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 NewColour (IndexedColour *, BOOL)
 Create a new colour list item from the given indexed colour.
BOOL AddDuplicateColour (IndexedColour **pNewCol, BOOL AlreadyExists)
 Add another definition of a colour to an existing colour definition. i.e. We have a new colour but we have already found a definition of this colour name while importing, so we have duplicate colour names, so the IndexedColour object pointed to by pNewCol should be linked to the existing item (with which it shares a colour name).

Public Attributes

IndexedColourpCol
BOOL AlreadyExistsInDoc
BOOL Duplicate
PColourCMYK ColDefn
NewColourpNextDuplicate
INT32 RecordNumber
UINT32 EntryNumber

Detailed Description

Represents a new colour object to be added to a document after a file has beeen imported. It holds information on whether the colour name will need to be mangled.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/94
See also:
NewColourList; ImportedColours

Definition at line 143 of file impcol.h.


Constructor & Destructor Documentation

NewColour::NewColour IndexedColour pNewCol,
BOOL  AlreadyExists
 

Create a new colour list item from the given indexed colour.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/94
Parameters:
pNewCol - the colour to put in the list. [INPUTS] AlreadyExists - TRUE if pNewCol points to a colour that already exists in the destination document; FALSE if pNewCol poinst to a brand new colour.
See also:
NewColourList; NewColourList::AddColour

Definition at line 305 of file impcol.cpp.

00306 {
00307     // Initialise to sensible values.
00308     pCol = pNewCol;
00309     AlreadyExistsInDoc = AlreadyExists;
00310     Duplicate = FALSE;
00311     pNextDuplicate = NULL;
00312 
00313     // Get CMYK version of this colour for comparisons - this looks a bit nasty, but 
00314     // actually I think it's the cleanest way of doing this.
00315     DocColour TempCol;
00316     TempCol.MakeRefToIndexedColour(pNewCol);
00317     TempCol.GetCMYKValue(&ColDefn);
00318 
00319     // New web/native filter bits
00320     RecordNumber = 0L;
00321     EntryNumber = 0L;
00322 }


Member Function Documentation

BOOL NewColour::AddDuplicateColour IndexedColour **  pNewCol,
BOOL  AlreadyExists
 

Add another definition of a colour to an existing colour definition. i.e. We have a new colour but we have already found a definition of this colour name while importing, so we have duplicate colour names, so the IndexedColour object pointed to by pNewCol should be linked to the existing item (with which it shares a colour name).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/94
Parameters:
pNewCol - (pointer to a) pointer to the IndexedColour object to link to pMaster [INPUTS] because they both have the same colour name.
AlreadyExists - TRUE => pNewCol matches a colour that is already in the destination document. FALSE => pNewCol does not match any colours in the destination document.

Parameters:
pNewCol pointer is updated to point at the colour to use for the colour [OUTPUTS] passed in (see below).
Returns:
TRUE if the duplicate could be added; FALSE if out of memory => ERROR1
Notes: AddDuplicateColour handles 2 types of duplicates:

1) Duplicated name, but different colour definitions. In this case, the dupes are remembered and added to the document (the colour list will ensure they have unique names when finally added)

2) Exact duplicate (now possible with parents of shade colours which might be defined twice in a CamEPS document). These are deleted out of hand, and the pNewCol pointer is updated to point at the original/first definition of the identical colour.

Returns:
Errors: Out of memory => ERROR1
See also:
NewColour; ImportedColours::AddColour

Definition at line 368 of file impcol.cpp.

00369 {
00370     ERROR3IF(pNewCol == NULL || *pNewCol == NULL, "Illegal NULL param");
00371 
00372     // --- First, check if this colour is a real duplicate or just a duplicate in name
00373     // If it is a duplicate name, then we keep a copy around, but if it is a complete
00374     // duplicate, then we want to vape it and NOT put it in the dupes list - Jason
00375 
00376     // NOTE: We *ONLY* do this if the colour is not already part of the existing document
00377     // (i.e. was merged with an existing exact match colour in the doc), i.e. if !AlreadyExists
00378 
00379     if (!AlreadyExists)
00380     {
00381         NewColour *Ptr = this;
00382         while (Ptr != NULL)
00383         {
00384             if (!(*pNewCol)->IsDifferent(*(Ptr->pCol)))
00385             {
00386                 delete (*pNewCol);          // delete the identical twin
00387                 *pNewCol = Ptr->pCol;       // and return the pointer pointing at the original definition
00388                 return(TRUE);
00389             }
00390 
00391             Ptr = Ptr->pNextDuplicate;
00392         }
00393     }   
00394 
00395     // --- And now back to our regularly scheduled programme...
00396 
00397 
00398 
00399     // First, try to make a new item
00400     NewColour *pNewItem = new NewColour(*pNewCol, AlreadyExists);
00401     if (pNewItem == NULL)
00402         return FALSE;
00403 
00404     // Mark this object as being a duplicate
00405     Duplicate = TRUE;
00406 
00407     // Ok, link to this object (at end of the one-way list)...
00408     NewColour *pLast = this;
00409     while (pLast->pNextDuplicate != NULL)
00410         pLast = pLast->pNextDuplicate;
00411 
00412     // Found end of list - link it in and mark it as being a duplicate
00413     pLast->pNextDuplicate = pNewItem;
00414     pNewItem->Duplicate = TRUE;
00415 
00416     // Worked ok
00417     return TRUE;
00418 }


Member Data Documentation

BOOL NewColour::AlreadyExistsInDoc
 

Definition at line 158 of file impcol.h.

PColourCMYK NewColour::ColDefn
 

Definition at line 165 of file impcol.h.

BOOL NewColour::Duplicate
 

Definition at line 162 of file impcol.h.

UINT32 NewColour::EntryNumber
 

Definition at line 178 of file impcol.h.

IndexedColour* NewColour::pCol
 

Definition at line 154 of file impcol.h.

NewColour* NewColour::pNextDuplicate
 

Definition at line 170 of file impcol.h.

INT32 NewColour::RecordNumber
 

Definition at line 175 of file impcol.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:56:28 2007 for Camelot by  doxygen 1.4.4