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 #include "camtypes.h"
00101
00102
00103 #define COMPILING_CMXISTUT_CPP
00104
00105
00106
00107
00108
00109 #include "cmxistut.h"
00110 #include "cmxifltr.h"
00111 #include "cmxibits.h"
00112 #include "cmxform.h"
00113
00114
00115 #define new CAM_DEBUG_NEW
00116
00117
00118
00119
00120
00121
00122 START_CMXDESC(FileHeader)
00123 CI_READSTRINGF(32),
00124 CI_SKIPIN_BYTES(16),
00125 CI_READINT32,
00126 CI_READINT16,
00127 CI_READINT32,
00128 CI_READINT32,
00129 CI_READINT16,
00130 CI_READDOUBLE,
00131 CI_READINT32, CI_READINT32, CI_READINT32,
00132 CI_READINT32,
00133 CI_READINT32,
00134 CI_READINT32,
00135 CI_READINT32, CI_READINT32, CI_READINT32, CI_READINT32,
00136 CI_READINT32
00137 END_CMXDESC
00138
00139 START_CMXDESC(MasterIndexHeader)
00140 CI_READINT16,
00141 CI_READINT16,
00142 CI_READINT16
00143 END_CMXDESC
00144
00145 START_CMXDESC(MasterIndexEntry)
00146 CI_READINT16,
00147 CI_READOFFSET
00148 END_CMXDESC
00149
00150 START_CMXDESC(SimpleIndexHeader)
00151 CI_READINT16
00152 END_CMXDESC
00153
00154 START_CMXDESC(PageIndexEntry)
00155 CI_DO16,
00156 CI_SKIPOUT(INT32),
00157 CI_DO32,
00158 CI_STORENEXT,
00159 CI_READINT16,
00160 CI_SETINMARKER,
00161 CI_DOALL,
00162 CI_READOFFSET,
00163 CI_READOFFSET,
00164 CI_READOFFSET,
00165 CI_READOFFSET,
00166 CI_DO32,
00167 CI_ENSUREINLOC
00168 END_CMXDESC
00169
00170 START_CMXDESC(CommandHeader)
00171 CI_READUINT16,
00172 CI_READINT16
00173 END_CMXDESC
00174
00175 START_CMXDESC(BeginPage)
00176 CI_TAG(cmxTAG_BeginPage_PageSpecification),
00177 CI_READINT16,
00178 CI_READUINT32,
00179 CI_READBBOX,
00180 CI_READOFFSET,
00181 CI_READINT16,
00182 CI_READINT32,
00183 CI_ENDTAG,
00184 CI_TAG(cmxTAG_BeginPage_Matrix),
00185 CI_READMATRIX,
00186 CI_ENDTAG,
00187
00188 CI_MINENDTAG
00189 END_CMXDESC
00190
00191 START_CMXDESC(BeginLayer)
00192 CI_TAG(cmxTAG_BeginLayer_LayerSpecification),
00193 CI_READINT16,
00194 CI_READINT16,
00195 CI_READUINT32,
00196 CI_READINT32,
00197 CI_READSTRING,
00198 CI_ENDTAG,
00199 CI_TAG(cmxTAG_BeginLayer_Matrix),
00200 CI_READMATRIX,
00201 CI_ENDTAG,
00202
00203 CI_MINENDTAG
00204 END_CMXDESC
00205
00206
00207 START_CMXDESC(RenderAttr)
00208 CI_STORENEXT,
00209 CI_READBYTE,
00210
00211 CI_SETOUTMARKER,
00212 CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxRENDATTRMASK_FILL),
00213 CI_TAG(cmxTAG_RenderAttr_FillSpec),
00214 CI_STORENEXT,
00215 CI_READINT16,
00216
00217 CI_IFSTOREDIS(CI_IFTYPE_VALUE, cmxFILLID_UNIFORM),
00218 CI_TAG(cmxTAG_RenderAttr_FillSpec_Uniform),
00219 CI_READREFERENCE,
00220 CI_READREFERENCE,
00221 CI_ENDTAG,
00222 CI_MINENDTAG,
00223
00224 CI_ELSEIF(CI_IFTYPE_VALUE, cmxFILLID_FOUNTAIN),
00225 CI_TAG(cmxTAG_RenderAttr_FillSpec_Fountain_Base),
00226 CI_READINT16,
00227 CI_READREFERENCE,
00228 CI_READINT16,
00229 CI_READANGLE,
00230 CI_DO16,
00231 CI_SKIPIN(WORD),
00232 CI_DOALL,
00233 CI_READCOORD,
00234 CI_READINT16,
00235 CI_READINT16,
00236 CI_DO32,
00237 CI_READINT16,
00238 CI_READINT16,
00239 CI_DO16,
00240 CI_SKIPOUT_BYTES(sizeof(INT32) * 2),
00241 CI_DOALL,
00242 CI_ENDTAG,
00243 CI_TAG(cmxTAG_RenderAttr_FillSpec_Fountain_Color),
00244 CI_READCOLOURLIST,
00245 CI_ENDTAG,
00246 CI_MINENDTAG,
00247
00248 CI_ELSEIF(CI_IFTYPE_VALUE, cmxFILLID_PS),
00249 CI_TAG(cmxTAG_RenderAttr_FillSpec_Postscript_Base),
00250 CI_READREFERENCE,
00251 CI_STORENEXT,
00252 CI_READINT16,
00253 CI_SKIPINTIMES(WORD),
00254 CI_ENDTAG,
00255 CI_TAG(cmxTAG_RenderAttr_FillSpec_Postscript_UserFunc),
00256 CI_READSTRING,
00257 CI_ENDTAG,
00258 CI_MINENDTAG,
00259
00260 CI_ELSEIF(CI_IFTYPE_VALUE, cmxFILLID_COLPATTERN),
00261 CI_TAG(cmxTAG_RenderAttr_FillSpec_MonoBM),
00262 CI_READREFERENCE,
00263 CI_READTILING,
00264 CI_READREFERENCE,
00265 CI_READREFERENCE,
00266 CI_READREFERENCE,
00267 CI_ENDTAG,
00268 CI_MINENDTAG,
00269
00270 CI_ELSEIF(CI_IFTYPE_VALUE, cmxFILLID_BITMAPFILL),
00271 CI_TAG(cmxTAG_RenderAttr_FillSpec_ColorBM),
00272 CI_READREFERENCE,
00273 CI_READTILING,
00274 CI_READBBOX,
00275 CI_ENDTAG,
00276 CI_MINENDTAG,
00277
00278 CI_ELSEIF(CI_IFTYPE_VALUE, cmxFILLID_BITMAPFILL16),
00279 CI_TAG(cmxTAG_RenderAttr_FillSpec_ColorBM),
00280 CI_READREFERENCE,
00281 CI_READTILING,
00282 CI_READBBOX,
00283 CI_ENDTAG,
00284 CI_MINENDTAG,
00285
00286 CI_ELSEIF(CI_IFTYPE_VALUE, cmxFILLID_TEXTURE),
00287
00288 CI_TAG(cmxTAG_RenderAttr_FillSpec_Texture),
00289 CI_TAG(cmxTAG_RenderAttr_FillSpec_ColorBM),
00290 CI_READREFERENCE,
00291 CI_READTILING,
00292 CI_READBBOX,
00293 CI_ENDTAG,
00294 CI_MINENDTAG,
00295
00296 CI_SKIPIN_BYTES(7),
00297 CI_STORENEXT,
00298 CI_READINT16,
00299 CI_SKIPINTIMES(BYTE),
00300 CI_STORENEXT,
00301 CI_READINT16,
00302 CI_SKIPINTIMES(BYTE),
00303 CI_STORENEXT,
00304 CI_READINT16,
00305 CI_SKIPINTIMES(BYTE),
00306 CI_STORENEXT,
00307 CI_READINT16,
00308 CI_SKIPINTIMES_BYTES(8),
00309 CI_ENDTAG,
00310 CI_MINENDTAG,
00311
00312 CI_ENDIF,
00313 CI_ENDTAG,
00314 CI_MINENDTAG,
00315 CI_ENDIF,
00316 CI_GOTOOUTLOC(cmxiFillSpec),
00317
00318
00319 CI_SETOUTMARKER,
00320 CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxRENDATTRMASK_OUTLINE),
00321 CI_TAG(cmxTAG_RenderAttr_OutlineSpec),
00322 CI_READREFERENCE,
00323 CI_ENDTAG,
00324 CI_MINENDTAG,
00325 CI_ENDIF,
00326 CI_GOTOOUTLOC(INT32),
00327
00328
00329 CI_SETOUTMARKER,
00330 CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxRENDATTRMASK_LENS),
00331 CI_TAG(cmxTAG_RenderAttr_LensSpec_Base),
00332 CI_STORENEXT,
00333 CI_READBYTE,
00334 CI_IFSTOREDIS(CI_IFTYPE_VALUE, cmxLENSTYPE_GLASS),
00335 CI_READBYTE,
00336 CI_READINT16,
00337 CI_READREFERENCE,
00338 CI_READREFERENCE,
00339 CI_ELSEIF(CI_IFTYPE_VALUE, cmxLENSTYPE_MAGNIFYING),
00340 CI_READINT16,
00341 CI_READREFERENCE,
00342 CI_ELSEIF(CI_IFTYPE_VALUE, cmxLENSTYPE_FISHEYE),
00343 CI_READINT16,
00344 CI_READREFERENCE,
00345 CI_ELSEIF(CI_IFTYPE_VALUE, cmxLENSTYPE_FISHEYE2),
00346 CI_READINT16,
00347 CI_READREFERENCE,
00348 CI_ELSEIF(CI_IFTYPE_VALUE, cmxLENSTYPE_WIREFRAME),
00349 CI_READBYTE,
00350 CI_READREFERENCE,
00351 CI_READBYTE,
00352 CI_READREFERENCE,
00353 CI_READREFERENCE,
00354 CI_ELSEIF(CI_IFTYPE_VALUE, cmxLENSTYPE_WIREFRAME2 ),
00355 CI_READBYTE,
00356 CI_READREFERENCE,
00357 CI_READBYTE,
00358 CI_READREFERENCE,
00359 CI_READREFERENCE,
00360
00361
00362
00363
00364 CI_ENDIF,
00365
00366
00367 CI_IF_TAG(cmxTAG_RenderAttr_LensSpec_FrozViewp),
00368
00369
00370 CI_DOALL,
00371 CI_ENDTAG,
00372 CI_MINENDTAG,
00373 CI_ENDIF,
00374 CI_GOTOOUTLOC(cmxiLensSpec),
00375
00376
00377
00378 CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxRENDATTRMASK_CONTAIN),
00379 CI_TAG(cmxTAG_RenderAttr_ContainerSpec),
00380 CI_READREFERENCE,
00381 CI_READBOOLEAN,
00382 CI_ENDTAG,
00383 CI_MINENDTAG,
00384 CI_ENDIF
00385 END_CMXDESC
00386
00387 START_CMXDESC(PolyCurve)
00388 CI_TAG(cmxTAG_PolyCurve_RenderingAttr),
00389 CI_READRENDATTR,
00390 CI_ENDTAG,
00391 CI_TAG(cmxTAG_PolyCurve_PointList),
00392 CI_READPOINTLIST,
00393 CI_ENDTAG,
00394 CI_TAG(cmxTAG_PolyCurve_BoundingBox),
00395 CI_READBBOX,
00396 CI_ENDTAG,
00397 CI_MINENDTAG
00398 END_CMXDESC
00399
00400 START_CMXDESC ( Rectangle )
00401 CI_TAG ( cmxTAG_Rectangle_RenderingAttr ),
00402 CI_READRENDATTR,
00403 CI_ENDTAG,
00404 CI_TAG ( cmxTAG_Rectangle_RectangleSpecification ),
00405 CI_READCOORD,
00406 CI_READLENGTH,
00407 CI_READLENGTH,
00408 CI_READANGLE,
00409 CI_READANGLE,
00410 CI_READBBOX,
00411 CI_ENDTAG,
00412 CI_MINENDTAG
00413 END_CMXDESC
00414
00415 START_CMXDESC(AddGlobalTransform)
00416 CI_TAG(cmxTAG_AddGlobalTransform_Matrix),
00417 CI_READMATRIX,
00418 CI_ENDTAG,
00419 CI_MINENDTAG
00420 END_CMXDESC
00421
00422 START_CMXDESC(SetGlobalTransform)
00423 CI_TAG(cmxTAG_SetGlobalTransfo_Matrix),
00424 CI_READMATRIX,
00425 CI_ENDTAG,
00426 CI_MINENDTAG
00427 END_CMXDESC
00428
00429 START_CMXDESC(Colour)
00430 CI_TAG(cmxTAG_DescrSection_Color_Base),
00431 CI_STORENEXT,
00432 CI_READBYTE,
00433 CI_READBYTE,
00434 CI_ENDTAG,
00435 CI_TAG(cmxTAG_DescrSection_Color_ColorDescr),
00436 CI_IFSTOREDIS(CI_IFTYPE_VALUE, cmxCOLMODEL_PANTONE),
00437 CI_READINT16,
00438 CI_READINT16,
00439 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_CMYK),
00440 CI_READBYTE,
00441 CI_READBYTE,
00442 CI_READBYTE,
00443 CI_READBYTE,
00444 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_CMYK255),
00445 CI_READBYTE,
00446 CI_READBYTE,
00447 CI_READBYTE,
00448 CI_READBYTE,
00449 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_CMY),
00450 CI_READBYTE,
00451 CI_READBYTE,
00452 CI_READBYTE,
00453 CI_READBYTE,
00454 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_RGB),
00455 CI_READBYTE,
00456 CI_READBYTE,
00457 CI_READBYTE,
00458 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_HSB),
00459 CI_READINT16,
00460 CI_READBYTE,
00461 CI_READBYTE,
00462 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_HLS),
00463 CI_READINT16,
00464 CI_READBYTE,
00465 CI_READBYTE,
00466 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_BW),
00467 CI_READBYTE,
00468 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_LAB),
00469 CI_READBYTE,
00470 CI_READBYTE,
00471 CI_READBYTE,
00472 CI_READBYTE,
00473 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_GREY),
00474 CI_READBYTE,
00475 CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_YIG255),
00476 CI_READBYTE,
00477 CI_READBYTE,
00478 CI_READBYTE,
00479 CI_READBYTE,
00480 CI_ENDIF,
00481
00482 CI_ENDTAG,
00483 CI_MINENDTAG
00484 END_CMXDESC
00485
00486 START_CMXDESC(Outline)
00487 CI_TAG(cmxTAG_DescrSection_Outline),
00488 CI_READREFERENCE,
00489 CI_READREFERENCE,
00490 CI_READREFERENCE,
00491 CI_READREFERENCE,
00492 CI_READREFERENCE,
00493 CI_READREFERENCE,
00494 CI_ENDTAG,
00495 CI_MINENDTAG
00496 END_CMXDESC
00497
00498 START_CMXDESC(Pen)
00499 CI_TAG(cmxTAG_DescrSection_Pen),
00500 CI_READLENGTH,
00501 CI_READINT16,
00502 CI_READANGLE,
00503 CI_DO16,
00504 CI_SKIPIN(WORD),
00505 CI_DOALL,
00506 CI_READMATRIX,
00507 CI_ENDTAG,
00508 CI_MINENDTAG
00509 END_CMXDESC
00510
00511 START_CMXDESC(LineStyle)
00512 CI_TAG(cmxTAG_DescrSection_LineStyle),
00513 CI_READBYTE,
00514 CI_READBYTE,
00515 CI_ENDTAG,
00516 CI_MINENDTAG
00517 END_CMXDESC
00518
00519 START_CMXDESC(DotDash)
00520 CI_TAG(cmxTAG_DescrSection_Dash),
00521 CI_READINT16ARRAY,
00522 CI_ENDTAG,
00523 CI_MINENDTAG
00524 END_CMXDESC
00525
00526
00527 START_CMXDESC(DrawImage)
00528 CI_TAG(cmxTAG_DrawImage_RenderingAttr),
00529 CI_READRENDATTR,
00530 CI_ENDTAG,
00531 CI_TAG(cmxTAG_DrawImage_DrawImageSpecification),
00532 CI_READBBOX,
00533 CI_READBBOX,
00534 CI_READMATRIX,
00535 CI_READINT16,
00536 CI_READREFERENCE,
00537 CI_READREFERENCE,
00538 CI_ENDTAG,
00539 CI_MINENDTAG
00540 END_CMXDESC
00541
00542 START_CMXDESC(EmbeddedFileIndexEntry)
00543 CI_DO16,
00544 CI_SKIPOUT(INT32),
00545 CI_DO32,
00546 CI_STORENEXT,
00547 CI_READINT16,
00548 CI_SETINMARKER,
00549 CI_DOALL,
00550 CI_READOFFSET,
00551 CI_READINT16,
00552 CI_DO32,
00553 CI_ENSUREINLOC
00554 END_CMXDESC
00555
00556 START_CMXDESC(ProcedureIndexEntry)
00557 CI_DO16,
00558 CI_SKIPOUT(INT32),
00559 CI_DO32,
00560 CI_STORENEXT,
00561 CI_READINT16,
00562 CI_SETINMARKER,
00563 CI_DOALL,
00564 CI_READOFFSET,
00565 CI_READOFFSET,
00566 CI_DO32,
00567 CI_ENSUREINLOC
00568 END_CMXDESC
00569
00570 START_CMXDESC(JumpAbsolute)
00571 CI_TAG(cmxTAG_JumpAbsolute_Offset),
00572 CI_READOFFSET,
00573 CI_ENDTAG,
00574 CI_MINENDTAG
00575 END_CMXDESC
00576
00577 START_CMXDESC(ImageInfo)
00578 CI_TAG(cmxTAG_DescrSection_Image_ImageInfo),
00579 CI_READINT16,
00580 CI_READINT16,
00581 CI_READINT32,
00582 CI_READINT32,
00583 CI_ENDTAG,
00584 CI_MINENDTAG
00585 END_CMXDESC
00586
00587 START_CMXDESC(ImageContents)
00588 CI_DO32,
00589 CI_SKIPIN_BYTES(5),
00590 CI_DOALL,
00591 CI_READUINT16,
00592 CI_READUINT32,
00593 CI_READUINT16,
00594 CI_READUINT16,
00595 CI_READUINT32
00596 END_CMXDESC
00597
00598 START_CMXDESC(ImageContentsDIB)
00599 CI_READUINT16,
00600 CI_READUINT32,
00601 CI_READUINT16,
00602 CI_READUINT16,
00603 CI_READUINT32
00604 END_CMXDESC
00605
00606 START_CMXDESC(RImageHeader)
00607 CI_READUINT32,
00608 CI_READUINT32,
00609 CI_READUINT32,
00610 CI_READUINT32,
00611 CI_READUINT32,
00612 CI_READUINT32,
00613 CI_READUINT32,
00614 CI_READUINT32,
00615 CI_READUINT32,
00616 CI_READUINT32,
00617 CI_READUINT32,
00618 CI_READINT32,
00619 CI_READINT32,
00620 CI_READINT32,
00621 CI_READINT32,
00622 CI_READINT32
00623 END_CMXDESC
00624
00625 START_CMXDESC(RImagePalette)
00626 CI_READINT16,
00627 CI_READINT16
00628 END_CMXDESC
00629
00630 START_CMXDESC(RImagePaletteEntry)
00631 CI_READBYTE,
00632 CI_READBYTE,
00633 CI_READBYTE
00634 END_CMXDESC
00635
00636 START_CMXDESC(Tiling)
00637 CI_TAG(cmxTAG_Tiling),
00638 CI_READLENGTH,
00639 CI_READLENGTH,
00640 CI_READINT16,
00641 CI_READINT16,
00642 CI_READINT16,
00643 CI_READINT16,
00644 CI_ENDTAG,
00645 CI_MINENDTAG
00646 END_CMXDESC
00647
00648
00649 START_CMXDESC(AddClippingRegion)
00650 CI_TAG(cmxTAG_AddClippingRegion_RegionSpecification),
00651 CI_STORENEXT,
00652 CI_READINT16,
00653 CI_SETOUTMARKER,
00654
00655 CI_IFSTOREDIS(CI_IFTYPE_VALUE, 1),
00656 CI_READLENGTH,
00657 CI_READLENGTH,
00658 CI_ELSEIF(CI_IFTYPE_VALUE, 2),
00659 CI_READLENGTH,
00660 CI_READLENGTH,
00661 CI_ELSEIF(CI_IFTYPE_VALUE, 3),
00662 CI_READBBOX,
00663 CI_ELSEIF(CI_IFTYPE_VALUE, 4),
00664 CI_READPOINTLIST,
00665 CI_ENDIF,
00666
00667 CI_GOTOOUTLOC(cmxiRegionSpec),
00668 CI_ENDTAG,
00669 CI_TAG(cmxTAG_AddClippingRegion_ClipModeRecoverySpecification),
00670 CI_READINT16,
00671 CI_READINT16,
00672 CI_ENDTAG,
00673 CI_MINENDTAG
00674 END_CMXDESC
00675
00676 START_CMXDESC(ArrowShapeIndexHeader)
00677 CI_READINT16,
00678 CI_DO32,
00679 CI_READINT16,
00680 CI_DO16,
00681 CI_SKIPOUT(INT32),
00682 CI_DOALL,
00683 CI_READINT16
00684 END_CMXDESC
00685
00686 START_CMXDESC(ArrowShapeIndexEntry)
00687 CI_READOFFSET
00688 END_CMXDESC
00689
00690 START_CMXDESC(ArrowShape)
00691 CI_TAG(cmxTAG_DescrSection_Arrow),
00692 CI_READPOINTLIST,
00693 CI_READLENGTH,
00694 CI_ENDTAG,
00695 CI_MINENDTAG
00696 END_CMXDESC
00697
00698 START_CMXDESC(Arrowheads)
00699 CI_READREFERENCE,
00700 CI_READREFERENCE
00701 END_CMXDESC
00702
00703 START_CMXDESC(BitmapIndexHeader)
00704 CI_READINT16,
00705 CI_DO32,
00706 CI_READINT16,
00707 CI_DO16,
00708 CI_SKIPOUT(INT32),
00709 CI_DOALL,
00710 CI_READINT16
00711 END_CMXDESC
00712
00713 START_CMXDESC(BitmapIndexEntry)
00714 CI_READOFFSET
00715 END_CMXDESC
00716
00717
00718 START_CMXDESC(BeginTextStream)
00719 CI_TAG(cmxTAG_BeginTextStream_TextStreamSpecification),
00720 CI_READBOOLEAN,
00721 CI_READBYTE,
00722 CI_READBBOX,
00723 CI_READINT16,
00724 CI_READINT16,
00725 CI_READINT32,
00726 CI_ENDTAG,
00727 CI_MINENDTAG
00728 END_CMXDESC
00729
00730 START_CMXDESC(TextFrame)
00731 CI_TAG(cmxTAG_TextFrame_ColumnSpecification),
00732
00733
00734
00735
00736
00737
00738
00739
00740 CI_READCOLUMN,
00741 CI_ENDTAG,
00742 CI_TAG(cmxTAG_TextFrame_HeightSkewMatrix),
00743 CI_READLENGTH,
00744 CI_READLENGTH,
00745 CI_READMATRIX,
00746 CI_ENDTAG,
00747 CI_MINENDTAG
00748 END_CMXDESC
00749
00750
00751 START_CMXDESC(BeginParagraph)
00752 CI_TAG(cmxTAG_BeginParagraph_RenderingAttr),
00753 CI_READRENDATTR,
00754 CI_ENDTAG,
00755 CI_TAG(cmxTAG_BeginParagraph_FontSpecification),
00756 CI_READREFERENCE,
00757
00758 CI_READLENGTH,
00759 CI_ENDTAG,
00760
00761
00762
00763 CI_TAG(cmxTAG_BeginParagraph_KerningSpecification),
00764 CI_READLENGTH,
00765 CI_READLENGTH,
00766 CI_READANGLE,
00767 CI_ENDTAG,
00768 CI_TAG(cmxTAG_BeginParagraph_Justification),
00769 CI_READBYTE,
00770 CI_ENDTAG,
00771 CI_TAG(cmxTAG_BeginParagraph_SpacingSpecification),
00772
00773 CI_READLENGTH,
00774 CI_READLENGTH,
00775 CI_READLENGTH,
00776 CI_READLENGTH,
00777 CI_READLENGTH,
00778 CI_READLENGTH,
00779 CI_READLENGTH,
00780 CI_READLENGTH,
00781 CI_READBYTE,
00782 CI_DO16,
00783 CI_SKIPOUT_BYTES(sizeof(INT32)*33),
00784 CI_DO32,
00785
00786
00787 CI_READBYTE,
00788 CI_READINT32,
00789 CI_READINT32,
00790
00791 CI_READBYTE,
00792 CI_READINT32,
00793 CI_READINT32,
00794
00795 CI_READBYTE,
00796 CI_READINT32,
00797 CI_READINT32,
00798
00799 CI_READBYTE,
00800 CI_READINT32,
00801 CI_READINT32,
00802
00803 CI_READBYTE,
00804 CI_READINT32,
00805 CI_READINT32,
00806
00807 CI_READBYTE,
00808 CI_READINT32,
00809 CI_READINT32,
00810
00811 CI_READBYTE,
00812 CI_READINT32,
00813 CI_READINT32,
00814
00815 CI_READBYTE,
00816 CI_READINT32,
00817 CI_READINT32,
00818
00819 CI_READBYTE,
00820 CI_READINT32,
00821 CI_READINT32,
00822
00823 CI_READBYTE,
00824 CI_READINT32,
00825 CI_READINT32,
00826
00827 CI_READBYTE,
00828 CI_READINT32,
00829 CI_READINT32,
00830 CI_DOALL,
00831 CI_ENDTAG,
00832 CI_TAG(cmxTAG_BeginParagraph_TabSpecification),
00833
00834 CI_STORENEXT,
00835 CI_READINT16,
00836 CI_DO16,
00837 CI_SKIPINTIMES_BYTE(sizeof(WORD)+sizeof(BYTE)),
00838 CI_DO32,
00839 CI_SKIPINTIMES_BYTE(sizeof(DWORD)+sizeof(BYTE)),
00840 CI_DOALL,
00841 CI_ENDTAG,
00842 CI_TAG(cmxTAG_BeginParagraph_BulletSpecification),
00843 CI_DO16,
00844 CI_SKIPOUT_BYTES(sizeof(INT32)*3),
00845 CI_READUINT16,
00846 CI_READLENGTH,
00847 CI_READLENGTH,
00848 CI_READANGLE,
00849 CI_READRENDATTR,
00850 CI_DO32,
00851 CI_STORENEXT,
00852 CI_READBOOLEAN,
00853 CI_IFSTOREDIS(CI_IFTYPE_BOOL, TRUE),
00854 CI_READBYTE,
00855 CI_READREFERENCE,
00856 CI_READINT32,
00857 CI_READUINT16,
00858 CI_READLENGTH,
00859 CI_READLENGTH,
00860 CI_READANGLE,
00861 CI_READRENDATTR,
00862 CI_ELSEIF(CI_IFTYPE_BOOL, FALSE),
00863 CI_SKIPOUT_BYTES(sizeof(INT32)*6),
00864 CI_SKIPOUT_BYTES(sizeof(double)),
00865 CI_SKIPOUT_BYTES(sizeof(cmxiRenderAttr)),
00866 CI_ENDIF,
00867 CI_DOALL,
00868 CI_ENDTAG,
00869 CI_TAG(cmxTAG_BeginParagraph_Indentation),
00870 CI_READLENGTH,
00871 CI_READLENGTH,
00872 CI_READLENGTH,
00873 CI_READLENGTH,
00874 CI_ENDTAG,
00875 CI_TAG(cmxTAG_BeginParagraph_Hyphenation),
00876 CI_READBOOLEAN,
00877 CI_DO32,
00878 CI_READBOOLEAN,
00879 CI_READINT32,
00880 CI_READINT32,
00881 CI_READINT32,
00882 CI_READINT32,
00883 CI_DO16,
00884 CI_SKIPOUT_BYTES(sizeof(BOOL)),
00885 CI_SKIPOUT_BYTES(sizeof(INT32)*3),
00886 CI_READINT16,
00887 CI_ENDTAG,
00888 CI_TAG(cmxTAG_BeginParagraph_DropCap),
00889 CI_DO32,
00890
00891 CI_READBOOLEAN,
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903 CI_DO16,
00904 CI_SKIPOUT_BYTES(sizeof(BOOL)),
00905
00906
00907 CI_DOALL,
00908 CI_ENDTAG,
00909 CI_MINENDTAG
00910 END_CMXDESC
00911
00912
00913 START_CMXDESC(Characters)
00914 CI_TAG(cmxTAG_Characters_CountIndex),
00915 CI_READCHARLIST,
00916 CI_ENDTAG,
00917 CI_MINENDTAG
00918 END_CMXDESC
00919
00920 START_CMXDESC(CharInfo)
00921 CI_TAG(cmxTAG_CharInfo_CharInfo),
00922 CI_STORENEXT,
00923
00924 CI_DO16,
00925 CI_READINT16,
00926 CI_DO32,
00927 CI_READUINT16,
00928 CI_DOALL,
00929 CI_SETOUTMARKER,
00930 CI_IFSTOREDIS(CI_IFTYPE_BITSET, (char)(cmxUSAGEMASK_UseTypeNum | cmxUSAGEMASK_UseTypeStyle)),
00931 CI_READREFERENCE,
00932 CI_ENDIF,
00933 CI_GOTOOUTLOC(INT32),
00934 CI_SETOUTMARKER,
00935 CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxUSAGEMASK_UseTypeSize),
00936 CI_READLENGTH,
00937 CI_ENDIF,
00938 CI_GOTOOUTLOC(INT32),
00939 CI_SETOUTMARKER,
00940 CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxUSAGEMASK_UseCharAngle),
00941 CI_READANGLE,
00942 CI_ENDIF,
00943 CI_GOTOOUTLOC(double),
00944 CI_SETOUTMARKER,
00945 CI_IFSTOREDIS(CI_IFTYPE_BITSET, (char)(cmxUSAGEMASK_UseCharFill | cmxUSAGEMASK_UseCharOutline)),
00946 CI_READRENDATTR,
00947 CI_ENDIF,
00948 CI_GOTOOUTLOC(cmxiRenderAttr),
00949 CI_SETOUTMARKER,
00950 CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxUSAGEMASK_UseCharHShift),
00951
00952 CI_READLENGTH,
00953 CI_ENDIF,
00954 CI_GOTOOUTLOC(INT32),
00955 CI_SETOUTMARKER,
00956 CI_IFSTOREDIS(CI_IFTYPE_BITSET, (char)cmxUSAGEMASK_UseCharVShift),
00957
00958 CI_READLENGTH,
00959 CI_ENDIF,
00960 CI_GOTOOUTLOC(INT32),
00961 CI_ENDTAG,
00962 CI_MINENDTAG
00963 END_CMXDESC
00964
00965
00966
00967
00968 START_CMXDESC(FontIndexHeader)
00969 CI_READINT16,
00970 CI_DO32,
00971 CI_READINT16,
00972 CI_DO16,
00973 CI_SKIPOUT(INT32),
00974 CI_DOALL,
00975 CI_READINT16
00976 END_CMXDESC
00977
00978 START_CMXDESC(FontIndexEntry)
00979 CI_READOFFSET
00980 END_CMXDESC
00981
00982
00983 START_CMXDESC(FontRecord)
00984 CI_TAG(cmxTAG_DescrSection_Font_FontInfo),
00985 CI_READSTRING,
00986 CI_READUINT32,
00987 CI_ENDTAG,
00988 CI_TAG(cmxTAG_DescrSection_Font_Panose),
00989 CI_READBYTE,
00990 CI_READBYTE,
00991 CI_READBYTE,
00992 CI_READBYTE,
00993 CI_READBYTE,
00994 CI_READBYTE,
00995 CI_READBYTE,
00996 CI_READBYTE,
00997 CI_READBYTE,
00998 CI_READBYTE,
00999 CI_ENDTAG,
01000 CI_MINENDTAG
01001 END_CMXDESC
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016 #define RDIN(type, name) type name; pFile->read(&name, sizeof(name));
01017 #define RDOUT(type, name) {*((type *)pOut) = name; pOut += sizeof(type);}
01018 #define RDSTORE(name) if(StoreNext) {StoreStack[StackLevel] = (INT32)name; \
01019 \
01020 StoreNext = FALSE;}
01021 #define SIMPLEREAD(instr, intype, outtype) case instr: \
01022 {RDIN(intype, data) RDOUT(outtype, data) \
01023 \
01024 RDSTORE(data) } break;
01025 #define READLENGTH(name) INT32 name; if(Is32Bit) {RDIN(SDWORD, data) name = data;} \
01026 else {RDIN(SWORD, data) name = data;}
01027 #define MAXSTACKLEVEL 16
01028 #define MAXTAGLEVEL 16
01029 #define STACKLEVELUP {ERROR2IF((StackLevel + 1) >= MAXSTACKLEVEL, FALSE, "stack level exceeded in CMXImportFilter::ReadData"); \
01030 StackLevel++; StoreStack[StackLevel] = StoreStack[StackLevel - 1]; \
01031 OutputMarkerStack[StackLevel] = OutputMarkerStack[StackLevel - 1]; \
01032 IfExecStack[StackLevel] = IfExecStack[StackLevel - 1]; \
01033 InputMarkerStack[StackLevel] = InputMarkerStack[StackLevel - 1];}
01034 #define STACKLEVELDOWN {ERROR2IF(StackLevel < 1, FALSE, "unmatched stack levels in CMXImportFilter::ReadData"); \
01035 StackLevel--;}
01036 #define STOREDVALUE (StoreStack[StackLevel])
01037 #define PARAM(n) (Instructions[n+1])
01038 #define OUTPUTMARKER (OutputMarkerStack[StackLevel])
01039 #define INPUTMARKER (InputMarkerStack[StackLevel])
01040
01041 BOOL CMXImportFilter::ReadData(void *Out, char *Instructions)
01042 {
01043 TRACEUSER( "Graeme", _T("readdata\n"));
01044 BYTE *pOut = (BYTE *)Out;
01045
01046 INT32 StackLevel = 0;
01047 INT32 StoreStack[MAXSTACKLEVEL];
01048 BYTE *OutputMarkerStack[MAXSTACKLEVEL];
01049 INT32 InputMarkerStack[MAXSTACKLEVEL];
01050 BOOL IfExecStack[MAXSTACKLEVEL];
01051 BOOL StoreNext = FALSE;
01052 BOOL ExecutionEnabled = TRUE;
01053 BOOL IfLevel = 0;
01054 INT32 TagEnds[MAXTAGLEVEL];
01055 INT32 TagLevel = 0;
01056 IfExecStack[0] = TRUE;
01057 INT32 Count = 0;
01058
01059
01060 while(TRUE)
01061 {
01062 TRACEUSER( "Graeme", _T("LOOP %d.\n"), Count++);
01063 TRACEUSER( "Claude", _T("Instruction %d\n"), *Instructions);
01064 TRACEUSER( "Graeme", _T("Instruction %d\n"), *Instructions);
01065 ERROR2IF(CMXIinfo::CommandLengths[*Instructions] == 0, FALSE, "Instruction code not defined in CMXImportFilter::ReadData()");
01066
01067
01068
01069 switch(*Instructions)
01070 {
01071 case CI_STOP:
01072 TRACEUSER( "Claude", _T("end readdata\n"));
01073 TRACEUSER( "Graeme", _T("end readdata\n"));
01074 ERROR3IF(StackLevel != 0, "unmatched stack levels");
01075 ERROR3IF(IfLevel != 0, "unmatched if levels");
01076 return TRUE;
01077 break;
01078
01079 case CI_IFSTOREDIS_VAL:
01080 {
01081
01082 IfExecStack[StackLevel] = ExecutionEnabled;
01083
01084 BOOL Test = FALSE;
01085 if(PARAM(0) == CI_IFTYPE_VALUE)
01086 {
01087 if(STOREDVALUE == PARAM(1))
01088 Test = TRUE;
01089 }
01090 else if(PARAM(0) == CI_IFTYPE_BITSET)
01091 {
01092 if((STOREDVALUE & PARAM(1)) != 0)
01093 Test = TRUE;
01094 }
01095 else if(PARAM(0) == CI_IFTYPE_BOOL)
01096 {
01097 BOOL Val = (STOREDVALUE == 0)?FALSE:TRUE;
01098 if(Val == PARAM(1))
01099 Test = TRUE;
01100 }
01101 if(!ExecutionEnabled)
01102 Test = FALSE;
01103
01104 ExecutionEnabled = Test;
01105
01106 IfLevel++;
01107 STACKLEVELUP
01108 }
01109 break;
01110
01111 case CI_ELSEIF_VAL:
01112 {
01113 ERROR2IF(IfLevel <= 0, FALSE, "Haven't got an if being active right now");
01114 STACKLEVELDOWN
01115
01116 BOOL Test = FALSE;
01117 if(PARAM(0) == CI_IFTYPE_VALUE)
01118 {
01119 if(STOREDVALUE == PARAM(1))
01120 Test = TRUE;
01121 }
01122 else if(PARAM(0) == CI_IFTYPE_BITSET)
01123 {
01124 if((STOREDVALUE & PARAM(1)) != 0)
01125 Test = TRUE;
01126 }
01127 else if(PARAM(0) == CI_IFTYPE_BOOL)
01128 {
01129 BOOL Val = (STOREDVALUE == 0)?FALSE:TRUE;
01130 if(Val == PARAM(1))
01131 Test = TRUE;
01132 }
01133 if(!IfExecStack[StackLevel])
01134 Test = FALSE;
01135
01136 ExecutionEnabled = Test;
01137
01138 STACKLEVELUP
01139 }
01140 break;
01141
01142 case CI_ENDIF:
01143 ERROR2IF(IfLevel <= 0, FALSE, "Can't end an if which didn't start");
01144 IfLevel--;
01145
01146 STACKLEVELDOWN
01147
01148 ExecutionEnabled = IfExecStack[StackLevel];
01149 break;
01150
01151 default:
01152 break;
01153 }
01154
01155
01156 if(ExecutionEnabled)
01157 {
01158 switch(*Instructions)
01159 {
01160
01161 SIMPLEREAD(CI_READBYTE, BYTE, INT32)
01162 SIMPLEREAD(CI_READINT16, SWORD, INT32)
01163 SIMPLEREAD(CI_READINT32, SDWORD, INT32)
01164 SIMPLEREAD(CI_READUINT16, WORD, UINT32)
01165 SIMPLEREAD(CI_READUINT32, DWORD, UINT32)
01166 SIMPLEREAD(CI_READREFERENCE, WORD, INT32)
01167 SIMPLEREAD(CI_READOFFSET, DWORD, UINT32)
01168 SIMPLEREAD(CI_READDOUBLE, double, double)
01169
01170 case CI_READLENGTH:
01171 {
01172 READLENGTH(len)
01173 RDOUT(INT32, len)
01174 RDSTORE(len)
01175 }
01176 break;
01177
01178 case CI_READCOORD:
01179 {
01180 READLENGTH(x)
01181 READLENGTH(y)
01182 DocCoord coord(x, y);
01183 RDOUT(DocCoord, coord)
01184 RDSTORE(x)
01185 }
01186 break;
01187
01188 case CI_READBBOX:
01189 {
01190 READLENGTH(x0)
01191 READLENGTH(y1)
01192 READLENGTH(x1)
01193 READLENGTH(y0)
01194 DocRect rect;
01195 if(x0 > x1)
01196 {
01197 INT32 t = x0;
01198 x0 = x1;
01199 x1 = t;
01200 }
01201 if(y0 > y1)
01202 {
01203 INT32 t = y0;
01204 y0 = y1;
01205 y1 = t;
01206 }
01207 rect.lo.x = x0; rect.lo.y = y0;
01208 rect.hi.x = x1; rect.hi.y = y1;
01209 RDOUT(DocRect, rect)
01210 RDSTORE(x0)
01211 }
01212 break;
01213
01214 case CI_READNATURALWORD:
01215 {
01216 UINT32 word;
01217 if(Is32Bit)
01218 {
01219 RDIN(DWORD, data)
01220 word = data;
01221 }
01222 else
01223 {
01224 RDIN(WORD, data)
01225 word = data;
01226 }
01227 RDOUT(UINT32, word)
01228 RDSTORE(word)
01229 }
01230 break;
01231
01232 case CI_READBOOLEAN:
01233 {
01234 RDIN(BYTE, data)
01235 BOOL flag = (data == 0)?FALSE:TRUE;
01236 RDOUT(BOOL, flag)
01237 RDSTORE(flag)
01238 }
01239 break;
01240
01241 case CI_READANGLE:
01242 {
01243 double Angle;
01244 if(Is32Bit)
01245 {
01246 RDIN(SDWORD, an)
01247 Angle = (an * 2 * PI) / 360000000.0;
01248 }
01249 else
01250 {
01251 RDIN(SWORD, an)
01252 Angle = (an * 2 * PI) / 3600.0;
01253 }
01254
01255 if(Angle < 0)
01256 {
01257 while(Angle < 0) Angle += (2*PI);
01258 }
01259 else if(Angle > (2*PI))
01260 {
01261 while(Angle > (2*PI)) Angle -= (2*PI);
01262 }
01263 RDOUT(double, Angle)
01264 RDSTORE(Angle)
01265 }
01266 break;
01267
01268 case CI_READRENDATTR:
01269
01270
01271
01272
01273 if(!ReadData(pOut, cmxiRenderAttrDesc))
01274 return FALSE;
01275 pOut += sizeof(cmxiRenderAttr);
01276 break;
01277
01278 case CI_READTILING:
01279
01280 if(!ReadData(pOut, cmxiTilingDesc))
01281 return FALSE;
01282 pOut += sizeof(cmxiTiling);
01283 break;
01284
01285 case CI_READPOINTLIST:
01286
01287 Path *pPath;
01288 if(!ReadPointList(&pPath))
01289 return FALSE;
01290 RDOUT(Path *, pPath)
01291 break;
01292
01293 case CI_READCOLOURLIST:
01294 {
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319 CMXImportColourList *pColList = ReadColourList();
01320 if(pColList == NULL)
01321 return FALSE;
01322
01323 RDOUT(CMXImportColourList *, pColList)
01324 }
01325 break;
01326
01327 case CI_READSTRING:
01328 {
01329
01330
01331 RDIN(WORD, count)
01332
01333 TCHAR *text = (TCHAR *)CCMalloc(count + 4);
01334 if(text == NULL)
01335 return FALSE;
01336
01337
01338 pFile->read(text, count);
01339
01340 text[count] = '\0';
01341
01342
01343 StringBase *pString = new StringBase;
01344 if(!pString->Alloc(count + 4))
01345 return FALSE;
01346 (*pString) = text;
01347 if(pString == NULL)
01348 return FALSE;
01349
01350
01351 RDOUT(StringBase *, pString)
01352
01353
01354 CCFree(text);
01355 }
01356 break;
01357
01358
01359 case CI_READCHARLIST:
01360 {
01361 RDIN(DWORD, count)
01362
01363 characterList c;
01364
01365 c.count = count;
01366 c.characters = new WCHAR[c.count];
01367 c.indices = new WORD[c.count];
01368
01369 if((c.characters == NULL)||(c.indices ==NULL))
01370 return FALSE;
01371
01372 for(UINT32 i =0 ; i < count ; i++)
01373 {
01374 RDIN(WORD, character)
01375 c.characters[i] = character;
01376 }
01377
01378 for(i = 0 ; i < count ; i++)
01379 {
01380 RDIN(WORD, index)
01381 if(index == cmxMaxValueWORD)
01382 CorelDraw7 =TRUE;
01383 c.indices[i] = index;
01384 }
01385
01386 RDOUT(characterList, c)
01387
01388 }
01389 break;
01390
01391 case CI_READCOLUMN:
01392 {
01393 RDIN(SWORD, count)
01394 cmxiColumnList columns;
01395 columns.count = count;
01396 columns.columns = new INT32[columns.count];
01397 columns.gutters = new INT32[columns.count];
01398
01399 if((columns.columns == NULL)||(columns.gutters == NULL))
01400 return FALSE;
01401
01402 for(INT32 i =0 ; i < count ; i++)
01403 {
01404 READLENGTH(col)
01405 columns.columns[i] = col;
01406 READLENGTH(gut)
01407 columns.gutters[i] = gut;
01408 }
01409
01410
01411 RDOUT(cmxiColumnList, columns)
01412
01413
01414 }
01415 break;
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437 case CI_READMATRIX:
01438 {
01439 RDIN(WORD, Type)
01440 Matrix Mat;
01441 if(Type == cmxMATRIXTYPE_GENERAL)
01442 {
01443
01444
01445 struct cmxmatdo {
01446 double a,b,c,d,e,f;
01447 };
01448 RDIN(struct cmxmatdo, in)
01449 Mat = Matrix(in.a, in.b, in.c, in.d, (INT32)in.e, (INT32)in.f);
01450 }
01451 RDOUT(Matrix, Mat)
01452 }
01453 break;
01454
01455 case CI_READSTRINGF_VAL:
01456
01457 pFile->read(pOut, PARAM(0));
01458 pOut += PARAM(0);
01459 break;
01460
01461 case CI_READINT16ARRAY:
01462 {
01463 RDIN(WORD, Count)
01464 cmxiIntArray ar;
01465 ar.NumElements = Count;
01466 if(Count != 0)
01467 {
01468 ar.pElements = new INT32[Count];
01469 if(ar.pElements == NULL)
01470 return FALSE;
01471 for(INT32 l = 0; l < Count; l++)
01472 {
01473 RDIN(WORD, El)
01474 ar.pElements[l] = El;
01475 }
01476 }
01477 else
01478 {
01479 ar.pElements = NULL;
01480 }
01481 RDOUT(cmxiIntArray, ar)
01482 }
01483 break;
01484
01485 case CI_TRANSPARENCY:
01486 {
01487
01488 TRACEUSER( "Claude", _T("Transparency stuffs\n"));
01489 TRACEUSER( "Graeme", _T("Transparency stuffs\n"));
01490
01491 }
01492 break;
01493
01494
01495 case CI_SKIPIN_VAL:
01496 {
01497 char dummy;
01498 for(INT32 l = 0; l < PARAM(0); l++)
01499 pFile->get(dummy);
01500 }
01501 break;
01502
01503 case CI_SKIPINTIMES_VAL:
01504 {
01505 char dummy;
01506 for(INT32 l = 0; l < (PARAM(0) * STOREDVALUE); l++)
01507 pFile->get(dummy);
01508 }
01509 break;
01510
01511 case CI_SKIPOUT_VAL:
01512 {
01513 BYTE nul = 0;
01514 for(INT32 l = 0; l < PARAM(0); l++)
01515 RDOUT(BYTE, nul)
01516 }
01517 break;
01518
01519 case CI_STORENEXT:
01520 StoreNext = TRUE;
01521 break;
01522
01523
01524
01525 case CI_DO16:
01526 {
01527 if(Is32Bit)
01528 {
01529
01530 while(TRUE)
01531 {
01532 if((*Instructions) == CI_DO32 || (*Instructions) == CI_DOALL)
01533 break;
01534
01535 if((*Instructions) == CI_STOP)
01536 return TRUE;
01537
01538
01539 Instructions += CMXIinfo::CommandLengths[*Instructions];
01540 }
01541 }
01542 }
01543 break;
01544
01545 case CI_DO32:
01546 {
01547 if(!Is32Bit)
01548 {
01549
01550 while(TRUE)
01551 {
01552 if((*Instructions) == CI_DO16 || (*Instructions) == CI_DOALL)
01553 break;
01554
01555 if((*Instructions) == CI_STOP)
01556 return TRUE;
01557
01558
01559 Instructions += CMXIinfo::CommandLengths[*Instructions];
01560 }
01561 }
01562 }
01563 break;
01564
01565 case CI_DOALL:
01566
01567 break;
01568
01569 case CI_TAG_VAL:
01570 if(Is32Bit)
01571 {
01572 ERROR2IF((TagLevel + 1) >= MAXTAGLEVEL, FALSE, "too many nested tags");
01573
01574 TagLevel++;
01575 TRACEUSER( "Claude", _T("tag = %d, level = %d\n"), PARAM(0), TagLevel);
01576 TRACEUSER( "Graeme", _T("tag = %d, level = %d\n"), PARAM(0), TagLevel);
01577 while(TRUE)
01578 {
01579 INT32 start = Tell();
01580 RDIN(BYTE, type)
01581 if(type == cmxTAG_EndTag)
01582 CMXFORMATERROR(FALSE)
01583
01584
01585 RDIN(WORD, Size)
01586 if(type == PARAM(0))
01587 {
01588
01589 TagEnds[TagLevel] = start + Size;
01590 break;
01591 }
01592
01593 TRACEUSER( "Ben", _T("WARNING: tag skipped unknown tag, type = %d\n"), type);
01594 TRACEUSER( "Claude", _T("WARNING: tag skipped unknown tag, type = %d\n"), type);
01595 TRACEUSER( "Graeme", _T("WARNING: tag skipped unknown tag, type = %d\n"), type);
01596 Seek(start + Size);
01597
01598
01599
01600 }
01601 }
01602 break;
01603
01604 case CI_TAG_IF_THERE:
01605 if(Is32Bit)
01606 {
01607 ERROR2IF((TagLevel + 1) >= MAXTAGLEVEL, FALSE, "too many nested tags");
01608
01609 TagLevel++;
01610 TRACEUSER( "Claude", _T("tag = %d, level = %d\n"), PARAM(0), TagLevel);
01611 TRACEUSER( "Graeme", _T("tag = %d, level = %d\n"), PARAM(0), TagLevel);
01612
01613 INT32 start = Tell();
01614 RDIN(BYTE, type)
01615 if(type == cmxTAG_EndTag)
01616 {
01617 Seek(start);
01618 break;
01619 }
01620
01621
01622 RDIN(WORD, Size)
01623 if(type == PARAM(0))
01624 {
01625
01626 TagEnds[TagLevel] = start + Size;
01627 Seek(start + Size);
01628
01629
01630 TagLevel--;
01631 break;
01632 }
01633
01634
01635
01636 TRACEUSER( "Claude", _T("WARNING: tag skipped unknown tag, type = %d\n"), type);
01637 TRACEUSER( "Graeme", _T("WARNING: tag skipped unknown tag, type = %d\n"), type);
01638 Seek(start + Size);
01639 }
01640 break;
01641
01642 case CI_ENDTAG:
01643 if(Is32Bit)
01644 {
01645
01646
01647 ERROR2IF(TagLevel < 1, FALSE, "no tag when we tried to end");
01648 if(Tell() != TagEnds[TagLevel])
01649 {
01650 TRACEUSER( "Ben", _T("WARNING: end tag skipped %d bytes of data\n"), TagEnds[TagLevel] - Tell());
01651 TRACEUSER( "Graeme", _T("WARNING: end tag skipped %d bytes of data\n"), TagEnds[TagLevel] - Tell());
01652 Seek(TagEnds[TagLevel]);
01653 }
01654 TagLevel--;
01655 }
01656 break;
01657
01658 case CI_MINENDTAG:
01659 if(Is32Bit)
01660 {
01661
01662
01663 while(TRUE)
01664 {
01665 RDIN(BYTE, Thingy)
01666 if(Thingy == cmxTAG_EndTag)
01667 {
01668 break;
01669 }
01670 else
01671 {
01672 TRACEUSER( "Ben", _T("WARNING: min end tag skipped unknown tag, type = %d\n"), Thingy);
01673 TRACEUSER( "Graeme", _T("WARNING: min end tag skipped unknown tag, type = %d\n"), Thingy);
01674 RDIN(WORD, size)
01675 Seek(Tell() + size - sizeof(BYTE) - sizeof(WORD));
01676 }
01677 }
01678 }
01679 break;
01680
01681 case CI_SETOUTMARKER:
01682 OutputMarkerStack[StackLevel] = pOut;
01683 break;
01684
01685 case CI_GOTOOUTLOC_VAL:
01686
01687
01688 pOut = OUTPUTMARKER + PARAM(0);
01689 break;
01690
01691 case CI_SETINMARKER:
01692 InputMarkerStack[StackLevel] = Tell();
01693 break;
01694
01695 case CI_ENSUREINLOC:
01696
01697
01698
01699 {
01700 INT32 TargetPos = INPUTMARKER + STOREDVALUE;
01701 if(Tell() != TargetPos)
01702 Seek(TargetPos);
01703 }
01704 break;
01705
01706
01707
01708 #ifdef _DEBUG
01709 case CI_TRACE_VAL:
01710 TRACEUSER( "Ben", _T("rd TRACE: %d, out = %x, in = %x, stored = %d = 0x%x, iflevel = %d, stacklevel = %d\n"), PARAM(0), pOut, Tell(), STOREDVALUE, STOREDVALUE, IfLevel, StackLevel);
01711 TRACEUSER( "Claude", _T("rd TRACE: %d, out = %x, in = %x, stored = %d = 0x, iflevel = %d, stacklevel = %d\n"), PARAM(0), pOut, Tell(), STOREDVALUE, STOREDVALUE, IfLevel, StackLevel);
01712 TRACEUSER( "Graeme", _T("rd TRACE: %d, out = %x, in = %x, stored = %d = 0x, iflevel = %d, stacklevel = %d\n"), PARAM(0), pOut, Tell(), STOREDVALUE, STOREDVALUE, IfLevel, StackLevel);
01713 break;
01714 #endif
01715
01716
01717 default:
01718 ERROR3("Defined instruction code not implemented");
01719 break;
01720
01721
01722 case CI_STOP:
01723 case CI_IFSTOREDIS_VAL:
01724 case CI_ELSEIF_VAL:
01725 case CI_ENDIF:
01726 break;
01727 }
01728 }
01729
01730 Instructions += CMXIinfo::CommandLengths[*Instructions];
01731 }
01732
01733 return FALSE;
01734 }
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750 BOOL CMXImportFilter::ReadPointList(Path **ppPath)
01751 {
01752 (*ppPath) = 0;
01753
01754
01755
01756
01757
01758 RDIN(WORD, Count)
01759
01760 INT32 NumCoords = Count;
01761 DocCoord *pCoords = new DocCoord[NumCoords];
01762 if(pCoords == NULL)
01763 return FALSE;
01764
01765
01766 if(Is32Bit)
01767 {
01768 cmxPoint32 PointyThing;
01769
01770 for(INT32 l = 0; l < NumCoords; l++)
01771 {
01772 pFile->read(&PointyThing, sizeof(PointyThing));
01773 pCoords[l].x = PointyThing.x;
01774 pCoords[l].y = PointyThing.y;
01775 }
01776 }
01777 else
01778 {
01779 cmxPoint16 PointyThing;
01780
01781 for(INT32 l = 0; l < NumCoords; l++)
01782 {
01783 pFile->read(&PointyThing, sizeof(PointyThing));
01784 pCoords[l].x = PointyThing.x;
01785 pCoords[l].y = PointyThing.y;
01786 }
01787 }
01788
01789
01790 Path *pPath = new Path;
01791 if(pPath == 0 || !pPath->Initialise())
01792 return FALSE;
01793
01794 pPath->IsFilled = FALSE;
01795 pPath->IsStroked = TRUE;
01796
01797
01798 pPath->FindStartOfPath();
01799
01800
01801
01802 INT32 c;
01803 PathFlags Flags;
01804 BOOL NeedMoveTo = TRUE;
01805
01806
01807 for(c = 0; c < NumCoords; c++)
01808 {
01809 RDIN(BYTE, Verb)
01810
01811 INT32 CoordType = Verb & CMXNODETYPE_TYPE_MASK;
01812
01813
01814 if(NeedMoveTo && CoordType != CMXNODETYPE_TYPE_MOVE)
01815 {
01816 if(!pPath->InsertMoveTo(pCoords[c]))
01817 return FALSE;
01818 }
01819
01820 NeedMoveTo = FALSE;
01821
01822
01823 switch(CoordType)
01824 {
01825 case CMXNODETYPE_TYPE_MOVE:
01826
01827 if(!pPath->InsertMoveTo(pCoords[c]))
01828 return FALSE;
01829 break;
01830
01831 case CMXNODETYPE_TYPE_LINE:
01832
01833 if(!pPath->InsertLineTo(pCoords[c]))
01834 return FALSE;
01835 break;
01836
01837 case CMXNODETYPE_TYPE_CURVE:
01838
01839
01840 if(c < 2)
01841 {
01842 TRACEUSER( "Ben", _T("No control points for curve element\n"));
01843 break;
01844 }
01845
01846
01847 Flags.IsSelected = FALSE;
01848 Flags.IsSmooth = Flags.IsRotate = ((Verb & CMXNODETYPE_CONTINUITYMASK) != 0)?TRUE:FALSE;
01849 Flags.IsEndPoint = FALSE;
01850
01851
01852 if(!pPath->InsertCurveTo(pCoords[c-2], pCoords[c-1], pCoords[c], &Flags))
01853 return FALSE;
01854 break;
01855
01856 case CMXNODETYPE_TYPE_ARC:
01857
01858 break;
01859
01860 default:
01861
01862 break;
01863 }
01864
01865
01866 if((Verb & CMXNODETYPE_CLOSED) != 0 && CoordType != CMXNODETYPE_TYPE_ARC)
01867 {
01868
01869 if(CoordType != CMXNODETYPE_TYPE_MOVE)
01870 {
01871 if(!pPath->CloseSubPath())
01872 return FALSE;
01873
01874
01875 NeedMoveTo = TRUE;
01876
01877
01878 pPath->IsFilled = TRUE;
01879 }
01880 }
01881 }
01882
01883
01884
01885
01886 delete [] pCoords;
01887
01888
01889 if(!pPath->EnsureValid())
01890 {
01891
01892
01893 pPath->ClearPath();
01894 pPath->InsertMoveTo(DocCoord(0,0));
01895 pPath->InsertLineTo(DocCoord(72,72));
01896 }
01897
01898
01899 (*ppPath) = pPath;
01900
01901 return TRUE;
01902 }
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917 CMXImportColourList *CMXImportFilter::ReadColourList(void)
01918
01919 {
01920
01921 CMXImportColourList *pColList = new CMXImportColourList;
01922 if(pColList == NULL)
01923 return NULL;
01924
01925
01926 RDIN(WORD, Count);
01927
01928
01929 for(INT32 l = 0; l < Count; l++)
01930 {
01931
01932 RDIN(cmxGradFillColour, col);
01933
01934
01935 if(!pColList->AddColour(col.ColRef, col.ColPos))
01936 return NULL;
01937 }
01938
01939 return pColList;
01940 }
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954 void CMXIinfo::SetUpInfo(void)
01955 {
01956 char SingleBytes[] = {CI_READBYTE, CI_READINT16, CI_READINT32, CI_READUINT16,
01957 CI_READUINT32, CI_READREFERENCE, CI_READLENGTH, CI_READCOORD, CI_READBBOX,
01958 CI_READBBOX, CI_READNATURALWORD, CI_READOFFSET,
01959 CI_READBOOLEAN, CI_READANGLE, CI_READDOUBLE, CI_STOP,
01960 CI_STORENEXT, CI_ENDIF, CI_DO16, CI_DO32, CI_DOALL,
01961 CI_ENDTAG, CI_MINENDTAG, CI_SETOUTMARKER, CI_READRENDATTR,
01962 CI_READPOINTLIST, CI_READCOLOURLIST, CI_READSTRING, CI_READMATRIX,
01963 CI_SETINMARKER, CI_ENSUREINLOC, CI_READTILING, CI_READINT16ARRAY,
01964 CI_SETINMARKER, CI_ENSUREINLOC, CI_READTILING,CI_READPOINTLIST, CI_READCOLOURLIST,
01965 CI_READSTRING, CI_READCHARLIST, CI_READMATRIX, CI_SETINMARKER, CI_ENSUREINLOC,
01966 CI_READCOLUMN, CI_TRANSPARENCY};
01967 char OneParam[] = {CI_SKIPIN_VAL, CI_SKIPOUT_VAL, CI_TAG_VAL, CI_GOTOOUTLOC_VAL, CI_TAG_IF_THERE,
01968 #ifdef _DEBUG
01969 CI_TRACE_VAL,
01970 #endif
01971 CI_SKIPINTIMES_VAL, CI_READSTRINGF_VAL};
01972 char TwoParam[] = {CI_IFSTOREDIS_VAL, CI_ELSEIF_VAL};
01973
01974 memset(CommandLengths, 0, sizeof(CommandLengths));
01975 SetLengths(SingleBytes, sizeof(SingleBytes), 1);
01976 SetLengths(OneParam, sizeof(OneParam), 2);
01977 SetLengths(TwoParam, sizeof(TwoParam), 3);
01978 CommandLengths[0] = 1;
01979
01980
01981
01982
01983
01984
01985
01986 }
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001 void CMXIinfo::SetLengths(char *instrs, INT32 num, INT32 val)
02002 {
02003 for(INT32 l = 0; l < num; l++)
02004 {
02005 CommandLengths[instrs[l]] = val;
02006 }
02007 }
02008
02009 char CMXIinfo::CommandLengths[256];
02010
02011
02012