00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #include "camtypes.h"
00102
00103 #include "rechbmp.h"
00104 #include "bmpcomp.h"
00105
00106 #include "cxfile.h"
00107 #include "cxftags.h"
00108
00109
00110
00111
00112 #include "nodebmp.h"
00113
00114
00115 DECLARE_SOURCE("$Revision: 1688 $");
00116
00117
00118 #define new CAM_DEBUG_NEW
00119
00120
00121 CC_IMPLEMENT_DYNAMIC(BitmapRecordHandler,CamelotRecordHandler);
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 BOOL BitmapRecordHandler::BeginImport()
00141 {
00142 pBmpComponent = GetBitmapDocComponent();
00143
00144 return (pBmpComponent != NULL);
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 UINT32* BitmapRecordHandler::GetTagList()
00162 {
00163 static UINT32 TagList[] = {TAG_NODE_BITMAP, TAG_NODE_CONTONEDBITMAP,
00164 TAG_DEFINEBITMAP_BMP, TAG_DEFINEBITMAP_GIF, TAG_DEFINEBITMAP_JPEG,
00165 TAG_DEFINEBITMAP_PNG, TAG_DEFINEBITMAP_BMPZIP, TAG_DEFINESOUND_WAV,
00166 TAG_DEFINEBITMAP_JPEG8BPP,
00167 TAG_PREVIEWBITMAP_BMP, TAG_PREVIEWBITMAP_GIF, TAG_PREVIEWBITMAP_JPEG,
00168 TAG_PREVIEWBITMAP_PNG, TAG_PREVIEWBITMAP_TIFFLZW,
00169 TAG_DEFINEBITMAP_XPE,
00170 CXFRH_TAG_LIST_END};
00171
00172 return (UINT32*)&TagList;
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 BOOL BitmapRecordHandler::IsStreamed(UINT32 Tag)
00191 {
00192
00193 BOOL Streamed = FALSE;
00194 switch (Tag)
00195 {
00196 case TAG_NODE_BITMAP:
00197 case TAG_NODE_CONTONEDBITMAP:
00198 case TAG_DEFINEBITMAP_XPE:
00199
00200 Streamed = FALSE;
00201 break;
00202 case TAG_PREVIEWBITMAP_BMP:
00203 case TAG_PREVIEWBITMAP_GIF:
00204 case TAG_PREVIEWBITMAP_JPEG:
00205 case TAG_PREVIEWBITMAP_PNG:
00206 case TAG_PREVIEWBITMAP_TIFFLZW:
00207 case TAG_DEFINEBITMAP_BMP:
00208 case TAG_DEFINEBITMAP_GIF:
00209 case TAG_DEFINEBITMAP_JPEG:
00210 case TAG_DEFINEBITMAP_PNG:
00211 case TAG_DEFINEBITMAP_BMPZIP:
00212 case TAG_DEFINESOUND_WAV:
00213 case TAG_DEFINEBITMAP_JPEG8BPP:
00214
00215 Streamed = TRUE;
00216 break;
00217 default:
00218 Streamed = FALSE;
00219 ERROR3_PF(("BitmapRecordHandler::IsStreamed I don't handle records with the tag (%d)\n", Tag));
00220 break;
00221 }
00222
00223 return Streamed;
00224 }
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 BOOL BitmapRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord)
00241 {
00242 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"BitmapRecordHandler::HandleRecord pCXaraFileRecord is NULL");
00243
00244 BOOL ok = TRUE;
00245
00246 INT32 Tag = pCXaraFileRecord->GetTag();
00247 switch (Tag)
00248 {
00249 case TAG_NODE_BITMAP:
00250 {
00251
00252 ok = HandleNodeBitmap(pCXaraFileRecord, Tag);
00253 break;
00254 }
00255 case TAG_NODE_CONTONEDBITMAP:
00256 {
00257
00258 ok = HandleNodeBitmap(pCXaraFileRecord, Tag);
00259 break;
00260 }
00261 case TAG_DEFINEBITMAP_XPE:
00262 {
00263
00264 ok = HandleXPEBitmapPlaceHolder(pCXaraFileRecord, Tag);
00265 break;
00266 }
00267
00268 default:
00269 ok = FALSE;
00270 ERROR3_PF(("BitmapRecordHandler::HandleRecord I don't handle records with the tag (%d)\n", Tag));
00271 break;
00272 }
00273
00274 return ok;
00275 }
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 BOOL BitmapRecordHandler::HandleStreamedRecord(CXaraFile * pCXFile, UINT32 Tag,UINT32 Size,UINT32 RecordNumber)
00297 {
00298 ERROR2IF(pCXFile == NULL,FALSE,"BitmapRecordHandler::HandleStreamedRecord pCXFile is NULL");
00299
00300 BOOL ok = TRUE;
00301
00302 switch (Tag)
00303 {
00304 case TAG_PREVIEWBITMAP_BMP:
00305 case TAG_PREVIEWBITMAP_GIF:
00306 case TAG_PREVIEWBITMAP_JPEG:
00307 case TAG_PREVIEWBITMAP_PNG:
00308 case TAG_PREVIEWBITMAP_TIFFLZW:
00309 {
00310
00311 TRACEUSER( "Neville", _T("BitmapRecordHandler::HandleStreamedRecord PREVIEWBITMAP\n"));
00312
00313
00314 CCLexFile* pFile = pCXFile->GetCCFile();
00315 if (pFile)
00316 {
00317
00318 FilePos pos = pFile->tellIn();
00319 pFile->seekIn(pos + Size);
00320 }
00321 break;
00322 }
00323 case TAG_DEFINEBITMAP_BMP:
00324 case TAG_DEFINEBITMAP_GIF:
00325 case TAG_DEFINEBITMAP_JPEG:
00326 case TAG_DEFINEBITMAP_PNG:
00327 case TAG_DEFINEBITMAP_BMPZIP:
00328 case TAG_DEFINEBITMAP_JPEG8BPP:
00329
00330 if (pBmpComponent)
00331 {
00332 TRACEUSER( "Neville", _T("BitmapRecordHandler::HandleStreamedRecord DEFINEBITMAP\n"));
00333 ok = pBmpComponent->LoadBitmapDefinition(this, pCXFile, Tag, Size, RecordNumber);
00334 }
00335 else
00336 ERROR3("BitmapRecordHandler::HandleStreamedRecord no pBmpComponent");
00337 break;
00338
00339 case TAG_DEFINESOUND_WAV:
00340 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00341 TRACEUSER( "Neville", _T("BitmapRecordHandler::HandleStreamedRecord DEFINESOUND\n"));
00342 ok = SGLibOil::LoadSoundDefinition(this, pCXFile, Tag, Size, RecordNumber);
00343 #endif
00344 break;
00345
00346 default:
00347 ok = FALSE;
00348 ERROR3_PF(("BitmapRecordHandler::HandleStreamedRecord I don't handle records with the tag (%d)\n", Tag));
00349 break;
00350 }
00351
00352 return ok;
00353 }
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371 BOOL BitmapRecordHandler::HandleNodeBitmap(CXaraFileRecord* pCXaraFileRecord, INT32 Tag)
00372 {
00373 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"BitmapRecordHandler::HandleNodeBitmap pCXaraFileRecord is NULL");
00374
00375 BOOL ok = TRUE;
00376
00377
00378 NodeBitmap * pNodeBmp = NULL;
00379 pNodeBmp = new NodeBitmap;
00380 if ((pNodeBmp == NULL) || (!pNodeBmp->SetUpPath(12,12)))
00381 return FALSE;
00382
00383
00384
00385
00386
00387 DocCoord Parallel[4];
00388 INT32 i;
00389 for (i = 0; i < 4; i++)
00390 {
00391 if (ok) ok = pCXaraFileRecord->ReadCoord(&Parallel[i]);
00392 pNodeBmp->Parallel[i] = Parallel[i];
00393 }
00394
00395
00396 pNodeBmp->InkPath.InsertMoveTo(Parallel[0]);
00397
00398 for (i = 1; i <= 3; i++)
00399 pNodeBmp->InkPath.InsertLineTo(Parallel[i]);
00400
00401 pNodeBmp->InkPath.InsertLineTo(Parallel[0]);
00402 pNodeBmp->InkPath.CloseSubPath();
00403
00404
00405
00406 INT32 BitmapRecordRef = 0;
00407 if (ok) ok = pCXaraFileRecord->ReadINT32(&BitmapRecordRef);
00408 if (BitmapRecordRef == 0)
00409 return FALSE;
00410
00411 KernelBitmap * pBitmap = NULL;
00412 pBitmap = GetReadBitmapReference(BitmapRecordRef);
00413 if (pBitmap == NULL)
00414 return FALSE;
00415
00416
00417 pNodeBmp->GetBitmapRef()->Attach(pBitmap, NULL);
00418
00419 pNodeBmp->InvalidateBoundingRect();
00420 if (ok) ok = InsertNode(pNodeBmp);
00421
00422
00423
00424 INT32 StartColourRecordRef = 0;
00425 INT32 EndColourRecordRef = 0;
00426 switch (Tag)
00427 {
00428 case TAG_NODE_CONTONEDBITMAP:
00429 {
00430
00431 if (ok) ok = pCXaraFileRecord->ReadINT32(&StartColourRecordRef);
00432 if (ok) ok = pCXaraFileRecord->ReadINT32(&EndColourRecordRef);
00433
00434 DocColour * pStartColour = new DocColour;
00435 if (pStartColour && ok)
00436 ok = GetDocColour(StartColourRecordRef, pStartColour);
00437 pNodeBmp->SetStartColour(pStartColour);
00438 delete pStartColour;
00439
00440 DocColour * pEndColour = new DocColour;
00441 if (pEndColour && ok)
00442 ok = GetDocColour(EndColourRecordRef, pEndColour);
00443 pNodeBmp->SetEndColour(pEndColour);
00444 delete pEndColour;
00445 break;
00446 }
00447
00448 case TAG_NODE_BITMAP:
00449 {
00450
00451 pNodeBmp->SetStartColour(NULL);
00452 pNodeBmp->SetEndColour(NULL);
00453 break;
00454 }
00455
00456 default:
00457 ok = FALSE;
00458 ERROR3_PF(("BitmapRecordHandler::HandleNodeBitmap I don't handle records with the tag (%d)\n", Tag));
00459 break;
00460 }
00461
00462 return ok;
00463 }
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482 BOOL BitmapRecordHandler::HandleXPEBitmapPlaceHolder(CXaraFileRecord* pCXaraFileRecord, INT32 Tag)
00483 {
00484 ERROR2IF(pCXaraFileRecord == NULL, FALSE,
00485 "BitmapRecordHandler::HandleXPEBitmapPlaceHolder pCXaraFileRecord is NULL");
00486
00487 BOOL ok = TRUE;
00488
00489
00490
00491
00492
00493
00494 KernelBitmap* pBitmap = NULL;
00495
00496
00497
00498
00499 pBitmap = KernelBitmap::MakeKernelBitmap(NULL, NULL, TRUE);
00500
00501
00502
00503
00504
00505
00506 if (pBitmap != NULL)
00507 {
00508 PORTNOTETRACE("other","HandleXPEBitmapPlaceHolder - Removed ImportedBitmaps usage");
00509 #ifndef EXCLUDE_FROM_XARALX
00510 pBmpComponent->GetImportList()->AddBitmap(pBitmap, pCXaraFileRecord->GetRecordNumber());
00511 #endif
00512 }
00513
00514 return ok;
00515 }
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533 #ifdef XAR_TREE_DIALOG
00534 void BitmapRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord, StringBase* pStr)
00535 {
00536 if (pStr == NULL || pRecord == NULL)
00537 return;
00538
00539
00540
00541 CamelotRecordHandler::GetRecordDescriptionText(pRecord,pStr);
00542
00543 UINT32 Tag = pRecord->GetTag();
00544 BOOL ok = TRUE;
00545 TCHAR s[340];
00546 INT32 RecordNumber = pRecord->GetRecordNumber();
00547
00548
00549 String_256 BmpName;
00550 String_256 BitmapDetails;
00551 if (Tag >= TAG_DEFINEBITMAP_BMP && Tag <= TAG_DEFINEBITMAP_BMPZIP)
00552 {
00553 if (ok) ok = pRecord->ReadUnicode(&BmpName);
00554 if (BmpName.Length() == 0)
00555 BmpName = _T("Unnamed\r\n\r\n");
00556 else
00557 {
00558 BitmapDetails = _T("Bitmap name:- ");
00559 BitmapDetails += BmpName;
00560 BitmapDetails += _T("\r\n\r\n");
00561 }
00562 }
00563
00564 INT32 BitmapRecordRef = 0;
00565 INT32 StartColourRecordRef = 0;
00566 INT32 EndColourRecordRef = 0;
00567 DocCoord Parallel[4];
00568 switch (Tag)
00569 {
00570
00571 case TAG_NODE_BITMAP:
00572 {
00573
00574 if (ok) ok = pRecord->ReadCoord(&Parallel[0]);
00575 if (ok) ok = pRecord->ReadCoord(&Parallel[1]);
00576 if (ok) ok = pRecord->ReadCoord(&Parallel[2]);
00577 if (ok) ok = pRecord->ReadCoord(&Parallel[3]);
00578 if (ok) ok = pRecord->ReadINT32(&BitmapRecordRef);
00579 (*pStr) += _T("Node bitmap\r\n\r\n");
00580 camSprintf(s,_T("Bitmap reference : %d\r\n\r\n"),BitmapRecordRef);
00581 (*pStr) += s;
00582 (*pStr) += _T("\tNum\tX Coord\tY Coord\r\n");
00583 for (INT32 i = 0; i < 4; i++)
00584 {
00585 camSprintf(s,_T("\t%d\t%d\t%d\r\n"),i,Parallel[i].x,Parallel[i].y);
00586 (*pStr) += s;
00587 }
00588 break;
00589 }
00590 case TAG_NODE_CONTONEDBITMAP:
00591 {
00592
00593 if (ok) ok = pRecord->ReadCoord(&Parallel[0]);
00594 if (ok) ok = pRecord->ReadCoord(&Parallel[1]);
00595 if (ok) ok = pRecord->ReadCoord(&Parallel[2]);
00596 if (ok) ok = pRecord->ReadCoord(&Parallel[3]);
00597 if (ok) ok = pRecord->ReadINT32(&BitmapRecordRef);
00598 if (ok) ok = pRecord->ReadINT32(&StartColourRecordRef);
00599 if (ok) ok = pRecord->ReadINT32(&EndColourRecordRef);
00600 camSprintf(s,_T("Node contoned bitmap\r\n\r\n"));
00601 (*pStr) += s;
00602 camSprintf(s,_T("Bitmap reference :\t %d\r\n\r\n"),BitmapRecordRef);
00603 (*pStr) += s;
00604 camSprintf(s,_T("Start colour reference :\t %d\r\n\r\n"),StartColourRecordRef);
00605 (*pStr) += s;
00606 camSprintf(s,_T("End colour reference :\t %d\r\n\r\n"),EndColourRecordRef);
00607 (*pStr) += s;
00608 camSprintf(s,_T("\tNum\tX Coord\tY Coord\r\n"));
00609 (*pStr) += s;
00610 for (INT32 i = 0; i < 4; i++)
00611 {
00612 camSprintf(s,_T("\t%d\t%d\t%d\r\n"),i,Parallel[i].x,Parallel[i].y);
00613 (*pStr) += s;
00614 }
00615 break;
00616 }
00617
00618 case TAG_PREVIEWBITMAP_BMP:
00619 (*pStr) += _T("Preview bitmap type BMP\r\n\r\n");
00620 break;
00621 case TAG_PREVIEWBITMAP_GIF:
00622 (*pStr) += _T("Preview bitmap type GIF\r\n\r\n");
00623 break;
00624 case TAG_PREVIEWBITMAP_JPEG:
00625 (*pStr) += _T("Preview bitmap type JPEG\r\n\r\n");
00626 break;
00627 case TAG_PREVIEWBITMAP_PNG:
00628 (*pStr) += _T("Preview bitmap type PNG\r\n\r\n");
00629 break;
00630 case TAG_PREVIEWBITMAP_TIFFLZW:
00631 (*pStr) += _T("Preview bitmap type TIFF LZW\r\n\r\n");
00632 break;
00633
00634
00635 case TAG_DEFINEBITMAP_BMP:
00636 camSprintf(s,_T("Define BMP bitmap reference %d\r\n\r\n"),RecordNumber);
00637 (*pStr) += s;
00638 (*pStr) += BitmapDetails;
00639 break;
00640 case TAG_DEFINEBITMAP_GIF:
00641 camSprintf(s,_T("Define GIF bitmap reference %d\r\n\r\n"),RecordNumber);
00642 (*pStr) += s;
00643 (*pStr) += BitmapDetails;
00644 break;
00645 case TAG_DEFINEBITMAP_JPEG:
00646 camSprintf(s,_T("Define JPEG bitmap reference %d\r\n\r\n"),RecordNumber);
00647 (*pStr) += s;
00648 (*pStr) += BitmapDetails;
00649 break;
00650 case TAG_DEFINEBITMAP_PNG:
00651 camSprintf(s,_T("Define PNG bitmap reference %d\r\n\r\n"),RecordNumber);
00652 (*pStr) += s;
00653 (*pStr) += BitmapDetails;
00654 break;
00655 case TAG_DEFINEBITMAP_BMPZIP:
00656 camSprintf(s,_T("Define zipped BMP bitmap reference %d\r\n\r\n"),RecordNumber);
00657 (*pStr) += s;
00658 (*pStr) += BitmapDetails;
00659 break;
00660 case TAG_DEFINEBITMAP_JPEG8BPP:
00661 {
00662 camSprintf(s,_T("Define 8bpp JPEG bitmap reference %d\r\n\r\n"),RecordNumber);
00663 (*pStr) += s;
00664 (*pStr) += BitmapDetails;
00665 BYTE Entries = 0;
00666 if (ok) ok = pRecord->ReadBYTE(&Entries);
00667 camSprintf(s,_T("Palette entries %d\r\n\r\n"),Entries + 1);
00668 (*pStr) += s;
00669 break;
00670 }
00671 default:
00672 (*pStr) += _T("Unknown type of bitmap record\r\n");
00673 break;
00674 }
00675
00676 return;
00677 }
00678 #endif // XAR_TREE_DIALOG
00679
00680
00681