00001 // $Id: fttyplis.h 1282 2006-06-09 09:46:49Z alex $ 00002 // Header for the controlling class of the v2 file format 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 // This class has been implemented completely inline for speed reasons 00101 // It is called from every WriteXXXX function in the CXaraFileRecord class... 00102 00103 #ifndef INC_FTTYPLIS 00104 #define INC_FTTYPLIS 00105 00106 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 00108 typedef enum 00109 { 00110 FTT_BYTE = 1, 00111 FTT_UINT32, // 2 00112 FTT_INT32, // 3 00113 FTT_UINT16, // 4 00114 FTT_INT16, // 5 00115 FTT_FLOAT, // 6 00116 FTT_DOUBLE, // 7 00117 FTT_BINHEX, // 8 00118 FTT_WCHAR, // 9 00119 FTT_ASCII, // A 00120 FTT_UNICODE, // B 00121 FTT_COORD, // C 00122 FTT_INTCOORD, // D 00123 FTT_REFERENCE, // E 00124 FTT_MAXTYPE // F 00125 } FTType; 00126 00127 // Now a couple of macros to make life easier in the write functions 00128 00129 #define ENTERWRITEFUNCTION(type) \ 00130 BOOL bFTTLUnlock = FALSE; \ 00131 if (m_pTypeList) \ 00132 bFTTLUnlock = m_pTypeList->AddToListAndLock(type); 00133 00134 #define LEAVEWRITEFUNCTION \ 00135 if (bFTTLUnlock) \ 00136 m_pTypeList->Unlock(); 00137 00138 #define STORELENGTH(len) \ 00139 ((bFTTLUnlock) ? (m_pTypeList->StoreLength(len)) : (ok)) 00140 00141 /******************************************************************************************** 00142 00143 > class FTTypeList : public CCObject 00144 00145 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00146 Created: 10/07/97 00147 Purpose: Object used by CXaraFileRecord for recording type information while writing 00148 00149 ********************************************************************************************/ 00150 00151 class FTTypeList : public CCObject 00152 { 00153 // Give my name in memory dumps 00154 // The matching implement macro is in cxfrec.cpp 00155 CC_DECLARE_DYNAMIC(FTTypeList); 00156 00157 public: 00158 FTTypeList() 00159 { 00160 m_pArray = NULL; 00161 m_Used = 0; 00162 m_bLock = FALSE; 00163 m_Length = 0; 00164 }; 00165 00166 virtual ~FTTypeList() 00167 { 00168 if (m_pArray) 00169 CCFree(m_pArray); 00170 }; 00171 00172 DWORD GetCount(void) { return(m_Used); }; 00173 00174 BOOL StoreLength(DWORD len) 00175 { 00176 // Ensure 4 bytes of space (chances are this is the last thing to be written) 00177 if (!Enlarge(4)) 00178 return(FALSE); 00179 00180 DWORD* pLen = (DWORD*)(m_pArray + m_Used); 00181 *pLen = len; 00182 m_Used += 4; 00183 return(TRUE); 00184 }; 00185 00186 BOOL AddToListAndLock(FTType Type) 00187 { 00188 if (m_bLock) 00189 return(FALSE); 00190 00191 // Add the type to the list 00192 00193 if (m_Used == m_Length) 00194 { 00195 if (!Enlarge()) 00196 return(FALSE); 00197 } 00198 00199 // This must exist now 00200 m_pArray[m_Used] = Type; 00201 m_Used++; 00202 00203 m_bLock = TRUE; 00204 return(TRUE); 00205 }; 00206 00207 void Unlock(void) { m_bLock = FALSE; }; 00208 00209 BYTE* GetBuffer(void) { return(m_pArray); }; 00210 00211 protected: 00212 // Ensures at least Size entries available 00213 // FALSE if failed 00214 BOOL Enlarge(DWORD Size = 16) 00215 { 00216 if ((m_pArray == NULL) || 00217 ((m_Length - m_Used) < Size)) 00218 { 00219 DWORD NewLength = m_Length + Size; 00220 BYTE* pNew = (BYTE*)CCRealloc(m_pArray, NewLength); 00221 00222 if (pNew == NULL) 00223 return(FALSE); 00224 00225 m_pArray = pNew; 00226 m_Length = NewLength; 00227 } 00228 return(TRUE); 00229 }; 00230 00231 protected: 00232 DWORD m_Length; 00233 DWORD m_Used; 00234 BOOL m_bLock; 00235 BYTE* m_pArray; 00236 }; 00237 00238 #endif // INC_FTTYPLIS