cmxexdc.h

Go to the documentation of this file.
00001 // $Id: cmxexdc.h 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 // CMX export device context
00099 
00100 #ifndef __CMXEXDC_H
00101 #define __CMXEXDC_H
00102 
00103 #include "kerneldc.h"
00104 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "cmxform.h"
00106 //#include "pathtype.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "docrect.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "gradtype.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "attr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "arrows.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 
00113 class Filter;
00114 class CCDiskFile;
00115 class Rect;
00116 class CMXRenderRegion;
00117 class DocColour;
00118 class FillGeometryAttribute;
00119 class KernelBitmap;
00120 class CMXReferBitmap;
00121 class CMXReferListItem;
00122 class CMXReferPage;
00123 class CMXExportDC;
00124 class Operation;
00125 class Document;
00126 class PathName;
00127 
00128 // how many overlapping lenses we allow
00129 #define CMX_MAX_OVERLAP_LENSES      3
00130 
00131 // the size of the cache for future values
00132 #define CMXFUTUREVALUECACHESIZE     128
00133 
00134 // macro for helping to set up future values
00135 #define FUTURE_BACKLOC(obj, mem) (0-(sizeof(*obj) - ( ((INT32)(&((obj)->mem))) - ((INT32)(obj)) )))
00136 
00137 // base class for information written, but not know yet
00138 class CMXFutureUpdater : public CCObject
00139 {
00140     CC_DECLARE_DYNAMIC(CMXFutureUpdater);
00141 
00142 public:
00143     CMXFutureUpdater();
00144     ~CMXFutureUpdater();
00145     BOOL Init(CMXExportDC *pDC, INT32 RelativePos, UINT32 DataSize);
00146     virtual BOOL Write(CMXExportDC *pDC) = 0;
00147 protected:
00148     BOOL WriteValue(CMXExportDC *pDC, INT32 Value);
00149     virtual void Reset(void) {};
00150 private:
00151     INT32 AbsPosition;
00152     UINT32 DataSize;
00153 };
00154 
00155 // thing for writing lengths
00156 class CMXFutureLength : public CMXFutureUpdater
00157 {
00158     CC_DECLARE_DYNAMIC(CMXFutureLength);
00159 
00160 public:
00161     CMXFutureLength();
00162     BOOL SetLengthStartPos(CMXExportDC *pDC, INT32 RelativePos);
00163     BOOL Write(CMXExportDC *pDC);
00164 protected:
00165     void Reset(void);
00166 private:
00167     INT32 StartPos;
00168 };
00169 
00170 // thing for writing numbers
00171 class CMXFutureNumber : public CMXFutureUpdater
00172 {
00173     CC_DECLARE_DYNAMIC(CMXFutureNumber);
00174 
00175 public:
00176     BOOL Write(CMXExportDC *pDC);
00177 
00178     INT32 operator=(INT32 eq)   {return Number=eq;};
00179     INT32 operator++()      {return ++Number;};
00180     INT32 operator++(INT32) {return Number++;};
00181     INT32 operator--()      {return --Number;};
00182     INT32 operator--(INT32) {return Number--;};
00183     operator INT32()            {return Number;};
00184     
00185 private:
00186     INT32 Number;
00187 };
00188 
00189 // thing for writing indexes (offsets to things later on in the file)
00190 class CMXFutureIndex : public CMXFutureUpdater
00191 {
00192     CC_DECLARE_DYNAMIC(CMXFutureIndex);
00193 
00194 public:
00195     BOOL Write(CMXExportDC *pDC);
00196 };
00197 
00198 #define cmxINDEX_NONE           0
00199 #define cmxINDEX_ARROW          1
00200 #define cmxINDEX_BITMAP         2
00201 #define cmxINDEX_EMBEDFILE      3
00202 #define cmxINDEX_LAYER          4
00203 #define cmxINDEX_PAGE           5
00204 #define cmxINDEX_PROCEDURE      6
00205 #define cmxINDEX_MASTERLAYER    7
00206 #define cmxINDEX_MASTERINDEX    8
00207 
00208 #define cmxDESC_NONE            0
00209 #define cmxDESC_ARROW           1
00210 #define cmxDESC_ARROWHEADS      2
00211 #define cmxDESC_DOTDASH         3
00212 #define cmxDESC_FONT            4
00213 #define cmxDESC_IMAGE           5
00214 #define cmxDESC_OUTLINE         6
00215 #define cmxDESC_LINESTYLE       7
00216 #define cmxDESC_PEN             8
00217 #define cmxDESC_LENS            9
00218 #define cmxDESC_SCREEN          10
00219 #define cmxDESC_COLOUR          11
00220 
00221 /********************************************************************************************
00222 
00223 >   class CMXExportDC : public ExportDX
00224 
00225     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
00226     Created:    18/6/96
00227     Purpose:    Export device context for CMX files.
00228     SeeAlso:    ExportDC
00229 
00230 ********************************************************************************************/
00231 
00232 class CMXExportDC : public ExportDC
00233 {
00234 public:
00235     CMXExportDC(Filter *);
00236     BOOL Init(CCLexFile*, CMXRenderRegion *pReg, BOOL bThirtyTwoBit, BOOL ClipboardExport);
00237 
00238     // data definitions local to this class
00239     typedef enum {
00240         CMXSECTION_NONE,        // not proccessing one
00241         CMXSECTION_HEADER,
00242         CMXSECTION_PAGE,
00243         CMXSECTION_REFLIST,
00244         CMXSECTION_INDEX,
00245         CMXSECTION_ARROW,
00246         CMXSECTION_ARROWHEADS,
00247         CMXSECTION_COLOUR,
00248         CMXSECTION_DOTDASH,
00249         CMXSECTION_FONT,
00250         CMXSECTION_IMAGE,
00251         CMXSECTION_OUTLINE,
00252         CMXSECTION_LINESTYLE,
00253         CMXSECTION_PEN,
00254         CMXSECTION_LENS,
00255         CMXSECTION_SCREEN,
00256         CMXSECTION_TRAILER,
00257         CMXSECTION_IMAGINFO,
00258         CMXSECTION_IMAGDATA,
00259         CMXSECTION_PROCBITFILL,
00260         CMXSECTION_PREVIEWBITMAP
00261     } CMXSectionType;
00262 
00263     // structure for caching future numbers
00264     typedef struct {
00265         INT32 Location;
00266         INT32 Data;
00267         UINT32 DataSize;
00268     } CMXFutureDataCacheEntry;
00269     
00270     // Functions to do the actual output to the CMX file.
00271     BOOL StartSection(CMXSectionType Type);
00272     BOOL EndSection(void);
00273     BOOL StartRIFFList(INT32 Type);
00274     BOOL EndRIFFList(void);
00275     BOOL CreateHeader(DocRect *pFileBBox);
00276     BOOL PolishOffThatFile(void);
00277     BOOL WriteNumber(INT32 Position, UINT32 DataSize, INT32 Value);
00278     BOOL WriteBBox(DocRect *BBox, BOOL Transform = TRUE);
00279     BOOL WriteString(StringBase *Str);
00280     void CleanUp(void);
00281     BOOL WriteReferenceList(void);
00282     BOOL WriteData(void *data, INT32 Size) {ExportFile->write(data, Size); return TRUE;};
00283     void WriteByte(BYTE Thing) {ExportFile->put(Thing);};   // will exception not return false
00284     BOOL WriteIndex(void);
00285     BOOL WriteAnIndex(INT32 Which);
00286     BOOL WriteADesc(INT32 Which);
00287     BOOL WriteDescriptionSections(void);
00288     BOOL WriteMatrix(Matrix *pMatrix = NULL);
00289     INT32 GetGroupCount(void) {return PageGroupCount;};
00290     static void CalcCorelBBox(DocCoord *Coords, INT32 NumCoords, DocRect *Result);
00291     void WriteAngle(double theta);
00292     BOOL WriteReferSections(void);
00293     void WriteSizeInFile(WORD Size) {if(ThirtyTwoBit) ExportFile->write(&Size, sizeof(Size));};
00294     BOOL WriteCamComment(void);
00295     BOOL WritePreviewBitmap(void);
00296 
00297     // access functions
00298     void SetTransMatrix(Matrix *pM)
00299     {
00300         pMatrix = pM;
00301         FIXED16 sf;
00302         pMatrix->Decompose(&sf);
00303         ScaleFactor = sf.MakeDouble();
00304     };
00305 
00306     Matrix *GetTransMatrix(void) {return pMatrix;};
00307     INT32 GetFilePosition();
00308     BOOL IsThirtyTwoBit() {return ThirtyTwoBit;};
00309     INT32 GetFirstInstrFilePosition(void) {return FirstInstrFilePosition;};
00310     INT32 GetCurrentInstrFilePosition(void) {return CurrentInstrFilePosition;};
00311     INT32 GetRefListOffset(void) {return RefListOffset;};
00312     INT32 GetInstructionTally(void) {return Tally;};
00313     WORD GetLayerNumber(void) {return LayerNumber;};
00314     CMXRenderRegion *GetRenderRegion(void) {return pRenderRegion;};
00315     double GetScaleFactor(void) {return ScaleFactor;};
00316     void SetInfo(Operation* op, PathName* ptPath, Document* ptDoc) {pOp = op, pPath = ptPath, TheDocument = ptDoc;};
00317 
00318     // functions to handle structural information
00319     BOOL StartPage(DocRect *BBox, BOOL IsProcedure = FALSE);
00320     BOOL EndPage(void);
00321     BOOL StartLayer(String_256 &Name);
00322     BOOL EndLayer(void);
00323     BOOL StartGroup(DocRect *BBox, BOOL TransformBBox = TRUE);
00324     BOOL EndGroup(void);
00325     void SetCMXFlag(INT32 flag);
00326 
00327     // functions to handle small structure information
00328     BOOL WriteCommand(UINT32 Tag, void *Data = 0, UINT32 Size = 0);
00329     BOOL StartCommand(UINT32 Tag);
00330     BOOL EndCommand(void);
00331     BOOL WriteTag(INT32 Tag, void *Data = 0, UINT32 Size = 0)
00332         {return DoWriteTag(Tag, Data, Size, FALSE);};
00333     BOOL StartTag(INT32 Tag);
00334     BOOL EndTag(void);
00335     BOOL StartNestedTag(INT32 Tag);
00336     BOOL EndNestedTag(void);
00337     BOOL WriteNestedTag(INT32 Tag, void *Data = 0, UINT32 Size = 0)
00338         {return DoWriteTag(Tag, Data, Size, TRUE);};
00339     // the following fn is necessary as some end tags require the full tag
00340     // but some don't. 
00341     BOOL WriteMinEndTag(void) {if(ThirtyTwoBit) WriteByte(cmxTAG_EndTag); return TRUE;};
00342 
00343     // attributes
00344     BOOL WriteAttributes(CMXRenderRegion *pReg, INT32 Tag, DocCoord *Coords, INT32 NumCoords, BOOL ForceNoFill = FALSE);
00345     BOOL WriteBlankAttributes(INT32 Tag);
00346     BOOL WriteAttrCheckLens(CMXRenderRegion *pReg, INT32 Tag, DocCoord *Coords, INT32 NumCoords, BOOL *WasLens);
00347     BOOL WriteAttrCheckIgnoreLens(CMXRenderRegion *pReg, DocCoord *Coords, INT32 NumCoords);
00348     BOOL WriteOutlineSpec(CMXRenderRegion *pReg);
00349     BOOL WriteFillSpec(CMXRenderRegion *pReg, DocCoord *Coords, INT32 NumCoords, BOOL NoFill);
00350     BOOL WriteFillType(WORD FillID);
00351     BOOL WriteFillSpecFlat(CMXRenderRegion *pReg, FillGeometryAttribute *pAttr);
00352     BOOL WriteFillSpecGrad(CMXRenderRegion *pReg, FillGeometryAttribute *pAttr, DocCoord *Coords, INT32 NumCoords);
00353     BOOL WriteFillSpecBitmap(CMXRenderRegion *pReg, FillGeometryAttribute *pAttr, DocCoord *Coords, INT32 NumCoords);
00354 
00355     // references
00356     WORD GetColourReference(DocColour *pTheLovelyColour);
00357     WORD GetBitmapReference(KernelBitmap *pTheLovelyBitmap, DocColour *pStartCol, DocColour *pEndCol, EFFECTTYPE Effect, CMXReferBitmap **ppRB = NULL);
00358     WORD GetProcedureReference(CMXReferListItem *pProc);
00359     WORD GetArrowReference(ArrowRec *pArrow);
00360 
00361     // thingy
00362     typedef enum {
00363         CMXBITMAPCOLOURSOURCE_NONE,
00364         CMXBITMAPCOLOURSOURCE_LINEANDFILL,
00365         CMXBITMAPCOLOURSOURCE_FILLGEOMETRY
00366     } CMXBitmapColourSource;
00367 
00368     // objects
00369     BOOL WritePath ( DocCoord   *Coords,
00370                      PathVerb   *Verbs,
00371                      INT32      NumCoords,
00372                      BOOL       Filled);
00373 
00374     BOOL WriteBitmap ( KernelBitmap             *pBitmap,
00375                        DocCoord                 *pParallelogram,
00376                        CMXBitmapColourSource    ColSource = CMXBITMAPCOLOURSOURCE_NONE,
00377                        BOOL                     TransformParallelogram = TRUE,
00378                        WORD                     BitmapReference = 0 );
00379 
00380     static double Round ( double ToRound );
00381 
00382 protected:
00383     DoWriteTag(INT32 Tag, void *Data = 0, UINT32 Size = 0, BOOL Nested = FALSE);
00384     BOOL WriteFutureDataCache();
00385 
00386 private:        // all the lovely data we'll need
00387     CMXRenderRegion *pRenderRegion;         // pointer to the render region -- we need it occasionally
00388 
00389     CMXSectionType CurrentSection;          // the type of the section we're currently thinking about
00390     CMXFutureLength SectionLengthFuture;    // the length of the section
00391 
00392     BOOL ThirtyTwoBit;                      // the bitness of the file we're writing
00393 
00394     CMXFutureLength FileLengthFuture;       // length of file
00395     CMXFutureNumber Tally;                  // tally of commands in the file
00396     CMXFutureIndex PageEndIndexFuture;      // for index of end page command
00397     CMXFutureNumber PageInstructionCount;   // for instructions in page
00398     CMXFutureNumber PageGroupCount;         // for the number of groups in the page
00399     CMXFutureNumber PageFlags;              // for the page flags
00400     CMXFutureNumber LayerInstructionCount;  // for layer...
00401     CMXFutureNumber LayerFlags;             // for layer flags
00402     CMXFutureLength CommandLengthFuture;    // for the length of the current command
00403     CMXFutureIndex IndexSectionFuture;      // for the offset to the index section
00404     CMXFutureIndex TrailerIndexFuture;      // location of the index section
00405     CMXFutureIndex ThumbnailIndexFuture;    // location of the index section
00406     CMXFutureLength TagLengthFuture;        // for the size of each tag
00407     CMXFutureLength RIFFListLengthFuture;   // for size of riff lists
00408 
00409     BOOL DoingCommand;                      // whether we're currently doing a command or not
00410     BOOL DoingPage;                         // whether we're in a page or not
00411     BOOL DoingLayer;                        // whether we're in a layer or not
00412     BOOL DoingTag;                          // whether we're doing a tag
00413     WORD LayerNumber;                       // number of layer we're doing
00414     BOOL DoingRIFFList;                     // doing a RIFF list
00415     BOOL PageIsProc;                        // page is really a procedure
00416 
00417     INT32 NestedTagLevel;                       // level of nested tags
00418     List NestedTagList;
00419     List ReferList;                         // List of things to refer to
00420     CMXReferPage *PageRefer;                // address of the current page reference
00421     INT32 RefListOffset;                        // offset of reflist chunk in file
00422     List GroupList;                         // list of groups -- stack type thing
00423     Matrix *pMatrix;                        // matrix to transform all exported things by
00424     INT32 FirstInstrFilePosition;           // position of the first instruction in the file
00425     INT32 CurrentInstrFilePosition;         // the position of the current instruction in the file
00426 
00427     INT32 NumberOfEntriesUsedInCache;           // number of entries used in the cache
00428     CMXFutureDataCacheEntry FutureDataCache[CMXFUTUREVALUECACHESIZE];
00429                                             // the cache for writing number
00430     double ScaleFactor;                     // scale factor between cam and CMX coords
00431 
00432     // stuff to handle not putting out too many overlapped lens objects
00433     List LensBBoxes;                        // a list of lens bounding boxes to avoid overlapping them too much
00434     BOOL OverlappedLensesHaveBeenIgnored;   // whether we ignored something
00435     BOOL AreIgnoreingOverlappedLenses;      // a flag to tell whether the user said we could ignore them
00436     BOOL HaveAskedUserAboutLenses;          // whether we've asked the user about stuff
00437 
00438     Document *TheDocument;
00439     Operation *pOp;
00440     PathName *pPath;
00441 };
00442 
00443 
00444 // class for putting things into reference lists and other stuff
00445 class CMXReferListItem : public ListItem
00446 {
00447     CC_DECLARE_DYNAMIC(CMXReferListItem);
00448 
00449 public:
00450     CMXReferListItem(CMXExportDC *pDC) {};
00451 
00452     virtual BOOL IsInReferenceList(void) {return FALSE;};
00453     virtual BOOL WriteInReferenceList(CMXExportDC *pDC) {return TRUE;};
00454 
00455     virtual INT32 IsInWhichIndex(void) {return cmxINDEX_NONE;};
00456     virtual BOOL WriteInIndex(CMXExportDC *pDC) {return TRUE;};
00457     virtual INT32 IndexEntrySize(CMXExportDC *pDC) {return 0;};     // size of entry which goes in index
00458 
00459     virtual INT32 IsInWhichDesc(void) {return cmxDESC_NONE;};
00460     virtual BOOL WriteInDesc(CMXExportDC *pDC) {return TRUE;};
00461 
00462     virtual BOOL IsASection(void) {return FALSE;};
00463     virtual BOOL WriteSection(CMXExportDC *pDC) {return TRUE;};
00464 
00465     virtual BOOL IsAProcedure(void) {return FALSE;};
00466 };
00467 
00468 // a version of the refer list item which gets an offset of where it is in the exported file
00469 class CMXReferListItemOffset : public CMXReferListItem
00470 {
00471     CC_DECLARE_DYNAMIC(CMXReferListItemOffset);
00472 
00473 public:
00474     CMXReferListItemOffset(CMXExportDC *pDC);
00475 
00476 protected:
00477     INT32 Offset;
00478 };
00479 
00480 // list item for layers
00481 class CMXReferLayer : public CMXReferListItemOffset
00482 {
00483     CC_DECLARE_DYNAMIC(CMXReferLayer);
00484 
00485 public:
00486     CMXReferLayer(CMXExportDC *pDC) : CMXReferListItemOffset(pDC) {};
00487 
00488     void SetLayerDetails(WORD Number, String_256 *tName);
00489 
00490     BOOL IsInReferenceList(void) {return TRUE;};
00491     BOOL WriteInReferenceList(CMXExportDC *pDC);
00492 
00493     BOOL IsInWhichIndex(void) {return cmxINDEX_LAYER;};
00494     BOOL WriteInIndex(CMXExportDC *pDC);
00495     INT32 IndexEntrySize(CMXExportDC *pDC);
00496 
00497 protected:
00498     WORD LayerNumber;
00499     String_256 Name;
00500 };
00501 
00502 // list item for the default screen attributes
00503 class CMXReferDefaultScreen : public CMXReferListItem
00504 {
00505     CC_DECLARE_DYNAMIC(CMXReferDefaultScreen);
00506 
00507 public:
00508     CMXReferDefaultScreen(CMXExportDC *pDC) : CMXReferListItem(pDC) {};
00509 
00510     INT32 IsInWhichDesc(void) {return cmxDESC_SCREEN;};
00511     BOOL WriteInDesc(CMXExportDC *pDC);
00512 };
00513 
00514 // list item for dot-dash patterns
00515 class CMXReferDotDash : public CMXReferListItem
00516 {
00517     CC_DECLARE_DYNAMIC(CMXReferDotDash);
00518 
00519 public:
00520     CMXReferDotDash(CMXExportDC *pDC) : CMXReferListItem(pDC) {pDash = 0;};
00521 
00522     void Set(DashRec *ptDash) {pDash = ptDash;};
00523 
00524     INT32 IsInWhichDesc(void) {return cmxDESC_DOTDASH;};
00525     BOOL WriteInDesc(CMXExportDC *pDC);
00526 
00527     virtual BOOL AreYouThisDotDash(DashRec *ptDash) {return ((*pDash) == (*ptDash))?TRUE:FALSE;};
00528 
00529 protected:
00530     DashRec *pDash;
00531 };
00532 
00533 // list item for default dot-dash attr
00534 class CMXReferDefaultDotDash : public CMXReferDotDash
00535 {
00536     CC_DECLARE_DYNAMIC(CMXReferDefaultDotDash);
00537 
00538 public:
00539     CMXReferDefaultDotDash(CMXExportDC *pDC) : CMXReferDotDash(pDC) {};
00540 
00541     INT32 IsInWhichDesc(void) {return cmxDESC_DOTDASH;};
00542     BOOL WriteInDesc(CMXExportDC *pDC);
00543 
00544     BOOL AreYouThisDotDash(DashRec *ptDash) {return (ptDash->Elements == 0)?TRUE:FALSE;};
00545 };
00546 
00547 #define CMXDEFAULTDOTDASHREF    1
00548 
00549 // list item for colours
00550 class CMXReferColour : public CMXReferListItem
00551 {
00552     CC_DECLARE_DYNAMIC(CMXReferColour);
00553 
00554 public:
00555     CMXReferColour(CMXExportDC *pDC) : CMXReferListItem(pDC) {};
00556 
00557     BOOL SetColour(DocColour *pCol) {Colour = *pCol; return TRUE;};
00558     BOOL AreYouThisColour(DocColour *pCompareColour)
00559         {return ((*pCompareColour) == (Colour))?TRUE:FALSE;};
00560 
00561     INT32 IsInWhichDesc(void) {return cmxDESC_COLOUR;};
00562     BOOL WriteInDesc(CMXExportDC *pDC);
00563 
00564 protected:
00565     DocColour Colour;
00566 };
00567 
00568 // list item for pens
00569 class CMXReferPen : public CMXReferListItem
00570 {
00571     CC_DECLARE_DYNAMIC(CMXReferPen);
00572 
00573 public:
00574     CMXReferPen(CMXExportDC *pDC) : CMXReferListItem(pDC) {Width = -1;};
00575 
00576     BOOL SetWidth(MILLIPOINT TWidth) {ERROR2IF(Width != -1, FALSE, "width already set");
00577                                         Width = TWidth; return TRUE;};
00578     BOOL AreYouThisWidth(MILLIPOINT CompareWidth) {return (CompareWidth == Width)?TRUE:FALSE;};
00579 
00580     INT32 IsInWhichDesc(void) {return cmxDESC_PEN;};
00581     BOOL WriteInDesc(CMXExportDC *pDC);
00582 
00583 protected:
00584     MILLIPOINT Width;
00585 };
00586 
00587 // list item for line styles
00588 class CMXReferLineStyle : public CMXReferListItem
00589 {
00590     CC_DECLARE_DYNAMIC(CMXReferLineStyle);
00591 
00592 public:
00593     CMXReferLineStyle(CMXExportDC *pDC) : CMXReferListItem(pDC) {};
00594 
00595     void SetLineStyle(cmxLineStyle *pLineStyle) {LineStyle = *pLineStyle;};
00596     BOOL AreYouThisStyle(cmxLineStyle *pLineStyle);
00597 
00598     INT32 IsInWhichDesc(void) {return cmxDESC_LINESTYLE;};
00599     BOOL WriteInDesc(CMXExportDC *pDC);
00600 
00601 protected:
00602     cmxLineStyle LineStyle;
00603 };
00604 
00605 // list item for outlines
00606 class CMXReferOutline : public CMXReferListItem
00607 {
00608     CC_DECLARE_DYNAMIC(CMXReferOutline);
00609 
00610 public:
00611     CMXReferOutline(CMXExportDC *pDC) : CMXReferListItem(pDC) {};
00612 
00613     void SetOutline(cmxOutline *pOutline) {Outline = *pOutline;};
00614     BOOL AreYouThisOutline(cmxOutline *pOutline);
00615 
00616     INT32 IsInWhichDesc(void) {return cmxDESC_OUTLINE;};
00617     BOOL WriteInDesc(CMXExportDC *pDC);
00618 
00619 protected:
00620     cmxOutline Outline;
00621 };
00622 
00623 // list item for arrowheads
00624 class CMXReferArrowheads : public CMXReferListItem
00625 {
00626     CC_DECLARE_DYNAMIC(CMXReferArrowheads);
00627 
00628 public:
00629     CMXReferArrowheads(CMXExportDC *pDC) : CMXReferListItem(pDC) {};
00630 
00631     void SetArrowheads(WORD StartArrow, WORD EndArrow) {Start = StartArrow; End = EndArrow;};
00632     BOOL AreYouThisArrowheads(WORD StartArrow, WORD EndArrow) {return (Start == StartArrow) && (End == EndArrow);};
00633 
00634     INT32 IsInWhichDesc(void) {return cmxDESC_ARROWHEADS;};
00635     BOOL WriteInDesc(CMXExportDC *pDC);
00636 
00637 protected:
00638     WORD Start, End;
00639 };
00640 
00641 // list item for the actual arrow description
00642 class CMXReferArrow : public CMXReferListItem
00643 {
00644     CC_DECLARE_DYNAMIC(CMXReferArrow);
00645 
00646 public:
00647     CMXReferArrow(CMXExportDC *pDC) : CMXReferListItem(pDC) {pArrow = 0;};
00648     
00649     void Set(ArrowRec *ptArrow) {pArrow = ptArrow;};
00650 
00651     INT32 IsInWhichDesc(void) {return cmxDESC_ARROW;};
00652     BOOL WriteInDesc(CMXExportDC *pDC);
00653 
00654     BOOL AreYouThisArrow(ArrowRec *ptArrow)
00655         {return ((ptArrow->ArrowID == pArrow->ArrowID) || (ptArrow == pArrow))?TRUE:FALSE;};
00656 
00657     INT32 IsInWhichIndex(void) {return cmxINDEX_ARROW;};
00658     BOOL WriteInIndex(CMXExportDC *pDC);
00659     INT32 IndexEntrySize(CMXExportDC *pDC) {return sizeof(cmxArrowIndexEntry);};
00660 
00661 protected:
00662     INT32 ArrowFilePosition;
00663     ArrowRec *pArrow;
00664 };
00665 
00666 // list item for lenses
00667 class CMXReferLens : public CMXReferListItem
00668 {
00669     CC_DECLARE_DYNAMIC(CMXReferLens);
00670 
00671 public:
00672     CMXReferLens(CMXExportDC *pDC) : CMXReferListItem(pDC) {};
00673 
00674     BOOL Set(CMXExportDC *pDC, DocRect *tBBox);
00675 
00676     BOOL IsInReferenceList(void) {return TRUE;};
00677     BOOL WriteInReferenceList(CMXExportDC *pDC);
00678 
00679     BOOL IsASection(void) {return TRUE;};
00680     BOOL WriteSection(CMXExportDC *pDC);
00681 
00682     BOOL IsAProcedure(void) {return TRUE;};
00683 
00684     INT32 IsInWhichIndex(void) {return cmxINDEX_PROCEDURE;};
00685     BOOL WriteInIndex(CMXExportDC *pDC);
00686     INT32 IndexEntrySize(CMXExportDC *pDC) {return sizeof(cmxProcIndexEntry)+(pDC->IsThirtyTwoBit()?sizeof(WORD):0);};      // size of entry which goes in index
00687 
00688 protected:
00689     INT32 CommandFilePosition;  // position of the layer instruction
00690     DocRect BBox;
00691     INT32 LayerNumber;
00692     INT32 LensDescFilePosition;
00693 };
00694 
00695 // list item for pages
00696 class CMXReferPage : public CMXReferListItemOffset
00697 {
00698     CC_DECLARE_DYNAMIC(CMXReferPage);
00699 
00700 public:
00701     CMXReferPage(CMXExportDC *pDC) : CMXReferListItemOffset(pDC) {};
00702 
00703     void SetLayerTableOffset(INT32 off) {LayerTableOffset = off;};
00704     void SetRefListOffset(INT32 off) {RefListOffset = off;};
00705 
00706     BOOL IsInWhichIndex(void) {return cmxINDEX_PAGE;};
00707     BOOL WriteInIndex(CMXExportDC *pDC);
00708     INT32 IndexEntrySize(CMXExportDC *pDC) {return sizeof(cmxPageIndexEntry)+(pDC->IsThirtyTwoBit()?sizeof(WORD):0);};
00709 
00710 protected:
00711     INT32 LayerTableOffset;
00712     INT32 RefListOffset;
00713 };
00714 
00715 // list item for indexes
00716 class CMXReferMasterIndex : public CMXReferListItemOffset
00717 {
00718     CC_DECLARE_DYNAMIC(CMXReferMasterIndex);
00719 
00720 public:
00721     CMXReferMasterIndex(CMXExportDC *pDC) : CMXReferListItemOffset(pDC) {};
00722 
00723     void SetType(WORD tType) {Type = tType;};
00724 
00725     BOOL IsInWhichIndex(void) {return cmxINDEX_MASTERINDEX;};
00726     BOOL WriteInIndex(CMXExportDC *pDC);
00727     INT32 IndexEntrySize(CMXExportDC *pDC) {return sizeof(cmxMasterIndexEntry);};
00728 
00729 protected:
00730     WORD Type;
00731 };
00732 
00733 
00734 // list item for master layer index
00735 class CMXReferMasterLayer : public CMXReferListItemOffset
00736 {
00737     CC_DECLARE_DYNAMIC(CMXReferMasterLayer);
00738 
00739 public:
00740     CMXReferMasterLayer(CMXExportDC *pDC) : CMXReferListItemOffset(pDC) {};
00741 
00742     BOOL IsInWhichIndex(void) {return cmxINDEX_MASTERLAYER;};
00743     BOOL WriteInIndex(CMXExportDC *pDC);
00744     INT32 IndexEntrySize(CMXExportDC *pDC) {return (pDC->IsThirtyTwoBit())?sizeof(cmxMasterLayerEntry32):sizeof(cmxMasterLayerEntry16);};
00745 };
00746 
00747 
00748 // list item for bitmaps
00749 class CMXReferBitmap : public CMXReferListItem
00750 {
00751     CC_DECLARE_DYNAMIC(CMXReferBitmap);
00752 
00753 public:
00754     CMXReferBitmap(CMXExportDC *pDC) : CMXReferListItem(pDC)
00755         {Effect = EFFECT_RGB; Contone = FALSE;};
00756 
00757     void Set(KernelBitmap *pBitmap, DocColour *pStartCol, DocColour *pEndCol, EFFECTTYPE tEffect)
00758         {if(pStartCol != 0 && pEndCol != 0)
00759             {StartColour = *pStartCol; EndColour = *pEndCol; Contone = TRUE;}
00760             Effect = tEffect; Ref.Attach(pBitmap, NULL);};
00761 
00762     BOOL IsInWhichIndex(void) {return cmxINDEX_EMBEDFILE;};
00763     BOOL WriteInIndex(CMXExportDC *pDC);
00764     INT32 IndexEntrySize(CMXExportDC *pDC) {return sizeof(cmxEmbedFileIndexEntry)+(pDC->IsThirtyTwoBit()?sizeof(WORD):0);};
00765 
00766     BOOL IsASection(void) {return TRUE;};
00767     BOOL WriteSection(CMXExportDC *pDC);
00768 
00769     BOOL AreYouThisBitmap(KernelBitmap *pBitmap, DocColour *pStartCol, DocColour *pEndCol, EFFECTTYPE tEffect)
00770         {return ((pBitmap == Ref.GetBitmap())
00771             && ( (!Contone && (pStartCol == NULL)) || ((pStartCol != NULL) && ((*pStartCol) == StartColour)))
00772             && ( (!Contone && (pEndCol == NULL  )) || ((pEndCol != NULL  ) && ((*pEndCol)   == EndColour  )))
00773             && (tEffect == Effect))
00774             ?TRUE:FALSE;};
00775 
00776     KernelBitmap *GetBitmap(void) {return Ref.GetBitmap();};
00777 
00778 protected:
00779     INT32 BitmapFileOffset;
00780     KernelBitmapRef Ref;
00781     DocColour StartColour;
00782     DocColour EndColour;
00783     EFFECTTYPE Effect;
00784     BOOL Contone;
00785 };
00786 
00787 #define cmxBITMAPFILLTILESIZE_X     (1024*24)
00788 #define cmxBITMAPFILLTILESIZE_Y     (1024*24)
00789 
00790 class CMXReferBitmapFill : public CMXReferListItem
00791 {
00792     CC_DECLARE_DYNAMIC(CMXReferBitmapFill);
00793 
00794 public:
00795     CMXReferBitmapFill(CMXExportDC *pDC) : CMXReferListItem(pDC) {};
00796 
00797     void Set(WORD Ref) {BitmapReference = Ref;};
00798 
00799     BOOL IsASection(void) {return TRUE;};
00800     BOOL WriteSection(CMXExportDC *pDC);
00801 
00802     BOOL IsAProcedure(void) {return TRUE;};
00803 
00804     INT32 IsInWhichIndex(void) {return cmxINDEX_PROCEDURE;};
00805     BOOL WriteInIndex(CMXExportDC *pDC);
00806     INT32 IndexEntrySize(CMXExportDC *pDC) {return sizeof(cmxProcIndexEntry)+(pDC->IsThirtyTwoBit()?sizeof(WORD):0);};      // size of entry which goes in index
00807 
00808 protected:
00809     WORD BitmapReference;
00810     INT32 ProcedureFilePosition;
00811 };
00812 
00813 // group record class
00814 class CMXGroupRecord : public ListItem
00815 {
00816     CC_DECLARE_DYNAMIC(CMXGroupRecord);
00817 
00818 public:
00819     CMXGroupRecord(CMXExportDC *pDC);
00820     BOOL Write(CMXExportDC *pDC);
00821 
00822 protected:
00823     INT32 Offset;
00824     INT32 TallyAtStart;
00825     INT32 GroupCountAtStart;
00826 };
00827 
00828 
00829 // nested tag class
00830 class CMXNestedTagRecord : public ListItem
00831 {
00832     CC_DECLARE_DYNAMIC(CMXNestedTagRecord);
00833 
00834 public:
00835     CMXFutureLength LengthFuture;
00836 };
00837 
00838 class CMXLensBBox : public ListItem
00839 {
00840     CC_DECLARE_DYNAMIC(CMXLensBBox);
00841 
00842 public:
00843     CMXLensBBox(DocRect *bbox) {BBox = *bbox;};
00844 
00845     BOOL DoesIntersect(DocRect *pBBox) {return BBox.IsIntersectedWith(*pBBox);};
00846 
00847 private:
00848     DocRect BBox;
00849 };
00850 
00851 #endif // __ CMXEXDC_H

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