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 "rechcol.h"
00104 #include "colcomp.h"
00105
00106 #include "cxftags.h"
00107
00108
00109 DECLARE_SOURCE("$Revision: 1688 $");
00110
00111
00112 CC_IMPLEMENT_DYNAMIC(ColourRecordHandler,CamelotRecordHandler);
00113
00114
00115 #define new CAM_DEBUG_NEW
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 BOOL ColourRecordHandler::BeginImport()
00135 {
00136 pColComponent = GetColourDocComponent();
00137
00138 return (pColComponent != NULL);
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 UINT32* ColourRecordHandler::GetTagList()
00156 {
00157 static UINT32 TagList[] = {TAG_DEFINERGBCOLOUR,TAG_DEFINECOMPLEXCOLOUR,CXFRH_TAG_LIST_END};
00158
00159 return (UINT32*)&TagList;
00160 }
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 BOOL ColourRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord)
00177 {
00178 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"ColourRecordHandler::HandleRecord pCXaraFileRecord is NULL");
00179
00180 BOOL ok = TRUE;
00181
00182 switch (pCXaraFileRecord->GetTag())
00183 {
00184 case TAG_DEFINERGBCOLOUR:
00185
00186 if (pColComponent)
00187 ok = pColComponent->ImportSimpleColour(pCXaraFileRecord);
00188 else
00189 ERROR3("ColourRecordHandler::HandleRecord no pColComponent");
00190 break;
00191 case TAG_DEFINECOMPLEXCOLOUR:
00192
00193 if (pColComponent)
00194 ok = pColComponent->ImportColourDefinition(pCXaraFileRecord);
00195 else
00196 ERROR3("ColourRecordHandler::HandleRecord no pColComponent");
00197 break;
00198
00199 default:
00200 ok = FALSE;
00201 ERROR3_PF(("ColourRecordHandler::HandleRecord I don't handle records with the tag (%d)\n",pCXaraFileRecord->GetTag()));
00202 break;
00203 }
00204
00205 return ok;
00206 }
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223 #ifdef XAR_TREE_DIALOG
00224 void ColourRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord, StringBase* pStr)
00225 {
00226 if (pStr == NULL || pRecord == NULL)
00227 return;
00228
00229
00230
00231 CamelotRecordHandler::GetRecordDescriptionText(pRecord,pStr);
00232
00233 UINT32 Tag = pRecord->GetTag();
00234 BOOL ok = TRUE;
00235 TCHAR s[256];
00236 INT32 RecordNumber = pRecord->GetRecordNumber();
00237 switch (Tag)
00238 {
00239 case TAG_DEFINERGBCOLOUR:
00240 {
00241 camSprintf(s,_T("Define simple colour reference %d\r\n\r\n"),RecordNumber);
00242 (*pStr) += s;
00243
00244 BYTE Red = 0;
00245 if (ok) ok = pRecord->ReadBYTE(&Red);
00246 camSprintf(s,_T("Red\t= %d\r\n"),Red);
00247 (*pStr) += s;
00248 BYTE Green = 0;
00249 if (ok) ok = pRecord->ReadBYTE(&Green);
00250 camSprintf(s,_T("Green\t= %d\r\n"),Green);
00251 (*pStr) += s;
00252 BYTE Blue = 0;
00253 if (ok) ok = pRecord->ReadBYTE(&Blue);
00254 camSprintf(s,_T("Blue\t= %d\r\n"),Blue);
00255 (*pStr) += s;
00256 break;
00257 }
00258
00259 case TAG_DEFINECOMPLEXCOLOUR:
00260 {
00261 camSprintf(s,_T("Define complex colour reference %d\r\n"),RecordNumber);
00262 (*pStr) += s;
00263
00264 BYTE Red = 0;
00265 if (ok) ok = pRecord->ReadBYTE(&Red);
00266 camSprintf(s,_T("Red\t= %d\r\n"),Red);
00267 (*pStr) += s;
00268 BYTE Green = 0;
00269 if (ok) ok = pRecord->ReadBYTE(&Green);
00270 camSprintf(s,_T("Green\t= %d\r\n"),Green);
00271 (*pStr) += s;
00272 BYTE Blue = 0;
00273 if (ok) ok = pRecord->ReadBYTE(&Blue);
00274 camSprintf(s,_T("Blue\t= %d\r\n"),Blue);
00275 (*pStr) += s;
00276
00277
00278 ColourModel ColModel = COLOURMODEL_RGBT;
00279 BYTE temp;
00280 if (ok) ok = pRecord->ReadBYTE(&temp);
00281 ColModel = (ColourModel)temp;
00282
00283
00284 ExportColourType ColType = EXPORT_COLOURTYPE_NORMAL;
00285 if (ok) ok = pRecord->ReadBYTE(&temp);
00286 ColType = (ExportColourType)temp;
00287
00288
00289 UINT32 EntryNumber = 0;
00290 if (ok) ok = pRecord->ReadUINT32(&EntryNumber);
00291
00292
00293 UINT32 ParentColour = 0;
00294 if (ok) ok = pRecord->ReadUINT32(&ParentColour);
00295
00296
00297 UINT32 Comp1 = 0;
00298 if (ok) ok = pRecord->ReadUINT32(&Comp1);
00299 UINT32 Comp2 = 0;
00300 if (ok) ok = pRecord->ReadUINT32(&Comp2);
00301 UINT32 Comp3 = 0;
00302 if (ok) ok = pRecord->ReadUINT32(&Comp3);
00303 UINT32 Comp4 = 0;
00304 if (ok) ok = pRecord->ReadUINT32(&Comp4);
00305
00306 String_64 ColName;
00307 if (ok) ok = pRecord->ReadUnicode(&ColName);
00308 if (ColName.Length() == 0)
00309 (*pStr) += _T("Unnamed\r\n\r\n");
00310 else
00311 {
00312 (*pStr) += _T("Colour name:- ");
00313 (*pStr) += ColName;
00314 (*pStr) += _T("\r\n\r\n");
00315 }
00316 if (ParentColour != 0)
00317 {
00318 camSprintf(s,_T("Parent colour reference = %d\r\n"),ParentColour);
00319 (*pStr) += s;
00320 }
00321 camSprintf(s,_T("Entry number in list = %d\r\n\r\n"),EntryNumber);
00322 (*pStr) += s;
00323
00324
00325 BOOL Linked = (ColType == EXPORT_COLOURTYPE_LINKED);
00326 switch (ColType)
00327 {
00328 case EXPORT_COLOURTYPE_NORMAL:
00329 (*pStr) += _T("Normal colour\r\n");
00330 DecodeColour(ColModel, Comp1, Comp2, Comp3, Comp4, Linked, pStr);
00331 break;
00332 case EXPORT_COLOURTYPE_SPOT:
00333 (*pStr) += _T("Spot colour\r\n");
00334 DecodeColour(ColModel, Comp1, Comp2, Comp3, Comp4, Linked, pStr);
00335 break;
00336 case EXPORT_COLOURTYPE_LINKED:
00337 (*pStr) += _T("Linked colour\r\n");
00338 DecodeColour(ColModel, Comp1, Comp2, Comp3, Comp4, Linked, pStr);
00339 break;
00340
00341 case EXPORT_COLOURTYPE_TINT:
00342 {
00343 (*pStr) += _T("Tint colour\r\n");
00344 FIXED24 Value24 = 0.0;
00345 Value24.SetAsFixed24(Comp1);
00346 camSprintf(s,_T("\tTint\t= %f\r\n"),Value24.MakeDouble());
00347 (*pStr) += s;
00348 }
00349 break;
00350
00351 case EXPORT_COLOURTYPE_SHADE:
00352 {
00353 (*pStr) += _T("Shade colour\r\n");
00354 FIXED24 Value24 = 0.0;
00355 Value24.SetAsFixed24(Comp1);
00356 camSprintf(s,_T("\tSaturation\t= %f\r\n"),Value24.MakeDouble());
00357 (*pStr) += s;
00358 Value24.SetAsFixed24(Comp2);
00359 camSprintf(s,_T("\tValue\t= %f\r\n"),Value24.MakeDouble());
00360 (*pStr) += s;
00361 }
00362 break;
00363
00364 default:
00365 (*pStr) += _T("Unknown type of colour\r\n");
00366 break;
00367 }
00368 }
00369 break;
00370 }
00371
00372 return;
00373 }
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393 void ColourRecordHandler::DecodeColour(ColourModel ColModel, UINT32 Comp1, UINT32 Comp2, UINT32 Comp3, UINT32 Comp4,
00394 BOOL Linked, StringBase* pStr)
00395 {
00396
00397 switch (ColModel)
00398 {
00399 case COLOURMODEL_RGBT:
00400 (*pStr) += _T("\tRed\t= ");
00401 DecodeComponent(Comp1, Linked, pStr);
00402 (*pStr) += _T("\tGreen\t= ");
00403 DecodeComponent(Comp2, Linked, pStr);
00404 (*pStr) += _T("\tBlue\t= ");
00405 DecodeComponent(Comp3, Linked, pStr);
00406 break;
00407
00408 case COLOURMODEL_CMYK:
00409 (*pStr) += _T("\tCyan\t= ");
00410 DecodeComponent(Comp1, Linked, pStr);
00411 (*pStr) += _T("\tMagenta\t= ");
00412 DecodeComponent(Comp2, Linked, pStr);
00413 (*pStr) += _T("\tYellow\t= ");
00414 DecodeComponent(Comp3, Linked, pStr);
00415 (*pStr) += _T("\tKey\t= ");
00416 DecodeComponent(Comp4, Linked, pStr);
00417 break;
00418 case COLOURMODEL_HSVT:
00419 (*pStr) += _T("\tHue\t\t= ");
00420 DecodeComponent(Comp1, Linked, pStr);
00421 (*pStr) += _T("\tSaturation\t= ");
00422 DecodeComponent(Comp2, Linked, pStr);
00423 (*pStr) += _T("\tValue\t\t= ");
00424 DecodeComponent(Comp3, Linked, pStr);
00425 break;
00426
00427 case COLOURMODEL_GREYT:
00428 (*pStr) += _T("\tGreyscale\t= ");
00429 DecodeComponent(Comp1, Linked, pStr);
00430 break;
00431 default:
00432 (*pStr) += _T("\tUnknown colour model\r\n");
00433 break;
00434 }
00435
00436 return;
00437 }
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455 void ColourRecordHandler::DecodeComponent(UINT32 Comp, BOOL Linked, StringBase* pStr)
00456 {
00457 TCHAR s[256];
00458
00459 FIXED24 LinkValue = FIXED24(-8.0);
00460 FIXED24 Value24 = 0.0;
00461 Value24.SetAsFixed24(Comp);
00462 if (Linked && (Value24 == LinkValue))
00463 {
00464 (*pStr) += _T("Inherits\r\n");
00465 }
00466 else
00467 {
00468 camSprintf(s,_T("%f\r\n"),Value24.MakeDouble());
00469 (*pStr) += s;
00470 }
00471 }
00472
00473 #endif
00474
00475
00476