cmxifltr.h

Go to the documentation of this file.
00001 // $Id: cmxifltr.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 import filter
00099 
00100 #ifndef CMXIFLTR_H
00101 #define CMXIFLTR_H
00102 
00103 //#include "filters.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "cmxres.h"
00105 //#include "paths.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "ccfile.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 
00108 #include "cmxistut.h"
00109 
00110 class CMXImportFilterDataSet;
00111 class CMXImportColourList;
00112 class CMXImportRImage;
00113 class CMXImportBitmap;
00114 class Progress;
00115 class SelOperation;
00116 
00117 /********************************************************************************************
00118 
00119 >   class CMXImportFilter : public VectorFilter
00120 
00121     Author:     Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
00122     Created:    05/08/96
00123     Purpose:    Import filter for CMX format (both 16 and 32 bit)
00124 
00125 ********************************************************************************************/
00126 
00127 class CMXImportFilter : public VectorFilter
00128 {
00129     CC_DECLARE_DYNAMIC(CMXImportFilter);
00130     friend class CMXImportRImage;
00131     friend class CMXImportBitmap;
00132 
00133 public:
00134     CMXImportFilter();
00135     BOOL Init();
00136     
00137     INT32 HowCompatible(PathName& Filename, 
00138                     ADDR  HeaderStart, 
00139                     UINT32 HeaderSize,
00140                     UINT32 FileSize);
00141 
00142     BOOL DoImport(SelOperation*, CCLexFile*, Document*, 
00143                 BOOL AutoChosen = FALSE, ImportPosition *Pos = NULL,
00144                 KernelBitmap** ppImportedBitmap = NULL,
00145                 DocCoord* pPosTranslate = NULL, String_256* = NULL);
00146 
00147     BOOL DoExport(Operation*, CCLexFile*, PathName*, Document*, BOOL) {return FALSE;};
00148 
00149     virtual BOOL IsDefaultDocRequired(const TCHAR* pcszPathName) {return TRUE;};
00150 
00151     // Function used by the gallery thumb nail code to check the file is the native/web format
00152     // and then get to the preview bitmap record and leave the file pointer sitting at the bitmap image
00153     static BOOL SkipToPreviewBitmap(CCLexFile * pFile);
00154 
00155 protected:
00156     // data reading things
00157     BOOL ReadData(void *Out, char *Instructions);
00158     BOOL ReadPointList(Path **ppPath);
00159     CMXImportColourList *ReadColourList(void);
00160     BOOL LocateRootLevelRIFFSection(DWORD Section);
00161     void Seek(INT32 to) {pFile->seekIn(to + StartPosition);};
00162     INT32 Tell(void) {return pFile->tellIn() - StartPosition;};
00163     BOOL GotoSectionFromIndex(INT32 MasterIndexEntry, DWORD PredictedRIFFType, BOOL NonExistanceIsFormatError, BOOL *Found = NULL, INT32 *Size = NULL);
00164 
00165     // do stuff functions
00166     BOOL Stage1_ReadHeader(Spread *pSpread);
00167     BOOL Stage2_ReadMasterIndex(void);
00168     BOOL Stage3_ConvertDescriptionSections(void);
00169     BOOL Stage4_ConvertPage(void);
00170     BOOL Stage5_PlaceObjectsInTree(Spread *pSpread, SelOperation *pOp, ImportPosition *pPos);
00171     BOOL ProcessCommand(INT32 *ProgressThingy = NULL);
00172 
00173     // command handling functions -- call new ones Process_<name of instruction in CMX spec>
00174     BOOL Process_BeginPage(void);
00175     BOOL Process_EndPage(void);
00176     BOOL Process_BeginLayer(void);
00177     BOOL Process_EndLayer(void);
00178     BOOL Process_BeginGroup(void);
00179     BOOL Process_EndGroup(void);
00180     BOOL Process_EndSection(void);
00181     BOOL Process_PolyCurve(void);
00182     BOOL Process_PolyCurveContainer(cmxiPolyCurve &pc);
00183     BOOL Process_Rectangle ( void );                    // Graeme (1-2-00)
00184     BOOL Process_AddGlobalTransform(void);
00185     BOOL Process_SetGlobalTransform(void);
00186     BOOL Process_RestoreLastGlobalTransform(void);
00187     BOOL Process_DrawImage(void);
00188     BOOL Process_DrawImage_Cropped(cmxiDrawImage &db);
00189     BOOL Process_AddClippingRegion(void);
00190     BOOL Process_RemoveLastClippingRegion(void);
00191     BOOL Process_ClearClipping(void);
00192     BOOL Process_BeginTextStream(void);
00193     BOOL Process_TextFrame(void);
00194     BOOL Process_Characters(void);
00195     BOOL Process_CharInfo(void);
00196     BOOL Process_BeginParagraph(void);
00197     BOOL Process_EndParagraph(void);
00198     BOOL Process_EndTextStream(void);
00199 
00200 
00201     // object processing things
00202     BOOL TransformNode(Node *pNode);
00203     BOOL SetAttributesForNode(Node *pNode, void *pAttr, BOOL DeleteStuff = TRUE);
00204     BOOL ClipNode(Node **pNode);
00205     BOOL ApplyAttributesToNode(Node *pNode);
00206 
00207     // attribute stuff
00208     BOOL SetNoFill(Node *pNode);
00209     BOOL SetNoStroke(Node *pNode);
00210     BOOL SetAttributesFountain(Node *pNode, cmxiFillSpec *Fill);
00211     BOOL SetAttributesLinearGrad(Node *pNode, cmxiFillSpec *GFill, DocRect &BBox, DocColour *StartColour, DocColour *EndColour);
00212     BOOL SetAttributesConicalGrad(Node *pNode, cmxiFillSpec *GFill, DocRect &BBox, DocColour *StartColour, DocColour *EndColour);
00213     BOOL SetAttributesRadialGrad(Node *pNode, cmxiFillSpec *GFill, DocRect &BBox, DocColour *StartColour, DocColour *EndColour, BOOL IsSquare = FALSE);
00214     BOOL SetAttributesBitmapFill(Node *pNode, INT32 VectorReference, cmxiTiling *Tile);
00215     BOOL SetAttributesTwoColourBitmapFill(Node *pNode, cmxiFillSpec *Fill);
00216     BOOL GetCorelBBox(NodeRenderableBounded *pNode, DocRect *BBox);
00217     BOOL GetTilingPoints(DocRect *BBox, cmxiTiling *Tile, DocCoord *StartPoint, DocCoord *EndPoint, DocCoord *EndPoint2);
00218     void SetNonTextAttributeIgnore();
00219     void SetNonTextAttributeNotIgnore();
00220     void SetTextAttributeIgnore();
00221     void SetTextAttributeNotIgnore();
00222 
00223 
00224     // misc stuff
00225     void CleanUpAfterImport(void);
00226 
00227     // approximation things
00228     void AttributeApproximated(void);
00229     void ClippingApproximated(void);
00230     void ObjectApproximated(void);
00231 
00232     // referency type stuff
00233     BOOL ConvertColours(void);
00234     DocColour *GetColourFromReference(INT32 Ref);
00235     BOOL AddColoursToDocument(void);
00236     BOOL ConvertPens(void);
00237     BOOL ConvertOutlines(void);
00238     BOOL ConvertLineStyles(void);
00239     BOOL ConvertDotDashes(void);
00240     BOOL ConvertArrowShapes(void);
00241     BOOL ConvertArrowheads(void);
00242     BOOL ReadEmbeddedFileIndex(void);
00243     BOOL ReadProcedureIndex(void);
00244     BOOL ReadBitmapIndex(void);
00245     BOOL ConvertFonts(void);
00246     BOOL ReadFontIndex(void);
00247 
00248     // transform and clipping things
00249 public:
00250     Matrix *GetBaseMatrix(void);
00251     Matrix *GetCurrentMatrix(void);
00252     void SetMatrix(Matrix *pNewMatrix);
00253     void SetClippingPath(Path *pClipper = NULL);
00254 
00255 private:
00256     CCLexFile *pFile;
00257     BOOL Is32Bit;
00258     BOOL CorelDraw7;
00259     INT32 StartPosition;        // the offset of the start of the CMX file
00260 
00261     // all the data we're using
00262     CMXImportFilterDataSet *Data;
00263 
00264 #ifdef _DEBUG
00265 public:
00266     static void FormatErrorBreakingFunction(void);
00267 #endif // _DEBUG
00268 };
00269 
00270 // use to mark an error in the CMX file we're importing
00271 #ifdef _DEBUG
00272 #define CMXFORMATERROR(ret)     {Error::SetError(IDT_CMXFILTER_CMXERROR, 0); \
00273                                 CMXImportFilter::FormatErrorBreakingFunction(); return ret;}
00274 #else
00275 #define CMXFORMATERROR(ret)     {Error::SetError(IDT_CMXFILTER_CMXERROR, 0); return ret;}
00276 #endif
00277 
00278 
00279 
00280 #endif // CMXIFLTR_H

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