cdrfiltr.h

Go to the documentation of this file.
00001 // $Id: cdrfiltr.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 // CorelDRAW filter
00099 
00100 /*
00101 */
00102 
00103 
00104 #ifndef INC_CDRFILTER
00105 #define INC_CDRFILTER
00106 
00107 //#include "filters.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 #include "colcomp.h"
00109 #include "impcol.h"
00110 #include "rifffile.h"
00111 //#include "fixst256.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 #include "cdrform.h"
00113 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 #include "cdrbitm.h"
00115 //#include "txtattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 
00117 class TextStory;
00118 
00119 typedef enum {
00120     CDRVERSION_NULL = 0,
00121     CDRVERSION_3 = 3,
00122     CDRVERSION_4 = 4,
00123     CDRVERSION_5 = 5,
00124     CDRVERSION_6 = 6
00125 } CDRVersion;
00126 
00127 /********************************************************************************************
00128 
00129 >   class CDRAttributeStore : public List
00130 
00131     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00132     Created:    22 03 95    
00133     Purpose:    A storage object for attributes from a CDR file import
00134 
00135 ********************************************************************************************/
00136 
00137 class CDRAttributeStore : public List
00138 {
00139     CC_DECLARE_MEMDUMP(CDRAttributeStore);
00140 
00141 public:
00142     virtual BOOL AddChunkToStore(RIFFFile *RIFF);
00143     
00144     // find chunks routines, return 0 if they couldn't be found
00145     ADDR Find(DWORD reference, INT32 *Size);        // find by double word reference
00146     ADDR Find(WORD reference, INT32 *Size);     // find by single word reference
00147 
00148 private:
00149 };
00150 
00151 
00152 /********************************************************************************************
00153 
00154 >   class CDRAttributeStoredItem : public ListItem
00155 
00156     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00157     Created:    22 03 95    
00158     Purpose:    A list item object for attributes from a CDR file import
00159 
00160 ********************************************************************************************/
00161 
00162 class CDRAttributeStoredItem : public ListItem
00163 {
00164 friend class CDRAttributeStore;
00165 friend class CDRArrowheadStore;
00166 friend class CDRArrowheadStoredItem;
00167 friend class CDRFontnameStore;
00168 
00169     CC_DECLARE_MEMDUMP(CDRAttributeStoredItem);
00170 
00171 public:
00172     CDRAttributeStoredItem(void);
00173     ~CDRAttributeStoredItem();
00174 
00175     BOOL Aquire(RIFFFile *RIFF);    
00176 
00177 protected:
00178     INT32 Size;
00179     ADDR Block;
00180 };
00181 
00182 
00183 /********************************************************************************************
00184 
00185 >   class CDRFontnameStore : public CDRAttributeStore
00186 
00187     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00188     Created:    22 03 95    
00189     Purpose:    A storage object for fontnames from a CDR file import
00190 
00191 ********************************************************************************************/
00192 
00193 class CDRFontnameStore : public CDRAttributeStore
00194 {
00195     CC_DECLARE_MEMDUMP(CDRFontnameStore);
00196 
00197 public:
00198     virtual BOOL AddChunkToStore(RIFFFile *RIFF, CDRVersion Version);
00199     virtual BOOL AddFontToStore(DWORD Reference, TCHAR *Fontname);
00200     virtual WORD GetHandleForReference(DWORD Reference);
00201 
00202 private:
00203 };
00204 
00205 
00206 /********************************************************************************************
00207 
00208 >   class CDRFontnameStoredItem : public CDRAttributeStoredItem
00209 
00210     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00211     Created:    22 03 95    
00212     Purpose:    A list item object for fontnames from a CDR file import
00213 
00214 ********************************************************************************************/
00215 
00216 class CDRFontnameStoredItem : public CDRAttributeStoredItem
00217 {
00218 friend class CDRAttributeStore;
00219 friend class CDRFontnameStore;
00220 
00221     CC_DECLARE_MEMDUMP(CDRFontnameStoredItem);
00222 
00223     BOOL GetTypefaceForUse(DWORD Reference, TCHAR *FontName);
00224 
00225 public:
00226     DWORD   Reference;
00227     WORD    hTypeface;
00228 
00229 private:
00230 };
00231 
00232 
00233 /********************************************************************************************
00234 
00235 >   class CDRArrowheadStore : public List
00236 
00237     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00238     Created:    22 03 95    
00239     Purpose:    A storage object for arrowheads from a CDR file import
00240 
00241 ********************************************************************************************/
00242 
00243 class CDRArrowheadStore : public CDRAttributeStore
00244 {
00245     CC_DECLARE_MEMDUMP(CDRArrowheadStore);
00246 
00247 public:
00248     BOOL AddChunkToStore(RIFFFile *RIFF);
00249 
00250     NodeRenderableBounded *GetConvertedNode(DWORD Reference, INT32 *Distance, BOOL *NotPresent);    
00251 
00252 private:
00253 };
00254 
00255 
00256 /********************************************************************************************
00257 
00258 >   class CDRArrowheadStoredItem : public CDRAttributeStoredItem
00259 
00260     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00261     Created:    22 03 95    
00262     Purpose:    A list item object for arrowheads from a CDR file import
00263 
00264 ********************************************************************************************/
00265 
00266 class CDRArrowheadStoredItem : public CDRAttributeStoredItem
00267 {
00268 friend class CDRAttributeStore;
00269 friend class CDRArrowheadStore;
00270 
00271     CC_DECLARE_MEMDUMP(CDRArrowheadStoredItem);
00272 
00273 public:
00274     CDRArrowheadStoredItem(void);
00275     ~CDRArrowheadStoredItem();
00276 
00277 private:
00278     NodeRenderableBounded *pNode;   // the cached converted arrowhead
00279 };
00280 
00281 
00282 /********************************************************************************************
00283 
00284 >   class CDRVectorStoredItem : public ListItem
00285 
00286     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00287     Created:    19/04/95    
00288     Purpose:    A storage item for vectors from a CDR file import
00289 
00290 ********************************************************************************************/
00291 
00292 class CDRVectorStoredItem : public ListItem
00293 {
00294 friend class CDRFilter;
00295 friend class CDRVectorStore;
00296     CC_DECLARE_MEMDUMP(CDRVectorStoredItem);
00297 
00298 public:
00299     CDRVectorStoredItem();
00300     ~CDRVectorStoredItem();
00301     KernelBitmap *GetBitmap(Document *pDocument);
00302 
00303 private:
00304     Node *Objects;
00305     DWORD Reference;
00306     DocRect BBox;
00307     KernelBitmap *pBitmap;
00308 };
00309 
00310 
00311 /********************************************************************************************
00312 
00313 >   class CDRVectorStore : public List
00314 
00315     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00316     Created:    19/04/95    
00317     Purpose:    A storage object for vectors from a CDR file import
00318 
00319 ********************************************************************************************/
00320 
00321 class CDRVectorStore : public List
00322 {
00323 friend class CDRFilter;
00324     CC_DECLARE_MEMDUMP(CDRVectorStore);
00325 
00326 public:
00327     Node *Find(DWORD Reference, DocRect *BBox);
00328     CDRVectorStoredItem *Find(DWORD Reference);
00329 };
00330 
00331 
00332 /********************************************************************************************
00333 
00334 >   class CDRBitmapStore : public List
00335 
00336     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00337     Created:    10/04/95    
00338     Purpose:    A storage object for bitmaps from a CDR file import
00339 
00340 ********************************************************************************************/
00341 
00342 class CDRBitmapStore : public CDRAttributeStore
00343 {
00344     CC_DECLARE_MEMDUMP(CDRBitmapStore);
00345 
00346 public:
00347     BOOL AddChunkToStore(RIFFFile *RIFF, BOOL Pattern, CDRFilter *C);
00348 
00349     KernelBitmap *FindBitmap(DWORD Reference);
00350 private:
00351 };
00352 
00353 
00354 /********************************************************************************************
00355 
00356 >   class CDRBitmapStoredItem : public CDRAttributeStoredItem
00357 
00358     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00359     Created:    10/03/95    
00360     Purpose:    A list item object for bitmaps from a CDR file import
00361 
00362 ********************************************************************************************/
00363 
00364 class CDRBitmapStoredItem : public CDRAttributeStoredItem
00365 {
00366 friend class CDRAttributeStore;
00367 friend class CDRBitmapStore;
00368 
00369     CC_DECLARE_MEMDUMP(CDRBitmapStoredItem);
00370 
00371 public:
00372     CDRBitmapStoredItem();
00373     ~CDRBitmapStoredItem();
00374 
00375 private:
00376     KernelBitmap *pBitmap;
00377     FOURCC Reference;
00378     BOOL Used;
00379 };
00380 
00381 
00382 /********************************************************************************************
00383 
00384 >   class CDRLayerList : public List
00385 
00386     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00387     Created:    23 03 95    
00388     Purpose:    A list object to store layers in a page during the conversion process
00389 
00390 ********************************************************************************************/
00391 
00392 class CDRLayerList : public List
00393 {
00394     CC_DECLARE_MEMDUMP(CDRLayerList);
00395 
00396 public:
00397     CDRLayerList();
00398     ~CDRLayerList();
00399 
00400 private:
00401 };
00402 
00403 
00404 /********************************************************************************************
00405 
00406 >   class CDRLayerListItem : public ListItem
00407 
00408     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00409     Created:    23 03 95    
00410     Purpose:    A list object to store layers in a page during the conversion process
00411 
00412 ********************************************************************************************/
00413 
00414 class CDRLayerListItem : public ListItem
00415 {
00416 friend CDRLayerList;
00417 friend class CDRFilter;
00418 
00419     CC_DECLARE_MEMDUMP(CDRLayerListItem);
00420 
00421 public:
00422     CDRLayerListItem();
00423     ~CDRLayerListItem();
00424 
00425 private:
00426     String_256 Name;
00427     
00428     Node *Objects;          // node at the top of this layers tree, 0 if there aren't any
00429                             // objects on this layer
00430     BOOL LayerInDocument;   // used to mark whether a layer has been inserted into the
00431                             // document during the final insertation phase of the conversion
00432                             // process
00433 
00434     BOOL IsVisible;         // layer attribute thingys
00435     BOOL IsLocked;
00436 };
00437 
00438 
00439 /********************************************************************************************
00440 
00441 >   class CDRPageList : public List
00442 
00443     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00444     Created:    23 03 95    
00445     Purpose:    A list object to store all my pages in during the conversion process
00446 
00447 ********************************************************************************************/
00448 
00449 class CDRPageList : public List
00450 {
00451     CC_DECLARE_MEMDUMP(CDRPageList);
00452 
00453 public:
00454     CDRPageList();
00455     ~CDRPageList();
00456 
00457 private:
00458 };
00459 
00460 
00461 /********************************************************************************************
00462 
00463 >   class CDRPageListItem : public ListItem
00464 
00465     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00466     Created:    23 03 95    
00467     Purpose:    A list object to store all my pages in during the conversion process
00468 
00469 ********************************************************************************************/
00470 
00471 class CDRPageListItem : public ListItem
00472 {
00473 friend CDRPageList;
00474 
00475     CC_DECLARE_MEMDUMP(CDRPageListItem);
00476 
00477 public:
00478     CDRPageListItem();
00479     ~CDRPageListItem();
00480 
00481     CDRLayerList Layers;        // layers in this page, public for ease of access in CDRFilter
00482 
00483 private:
00484 };
00485 
00486 
00487 /********************************************************************************************
00488 
00489 >   class CDRActionList : public List
00490 
00491     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00492     Created:    23 03 95    
00493     Purpose:    A list object to store actions which need to be taken after lists in the 
00494                 CDR file have ended
00495 
00496 ********************************************************************************************/
00497 
00498 class CDRActionList : public List
00499 {
00500     CC_DECLARE_MEMDUMP(CDRActionList);
00501 
00502 public:
00503 
00504 private:
00505 };
00506 
00507 
00508 /********************************************************************************************
00509 
00510 >   class CDRActionListItem : public ListItem
00511 
00512     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00513     Created:    23 03 95    
00514     Purpose:    A listitem object to store actions which need to be taken after lists in the 
00515                 CDR file have ended
00516 
00517 ********************************************************************************************/
00518 
00519 class CDRActionListItem : public ListItem
00520 {
00521 friend CDRActionList;
00522 
00523     CC_DECLARE_DYNAMIC(CDRActionListItem);
00524 
00525 public:
00526     CDRActionListItem() {Level = 0;};
00527 
00528     UINT32 GetLevel() {return Level;}
00529     void SetLevel(UINT32 Lev) {Level = Lev;}
00530 
00531     // do the action
00532     virtual BOOL DoAction(CDRFilter *C) = 0;
00533     // called if the import fails at any stage - the action should ensure nothing's lost    
00534     virtual void ImportFailure(CDRFilter *C) = 0;
00535 
00536 private:
00537     UINT32 Level;           // Level at which this action takes place
00538 };
00539 
00540 
00541 /********************************************************************************************
00542 
00543 >   class CDRActionTransform : public CDRActionListItem
00544 
00545     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00546     Created:    23 03 95    
00547     Purpose:    A transform action
00548 
00549 ********************************************************************************************/
00550 
00551 class CDRActionTransform : public CDRActionListItem
00552 {
00553 friend CDRActionList;
00554 friend CDRFilter;
00555 
00556     CC_DECLARE_DYNAMIC(CDRActionTransform);
00557 
00558 public:
00559     CDRActionTransform() {Chunk = 0; LinkTrans = FALSE; IsAGroupTransform = FALSE;};
00560     ~CDRActionTransform();
00561 
00562     BOOL Init(RIFFFile *RIFF, CDRVersion Version);
00563     
00564     BOOL DoAction(CDRFilter *C);
00565     void ImportFailure(CDRFilter *C);
00566 
00567     void SetIsAGroupTransform(BOOL IsOne) {IsAGroupTransform = IsOne;};
00568 
00569 public:
00570     ADDR Chunk;
00571     INT32 ChunkSize;
00572     BOOL LinkTrans;
00573 private:
00574     BOOL IsAGroupTransform;
00575 };
00576 
00577 
00578 /********************************************************************************************
00579 
00580 >   class CDRActionGroupEnd : public CDRActionListItem
00581 
00582     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00583     Created:    26 03 95    
00584     Purpose:    A group end
00585 
00586 ********************************************************************************************/
00587 
00588 class CDRActionGroupEnd : public CDRActionListItem
00589 {
00590 friend CDRActionList;
00591 friend CDRFilter;
00592 
00593     CC_DECLARE_DYNAMIC(CDRActionGroupEnd);
00594 
00595 public:
00596     CDRActionGroupEnd() {pOldLevelNodeList = 0;};
00597 
00598     BOOL DoAction(CDRFilter *C);
00599     void ImportFailure(CDRFilter *C);
00600 
00601 private:
00602     NodeRenderable *pOldLevelNodeList;
00603 };
00604 
00605 /********************************************************************************************
00606 
00607 >   class CDRBBoxList : public List
00608 
00609     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00610     Created:    01/05/95
00611     Purpose:    A list of bounding boxes for the CDR filter
00612 
00613 ********************************************************************************************/
00614 
00615 class CDRBBoxList : public List
00616 {
00617 public:
00618     CDRBBoxList();
00619     ~CDRBBoxList();
00620 
00621     BOOL Add(Node *N, DocRect *BBox, Justification Just);
00622     BOOL Find(Node *N, DocRect *BBox);
00623     DocRect *Find(Node *N);
00624 };
00625 
00626 
00627 /********************************************************************************************
00628 
00629 >   class CDRBBoxListItem : public ListItem
00630 
00631     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00632     Created:    01/05/95
00633     Purpose:    A bounding box list item
00634 
00635 ********************************************************************************************/
00636 
00637 class CDRBBoxListItem : public ListItem
00638 {
00639 friend CDRBBoxList;
00640 
00641 public:
00642     CDRBBoxListItem();
00643     ~CDRBBoxListItem();
00644 
00645 private:
00646     Node *pNode;        // the node this bbox is associated with
00647     DocRect BBox;       // and it's bbox
00648 };
00649 
00650 
00651 /********************************************************************************************
00652 
00653 >   class CDRTextOnPathLink : public ListItem
00654 
00655     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00656     Created:    01/05/95
00657     Purpose:    A bounding box list item
00658 
00659 ********************************************************************************************/
00660 
00661 class CDRTextOnPathLink : public ListItem
00662 {
00663     CC_DECLARE_MEMDUMP(CDRTextOnPathLink);
00664 
00665 public:
00666     CDRTextOnPathLink();
00667     ~CDRTextOnPathLink();
00668 
00669 public:
00670     INT32 PathSerialNumber;     // -1 for no thingy
00671     NodePath *pPath;            // pointer to path or zero - the real thing, not a copy
00672     INT32 TextSerialNumber;     // -1 for no thingy
00673     TextStory *pTextStory;      // pointer to text story
00674     Justification Justi;
00675     /*BaseShiftEnum*/ INT32 Position;
00676 };
00677 
00678 /********************************************************************************************
00679 
00680 misc structures
00681 
00682 ********************************************************************************************/
00683 
00684 typedef struct {
00685     INT32 Angle;
00686     INT32 Pad;
00687     INT32 HorizontalCentreOffset;
00688     INT32 VerticalCentreOffset;
00689 } CDRFillInfo;
00690 
00691 typedef struct
00692 {
00693     INT32 SizeX;
00694     INT32 SizeY;
00695     INT32 OffsetX;
00696     INT32 OffsetY;
00697     DWORD Reference;
00698 } CDRTiledFillInfo;
00699 
00700 #define CDRSCRIPT_NONE  0
00701 #define CDRSCRIPT_SUB   1
00702 #define CDRSCRIPT_SUPER 2
00703 
00704 typedef struct
00705 {
00706 //  TCHAR *FontName;
00707     DWORD FontReference;
00708     MILLIPOINT FontSize;
00709     BOOL Bold;
00710     BOOL Italic;
00711     BOOL Underline;
00712     UINT32 Script;
00713     MILLIPOINT LineSpace;
00714     INT32 ParaLineSpacePercent;     // line spacing percentage set in text style block
00715     Justification Just;
00716 } CDRTextStyle;
00717 
00718 typedef struct {
00719     DocRect OriginalBBox;
00720     DocCoord NewCorners[4];
00721 } cdrPerspective;
00722 
00723 typedef struct {
00724     FLOAT8 a, b, c, d, e, f;
00725 } cdrMatrix;
00726 // note that this is not the same element order as Camelot uses... the calculation is
00727 //    x, = ax + by + c
00728 //    y, = dx + ey + f
00729 
00730 typedef struct {
00731     FLOAT8  cf11;
00732     FLOAT8  cf21;
00733     FLOAT8  cf31;
00734     FLOAT8  cf41;
00735     FLOAT8  cf12;
00736     FLOAT8  cf22;
00737     FLOAT8  cf32;
00738     FLOAT8  cf42;
00739     FLOAT8  cf13;
00740     FLOAT8  cf23;
00741     FLOAT8  cf33;
00742     FLOAT8  cf43;
00743 } cdr3DMatrix;
00744 
00745 typedef struct {
00746     FLOAT8  x,y,z;
00747 } cdr3DCoord;
00748 
00749 typedef struct {
00750     cdr3DMatrix Trans;
00751     cdr3DCoord  Camera;
00752 } cdrExtrudeInfo;
00753 
00754 /********************************************************************************************
00755 
00756 >   class CDRFilter : public VectorFilter
00757 
00758     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00759     Created:    21 03 95    
00760     Purpose:    Corel Draw file importing class 
00761 
00762 ********************************************************************************************/
00763 
00764 class CDRFilter : public VectorFilter
00765 {
00766 friend CDRActionTransform;
00767 friend CDRActionGroupEnd;
00768 friend CDRBitmapStore;
00769 friend CDRBitmap;
00770 
00771     CC_DECLARE_DYNAMIC(CDRFilter);
00772 
00773 public:
00774     CDRFilter();
00775     BOOL Init();
00776     
00777     INT32 HowCompatible(PathName& Filename, 
00778                     ADDR  HeaderStart, 
00779                     UINT32 HeaderSize,
00780                     UINT32 FileSize);
00781 
00782     BOOL DoImport(SelOperation*, CCLexFile*, Document*, 
00783                 BOOL AutoChosen = FALSE, ImportPosition *Pos = NULL,
00784                 KernelBitmap** ppImportedBitmap = NULL,
00785                 DocCoord* pPosTranslate = NULL, String_256* = NULL);
00786 
00787     BOOL DoExport(Operation*, CCLexFile*, PathName*, Document*, BOOL);
00788 
00789 public:
00790     static INT32 BitmapNumber;      // the number of the next bitmap to import (used for names)
00791     static INT32 PatternNumber;     // number of next pattern
00792     static void DeleteNodeList(Node *);
00793     static BOOL GetCorelBBox(NodeRenderableBounded *pNode, DocRect *BBox);
00794     static ADDR FindDataInObject(cdrfOffsetHeader *Header, WORD Type);
00795     static BOOL AddElementsToPath(Path *pPath, INT32 NCoords, cdrfCoord *Coords, BYTE *Types, BOOL *IsClosed);
00796 
00797 private:
00798     class Document *pDocument;      // document
00799     class Spread *pSpread;          // spread to import to
00800     class Page *pPage;              // page to import to
00801 
00802     CDRVersion Version;             // version of the file we're importing
00803     BOOL Success;                   // whether the import suceeded
00804 
00805     RIFFFile *RIFF;                 // pointer to RIFF file object
00806     UndoableOperation *ThisOp;      // the operation we're doing
00807 
00808     BOOL SlowJobStarted;            // have started the indication thing
00809     UINT32 ProgressCount;               // count of number of times ProgressUpdate called
00810 
00811     BOOL InMasterPage;
00812     BOOL DoneMasterPage;            // master page handling things
00813 
00814     BOOL DoneDoc;                   // done doc list?
00815 
00816     BOOL UseLayers;                 // importing on layers?
00817 
00818     CDRAttributeStore Fills;        // store for fills
00819     CDRAttributeStore Outlines;     // outlines
00820     CDRAttributeStore Styles;       // styles
00821     CDRFontnameStore Fonts;         // fonts
00822     CDRArrowheadStore Arrowheads;   // arrowheads (has a special derviced store which
00823                                     // converts arrowheads into nodes)
00824     CDRBitmapStore Patterns;        // patterns (1bpp things with colours applied to them)
00825     CDRBitmapStore Bitmaps;         // bitmaps for the file
00826     CDRVectorStore Vectors;         // vectors for the file (things like full col pattern/texture fills)
00827 
00828     CDRVectorStore TextV4;          // text objects from version 4 files
00829 
00830     CDRPageList Pages;              // list to store all my nice pages in during conversion
00831     CDRPageListItem *ThisPage;      // pointer to the list entry we're working on
00832     CDRLayerListItem *ThisLayer;    // pointer to the layer we're working on
00833 
00834     CDRActionList Actions;          // list of actions to perform when list ends are detected
00835 
00836     CDRBBoxList TextBBoxes;         // list of bounding boxes of text nodes
00837 
00838     INT32 PageX;                        // page size (same for all pages in file)
00839     INT32 PageY;
00840     BOOL Landscape;                 // whether the page is landscape or not
00841 
00842     DocCoord Origin;                // the origin of the page
00843 
00844     INT32 TranslateByX;             // distance to translate the coords by in the x direction
00845     INT32 TranslateByY;             // y
00846 
00847     INT32 ObjectsConverted;         // number of objects converted OK
00848     INT32 ObjectsFormatWrong;       // number of objects found with a wrong format
00849     INT32 ObjectsUnknown;           // number of unknown objects
00850     INT32 EnvelopesApproximated;        // number of envelopes which have been approximated
00851 
00852     BOOL FormatError;               // whether the current object had a format error
00853 
00854     NodeRenderable *pLevelNodeList; // a linked list of nodes which have been created on this level
00855     NodeRenderable *pMadeNode;      // the node which has just been made but not linked in to the tree
00856 
00857     INT32 SerialNumber;             // serial number of object currently being converted
00858 
00859     BOOL ObjFilled;                 // last object converted should be filled
00860     BOOL ObjStroked;                // last object should be stroked
00861 
00862     BOOL IsText;                    // current object is a spot of text
00863     BOOL IsTextStory;               // the current object is a text story - apply bodges and remove
00864                                     // functionality
00865     BOOL AttrsAlreadyApplied;       // used when arrowheads are applied to an object
00866 
00867     ADDR ObjDataBlock;              // block to put the object data in
00868     INT32 ObjDataBlockSize;         // size of the block
00869 
00870     ColourList *ColList;            // documents colour list for adding local colours
00871 
00872     ADDR TransformChunk;            // a pointer to the transform chunk
00873     INT32 TransformChunkSize;       // and the size of it
00874 
00875     ADDR FontTableV3;               // pointer to font table for version 3 files
00876     INT32 FontTableEntriesV3;           // number of entries
00877     ADDR FontStylesV3;              // pointer to font styles block for version 3 files
00878 
00879     ADDR LinkTable;                 // pointer to the link table
00880 
00881     BOOL LinkTransformsExist;       // whether there are some link transforms in the action list (not necessarily correct but updated in ProcessObject)
00882 
00883     List TextOnPathLinks;           // list of links from text to paths
00884     BOOL IsTextOnAPath;             // flag for whether to search the link table for this one...
00885 
00886 private:
00887     BOOL ClearUp(void);
00888     BOOL UpdateProgress(BOOL Now = FALSE);
00889 
00890     // process large elements from CDR files
00891     BOOL ProcessDoc(void);
00892     BOOL ProcessPage(void);
00893     BOOL ProcessLayer(void);
00894     BOOL ProcessObjectTree(UINT32 Level);
00895     BOOL ProcessObject(void);
00896     BOOL ProcessGroup(UINT32 Level, BOOL FromLink = FALSE);
00897     BOOL ProcessLink(void);
00898     BOOL ProcessVectorList(ADDR Block, INT32 Size);
00899     BOOL ProcessVectorListEntry();
00900     BOOL ProcessTextList4();
00901     BOOL ProcessTextListItem4();
00902 
00903     // convert objects
00904     BOOL ConvertRectangle(cdrfOffsetHeader *);
00905     BOOL ConvertEllipse(cdrfOffsetHeader *);
00906     BOOL ConvertPath(cdrfOffsetHeader *);
00907     BOOL ConvertText(cdrfOffsetHeader *);
00908     BOOL ConvertText4Art(cdrfOffsetHeader *);
00909     BOOL ConvertText4Para(cdrfOffsetHeader *);
00910     BOOL ConvertText3(cdrfOffsetHeader *);
00911     BOOL ConvertBitmap(cdrfOffsetHeader *);
00912 
00913     // attribute setting functions
00914     BOOL SetLineAttr(cdrfOffsetHeader *Object);
00915     BOOL SetFillAttr(cdrfOffsetHeader *Object);
00916     BOOL SetLineAttr3(cdrfOffsetHeader *Object);
00917     BOOL SetFillAttr3(cdrfOffsetHeader *Object);
00918     BOOL SetFillAttrFlat(cdrfFillHeader *Fill, INT32 Size);
00919     BOOL SetFillAttrGrad(cdrfFillHeader *Fill, INT32 Size);
00920     BOOL SetUKFill(void);           // sets up the fill defn I use when I don't know about a fill type
00921     BOOL SetLinearGrad(CDRFillInfo *GFill, DocRect &BBox, DocColour *StartColour, DocColour *EndColour);
00922     BOOL SetRadialGrad(CDRFillInfo *GFill, DocRect &BBox, DocColour *StartColour, DocColour *EndColour);
00923     BOOL SetConicalGrad(CDRFillInfo *GFill, DocRect &BBox, DocColour *StartColour, DocColour *EndColour);
00924     BOOL SetFillAttrPattern(CDRTiledFillInfo *Info, DocColour *Colour1, DocColour *Colour2);
00925     BOOL SetFillAttrTexture(cdrfFillHeader *Fill, INT32 Size);
00926     BOOL SetFillAttrVector(CDRTiledFillInfo *Info);
00927     BOOL NoFill(void);
00928 
00929     // arrowhead functions
00930     BOOL AddAttributesToArrowheadNode(NodeRenderableBounded *N, DocColour *Col, INT32 LineWidth,
00931             LineCapType Cap, JointType Join);
00932     BOOL AddAttributesToArrowheadPath(NodePath *P, DocColour *Col, INT32 LineWidth,
00933             LineCapType Cap, JointType Join);
00934     BOOL DoesPathNeedArrowheads(NodePath *P);
00935     BOOL TransformArrowhead(NodeRenderableBounded *N, DocCoord *Point, DocCoord *Other, BOOL Start,
00936             INT32 LineWidth, INT32 Distance);
00937     BOOL AddArrowheadsToPath(DWORD StartArrow, DWORD EndArrow, DocColour *Col, INT32 LineWidth,
00938             LineCapType Cap, JointType Join);
00939         
00940     // misc functions
00941     BOOL ConvertColour(cdrfColour *Col, DocColour *Out);
00942     BOOL IsTransformJustMatrices(ADDR Trans, INT32 Size);
00943     BOOL TransformConvertedObject(NodeRenderable **N, ADDR Trans, INT32 Size, BOOL TranslateForPage = TRUE, BOOL IsAGroupTransform = FALSE, BOOL WorkAtOrigin = FALSE);
00944     BOOL TransformConvertedObjectDoMatrix(NodeRenderable **N, cdrMatrix *Ma, BOOL TranslateForPage);
00945     BOOL TransformConvertedObjectDoPerspective(NodeRenderable **N, cdrPerspective *P, BOOL TranslateShapeForPage = FALSE);
00946     BOOL TransformConvertedObjectDoEnvelope(NodeRenderable **N, Path *P, DocRect *OriginalBBox, INT32 *Corners, BOOL TranslateShapeForPage = FALSE);
00947     BOOL TransformConvertedObjectDoExtrude(NodeRenderable **N, cdrExtrudeInfo *Info, BOOL TranslateShapeForPage = FALSE);
00948     BOOL TransformConvertedObjectDoExtrudeTransPath(NodePath *pPath, cdrExtrudeInfo *Info);
00949     BOOL GetMatrixFromTransform(Matrix *M, ADDR Trans, INT32 Size, BOOL TranslateForPage = TRUE);
00950     BOOL GetObjCorelBBox(NodeRenderableBounded *pNode, DocRect *BBox);
00951     KernelBitmap *BitmapFromNodeList(Node *List);
00952     BOOL MakeTextOnPathLinkList();
00953     BOOL AttachTextToPaths();
00954     BOOL CheckTextForLinks(TextStory *pTextStory, cdrfOffsetHeader *Header);
00955 
00956     // text style functions
00957     BOOL GetTextStyleFromCDRStyle(CDRTextStyle *TS, WORD StyleRef, BOOL SearchForParent = TRUE);
00958     BOOL GetTextStyleFromDefn(CDRTextStyle *TS, cdrfTextInfoFontDefn *FontDefn, const CDRTextStyle *BasedOn);
00959     BOOL ApplyTextAttr(Node *ContextNode, const CDRTextStyle *TS, const CDRTextStyle *BasedOn);
00960     BOOL ApplyTextAttrDoApply(Node *ContextNode, TxtBaseClassAttribute *Attr, BOOL CheckExisting);
00961     TCHAR *GetFontName(WORD FontRef);
00962     BOOL GetTextStyle3(CDRTextStyle *TS, WORD Style, CDRTextStyle *BasedOn = 0);
00963     BOOL GetTextStyleFromChar4(CDRTextStyle *TS, cdrfTextCharStyledV4 *Char, CDRTextStyle *BasedOn);
00964 
00965 public:
00966     // this function is used by the CMX filter to add the same standard set of colours to CMX documents
00967     static BOOL AddStandardColourSet(Document *pDocument);
00968 
00969     // and this function is used to see if a file has a CMX file inside it
00970     static BOOL HasCDRFileGotCMXFile(PathName *FileName, CCLexFile *pFile = NULL);
00971 };
00972                 
00973 /********************************************************************************************
00974 
00975 >   class CDRTransformConvertor : public CCObject
00976 
00977     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>      
00978     Created:    26 03 95    
00979     Purpose:    Corel trfd transform block convertor - hides differences in format between
00980                 versions.
00981 
00982 ********************************************************************************************/
00983 
00984 typedef enum {
00985     CDRTRANSFORMTYPE_UNKNOWN,
00986     CDRTRANSFORMTYPE_MATRIX,
00987     CDRTRANSFORMTYPE_PERSPECTIVE,
00988     CDRTRANSFORMTYPE_ENVELOPE,
00989     CDRTRANSFORMTYPE_EXTRUDE
00990 } CDRTransformType;
00991 
00992 class CDRTransformConvertor : public CC_CLASS_MEMDUMP
00993 {
00994     CC_DECLARE_MEMDUMP(CDRTransformConvertor);
00995 
00996 public:
00997     virtual BOOL Init(ADDR Data, INT32 Size) = 0;
00998     virtual UINT32 GetNTransforms() = 0;                        // returns the number of transforms
00999     virtual CDRTransformType GetTransformType(UINT32 n) = 0;    // gets the type of transform
01000     virtual BOOL GetMatrix(cdrMatrix *M, UINT32 n) = 0;     // gets a matrix
01001     virtual BOOL GetPerspective(cdrPerspective *P, UINT32 n) = 0;       // gets a perspective
01002     virtual BOOL GetEnvelope(Path **P, DocRect *OriginalBBox, INT32 *Corners, UINT32 n) = 0;
01003     virtual BOOL GetExtrude(cdrExtrudeInfo *Info, UINT32 n) = 0;
01004 protected:
01005     BOOL ConvertPerspective(cdrPerspective *P, cdrfPerspectiveTransform *Trans);
01006     BOOL ConvertEnvelopeBBox(ADDR Entry, DocRect *BBox, INT32 *Corners);
01007     BOOL ConvertEnvelopePath(ADDR List, INT32 ListSize, INT32 Entry, Path **ppPath);
01008     BOOL ConvertExtrudeInfo(cdrfTransformExtrude *pTransform, cdrExtrudeInfo *pInfo);
01009 };
01010 
01011 
01012 class CDRTransformConvertor5 : public CDRTransformConvertor
01013 {
01014     CC_DECLARE_MEMDUMP(CDRTransformConvertor5);
01015 
01016 public:
01017     BOOL Init(ADDR Data, INT32 Size);
01018     UINT32 GetNTransforms() {return CDRDATA_WORD(Trans->NTransforms);};
01019     CDRTransformType GetTransformType(UINT32 n);
01020     BOOL GetMatrix(cdrMatrix *M, UINT32 n);
01021     BOOL GetPerspective(cdrPerspective *P, UINT32 n);
01022     BOOL GetEnvelope(Path **P, DocRect *OriginalBBox, INT32 *Corners, UINT32 n);
01023     BOOL GetExtrude(cdrExtrudeInfo *Info, UINT32 n);
01024 private:
01025     cdrfTransform *Trans;
01026     ADDR List;
01027     INT32 ListSize;
01028 };
01029 
01030 class CDRTransformConvertor4 : public CDRTransformConvertor
01031 {
01032     CC_DECLARE_MEMDUMP(CDRTransformConvertor4);
01033 
01034 public:
01035     BOOL Init(ADDR Data, INT32 Size);
01036     UINT32 GetNTransforms() {return CDRDATA_WORD(Trans->NTransforms);};
01037     CDRTransformType GetTransformType(UINT32 n);
01038     BOOL GetMatrix(cdrMatrix *M, UINT32 n);
01039     BOOL GetPerspective(cdrPerspective *P, UINT32 n);
01040     BOOL GetEnvelope(Path **P, DocRect *OriginalBBox, INT32 *Corners, UINT32 n);
01041     BOOL GetExtrude(cdrExtrudeInfo *Info, UINT32 n);
01042 private:
01043     cdrfTransformV4 *Trans;
01044     ADDR List;
01045     INT32 ListSize;
01046 };
01047 
01048 class CDRTransformConvertor3 : public CDRTransformConvertor
01049 {
01050     CC_DECLARE_MEMDUMP(CDRTransformConvertor3);
01051 
01052 public:
01053     BOOL Init(ADDR Data, INT32 Size) {Trans = (cdrfTransformV3 *)Data; return TRUE;};
01054     UINT32 GetNTransforms() {return CDRDATA_WORD(Trans->NTransforms);};
01055     CDRTransformType GetTransformType(UINT32 n);
01056     BOOL GetMatrix(cdrMatrix *M, UINT32 n);
01057     BOOL GetPerspective(cdrPerspective *P, UINT32 n);
01058     BOOL GetEnvelope(Path **P, DocRect *OriginalBBox, INT32 *Corners, UINT32 n);
01059     BOOL GetExtrude(cdrExtrudeInfo *Info, UINT32 n);
01060 private:
01061     cdrfTransformV3 *Trans;
01062 };
01063 
01064 #endif  // INC_CDRFILTR
01065 

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