drawfltr.h

Go to the documentation of this file.
00001 // $Id: drawfltr.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 
00099 // An input filter for importing RISC OS Draw format files.
00100 
00101 #ifndef INC_DRAWFLTR
00102 #define INC_DRAWFLTR
00103 
00104 //#include "ccfile.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "filters.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 
00107 class Node;
00108 
00109 /********************************************************************************************
00110 
00111 >   class DrawFileHeader
00112 
00113     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00114     Created:    18/11/93
00115     Purpose:    Holds the information contained in the header of an Acorn Draw file.
00116     SeeAlso:    DrawObjectHeader; AcornDrawFilter
00117 
00118 ********************************************************************************************/
00119 
00120 class DrawFileHeader
00121 {
00122 public:
00123     // Should be the string "Draw"
00124     char        Ident[4];
00125 
00126     // version number and name of program that created the Draw file
00127     UINT32      MajorVersion;
00128     UINT32      MinorVersion;
00129     char        Creator[12];
00130 
00131     // Bounding box of the whole draw file
00132     DocCoord    BBoxLo;
00133     DocCoord    BBoxHi;
00134 };
00135 
00136 /********************************************************************************************
00137 
00138     typedef DrawObjectType
00139 
00140     This is a simple type to decode the object types in an Acorn Draw file.
00141 
00142 ********************************************************************************************/
00143 
00144 typedef INT32 DrawObjectType;
00145 
00146 
00147 /********************************************************************************************
00148 
00149 >   class DrawObjectHeader
00150 
00151     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00152     Created:    18/11/93
00153     Purpose:    Contains the information contained in an object header of an Acorn Draw file.
00154     SeeAlso:    DrawFileHeader; AcornDrawFilter
00155 
00156 ********************************************************************************************/
00157 
00158 class DrawObjectHeader
00159 {
00160 public:
00161     // Type and size of object
00162     DrawObjectType  Type;
00163     UINT32          Size;
00164 
00165     // Bounding box of this object
00166     DocCoord        BBoxLo;
00167     DocCoord        BBoxHi;
00168 };
00169 
00170 
00171 
00172 // Various forward declarations for the AcornDrawFilter class
00173 class PathName;
00174 class Document;
00175 class NodePath;
00176 class Layer;
00177 class AttrLineWidth;
00178 class AttrStrokeColour;
00179 class AttrFillColour;
00180 class OpImportAcornDraw;
00181 class Page;
00182 class DrawPathHeader;
00183 
00184 /********************************************************************************************
00185 
00186 >   class AcornDrawFilter : public VectorFilter
00187 
00188     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00189     Created:    13/10/93
00190     Purpose:    Encapsulates an RISC OS Draw input filter system.
00191 
00192 ********************************************************************************************/
00193 
00194 class AcornDrawFilter : public VectorFilter
00195 {
00196     CC_DECLARE_DYNAMIC(AcornDrawFilter);
00197     
00198 public:
00199     AcornDrawFilter();
00200     ~AcornDrawFilter();
00201     BOOL Init();    
00202 
00203     // Works out if opening a file of this type requires a default document to be loaded
00204     // or does the file format supply the document.
00205     virtual BOOL IsDefaultDocRequired(const TCHAR* pcszPathName);
00206 
00207     INT32 HowCompatible(PathName& Filename, ADDR HeaderStart, UINT32 HeaderSize, UINT32 FileSize);
00208 
00209     BOOL DoImport(SelOperation *Op, CCLexFile*, Document *DestDoc, 
00210                   BOOL AutoChosen, ImportPosition *Pos = NULL,
00211                   KernelBitmap** ppImportedBitmap = NULL,
00212                   DocCoord* pPosTranslate = NULL, String_256* = NULL);
00213 
00214     BOOL DoExport(Operation*, CCLexFile*, PathName*, Document*, BOOL);
00215 
00216 private:
00217     BOOL PrepareToImport();
00218     void CleanUpAfterImport();
00219         
00220     // The file we are reading
00221     CCLexFile *DrawFile;
00222     
00223     // TRUE if the EOF has been reached
00224     BOOL eof;
00225     
00226     // The layer that objects are placed on
00227     Layer *pLayer;
00228     
00229     // The page that objects appear on
00230     Page *pPage;
00231     
00232     // The Node to which new objects are attached (may be a Layer or a Group node)
00233     Node *pNode;
00234     
00235     // TRUE if a complex path is being constructed
00236     BOOL ComplexPath;
00237     
00238     // TRUE if the path being constructed has not had any attributes added yet
00239     BOOL NoAttributes;
00240 
00241     // Co-ordinate transformations
00242     DocCoord Origin;
00243 
00244     // TransformCoord() - converts a DocCoord from Draw units (1/640 of a point) to
00245     // Camelot units (millipoints). (the factor 1000/640 is reduced to 25/16)
00246     void TransformCoord(DocCoord& C) 
00247         {   C.x *= 25; C.x /= 16; C.x += Origin.x;
00248             C.y *= 25; C.y /= 16; C.y += Origin.y; };
00249 
00250     // Buffers to hold data read from the Draw file.
00251     DrawFileHeader   FileHeader;
00252     DrawObjectHeader ObjectHeader;
00253     ADDR DataBuf; // Dynamically allocated when the file is read.
00254     UINT32 DataBufSize;
00255     UINT32 HeaderSize; // Not necessarily sizeof(DrawObjectHeader)! (Thanks, Acorn...)
00256     UINT32 DataSize;
00257 
00258     // Functions to read in and process the Draw objects
00259     BOOL ReadFileHeader();
00260     BOOL ReadObjectHeader();
00261     BOOL ReadObjectData();
00262     BOOL ProcessObject();
00263     BOOL ProcessPath();
00264     BOOL ProcessGroup();
00265     BOOL ProcessTaggedObject();
00266     BOOL SkipObject();
00267     BOOL AddAttributes(NodePath *pPath, DrawPathHeader *pHeader);
00268 
00269     // Used to update progress bar etc
00270     INT32 BytesRead;
00271     INT32 LastProgressUpdate;
00272 };
00273 
00274 
00275 #endif

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