00001 // $Id: cmxirefs.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 // handles referenced descriptions for CMX import 00099 00100 #include "camtypes.h" 00101 #include "riffform.h" 00102 //#include "ccfile.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00103 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00104 #include "colourix.h" 00105 #include "collist.h" 00106 00107 #include "cmxifltr.h" 00108 #include "cmxistut.h" 00109 #include "cmxidata.h" 00110 #include "cmxibitm.h" 00111 00112 #define CMX_COMPILE 00113 #include "cdrfiltr.h" 00114 00115 #define new CAM_DEBUG_NEW 00116 00117 /******************************************************************************************** 00118 00119 > BOOL CMXImportFilter::Stage2_ReadMasterIndex(void) 00120 00121 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00122 Created: 07/08/96 00123 Inputs: None 00124 Returns: error flag 00125 Purpose: Processes the master index, placing offsets in the table so other routines 00126 can find their stuff 00127 00128 ********************************************************************************************/ 00129 00130 BOOL CMXImportFilter::Stage2_ReadMasterIndex(void) 00131 { 00132 // here we find the master index, and get all the interesting objects from it 00133 Seek(Data->IndexFilePosition); // go there 00134 00135 // get the header of the section and have a peep at it 00136 RIFFck chdr; 00137 pFile->read(&chdr, sizeof(chdr)); 00138 00139 if(chdr.ckID != cmxRIFFCI_MasterIndex) 00140 CMXFORMATERROR(FALSE) 00141 00142 // get the header of the thingy 00143 CI_READDATA(MasterIndexHeader, mih) 00144 00145 if(mih.MasterID != cmxMASTERIN_MASTERIN) 00146 CMXFORMATERROR(FALSE) 00147 00148 TRACEUSER( "Ben", _T("Reading master index, has %d records\n"),mih.RecordCount); 00149 00150 for(INT32 l = 0; l < mih.RecordCount; l++) 00151 { 00152 CI_READDATA(MasterIndexEntry, mie) 00153 00154 TRACEUSER( "Ben", _T("Entry: type = %d, value = %d\n"), mie.IndexRecordID, mie.Offset); 00155 00156 // see what type the thing is 00157 if(mie.IndexRecordID >= 0 && mie.IndexRecordID < cmxMASTERIN_MAXENTRY) 00158 { 00159 // it's in the range we're interested it, store the offset 00160 Data->MasterIndexEntries[mie.IndexRecordID] = mie.Offset; 00161 } 00162 } 00163 00164 TRACEUSER( "Ben", _T("finished reading master index\n")); 00165 00166 return TRUE; 00167 } 00168 00169 00170 /******************************************************************************************** 00171 00172 > BOOL CMXImportFilter::Stage3_ConvertDescriptionSections(void) 00173 00174 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00175 Created: 07/08/96 00176 Inputs: None 00177 Returns: error flag 00178 Purpose: Goes through the description sections reading the data, and creates all the 00179 nice arrays of stuff. 00180 00181 ********************************************************************************************/ 00182 00183 BOOL CMXImportFilter::Stage3_ConvertDescriptionSections(void) 00184 { 00185 if(!ConvertColours() 00186 || !ConvertPens() 00187 || !ConvertLineStyles() 00188 || !ConvertDotDashes() 00189 || !ConvertArrowShapes() 00190 || !ConvertArrowheads() 00191 || !ConvertOutlines() 00192 || !ConvertFonts() 00193 || !ReadProcedureIndex() 00194 || !ReadBitmapIndex() 00195 || !ReadFontIndex() 00196 || !ReadEmbeddedFileIndex()) 00197 00198 return FALSE; 00199 00200 return TRUE; 00201 } 00202 00203 00204 /******************************************************************************************** 00205 00206 > BOOL CMXImportFilter::ConvertColours(void) 00207 00208 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00209 Created: 13/08/96 00210 Inputs: None 00211 Returns: error flag 00212 Purpose: converts the colours, reading them into an array of bits and pieces 00213 00214 ********************************************************************************************/ 00215 00216 BOOL CMXImportFilter::ConvertColours(void) 00217 { 00218 // go to the right place in the file 00219 if(!GotoSectionFromIndex(cmxMASTERIN_COLOUR, cmxRIFFCI_Desc_Colour, TRUE)) 00220 return FALSE; 00221 00222 // read the header 00223 CI_READDATA(SimpleIndexHeader, ih) 00224 00225 // do the record count thing... allocate some room for the colours 00226 Data->Colours = new CMXImportColour[ih.RecordCount]; 00227 TRACEUSER( "Ben", _T("file has %d colours\n"), ih.RecordCount); 00228 00229 // and run through the file getting the thingys 00230 for(INT32 l = 0; l < ih.RecordCount; l++) 00231 { 00232 CI_READDATA(Colour, col) 00233 00234 Data->Colours[l].Convert(&col); 00235 } 00236 00237 // set number of colours 00238 Data->NumColours = ih.RecordCount; 00239 00240 // done 00241 return TRUE; 00242 } 00243 00244 00245 /******************************************************************************************** 00246 00247 > BOOL CMXImportFilter::ConvertOutlines(void) 00248 00249 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00250 Created: 14/08/96 00251 Inputs: None 00252 Returns: error flag 00253 Purpose: converts the outlines, reading them into an array of bits and pieces 00254 00255 ********************************************************************************************/ 00256 00257 BOOL CMXImportFilter::ConvertOutlines(void) 00258 { 00259 // go to the right place in the file 00260 BOOL Found; 00261 if(!GotoSectionFromIndex(cmxMASTERIN_OUTLINE, cmxRIFFCI_Desc_Outline, FALSE, &Found)) 00262 return FALSE; 00263 00264 if(!Found) 00265 return TRUE; // not a problem if there isn't an outline list 00266 00267 // check we have some pens 00268 ERROR2IF(Data->Pens == NULL, FALSE, "No pens when we tried to convert the outlines"); 00269 // check we have some line styles 00270 ERROR2IF(Data->LineStyles == NULL, FALSE, "No pens when we tried to convert the outlines"); 00271 00272 // read the header 00273 CI_READDATA(SimpleIndexHeader, ih) 00274 00275 // do the record count thing... allocate some room for the colours 00276 Data->Outlines = new CMXImportOutline[ih.RecordCount]; 00277 TRACEUSER( "Ben", _T("file has %d outlines\n"), ih.RecordCount); 00278 00279 // and run through the file getting the thingys 00280 for(INT32 l = 0; l < ih.RecordCount; l++) 00281 { 00282 CI_READDATA(Outline, out) 00283 00284 Data->Outlines[l].Convert(&out, Data); 00285 } 00286 00287 // set number of outlines 00288 Data->NumOutlines = ih.RecordCount; 00289 00290 // we no longer need the pens 00291 delete [] Data->Pens; 00292 Data->Pens = NULL; 00293 00294 // done 00295 return TRUE; 00296 } 00297 00298 00299 /******************************************************************************************** 00300 00301 > BOOL CMXImportFilter::ConvertPens(void) 00302 00303 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00304 Created: 14/08/96 00305 Inputs: None 00306 Returns: error flag 00307 Purpose: converts the outlines, reading them into an array of bits and pieces 00308 00309 ********************************************************************************************/ 00310 00311 BOOL CMXImportFilter::ConvertPens(void) 00312 { 00313 // go to the right place in the file 00314 BOOL Found; 00315 if(!GotoSectionFromIndex(cmxMASTERIN_PEN, cmxRIFFCI_Desc_Pen, FALSE, &Found)) 00316 return FALSE; 00317 00318 if(!Found) 00319 return TRUE; // not a problem if it doesn't exist 00320 00321 // read the header 00322 CI_READDATA(SimpleIndexHeader, ih) 00323 00324 // do the record count thing... allocate some room for the colours 00325 Data->Pens = new CMXImportPen[ih.RecordCount]; 00326 TRACEUSER( "Ben", _T("file has %d pens\n"), ih.RecordCount); 00327 00328 // and run through the file getting the thingys 00329 INT32 l; 00330 for(l = 0; l < ih.RecordCount; l++) 00331 { 00332 CI_READDATA(Pen, pen) 00333 00334 Data->Pens[l].Convert(&pen); 00335 } 00336 00337 // set number of pens 00338 Data->NumPens = ih.RecordCount; 00339 00340 // done 00341 return TRUE; 00342 } 00343 00344 /******************************************************************************************** 00345 00346 > BOOL CMXImportFilter::ConvertFonts(void) 00347 00348 Author: Claude_Quemerais (Xara Group Ltd) <camelotdev@xara.com> 00349 Created: 22/08/96 00350 Inputs: None 00351 Returns: error flag 00352 Purpose: 00353 00354 ********************************************************************************************/ 00355 00356 BOOL CMXImportFilter::ConvertFonts(void) 00357 { 00358 return TRUE; 00359 } 00360 00361 00362 00363 /******************************************************************************************** 00364 00365 > BOOL CMXImportFilter::ConvertLineStyles(void) 00366 00367 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00368 Created: 15/08/96 00369 Inputs: None 00370 Returns: error flag 00371 Purpose: converts the outlines, reading them into an array of bits and pieces 00372 00373 ********************************************************************************************/ 00374 00375 BOOL CMXImportFilter::ConvertLineStyles(void) 00376 { 00377 // go to the right place in the file 00378 BOOL Found; 00379 if(!GotoSectionFromIndex(cmxMASTERIN_LINESTYLE, cmxRIFFCI_Desc_LineStyle, FALSE, &Found)) 00380 return FALSE; 00381 00382 if(!Found) 00383 return TRUE; // not a problem if it doesn't exist 00384 00385 // read the header 00386 CI_READDATA(SimpleIndexHeader, ih) 00387 00388 // do the record count thing... allocate some room for the line styles 00389 Data->LineStyles = new CMXImportLineStyle[ih.RecordCount]; 00390 TRACEUSER( "Ben", _T("file has %d line styles\n"), ih.RecordCount); 00391 00392 // and run through the file getting the thingys 00393 INT32 l; 00394 for(l = 0; l < ih.RecordCount; l++) 00395 { 00396 CI_READDATA(LineStyle, style) 00397 00398 Data->LineStyles[l].Convert(&style); 00399 } 00400 00401 // set number of lines styles 00402 Data->NumLineStyles = ih.RecordCount; 00403 00404 // done 00405 return TRUE; 00406 } 00407 00408 00409 /******************************************************************************************** 00410 00411 > BOOL CMXImportFilter::ConvertArrowShapes(void) 00412 00413 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00414 Created: 26/08/96 00415 Inputs: None 00416 Returns: error flag 00417 Purpose: converts the arrow shapes, reading them into an array of bits and pieces 00418 00419 ********************************************************************************************/ 00420 00421 BOOL CMXImportFilter::ConvertArrowShapes(void) 00422 { 00423 // go to the right place in the file 00424 BOOL Found; 00425 INT32 Size = 0; 00426 if(!GotoSectionFromIndex(cmxMASTERIN_ARROW, cmxRIFFCI_ArrowIndex, FALSE, &Found, &Size)) 00427 return FALSE; 00428 00429 if(!Found) 00430 return TRUE; // not a problem if it doesn't exist 00431 00432 // get the index header 00433 CI_READDATA(ArrowShapeIndexHeader, ih) 00434 00435 // do the record count thing... allocate some room for the arrow shapes 00436 Data->ArrowShapes = new CMXImportArrowShape[ih.RecordCount]; 00437 TRACEUSER( "Ben", _T("file has %d arrow shapes\n"), ih.RecordCount); 00438 00439 INT32 SizeInFile = (Is32Bit)?(ih.SizeInFile):(sizeof(DWORD)); 00440 00441 // and run through the file getting the thingys 00442 INT32 l; 00443 for(l = 0; l < ih.RecordCount; l++) 00444 { 00445 // get the index entry 00446 INT32 EndEntryFilePos = Tell() + SizeInFile; 00447 CI_READDATA(ArrowShapeIndexEntry, en) 00448 Seek(en.Offset); 00449 00450 // read the arrow shape, and convert it 00451 CI_READDATA(ArrowShape, as) 00452 00453 Data->ArrowShapes[l].Convert(&as, Is32Bit); 00454 00455 // go back for the next entry 00456 Seek(EndEntryFilePos); 00457 } 00458 00459 // set number of arrow shapes 00460 Data->NumArrowShapes = ih.RecordCount; 00461 00462 // done 00463 return TRUE; 00464 } 00465 00466 00467 /******************************************************************************************** 00468 00469 > BOOL CMXImportFilter::ConvertArrowheads(void) 00470 00471 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00472 Created: 26/08/96 00473 Inputs: None 00474 Returns: error flag 00475 Purpose: converts the arrowheads, reading them into an array of bits and pieces 00476 00477 ********************************************************************************************/ 00478 00479 BOOL CMXImportFilter::ConvertArrowheads(void) 00480 { 00481 // go to the right place in the file 00482 BOOL Found; 00483 if(!GotoSectionFromIndex(cmxMASTERIN_ARROWHEADS, cmxRIFFCI_Desc_Arrowheads, FALSE, &Found)) 00484 return FALSE; 00485 00486 if(!Found) 00487 return TRUE; // not a problem if it doesn't exist 00488 00489 // read the header 00490 CI_READDATA(SimpleIndexHeader, ih) 00491 00492 // do the record count thing... allocate some room for the line styles 00493 Data->Arrowheads = new CMXImportArrowheads[ih.RecordCount]; 00494 TRACEUSER( "Ben", _T("file has %d arrowheads\n"), ih.RecordCount); 00495 00496 // and run through the file getting the thingys 00497 INT32 l; 00498 for(l = 0; l < ih.RecordCount; l++) 00499 { 00500 CI_READDATA(Arrowheads, ah) 00501 00502 Data->Arrowheads[l].Convert(&ah, Data); 00503 } 00504 00505 // set number of lines styles 00506 Data->NumArrowheads = ih.RecordCount; 00507 00508 // done 00509 return TRUE; 00510 } 00511 00512 00513 /******************************************************************************************** 00514 00515 > BOOL CMXImportFilter::ConvertDotDashes(void) 00516 00517 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00518 Created: 22/08/96 00519 Inputs: None 00520 Returns: error flag 00521 Purpose: converts the dot dashes, reading them into an array of bits and pieces 00522 00523 ********************************************************************************************/ 00524 00525 BOOL CMXImportFilter::ConvertDotDashes(void) 00526 { 00527 // go to the right place in the file 00528 BOOL Found; 00529 if(!GotoSectionFromIndex(cmxMASTERIN_DOTDASH, cmxRIFFCI_Desc_DotDash, FALSE, &Found)) 00530 return FALSE; 00531 00532 if(!Found) 00533 return TRUE; // not a problem if it doesn't exist 00534 00535 // read the header 00536 CI_READDATA(SimpleIndexHeader, ih) 00537 00538 // do the record count thing... allocate some room for the dot dashes 00539 Data->DotDashes = new CMXImportDotDash[ih.RecordCount]; 00540 TRACEUSER( "Ben", _T("file has %d dot dashes\n"), ih.RecordCount); 00541 00542 // and run through the file getting the thingys 00543 INT32 l; 00544 for(l = 0; l < ih.RecordCount; l++) 00545 { 00546 CI_READDATA(DotDash, dot) 00547 00548 Data->DotDashes[l].Convert(&dot); 00549 } 00550 00551 // set number of lines styles 00552 Data->NumDotDashes = ih.RecordCount; 00553 00554 // done 00555 return TRUE; 00556 } 00557 00558 00559 /******************************************************************************************** 00560 00561 > BOOL CMXImportFilter::ReadEmbeddedFileIndex(void) 00562 00563 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00564 Created: 15/08/96 00565 Inputs: None 00566 Returns: error flag 00567 Purpose: reads the embedded file index, creating the RImage array 00568 00569 ********************************************************************************************/ 00570 00571 BOOL CMXImportFilter::ReadEmbeddedFileIndex(void) 00572 { 00573 // go to the right place in the file 00574 BOOL Found; 00575 if(!GotoSectionFromIndex(cmxMASTERIN_EMBEDFILE, cmxRIFFCI_EmbeddedFileIndex, FALSE, &Found)) 00576 return FALSE; 00577 00578 if(!Found) 00579 return TRUE; // not a problem if it doesn't exist 00580 00581 // read the header 00582 CI_READDATA(SimpleIndexHeader, ih) 00583 00584 // do the record count thing... allocate some room for the colours 00585 Data->RImages = new CMXImportRImage[ih.RecordCount]; 00586 TRACEUSER( "Ben", _T("file has %d embedded files\n"), ih.RecordCount); 00587 00588 // and run through the file getting the thingys 00589 INT32 l; 00590 for(l = 0; l < ih.RecordCount; l++) 00591 { 00592 CI_READDATA(EmbeddedFileIndexEntry, en) 00593 00594 switch(en.Type) 00595 { 00596 case cmxEMBEDFILETYPE_RIMAGE: 00597 // ok, mark an RImage at this position... 00598 Data->RImages[l].Mark(en.Offset); 00599 break; 00600 00601 default: 00602 // don't need to do anything special 00603 break; 00604 } 00605 } 00606 00607 // set number of lines styles 00608 Data->NumRImages = ih.RecordCount; 00609 00610 return TRUE; 00611 } 00612 00613 00614 /******************************************************************************************** 00615 00616 > BOOL CMXImportFilter::ReadBitmapIndex(void) 00617 00618 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00619 Created: 26/08/96 00620 Inputs: None 00621 Returns: error flag 00622 Purpose: reads the embedded file index, creating the RImage array 00623 00624 ********************************************************************************************/ 00625 00626 BOOL CMXImportFilter::ReadBitmapIndex(void) 00627 { 00628 // go to the right place in the file 00629 BOOL Found; 00630 if(!GotoSectionFromIndex(cmxMASTERIN_BITMAP, cmxRIFFCI_BitmapIndex, FALSE, &Found)) 00631 return FALSE; 00632 00633 if(!Found) 00634 return TRUE; // not a problem if it doesn't exist 00635 00636 // read the header 00637 CI_READDATA(BitmapIndexHeader, ih) 00638 00639 // do the record count thing... allocate some room for the bitmaps 00640 Data->Bitmaps = new CMXImportBitmap[ih.RecordCount]; 00641 TRACEUSER( "Ben", _T("file has %d bitmaps\n"), ih.RecordCount); 00642 00643 INT32 SizeInFile = (Is32Bit)?(ih.SizeInFile):(sizeof(DWORD)); 00644 00645 // and run through the file getting the thingys 00646 INT32 l; 00647 for(l = 0; l < ih.RecordCount; l++) 00648 { 00649 INT32 Start = Tell(); 00650 00651 CI_READDATA(BitmapIndexEntry, en) 00652 00653 Data->Bitmaps[l].Set(en.Offset); 00654 00655 if(Tell() != (Start + SizeInFile)) 00656 Seek(Start + SizeInFile); 00657 } 00658 00659 // set number of bitmaps 00660 Data->NumBitmaps = ih.RecordCount; 00661 00662 return TRUE; 00663 } 00664 00665 /******************************************************************************************** 00666 00667 > BOOL CMXImportFilter::ReadFontIndex(void) 00668 00669 Author: Claude_Quemerais (Xara Group Ltd) <camelotdev@xara.com> 00670 Created: 27/08/96 00671 Inputs: None 00672 Returns: error flag 00673 Purpose: reads the embedded font index 00674 00675 ********************************************************************************************/ 00676 00677 BOOL CMXImportFilter::ReadFontIndex(void) 00678 { 00679 // go to the right place in the file 00680 BOOL Found; 00681 if(!GotoSectionFromIndex(cmxMASTERIN_FONT, cmxRIFFCI_FontIndex, FALSE, &Found)) 00682 return FALSE; 00683 00684 if(!Found) 00685 return TRUE; // not a problem if it doesn't exist 00686 00687 // read the header 00688 CI_READDATA(FontIndexHeader, ih) 00689 00690 // do the record count thing... allocate some room for the fonts 00691 Data->Fonts = new CMXImportFont[ih.RecordCount]; 00692 TRACEUSER( "Claude", _T("file has %d fonts\n"), ih.RecordCount); 00693 00694 INT32 SizeInFile = (Is32Bit)?(ih.SizeInFile):(sizeof(DWORD)); 00695 00696 // and run through the file getting the thingys 00697 for(INT32 l = 0 ; l < ih.RecordCount ; l++) 00698 { 00699 INT32 Start = Tell(); 00700 00701 CI_READDATA(FontIndexEntry, en) 00702 00703 Seek(en.Offset); 00704 00705 CI_READDATA(FontRecord, rec) 00706 00707 Data->Fonts[l].Convert(&rec); 00708 00709 00710 00711 Seek(Start + SizeInFile); 00712 } 00713 00714 // set number of bitmaps 00715 Data->NumFonts = ih.RecordCount; 00716 00717 return TRUE; 00718 } 00719 00720 00721 /******************************************************************************************** 00722 00723 > BOOL CMXImportFilter::ReadProcedureIndex(void) 00724 00725 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00726 Created: 19/08/96 00727 Inputs: None 00728 Returns: error flag 00729 Purpose: reads the embedded file index, creating the RImage array 00730 00731 ********************************************************************************************/ 00732 00733 BOOL CMXImportFilter::ReadProcedureIndex(void) 00734 { 00735 // go to the right place in the file 00736 BOOL Found; 00737 if(!GotoSectionFromIndex(cmxMASTERIN_PROCEDURE, cmxRIFFCI_ProcIndex, FALSE, &Found)) 00738 return FALSE; 00739 00740 if(!Found) 00741 return TRUE; // not a problem if it doesn't exist 00742 00743 // read the header 00744 CI_READDATA(SimpleIndexHeader, ih) 00745 00746 // do the record count thing... allocate some room for the colours 00747 Data->Procedures = new CMXImportProcedure[ih.RecordCount]; 00748 TRACEUSER( "Ben", _T("file has %d procedures\n"), ih.RecordCount); 00749 00750 // and run through the file getting the thingys 00751 INT32 l; 00752 for(l = 0; l < ih.RecordCount; l++) 00753 { 00754 CI_READDATA(ProcedureIndexEntry, en) 00755 00756 Data->Procedures[l].Read(&en); 00757 } 00758 00759 // set number of lines styles 00760 Data->NumProcedures = ih.RecordCount; 00761 00762 return TRUE; 00763 } 00764 00765 00766 00767 /******************************************************************************************** 00768 00769 > DocColour *CMXImportFilter::GetColourFromReference(INT32 Ref) 00770 00771 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00772 Created: 13/08/96 00773 Inputs: None 00774 Returns: pointer to colour to use 00775 Purpose: gets a pointer to a colour we can use given a reference number 00776 00777 ********************************************************************************************/ 00778 00779 DocColour *CMXImportFilter::GetColourFromReference(INT32 Ref) 00780 { 00781 if(Ref <= 0 || Ref > Data->NumColours) 00782 CMXFORMATERROR(0); 00783 00784 return Data->Colours[Ref-1].GetColour(); 00785 } 00786 00787 00788 /******************************************************************************************** 00789 00790 > BOOL CMXImportFilter::AddColoursToDocument(void) 00791 00792 Author: Ben_Summers (Xara Group Ltd) <camelotdev@xara.com> 00793 Created: 13/08/96 00794 Inputs: None 00795 Returns: error flag 00796 Purpose: adds the colours (only the ones which have been used) to the document 00797 to keep everything happy 00798 00799 ********************************************************************************************/ 00800 00801 BOOL CMXImportFilter::AddColoursToDocument(void) 00802 { 00803 // sort out a colour list 00804 ColourList *ColList = TheDocument->GetIndexedColours(); 00805 00806 for(INT32 l = 0; l < Data->NumColours; l++) 00807 { 00808 // if the colour is used, add it's indexed colour to the list 00809 if(Data->Colours[l].IsUsed()) 00810 { 00811 ColList->GetUnnamedColours()->AddTail(Data->Colours[l].GetIndexedColour()); 00812 } 00813 } 00814 00815 return TRUE; //CDRFilter::AddStandardColourSet(TheDocument); 00816 } 00817 00818