#include <linecomp.h>
Inheritance diagram for LineComponent:
Public Member Functions | |
LineComponent () | |
Constructor. | |
virtual | ~LineComponent () |
Destructor. | |
virtual LineHandle | AddNewItem (LineDefinition *pLine, BOOL AskName=FALSE) |
Adds the given Line to the global Line list. | |
virtual LineDefinition * | FindDefinition (UINT32 Handle, BOOL Dummy=FALSE) |
UINT32 | GetNumberOfLines () |
virtual BOOL | StartImport (BaseCamelotFilter *pFilter) |
Called before we start to import a file. | |
virtual BOOL | EndImport (BaseCamelotFilter *pFilter, BOOL Success) |
Called on completion of an import. | |
virtual BOOL | StartExport (BaseCamelotFilter *pFilter)=0 |
Inform the document component that a WEb or Native export is about to start. | |
virtual BOOL | EndExport (BaseCamelotFilter *pFilter, BOOL Success) |
Called on completion of file export. | |
BOOL | EndImportLine (CamelotRecordHandler *pHandler) |
LineHandle | FindImportedLine (UINT32 ImportedHandle) |
To match up a handle from the currently importing file to the real internal LineHandle of the imported LineDefinition. | |
virtual BOOL | ExportLine (BaseCamelotFilter *pFilter, LineHandle Handle)=0 |
virtual BOOL | NameIsUnique (const String_32 &NameString) |
To find out if someone has already gotten this name. | |
virtual String_32 | GetUniqueName (String_32 *pName=NULL)=0 |
Static Public Member Functions | |
static void | DeleteList (void) |
static BOOL | StartImportLine (CamelotRecordHandler *pHandler, CXaraFileRecord *pRecord) |
To import a vector Line definition. | |
Protected Member Functions | |
virtual BOOL | ExpandArray (void)=0 |
Static Protected Member Functions | |
static void | DeleteLineList (void) |
Static deinitialisation function, called on shutdown. Clears out the global Line list. Must be called when all users of the Line system (documents) have already been deleted. | |
Static Protected Attributes | |
static LineDefinition ** | m_pLineArray = NULL |
static UINT32 | m_CurrentSize = 0 |
static UINT32 | m_Used = 0 |
static UINT32 | m_ImportHandle = 0 |
static UINT32 | m_ImportFlags = 0 |
static UINT32 | m_ImportData1 = 0 |
static UINT32 | m_ImportData2 = 0 |
static InsertTreeContext * | m_pImportPreviousContext = NULL |
static Node * | m_pImportNewLine = NULL |
static String_32 | m_ImportedName |
Definition at line 161 of file linecomp.h.
|
Constructor.
Definition at line 137 of file linecomp.cpp.
|
|
Destructor.
Definition at line 155 of file linecomp.cpp. 00156 { 00157 if (m_pImportPreviousContext != NULL) 00158 delete m_pImportPreviousContext; 00159 if (m_pImportNewLine != NULL) 00160 delete m_pImportNewLine; 00161 }
|
|
Adds the given Line to the global Line list.
YOU MUST NOT use the pLine pointer after this call! If the call fails, or if the Line is merged with an existing one, the object you passed in will be IMMEDIATELY DELETED! If you wish to use the Line after Adding it, you must call FindLine with the returned Line handle! Technical: Lines are recorded in an array of LineDefinition pointers. The LineHandle is just an index into this array, for fast lookup. When deleted, the array-entry is set NULL and never re-used, so that any handles floating around can be safely used (much better than getting IndexedColour deleted when in use errors, eh? ;-). New entries are thus always appended to the list. Reimplemented in BrushComponent. Definition at line 231 of file linecomp.cpp. 00232 { 00233 // ****!!!!TODO - if we're multi-threadig, this probably needs to be a critical section 00234 // because the list is global 00235 00236 ERROR3IF(pItem == NULL, "Illegal NULL param"); 00237 00238 // --- First, check if we can merge the given Line with one already in the list 00239 for (UINT32 i = 0; i < m_Used; i++) 00240 { 00241 if (m_pLineArray[i] != NULL && !pItem->IsDifferent(m_pLineArray[i])) 00242 { 00243 // The Line is the same as one we already have in our Line list, so we 00244 // delete the copy that was passed in, and return the existing ones handle 00245 // We copy the import handle value over, though, so that we don't "lose" 00246 // merged Lines during import! 00247 m_pLineArray[i]->SetIOStore(pItem->ReadIOStore()); 00248 delete pItem; 00249 return((LineHandle) i); 00250 } 00251 } 00252 00253 // --- Next, check if we have enough room in our Line array to add a new entry to the end 00254 if (m_Used >= m_CurrentSize) 00255 { 00256 if (!ExpandArray()) 00257 { 00258 delete pItem; 00259 return(LineHandle_NoLine); 00260 } 00261 } 00262 00263 // --- OK, we have a totally new Line, so add it to the end of the list 00264 LineHandle NewHandle = (LineHandle) m_Used; 00265 m_pLineArray[m_Used] = pItem; 00266 m_Used++; 00267 00268 00269 // --- And return the new handle 00270 return(NewHandle); 00271 }
|
|
Static deinitialisation function, called on shutdown. Clears out the global Line list. Must be called when all users of the Line system (documents) have already been deleted.
Definition at line 178 of file linecomp.cpp. 00179 { 00180 if (m_pLineArray != NULL) 00181 { 00182 for (UINT32 i = 0; i < m_Used; i++) 00183 { 00184 if (m_pLineArray[i] != NULL) 00185 delete m_pLineArray[i]; 00186 00187 m_pLineArray[i] = NULL; 00188 } 00189 00190 CCFree(m_pLineArray); 00191 m_pLineArray = NULL; 00192 } 00193 }
|
|
Definition at line 170 of file linecomp.h. 00170 { DeleteLineList();}
|
|
Called on completion of file export.
Reimplemented from DocComponent. Definition at line 388 of file linecomp.cpp. 00389 { 00390 BOOL ok = TRUE; 00391 TRACEUSER( "Diccon", _T("End Export Brush\n")); 00392 #if !defined(EXCLUDE_FROM_RALPH) 00393 if (pFilter == NULL) 00394 { 00395 ERROR3("LineComponent::EndExport filter is null!"); 00396 return(ok); 00397 } 00398 00399 if (!Success) // If we failed to export, then return immediately 00400 return(ok); 00401 00402 #endif 00403 return(ok); 00404 }
|
|
Called on completion of an import.
Reimplemented from DocComponent. Definition at line 366 of file linecomp.cpp. 00367 { 00368 return TRUE; 00369 }
|
|
Definition at line 201 of file linecomp.h. 00201 {return TRUE;}
|
|
Implemented in BrushComponent. |
|
Implemented in BrushComponent. |
|
|
|
To match up a handle from the currently importing file to the real internal LineHandle of the imported LineDefinition.
Definition at line 488 of file linecomp.cpp. 00489 { 00490 ImportedHandle &= 0x00ffffff; // Only the bottom 24 bits are relevant 00491 for (UINT32 Index = 0; Index < m_Used; Index++) 00492 { 00493 if (m_pLineArray[Index] != NULL && m_pLineArray[Index]->ReadIOStore() == ImportedHandle) 00494 return((LineHandle)Index); 00495 } 00496 00497 return(LineHandle_NoLine); 00498 }
|
|
Definition at line 182 of file linecomp.h. 00182 { return m_Used;}
|
|
Implemented in BrushComponent. |
|
To find out if someone has already gotten this name.
Reimplemented in BrushComponent. Definition at line 516 of file linecomp.cpp. 00517 { 00518 ERROR3IF(NameString.IsEmpty(), "Empty string in LineComponent::NameIsUnique"); 00519 00520 BOOL Unique = TRUE; 00521 UINT32 Counter = 0; 00522 String_32* pDefName = NULL; 00523 LineDefinition* pDef = NULL; 00524 while (Counter < m_Used) 00525 { 00526 pDef = FindDefinition(Counter); 00527 if (pDef == NULL) 00528 { 00529 ERROR3("null brush definition in LineComponent::NameIsUnique"); 00530 break; 00531 } 00532 pDefName = pDef->GetLineName(); 00533 if( pDefName != NULL ) 00534 { 00535 if (NameString == *pDefName) 00536 { 00537 Unique = FALSE; 00538 break; 00539 } 00540 } 00541 Counter++; 00542 } 00543 return Unique; 00544 00545 }
|
|
Inform the document component that a WEb or Native export is about to start.
Reimplemented from DocComponent. Implemented in BrushComponent. |
|
Called before we start to import a file.
Reimplemented from DocComponent. Definition at line 324 of file linecomp.cpp. 00325 { 00326 if (pFilter == NULL) 00327 { 00328 ERROR3("LineComponent::StartImport filter is null!"); 00329 return(TRUE); 00330 } 00331 00332 // Set the IOStore in all the Lines to 0xffffffff. During import, this entry is used 00333 // to map imported handles to the real handles they have been assigned. 00334 if (m_pLineArray != NULL) 00335 { 00336 for (UINT32 Index = 0; Index < m_Used; Index++) 00337 { 00338 if (m_pLineArray[Index] != NULL) 00339 m_pLineArray[Index]->SetIOStore(0xffffffff); 00340 } 00341 } 00342 00343 return(TRUE); 00344 }
|
|
To import a vector Line definition.
Definition at line 423 of file linecomp.cpp. 00424 { 00425 m_ImportHandle = 0xffffffff; 00426 m_ImportFlags = 0; 00427 m_ImportData1 = 0; 00428 m_ImportData2 = 0; 00429 m_pImportPreviousContext = NULL; 00430 m_pImportNewLine = NULL; 00431 00432 String_256 TempName; // Load the name into a nice large safe buffer 00433 00434 // Import the data from the record 00435 if (!pRecord->ReadUINT32(&m_ImportHandle) || !pRecord->ReadUINT32(&m_ImportFlags) || 00436 !pRecord->ReadUINT32(&m_ImportData1) || !pRecord->ReadUINT32(&m_ImportData2)) 00437 { 00438 return(FALSE); 00439 } 00440 00441 // If there is a name to be imported, read it as well 00442 if ((m_ImportFlags & 0x200) != 0 && !pRecord->ReadUnicode(&TempName)) 00443 return(FALSE); 00444 00445 // We remember the imported flags and suchlike, which we will use in EndImportLine. 00446 TempName.Left((StringBase *)&m_ImportedName, 31); 00447 00448 // Create a spread and set up the import system to import the brush into it 00449 // If this fails, then it'll just find somewhere "sensible" to import into 00450 m_pImportNewLine = new Spread; 00451 if (m_pImportNewLine == NULL) 00452 return(FALSE); 00453 00454 Layer *pLineLayer = new Layer(m_pImportNewLine, FIRSTCHILD, String_256(TEXT("Jason did this"))); 00455 if (pLineLayer == NULL) 00456 { 00457 delete m_pImportNewLine; 00458 m_pImportNewLine = NULL; 00459 return(FALSE); 00460 } 00461 00462 // Now, remember where we were importing into, and point the importer at our brush tree 00463 m_pImportPreviousContext = pHandler->GetInsertContext(); 00464 pHandler->SetInsertContextNode(pLineLayer); 00465 return(TRUE); 00466 }
|
|
Definition at line 220 of file linecomp.h. |
|
Definition at line 226 of file linecomp.h. |
|
Definition at line 227 of file linecomp.h. |
|
Definition at line 230 of file linecomp.h. |
|
Definition at line 225 of file linecomp.h. |
|
Definition at line 224 of file linecomp.h. |
|
Definition at line 229 of file linecomp.h. |
|
Definition at line 228 of file linecomp.h. |
|
Definition at line 219 of file linecomp.h. |
|
Definition at line 221 of file linecomp.h. |