cmxistut.cpp

Go to the documentation of this file.
00001 // $Id: cmxistut.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 // data reading stuff for CMX import
00099 
00100 #include "camtypes.h"
00101 
00102 // flag for parsing the header file
00103 #define COMPILING_CMXISTUT_CPP
00104 
00105 //#include "ccfile.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "basestr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
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 //-0-0---------------------------------------------------------------------------------------
00119 
00120 // descriptions for various bits
00121 
00122 START_CMXDESC(FileHeader)
00123     CI_READSTRINGF(32),     // id
00124     CI_SKIPIN_BYTES(16),    // don't bother about the OS
00125     CI_READINT32,           // byteorder
00126     CI_READINT16,           // coord size
00127     CI_READINT32,           // major version
00128     CI_READINT32,           // minor version
00129     CI_READINT16,           // unit
00130     CI_READDOUBLE,          // Factor
00131     CI_READINT32, CI_READINT32, CI_READINT32,       // unused stuff
00132     CI_READINT32,           // Index section
00133     CI_READINT32,           // info section
00134     CI_READINT32,           // thumbnail
00135     CI_READINT32, CI_READINT32, CI_READINT32, CI_READINT32, // bbox
00136     CI_READINT32            // tally
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,   // page number
00178     CI_READUINT32,  // flags
00179     CI_READBBOX,
00180     CI_READOFFSET,  // end page offset
00181     CI_READINT16,   // group count
00182     CI_READINT32,   // instruction count
00183     CI_ENDTAG,
00184     CI_TAG(cmxTAG_BeginPage_Matrix),
00185     CI_READMATRIX,
00186     CI_ENDTAG,
00187     // there is a mapping mode tag here, but this doesn't matter as we'll skip it
00188     CI_MINENDTAG
00189 END_CMXDESC
00190 
00191 START_CMXDESC(BeginLayer)
00192     CI_TAG(cmxTAG_BeginLayer_LayerSpecification),
00193     CI_READINT16,   // page number
00194     CI_READINT16,   // layer number
00195     CI_READUINT32,  // flags
00196     CI_READINT32,   // instruction count
00197     CI_READSTRING,  // layer name
00198     CI_ENDTAG,
00199     CI_TAG(cmxTAG_BeginLayer_Matrix),
00200     CI_READMATRIX,
00201     CI_ENDTAG,
00202     // mapping mode again...
00203     CI_MINENDTAG
00204 END_CMXDESC
00205 
00206 // scary rendering attributes thingy!
00207 START_CMXDESC(RenderAttr)
00208     CI_STORENEXT,
00209     CI_READBYTE,
00210     // ----------------------------- Fill spec
00211     CI_SETOUTMARKER,
00212     CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxRENDATTRMASK_FILL),
00213         CI_TAG(cmxTAG_RenderAttr_FillSpec),
00214         CI_STORENEXT,
00215         CI_READINT16,
00216         // ------------------------- Uniform fill
00217         CI_IFSTOREDIS(CI_IFTYPE_VALUE, cmxFILLID_UNIFORM),
00218             CI_TAG(cmxTAG_RenderAttr_FillSpec_Uniform),
00219             CI_READREFERENCE,   // colour reference
00220             CI_READREFERENCE,   // screen reference
00221             CI_ENDTAG,
00222             CI_MINENDTAG,
00223         // ------------------------- Fountain fill
00224         CI_ELSEIF(CI_IFTYPE_VALUE, cmxFILLID_FOUNTAIN),
00225             CI_TAG(cmxTAG_RenderAttr_FillSpec_Fountain_Base),
00226             CI_READINT16,       // type
00227             CI_READREFERENCE,   // screen
00228             CI_READINT16,       // padding
00229             CI_READANGLE,       // angle
00230             CI_DO16,
00231             CI_SKIPIN(WORD),    // seems to be added in there in 16 bit files
00232             CI_DOALL,
00233             CI_READCOORD,       // x,y offsets
00234             CI_READINT16,       // step count
00235             CI_READINT16,       // fill mode
00236             CI_DO32,
00237             CI_READINT16,       // rate method
00238             CI_READINT16,       // rate value
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,  // gets the list of colours
00245             CI_ENDTAG,
00246             CI_MINENDTAG,
00247         // ------------------------- Postscript fill
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         // ------------------------- Two colour bitmap
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         // ------------------------- Bitmap fill
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         // ------------------------- Bitmap fill (16 bit) / Vector (32 bit)
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         // ------------------------- Texture fill
00286         CI_ELSEIF(CI_IFTYPE_VALUE, cmxFILLID_TEXTURE),
00287             // 32 bit version
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             // right then, some random stuff
00296             CI_SKIPIN_BYTES(7),
00297             CI_STORENEXT,
00298             CI_READINT16,       // size of string
00299             CI_SKIPINTIMES(BYTE),
00300             CI_STORENEXT,
00301             CI_READINT16,       // size of another string
00302             CI_SKIPINTIMES(BYTE),
00303             CI_STORENEXT,
00304             CI_READINT16,       // size of yet another string
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),        // jump to after the end of the fill spec bit
00317 
00318     // ----------------------------- outline spec
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     // ----------------------------- lens spec
00329     CI_SETOUTMARKER,
00330     CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxRENDATTRMASK_LENS),
00331         CI_TAG(cmxTAG_RenderAttr_LensSpec_Base),
00332         CI_STORENEXT,
00333         CI_READBYTE,    // type
00334         CI_IFSTOREDIS(CI_IFTYPE_VALUE, cmxLENSTYPE_GLASS),
00335             CI_READBYTE,    // tint method
00336             CI_READINT16,   // uniform rate
00337             CI_READREFERENCE,   // colour
00338             CI_READREFERENCE,   // range procedure reference
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         //CI_ELSEIF(CI_IFTYPE_VALUE, cmxLENSTYPE_TRANSAPRENCY),
00361         //  CI_TAG(cmxTAG_RenderAttr_NewTransparency),
00362         //  CI_TRANSPARENCY,
00363         //  CI_ENDTAG,
00364         CI_ENDIF,
00365         // in cmx32 we might get another tag here
00366 //      CI_DO32,
00367         CI_IF_TAG(cmxTAG_RenderAttr_LensSpec_FrozViewp),
00368         //CI_SKIPIN_BYTES(18),      // some stuff. Don't like it. Won't load it.
00369         //CI_ENDTAG,
00370         CI_DOALL,
00371         CI_ENDTAG,
00372         CI_MINENDTAG,
00373     CI_ENDIF,
00374     CI_GOTOOUTLOC(cmxiLensSpec),
00375 
00376     // ----------------------------- container spec
00377     // don't need to bother with out markers as this is the last thing in the struct
00378     CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxRENDATTRMASK_CONTAIN),
00379         CI_TAG(cmxTAG_RenderAttr_ContainerSpec),
00380             CI_READREFERENCE,       // container ref
00381             CI_READBOOLEAN,         // auto transform flag
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 )                     // Graeme (1-2-00)
00401     CI_TAG ( cmxTAG_Rectangle_RenderingAttr ),
00402     CI_READRENDATTR,                            // Rendering attributes.
00403     CI_ENDTAG,                                  
00404     CI_TAG ( cmxTAG_Rectangle_RectangleSpecification ),
00405     CI_READCOORD,                               // Center of the rectangle.
00406     CI_READLENGTH,                              // Dimensions - Width.
00407     CI_READLENGTH,                              // Dimensions - Height.
00408     CI_READANGLE,                               // Corner radius.
00409     CI_READANGLE,                               // Rotation.
00410     CI_READBBOX,                                // Bounding box.
00411     CI_ENDTAG,
00412     CI_MINENDTAG                                // End of shape tag.
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,        // colour model
00433     CI_READBYTE,        // palette type
00434     CI_ENDTAG,
00435     CI_TAG(cmxTAG_DescrSection_Color_ColorDescr),
00436     CI_IFSTOREDIS(CI_IFTYPE_VALUE, cmxCOLMODEL_PANTONE),
00437         CI_READINT16,   // ID
00438         CI_READINT16,   // density
00439     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_CMYK),
00440         CI_READBYTE,    // cyan
00441         CI_READBYTE,    // magenta
00442         CI_READBYTE,    // yellow
00443         CI_READBYTE,    // key
00444     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_CMYK255),
00445         CI_READBYTE,    // cyan
00446         CI_READBYTE,    // magenta
00447         CI_READBYTE,    // yellow
00448         CI_READBYTE,    // key
00449     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_CMY),
00450         CI_READBYTE,    // cyan
00451         CI_READBYTE,    // magenta
00452         CI_READBYTE,    // yellow
00453         CI_READBYTE,    // pad
00454     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_RGB),
00455         CI_READBYTE,    // red
00456         CI_READBYTE,    // green
00457         CI_READBYTE,    // blue
00458     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_HSB),
00459         CI_READINT16,   // hue
00460         CI_READBYTE,    // saturation
00461         CI_READBYTE,    // value
00462     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_HLS),
00463         CI_READINT16,   // bue
00464         CI_READBYTE,    // lightness
00465         CI_READBYTE,    // saturation
00466     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_BW),
00467         CI_READBYTE,    // colour
00468     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_LAB),
00469         CI_READBYTE,    // luminocity
00470         CI_READBYTE,    // Green2Magenta
00471         CI_READBYTE,    // Blue2Yellow
00472         CI_READBYTE,    // pad
00473     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_GREY),
00474         CI_READBYTE,    // grey
00475     CI_ELSEIF(CI_IFTYPE_VALUE, cmxCOLMODEL_YIG255),
00476         CI_READBYTE,    // y
00477         CI_READBYTE,    // i
00478         CI_READBYTE,    // q
00479         CI_READBYTE,    // pad
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),        // some randomness in 16 bit files
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,        // image extent
00533     CI_READBBOX,        // cropping rectangle
00534     CI_READMATRIX,      // transformations
00535     CI_READINT16,       // image type
00536     CI_READREFERENCE,   // image reference 1
00537     CI_READREFERENCE,   // image reference 2
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,       // size in file, 32 bit only
00548     CI_SETINMARKER,
00549     CI_DOALL,
00550     CI_READOFFSET,      // embedded file offset
00551     CI_READINT16,       // type
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,       // size in file, 32 bit only
00562     CI_SETINMARKER,
00563     CI_DOALL,
00564     CI_READOFFSET,      // reference list offset
00565     CI_READOFFSET,      // offset in file
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,           // type...
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,         //  Artistic Text
00721     CI_READBYTE,            //  Pad
00722     CI_READBBOX,            //  Bounding Box
00723     CI_READINT16,           //  Frames
00724     CI_READINT16,           //  Number of paragraph
00725     CI_READINT32,           //  Number of instruction in stream
00726     CI_ENDTAG,
00727     CI_MINENDTAG
00728 END_CMXDESC
00729 
00730 START_CMXDESC(TextFrame)
00731     CI_TAG(cmxTAG_TextFrame_ColumnSpecification),
00732     //  Skip the column spec for we don't support them anyway
00733 /*  CI_STORENEXT,
00734     CI_READINT16,
00735     CI_DO16,
00736     CI_SKIPINTIMES_BYTE(sizeof(WORD)+sizeof(WORD)),
00737     CI_DO32,
00738     CI_SKIPINTIMES_BYTE(sizeof(DWORD)+sizeof(DWORD)),
00739     CI_DOALL,*/
00740     CI_READCOLUMN,
00741     CI_ENDTAG,
00742     CI_TAG(cmxTAG_TextFrame_HeightSkewMatrix),
00743     CI_READLENGTH,  // height
00744     CI_READLENGTH,  // skew
00745     CI_READMATRIX,  //  Transformation
00746     CI_ENDTAG,
00747     CI_MINENDTAG
00748 END_CMXDESC
00749 
00750 
00751 START_CMXDESC(BeginParagraph)
00752     CI_TAG(cmxTAG_BeginParagraph_RenderingAttr),
00753     CI_READRENDATTR,    //  Rendering Attributes
00754     CI_ENDTAG,
00755     CI_TAG(cmxTAG_BeginParagraph_FontSpecification),
00756     CI_READREFERENCE,   //  Default Font
00757             //  Font Size
00758     CI_READLENGTH,
00759     CI_ENDTAG,
00760     //  Tag_BeginParagraph_UseFontCombo should be here
00761     //  but no clue what's that for the moment so...
00762     //  It doesn't appear in Corel's files.
00763     CI_TAG(cmxTAG_BeginParagraph_KerningSpecification),
00764     CI_READLENGTH,      //  Vertical shift
00765     CI_READLENGTH,      //  Horizontal shift
00766     CI_READANGLE,       //  Kerning angle
00767     CI_ENDTAG,
00768     CI_TAG(cmxTAG_BeginParagraph_Justification),
00769     CI_READBYTE,        //  Justification
00770     CI_ENDTAG,
00771     CI_TAG(cmxTAG_BeginParagraph_SpacingSpecification),
00772     //  Spacing Specification
00773     CI_READLENGTH,      // Inter-Char Spacing
00774     CI_READLENGTH,      //  Inter-Word Spacing
00775     CI_READLENGTH,      //  Inter-Line Spacing
00776     CI_READLENGTH,      //  Before Paragraph Spacing
00777     CI_READLENGTH,      //  After Paragraph Spacing
00778     CI_READLENGTH,      //  MaxInterChar
00779     CI_READLENGTH,      //  MinInterWord
00780     CI_READLENGTH,      //  MaxInterWord
00781     CI_READBYTE,        //  Spacing Mode
00782     CI_DO16,    //  No underline in v5
00783     CI_SKIPOUT_BYTES(sizeof(INT32)*33),
00784     CI_DO32,    //  Not supported in v5.
00785     //  Underline Specification
00786         //  Underline
00787     CI_READBYTE,        //  Flag Absolute
00788     CI_READINT32,       //  Distance from Baseline
00789     CI_READINT32,       //  Stroke thickness
00790         //  Thick Underline
00791     CI_READBYTE,        //  Flag Absolute
00792     CI_READINT32,       //  Distance from Baseline
00793     CI_READINT32,       //  Stroke thickness
00794         //  Double Underline
00795     CI_READBYTE,        //  Flag Absolute
00796     CI_READINT32,       //  Distance from Baseline
00797     CI_READINT32,       //  Stroke thickness
00798         //  Double Underline1
00799     CI_READBYTE,        //  Flag Absolute
00800     CI_READINT32,       //  Distance from Baseline
00801     CI_READINT32,       //  Stroke thickness
00802         //  Double Underline2
00803     CI_READBYTE,        //  Flag Absolute
00804     CI_READINT32,       //  Distance from Baseline
00805     CI_READINT32,       //  Stroke thickness
00806         //  Thick Overline
00807     CI_READBYTE,        //  Flag Absolute
00808     CI_READINT32,       //  Distance from Baseline
00809     CI_READINT32,       //  Stroke thickness
00810         //  Double Overline1
00811     CI_READBYTE,        //  Flag Absolute
00812     CI_READINT32,       //  Distance from Baseline
00813     CI_READINT32,       //  Stroke thickness
00814         //  Double Overline2
00815     CI_READBYTE,        //  Flag Absolute
00816     CI_READINT32,       //  Distance from Baseline
00817     CI_READINT32,       //  Stroke thickness
00818         //  Thick Strikeout
00819     CI_READBYTE,        //  Flag Absolute
00820     CI_READINT32,       //  Distance from Baseline
00821     CI_READINT32,       //  Stroke thickness
00822         //  Double Strikeout1
00823     CI_READBYTE,        //  Flag Absolute
00824     CI_READINT32,       //  Distance from Baseline
00825     CI_READINT32,       //  Stroke thickness
00826         //  Double Strikeout2
00827     CI_READBYTE,        //  Flag Absolute
00828     CI_READINT32,       //  Distance from Baseline
00829     CI_READINT32,       //  Stroke thickness
00830     CI_DOALL,
00831     CI_ENDTAG,
00832     CI_TAG(cmxTAG_BeginParagraph_TabSpecification),
00833     //  Skip the tab for we don't support them anyway
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,      //  Bullet Character
00846     CI_READLENGTH,      //  Vertical Shift
00847     CI_READLENGTH,      //  Horizontal Shift
00848     CI_READANGLE,       //  Kerning angle
00849     CI_READRENDATTR,    //  Rendering Attributes
00850     CI_DO32,
00851     CI_STORENEXT,
00852     CI_READBOOLEAN,                     //  BulletOn?
00853     CI_IFSTOREDIS(CI_IFTYPE_BOOL, TRUE),    //  Yes
00854         CI_READBYTE,        //  Flag MultiColour
00855         CI_READREFERENCE,   //  Default Font
00856         CI_READINT32,       //  Font Size
00857         CI_READUINT16,      //  Bullet Character
00858         CI_READLENGTH,      //  Vertical Shift
00859         CI_READLENGTH,      //  Horizontal Shift
00860         CI_READANGLE,       //  Kerning angle
00861         CI_READRENDATTR,    //  Rendering Attributes
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,      //  Left Margin
00871     CI_READLENGTH,      //  Right Margin
00872     CI_READLENGTH,      //  First Line
00873     CI_READLENGTH,      //  Remaining Lines
00874     CI_ENDTAG,
00875     CI_TAG(cmxTAG_BeginParagraph_Hyphenation),
00876     CI_READBOOLEAN,     //  Auto Hyphenation
00877     CI_DO32,
00878     CI_READBOOLEAN,     //  Break Capitalised Words
00879     CI_READINT32,       //  MinWordLength
00880     CI_READINT32,       //  MinCharsBefore
00881     CI_READINT32,       //  MinCharsAfter
00882     CI_READINT32,       //  HotZone
00883     CI_DO16,
00884     CI_SKIPOUT_BYTES(sizeof(BOOL)),
00885     CI_SKIPOUT_BYTES(sizeof(INT32)*3),
00886     CI_READINT16,       //  HotZone
00887     CI_ENDTAG,
00888     CI_TAG(cmxTAG_BeginParagraph_DropCap),
00889     CI_DO32,
00890 //  CI_STORENEXT,
00891     CI_READBOOLEAN,     //  DropCapOn ?
00892 //  All this chunk of info doesn't seem to be there at all
00893 /*  CI_IFSTOREDIS(CI_IFTYPE_BOOL, TRUE),    //  Yes
00894         CI_READREFERENCE,   //  Default Font
00895         CI_READINT32,       //  Font Size
00896         CI_READINT32,       //  Vertical shift
00897         CI_READINT32,       //  Horizontal shift
00898         CI_READANGLE,       //  Kerning angle
00899     CI_ELSEIF(CI_IFTYPE_BOOL, TRUE),        //  No, then skip
00900         CI_SKIPOUT_BYTES(sizeof(INT32)*4),
00901         CI_SKIPOUT_BYTES(sizeof(double)),       
00902     CI_ENDIF,*/
00903     CI_DO16,
00904     CI_SKIPOUT_BYTES(sizeof(BOOL)),
00905     /*CI_SKIPOUT_BYTES(sizeof(INT32)*4),
00906     CI_SKIPOUT_BYTES(sizeof(double)),*/
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         //  Usage Mask
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,   //  Font Reference
00932     CI_ENDIF,   
00933     CI_GOTOOUTLOC(INT32),
00934     CI_SETOUTMARKER,
00935     CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxUSAGEMASK_UseTypeSize),
00936         CI_READLENGTH,  //  Type Size, different 16/32bit (not documented!!!
00937     CI_ENDIF,   
00938     CI_GOTOOUTLOC(INT32),
00939     CI_SETOUTMARKER,
00940     CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxUSAGEMASK_UseCharAngle),
00941         CI_READANGLE,   //  Character Angle
00942     CI_ENDIF,   
00943     CI_GOTOOUTLOC(double),
00944     CI_SETOUTMARKER,
00945     CI_IFSTOREDIS(CI_IFTYPE_BITSET, (char)(cmxUSAGEMASK_UseCharFill | cmxUSAGEMASK_UseCharOutline)),
00946         CI_READRENDATTR,    //  Rendering Attributes
00947     CI_ENDIF,
00948     CI_GOTOOUTLOC(cmxiRenderAttr),
00949     CI_SETOUTMARKER,
00950     CI_IFSTOREDIS(CI_IFTYPE_BITSET, cmxUSAGEMASK_UseCharHShift),
00951             //  Horizontal Shift
00952         CI_READLENGTH,
00953     CI_ENDIF,   
00954     CI_GOTOOUTLOC(INT32),
00955     CI_SETOUTMARKER,
00956     CI_IFSTOREDIS(CI_IFTYPE_BITSET, (char)cmxUSAGEMASK_UseCharVShift),
00957             //  Vertical Shift
00958         CI_READLENGTH,
00959     CI_ENDIF,   
00960     CI_GOTOOUTLOC(INT32),
00961     CI_ENDTAG,
00962     CI_MINENDTAG
00963 END_CMXDESC
00964 
00965 
00966 
00967 //  This is not documented in the Corel docs 
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,  //  Font String
00986     CI_READUINT32,  //  Font Style
00987     CI_ENDTAG,
00988     CI_TAG(cmxTAG_DescrSection_Font_Panose),
00989     CI_READBYTE,    //  bFamilyType
00990     CI_READBYTE,    //  bSerifStyle
00991     CI_READBYTE,    //  bWeight
00992     CI_READBYTE,    //  bProporion
00993     CI_READBYTE,    //  bContrast
00994     CI_READBYTE,    //  bStrokeVariation
00995     CI_READBYTE,    //  bArmStyle
00996     CI_READBYTE,    //  bLetterForm
00997     CI_READBYTE,    //  bMidline
00998     CI_READBYTE,    //  bXHeight
00999     CI_ENDTAG,
01000     CI_MINENDTAG
01001 END_CMXDESC
01002 
01003 /********************************************************************************************
01004 
01005 >   BOOL CMXImportFilter::ReadData(void *Out, char *Instructions)
01006 
01007     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
01008     Created:    06/08/96
01009     Inputs:     pointer to the structure to fill, instructions on what to fill it with
01010     Returns:    success
01011     Purpose:    fills the structure pointed to by Out according to the instructions
01012 
01013 ********************************************************************************************/
01014 
01015 // some macros to make things easier to write
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                             /*TRACEUSER( "Ben", _T("store %d = 0x%x\n"), (INT32)name, (INT32)name);*/ \
01020                             StoreNext = FALSE;}
01021 #define SIMPLEREAD(instr, intype, outtype)  case instr:         \
01022                             {RDIN(intype, data) RDOUT(outtype, data) \
01023                             /*TRACEUSER( "Ben", _T("simpleread value = %d = 0x%x\n"), data, data);*/ \
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];    // stores the value of ExecEnabled before the IF statement
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     // right then, loop around until we've
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         // first switch to handle structural stuff which controls execution of
01068         // other instructions
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;        // done everything
01077             break;
01078 
01079         case CI_IFSTOREDIS_VAL:
01080             {
01081                 // set the exec stack
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;              // not a problem here
01153         }
01154 
01155         // second switch to handle data instructions
01156         if(ExecutionEnabled)
01157         {
01158             switch(*Instructions)
01159             {
01160             // --------------- data reading codes ------------------
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                     // check the range of the thingy
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                 // we simply call this function with the appropriate structure defn -- easy!
01270                 // it may seem a little silly to do it like this, but it's so much easier than
01271                 // putting this ever so common function in every single object defn
01272 //TRACEUSER( "Ben", _T("**************** rend attr"));
01273                 if(!ReadData(pOut, cmxiRenderAttrDesc))
01274                     return FALSE;
01275                 pOut += sizeof(cmxiRenderAttr);
01276                 break;
01277 
01278             case CI_READTILING:
01279                 // see comments about about why we have a seperate thingy for this
01280                 if(!ReadData(pOut, cmxiTilingDesc))
01281                     return FALSE;
01282                 pOut += sizeof(cmxiTiling);
01283                 break;
01284 
01285             case CI_READPOINTLIST:
01286                 // calls a nice function which reads a point list from the file
01287                 Path *pPath;
01288                 if(!ReadPointList(&pPath))
01289                     return FALSE;
01290                 RDOUT(Path *, pPath)
01291                 break;
01292 
01293             case CI_READCOLOURLIST:
01294                 {
01295                     // call our nice function to do all the hard work for me
01296                     // but of course, I've written it too, so it's not as if
01297                     // I escape writing the thing. Which is a pity really.
01298                     // There should be lots of parsnips given out free in the
01299                     // streets, because parsnips are very good things. They're
01300                     // really tasty, and make an excellent accompanyment for
01301                     // other parsnips. What's especially good, though, is
01302                     // parsnip bake. What you do is chop up the lovely parsnips
01303                     // (apologise to them first for spoiling their good looks)
01304                     // into nice slices, and bung them into a pot type thing.
01305                     // What you want is layers of pasnip slices alternating
01306                     // with yogurt and cheese -- the layers shouldn't be very
01307                     // thick of either, but you don't want too much yogurt
01308                     // and cheese. On the top, you pop some more yogurt down
01309                     // and cover with a nice layer of cheese. Bung in the oven
01310                     // at about 200 degrees, and cook until it's lovely and
01311                     // moist, and completely yummy.
01312                     // what we need, apart from more parsnips, is to have some
01313                     // funny little green men to write all our code for us,
01314                     // so we don't have to do it ourselves. But you know, that
01315                     // could possibly put us out of work, so maybe it isn't such
01316                     // a good plan. I suppose I ought to go and write that little
01317                     // function, but it's important to think about parsnips,
01318                     // because they are very good.
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                     // we have a WORD giving count of bytes in the string,
01330                     // followed by the bytes of the string
01331                     RDIN(WORD, count)
01332 
01333                     TCHAR *text = (TCHAR *)CCMalloc(count + 4);
01334                     if(text == NULL)
01335                         return FALSE;
01336 
01337                     // read the characeters from the file
01338                     pFile->read(text, count);
01339 
01340                     text[count] = '\0';     // terminate the string
01341 
01342                     // create a string object
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                     // output it
01351                     RDOUT(StringBase *, pString)
01352 
01353                     // free the temporary buffer
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     /*      case CI_READ_FONTINDEX:
01418                 {
01419                     RDIN(SWORD, count)
01420                     RDIN(SWORD, size)
01421                     RDIN(SWORD, type)
01422                     fontList    fonts;
01423                     fonts.count =   count;
01424                     fonts.size  =   size;
01425                     fonts.type  =   type;
01426                     fonts.offsets   =   new UINT32[count];
01427                     for(INT32 i = 0 ; i < fonts.count ; i++)
01428                     {
01429                         RDIN(DWORD, offset)
01430                         fonts.offsets[i]    =   offset;
01431                     }
01432 
01433                     RDOUT(fontList, fonts) 
01434                 }
01435                 break;*/
01436 
01437             case CI_READMATRIX:
01438                 {
01439                     RDIN(WORD, Type)
01440                     Matrix Mat;     // identity matrix
01441                     if(Type == cmxMATRIXTYPE_GENERAL)
01442                     {
01443                         // OK, so it's not a identity matrix, but a proper one
01444                         // better load it then, I suppose.
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                 // read a fixed length string from the file... quite easy this one really
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;       // couldn't allocate array
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                 {   //  cannot deal with that yet so we're going to tell them
01487 
01488                 TRACEUSER( "Claude", _T("Transparency stuffs\n"));
01489                 TRACEUSER( "Graeme", _T("Transparency stuffs\n"));
01490                     
01491                 }
01492                 break;
01493 
01494             // --------------- structural bits ------------------
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             // do16 and d32 are implemented here to avoid clashes with the
01524             // if - elseif - endif system
01525             case CI_DO16:
01526                 {
01527                     if(Is32Bit)
01528                     {
01529                         // scan forward to find CI_DO32 or CI_DOALL
01530                         while(TRUE)
01531                         {
01532                             if((*Instructions) == CI_DO32 || (*Instructions) == CI_DOALL)
01533                                 break;
01534 
01535                             if((*Instructions) == CI_STOP)
01536                                 return TRUE;            // all done
01537 
01538                             // next thingy
01539                             Instructions += CMXIinfo::CommandLengths[*Instructions];
01540                         }
01541                     }
01542                 }
01543                 break;
01544 
01545             case CI_DO32:
01546                 {
01547                     if(!Is32Bit)
01548                     {
01549                         // scan forward to find CI_DO16 or CI_DOALL
01550                         while(TRUE)
01551                         {
01552                             if((*Instructions) == CI_DO16 || (*Instructions) == CI_DOALL)
01553                                 break;
01554 
01555                             if((*Instructions) == CI_STOP)
01556                                 return TRUE;            // all done
01557 
01558                             // next thingy
01559                             Instructions += CMXIinfo::CommandLengths[*Instructions];
01560                         }
01561                     }
01562                 }
01563                 break;
01564 
01565             case CI_DOALL:
01566                 // don't worry, chaps, we are
01567                 break;
01568 
01569             case CI_TAG_VAL:
01570                 if(Is32Bit)         // tags are ignored in 16 bit files
01571                 {
01572                     ERROR2IF((TagLevel + 1) >= MAXTAGLEVEL, FALSE, "too many nested tags");
01573                     // read data structure, trying to find the right tag
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)       // the tag wasn't there
01583 
01584                         // get the size of the tag
01585                         RDIN(WORD, Size)
01586                         if(type == PARAM(0))
01587                         {
01588                             // found the right one
01589                             TagEnds[TagLevel] = start + Size;
01590                             break;
01591                         }
01592                         // otherwise skip to the next one
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 //                      RDIN(BYTE, test)
01598                 //  TRACEUSER( "Claude", _T("test = %d\n"), test);  
01599 //                      break;
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                     // get the size of the tag
01622                     RDIN(WORD, Size)
01623                     if(type == PARAM(0))
01624                     {
01625                         // found the right one
01626                         TagEnds[TagLevel] = start + Size;
01627                         Seek(start + Size); //  WARNING! This actually skip the info 
01628                                             //  for the Frozen viewpoint thingy, as it did
01629                                             //  before but it's less obvious now.
01630                         TagLevel--;
01631                         break;
01632                     }
01633                     
01634                     
01635                     // otherwise skip to the next one
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)         // tags are ignored in 16 bit files
01644                 {
01645 //TRACEUSER( "Ben", _T("endtag, level = %d\n"), TagLevel);
01646                     // make sure the file is in the correct position for the next thing
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 //TRACEUSER( "Ben", _T("minendtag\n"));
01662                     // see if we can find the end tag -- there may be tags to skip
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                 // we need to make the output location n bytes after the
01687                 // last marker set
01688                 pOut = OUTPUTMARKER + PARAM(0);
01689                 break;
01690 
01691             case CI_SETINMARKER:
01692                 InputMarkerStack[StackLevel] = Tell();
01693                 break;
01694 
01695             case CI_ENSUREINLOC:
01696                 // we have a SizeInFile value in the stored value
01697                 // we need to ensure that the correct file location is
01698                 // the input marker plus that value
01699                 {
01700                     INT32 TargetPos = INPUTMARKER + STOREDVALUE;
01701                     if(Tell() != TargetPos)
01702                         Seek(TargetPos);
01703                 }
01704                 break;
01705 
01706             // --------------- debug ------------------
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             // --------------- catch all ------------------
01717             default:
01718                 ERROR3("Defined instruction code not implemented");
01719                 break;
01720 
01721             // things which are implemented in the first switch
01722             case CI_STOP:
01723             case CI_IFSTOREDIS_VAL:
01724             case CI_ELSEIF_VAL:
01725             case CI_ENDIF:
01726                 break;
01727             }
01728         }
01729         // get ready to do the next thingy
01730         Instructions += CMXIinfo::CommandLengths[*Instructions];
01731     }
01732 
01733     return FALSE;
01734 }
01735 
01736 
01737 /********************************************************************************************
01738 
01739 >   BOOL CMXImportFilter::ReadPointList(Path **ppPath)
01740 
01741     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
01742     Created:    06/08/96
01743     Inputs:     pointer to a pointer to return the new path in
01744     Returns:    success
01745     Purpose:    converts a point list from the file into one of our paths
01746                 it isn't transformed or anything
01747 
01748 ********************************************************************************************/
01749 
01750 BOOL CMXImportFilter::ReadPointList(Path **ppPath)
01751 {
01752     (*ppPath) = 0;
01753     // what we have in the file...
01754     // WORD Count
01755     // appropriate number of coords
01756     // appropriate number of verbs
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     // read in and convert the coordinates
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     // now create the path
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     // position the new elements at the beginning of the path
01798     pPath->FindStartOfPath();
01799 
01800     // run through inserting the elements
01801 
01802     INT32 c;                    // coord counter
01803     PathFlags Flags;
01804     BOOL NeedMoveTo = TRUE;
01805 
01806     // go though converting all the coords
01807     for(c = 0; c < NumCoords; c++)
01808     {
01809         RDIN(BYTE, Verb)
01810 
01811         INT32 CoordType = Verb & CMXNODETYPE_TYPE_MASK;
01812 
01813         // add in a move to if necessary
01814         if(NeedMoveTo && CoordType != CMXNODETYPE_TYPE_MOVE)
01815         {
01816             if(!pPath->InsertMoveTo(pCoords[c]))
01817                 return FALSE;
01818         }
01819 
01820         NeedMoveTo = FALSE;
01821         
01822         // process the coordinate       
01823         switch(CoordType)
01824         {
01825             case CMXNODETYPE_TYPE_MOVE:
01826                 // add a move to this path
01827                 if(!pPath->InsertMoveTo(pCoords[c]))
01828                     return FALSE;
01829                 break;
01830             
01831             case CMXNODETYPE_TYPE_LINE:
01832                 // add a line to this coord to the path
01833                 if(!pPath->InsertLineTo(pCoords[c]))
01834                     return FALSE;
01835                 break;
01836             
01837             case CMXNODETYPE_TYPE_CURVE:
01838                 // check we have some control points for this curve
01839                 // a control point cannot be the first coord, so it's OK to check against 0
01840                 if(c < 2)
01841                 {
01842                     TRACEUSER( "Ben", _T("No control points for curve element\n"));
01843                     break;
01844                 }
01845 
01846                 // create the curve
01847                 Flags.IsSelected = FALSE;
01848                 Flags.IsSmooth = Flags.IsRotate = ((Verb & CMXNODETYPE_CONTINUITYMASK) != 0)?TRUE:FALSE;
01849                 Flags.IsEndPoint = FALSE;
01850                 
01851                 // insert it into the path
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                 // control points for a node
01858                 break;
01859             
01860             default:
01861                 // can't get here as mask won't allow any other value than the ones above.
01862                 break;
01863         }
01864 
01865         // is this a close subpath situtation?
01866         if((Verb & CMXNODETYPE_CLOSED) != 0 && CoordType != CMXNODETYPE_TYPE_ARC)
01867         {
01868             // close the sub path
01869             if(CoordType != CMXNODETYPE_TYPE_MOVE)
01870             {
01871                 if(!pPath->CloseSubPath())
01872                     return FALSE;
01873 
01874                 // ensure that the next coord is a moveto
01875                 NeedMoveTo = TRUE;
01876 
01877                 // mark the path as possibly filled
01878                 pPath->IsFilled = TRUE;
01879             }
01880         }
01881     }
01882 
01883     // should have done it.
01884 
01885     // delete the coordinate array
01886     delete [] pCoords;
01887 
01888     // check the path
01889     if(!pPath->EnsureValid())
01890     {
01891         // let's just knock up a quick valid one to keep everything happy.
01892         // it's a bodge, so it'll feel nicely at home in Camelot.
01893         pPath->ClearPath();
01894         pPath->InsertMoveTo(DocCoord(0,0));
01895         pPath->InsertLineTo(DocCoord(72,72));
01896     }
01897 
01898     // return the path thingy
01899     (*ppPath) = pPath;
01900 
01901     return TRUE;
01902 }
01903 
01904 
01905 /********************************************************************************************
01906 
01907 >   CMXImportColourList *CMXImportFilter::ReadColourList(void)
01908 
01909     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
01910     Created:    14/08/96
01911     Inputs:     none
01912     Returns:    colour list or 0 for error
01913     Purpose:    reads a nice colour list thing from the CMX file
01914 
01915 ********************************************************************************************/
01916 
01917 CMXImportColourList *CMXImportFilter::ReadColourList(void)
01918 
01919 {
01920     // get a new colour list object to play with
01921     CMXImportColourList *pColList = new CMXImportColourList;
01922     if(pColList == NULL)
01923         return NULL;
01924 
01925     // get the count of stuff
01926     RDIN(WORD, Count);
01927 //  TRACEUSER( "Ben", _T("Colour list has %d entries\n"), Count);
01928 
01929     for(INT32 l = 0; l < Count; l++)
01930     {
01931         // load the thing in
01932         RDIN(cmxGradFillColour, col);
01933 
01934         // add it to the list
01935         if(!pColList->AddColour(col.ColRef, col.ColPos))
01936             return NULL;
01937     }
01938 
01939     return pColList;
01940 }
01941 
01942 /********************************************************************************************
01943 
01944 >   void CMXIinfo::SetUpInfo(void)
01945 
01946     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
01947     Created:    06/08/96
01948     Inputs:     none
01949     Returns:    none
01950     Purpose:    fixes up the array of command lengths
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 /*#ifdef _DEBUG
01981     for(INT32 l = 0; l < 256; l++)
01982     {
01983         TRACEUSER( "Ben", _T("en %d = %d\n"), l, CommandLengths[l]);
01984     }
01985 #endif*/
01986 }
01987 
01988 
01989 /********************************************************************************************
01990 
01991 >   static void CMXIinfo::SetLengths(char *instrs, INT32 num, INT32 val)
01992 
01993     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
01994     Created:    06/08/96
01995     Inputs:     none
01996     Returns:    none
01997     Purpose:    inserts lengths into the length array
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 

Generated on Sat Nov 10 03:44:46 2007 for Camelot by  doxygen 1.4.4