cxftfile.h

Go to the documentation of this file.
00001 // $Id: cxftfile.h 1679 2006-08-08 09:47:27Z gerry $
00002 // Header for the CXaraTemplateFile class
00003 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00004 ================================XARAHEADERSTART===========================
00005  
00006                Xara LX, a vector drawing and manipulation program.
00007                     Copyright (C) 1993-2006 Xara Group Ltd.
00008        Copyright on certain contributions may be held in joint with their
00009               respective authors. See AUTHORS file for details.
00010 
00011 LICENSE TO USE AND MODIFY SOFTWARE
00012 ----------------------------------
00013 
00014 This file is part of Xara LX.
00015 
00016 Xara LX is free software; you can redistribute it and/or modify it
00017 under the terms of the GNU General Public License version 2 as published
00018 by the Free Software Foundation.
00019 
00020 Xara LX and its component source files are distributed in the hope
00021 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00022 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00023 See the GNU General Public License for more details.
00024 
00025 You should have received a copy of the GNU General Public License along
00026 with Xara LX (see the file GPL in the root directory of the
00027 distribution); if not, write to the Free Software Foundation, Inc., 51
00028 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00029 
00030 
00031 ADDITIONAL RIGHTS
00032 -----------------
00033 
00034 Conditional upon your continuing compliance with the GNU General Public
00035 License described above, Xara Group Ltd grants to you certain additional
00036 rights. 
00037 
00038 The additional rights are to use, modify, and distribute the software
00039 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00040 library and any other such library that any version of Xara LX relased
00041 by Xara Group Ltd requires in order to compile and execute, including
00042 the static linking of that library to XaraLX. In the case of the
00043 "CDraw" library, you may satisfy obligation under the GNU General Public
00044 License to provide source code by providing a binary copy of the library
00045 concerned and a copy of the license accompanying it.
00046 
00047 Nothing in this section restricts any of the rights you have under
00048 the GNU General Public License.
00049 
00050 
00051 SCOPE OF LICENSE
00052 ----------------
00053 
00054 This license applies to this program (XaraLX) and its constituent source
00055 files only, and does not necessarily apply to other Xara products which may
00056 in part share the same code base, and are subject to their own licensing
00057 terms.
00058 
00059 This license does not apply to files in the wxXtra directory, which
00060 are built into a separate library, and are subject to the wxWindows
00061 license contained within that directory in the file "WXXTRA-LICENSE".
00062 
00063 This license does not apply to the binary libraries (if any) within
00064 the "libs" directory, which are subject to a separate license contained
00065 within that directory in the file "LIBS-LICENSE".
00066 
00067 
00068 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00069 ----------------------------------------------
00070 
00071 Subject to the terms of the GNU Public License (see above), you are
00072 free to do whatever you like with your modifications. However, you may
00073 (at your option) wish contribute them to Xara's source tree. You can
00074 find details of how to do this at:
00075   http://www.xaraxtreme.org/developers/
00076 
00077 Prior to contributing your modifications, you will need to complete our
00078 contributor agreement. This can be found at:
00079   http://www.xaraxtreme.org/developers/contribute/
00080 
00081 Please note that Xara will not accept modifications which modify any of
00082 the text between the start and end of this header (marked
00083 XARAHEADERSTART and XARAHEADEREND).
00084 
00085 
00086 MARKS
00087 -----
00088 
00089 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00090 designs are registered or unregistered trademarks, design-marks, and/or
00091 service marks of Xara Group Ltd. All rights in these marks are reserved.
00092 
00093 
00094       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00095                         http://www.xara.com/
00096 
00097 =================================XARAHEADEREND============================
00098  */
00099 
00100 #ifndef INC_CXFTFILE
00101 #define INC_CXFTFILE
00102 
00103 #include "cxfile.h"
00104 
00105 /********************************************************************************************
00106 
00107 >   class CXaraTemplateFile : public CXaraFile
00108 
00109     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00110     Created:    09/7/97
00111     Purpose:    CXaraFile derived class for handling Flare template files
00112                 This translates the records written by the standard native format export
00113                 into the text based format.
00114 
00115                 It achieves this by overriding certain functions to maintain a "type list"
00116                 of the contents of the record so it can translate it when the record is 
00117                 written to the file.
00118 
00119                 Streamed records also need to be translated and this is achieved by returning
00120                 a proxy CCFile derived class (CCBinHexFile) which translates all data written
00121                 from binary to the BinHex format (a stream of hexadecimal digits where
00122                 each pair of digits represents a byte e.g.
00123 
00124                 void Translate(const BYTE* pBuf, char* pStr);
00125                 {
00126                     for (i = 0; i < BUFSIZE; i++)
00127                     {
00128                         sprintf(pStr, "%02x", pBuf[i]);
00129                         pStr += 2;
00130                     }
00131                 }
00132 
00133                 (Not that it'll actually use that code, rampant as it is... 8-)
00134 
00135     SeeAlso:    CCBinHexFile
00136 
00137 ********************************************************************************************/
00138 
00139 
00140 class CXaraTemplateFile : public CXaraFile
00141 {
00142     // Give my name in memory dumps
00143     CC_DECLARE_DYNAMIC(CXaraTemplateFile);
00144 
00145 public:
00146     CXaraTemplateFile();
00147     virtual ~CXaraTemplateFile() { /* empty */ }
00148 
00149     virtual BOOL OpenToWrite(CCLexFile* pCCFile);
00150     virtual BOOL OpenToRead(CCLexFile* pThisCCFile);
00151     virtual BOOL Close(void);
00152 
00153     // This is overriden to return our special CCBinHexFile
00154     virtual CCLexFile* GetCCFile(void) const;
00155 
00156     virtual INT32 StartRecord(UINT32 Tag, INT32 Size);
00157     virtual BOOL EndRecord(void);
00158     virtual INT32 StartStreamedRecord(UINT32 Tag, INT32 Size);
00159     virtual BOOL EndStreamedRecord(UINT32 *RecordSize);
00160     virtual UINT32 Write(CXaraFileRecord* pRecord); // Writes a complete record out to file
00161     virtual UINT32 WriteDefinitionRecord(CXaraFileRecord* pRecord); // Writes a complete record out to file
00162     virtual BOOL Write(BYTE b);
00163 
00164     virtual BOOL StartCompression() { return(TRUE); };
00165     virtual BOOL StopCompression() { return(TRUE); };
00166     virtual BOOL IsCompressionOn() { return(FALSE); };
00167 
00168 
00169 protected:
00170     // Should only be used by people who know what they are doing e.g. compression
00171     // Hence why it is protected
00172     UINT32 WriteRecordHeader(UINT32 Tag, INT32 Size);
00173     virtual BOOL FixStreamedRecordHeader(UINT32 *RecordSize);
00174 
00175 protected:  
00176     // Functions for translating binary into text
00177     BOOL WriteAsText(CXaraFileRecord* pRecord);
00178     BOOL WriteBinHex(BYTE* pBuf, UINT32 BufSize);
00179     BOOL WriteLabel(void);
00180     BOOL IsSimpleUnicode(UINT16* pStr);
00181     BOOL WriteSimpleUnicode(UINT16* pStr);
00182     BOOL WriteSimpleASCII(char* pStr);
00183     UINT32 WriteMultipleWCHARs(BYTE* pTypes, DWORD Count, UINT16* pChars);
00184     BOOL WriteSingleWCHAR(WCHAR ch);
00185 
00186     inline BOOL IsPrint(WCHAR wc)
00187     {
00188         return(((wc) > 31) && ((wc) < 127));
00189     };
00190 
00191 protected:
00192     PathName m_TempPath;
00193     CCDiskFile* m_pTempFile;
00194     CCLexFile* m_pBinHexFile;
00195     CCLexFile* m_pOrigCCFile;
00196 };
00197 
00198 #endif  // INC_CXFTFILE

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