00001 // $Id: rechcomp.cpp 1688 2006-08-10 12:05:20Z gerry $ 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 // Implementation of the colour record handler class of the v2 file format 00100 00101 #include "camtypes.h" 00102 00103 #include "rechcomp.h" // CompressionRecordHandler for handling compression for v2 native/web files 00104 00105 #if !defined(EXCLUDE_FROM_XARLIB) 00106 #include "colcomp.h" // Document colour component, handles import of colours 00107 //#include "camfiltr.h" // BaseCamelotFilter - version 2 native filter - in camtypes.h [AUTOMATICALLY REMOVED] 00108 #endif 00109 00110 #include "cxftags.h" // TAG_DEFINERGBCOLOUR TAG_DEFINECOMPLEXCOLOUR 00111 //#include "cxfrec.h" // TAG_STARTCOMPRESSION TAG_STOPCOMPRESSION - in camtypes.h [AUTOMATICALLY REMOVED] 00112 00113 DECLARE_SOURCE("$Revision: 1688 $"); 00114 00115 // Declare smart memory handling in Debug builds 00116 #define new CAM_DEBUG_NEW 00117 00118 // An implement to match the Declare in the .h file. 00119 CC_IMPLEMENT_DYNAMIC(CompressionRecordHandler,CamelotRecordHandler); 00120 00121 //#if NEW_NATIVE_FILTER // New native filters, only available to those who need them at present 00122 00123 /******************************************************************************************** 00124 00125 > virtual UINT32* CompressionRecordHandler::GetTagList() 00126 00127 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00128 Created: 6/6/96 00129 Inputs: - 00130 Returns: Ptr to a list of tag values, terminated by CXFRH_TAG_LIST_END 00131 Purpose: Provides the record handler system with a list of records handled by this 00132 handler 00133 SeeAlso: - 00134 00135 ********************************************************************************************/ 00136 00137 UINT32* CompressionRecordHandler::GetTagList() 00138 { 00139 static UINT32 TagList[] = {TAG_STARTCOMPRESSION, TAG_ENDCOMPRESSION, CXFRH_TAG_LIST_END}; 00140 00141 return (UINT32*)&TagList; 00142 } 00143 00144 /******************************************************************************************** 00145 00146 > virtual BOOL CompressionRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord) 00147 00148 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00149 Created: 6/6/96 00150 Inputs: pCXaraFileRecord = ptr to record to handle 00151 Returns: TRUE if handled successfuly 00152 FALSE otherwise 00153 Purpose: Handles the given record. 00154 SeeAlso: - 00155 00156 ********************************************************************************************/ 00157 00158 BOOL CompressionRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord) 00159 { 00160 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"CompressionRecordHandler::HandleRecord pCXaraFileRecord is NULL"); 00161 00162 // This should be unused and we should error if this is called 00163 ERROR2(FALSE,"CompressionRecordHandler::HandleRecord called! Use Streamed form instead"); 00164 00165 BOOL ok = TRUE; 00166 00167 switch (pCXaraFileRecord->GetTag()) 00168 { 00169 case TAG_STARTCOMPRESSION: 00170 // Ask the compression system to be turned on 00171 TRACEUSER( "Neville", _T("Turn compression on\n")); 00172 ok = SetCompression(TRUE); 00173 break; 00174 case TAG_ENDCOMPRESSION: 00175 // Ask the compression system to be turned off 00176 TRACEUSER( "Neville", _T("Turn compression on\n")); 00177 ok = SetCompression(FALSE); 00178 break; 00179 00180 default: 00181 ok = FALSE; 00182 ERROR3_PF(("CompressionRecordHandler::HandleRecord I don't handle records with the tag (%d)\n",pCXaraFileRecord->GetTag())); 00183 break; 00184 } 00185 00186 return ok; 00187 } 00188 00189 /******************************************************************************************** 00190 00191 > virtual BOOL CompressionRecordHandler::HandleStreamedRecord(CXaraFile * pCXFile, UINT32 Tag,UINT32 Size,UINT32 RecordNumber) 00192 00193 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00194 Created: 7/6/96 00195 Inputs: pCXFile = access to the CXaraFile class 00196 Tag = the tag value 00197 Size = size of record 00198 RecordNumber = the record number in the file 00199 Returns: TRUE if handled ok 00200 FALSE otherwise 00201 Purpose: This is the streamed record handler. It is used when 00202 Errors: - 00203 SeeAlso: - 00204 00205 ********************************************************************************************/ 00206 00207 BOOL CompressionRecordHandler::HandleStreamedRecord(CXaraFile * pCXFile, UINT32 Tag,UINT32 Size,UINT32 RecordNumber) 00208 { 00209 ERROR2IF(Tag <= 0,FALSE,"CompressionRecordHandler::HandleStreamedRecord Tag is negative!"); 00210 00211 BOOL ok = TRUE; 00212 00213 switch (Tag) 00214 { 00215 case TAG_STARTCOMPRESSION: 00216 // Ask the compression system to be turned on 00217 TRACEUSER( "Neville", _T("Turn compression on\n")); 00218 ok = SetCompression(TRUE); 00219 break; 00220 case TAG_ENDCOMPRESSION: 00221 // Ask the compression system to be turned off 00222 TRACEUSER( "Neville", _T("Turn compression off\n")); 00223 ok = SetCompression(FALSE); 00224 break; 00225 00226 default: 00227 ok = FALSE; 00228 ERROR3_PF(("CompressionRecordHandler::HandleStreamedRecord I don't handle records with the tag (%d)\n",Tag)); 00229 break; 00230 } 00231 00232 return ok; 00233 } 00234 00235 00236 /******************************************************************************************** 00237 00238 > virtual BOOL CompressionRecordHandler::IsStreamed(UINT32 Tag) 00239 00240 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00241 Created: 7/6/96 00242 Inputs: The tag of the record 00243 Returns: TRUE if this is a streamed record 00244 FALSE otherwise 00245 Purpose: Function to find out if the record is streamed or not. 00246 Errors: - 00247 SeeAlso: - 00248 00249 ********************************************************************************************/ 00250 00251 BOOL CompressionRecordHandler::IsStreamed(UINT32 Tag) 00252 { 00253 // We don't want these records read in or handled by any outsiders as the ZLib code 00254 // reads things like the CRC and uncompressed size itself when compression is stopped 00255 return TRUE; 00256 } 00257 00258 00259 /******************************************************************************************** 00260 00261 > virtual void CompressionRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord,StringBase* pStr) 00262 00263 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00264 Created: 12/6/96 00265 Inputs: pRecord = ptr to a record 00266 pStr = ptr to string to update 00267 Returns: - 00268 Purpose: This provides descriptions for the compression on and off records. 00269 Errors: - 00270 SeeAlso: - 00271 00272 ********************************************************************************************/ 00273 00274 #ifdef XAR_TREE_DIALOG 00275 void CompressionRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord,StringBase* pStr) 00276 { 00277 if (pStr == NULL || pRecord == NULL) 00278 return; 00279 00280 // Call base class first 00281 // This outputs the tag and size 00282 CamelotRecordHandler::GetRecordDescriptionText(pRecord,pStr); 00283 00284 UINT32 Tag = pRecord->GetTag(); 00285 TCHAR s[256]; 00286 switch (Tag) 00287 { 00288 case TAG_STARTCOMPRESSION: 00289 { 00290 // Show what a compression on record looks like 00291 // Read the version number 00292 UINT32 Version = 0L; 00293 pRecord->ReadUINT32(&Version); 00294 00295 UINT32 Type = 0L; 00296 UINT32 MajorVersion = Version / 100; 00297 UINT32 MinorVersion = Version - MajorVersion * 100; 00298 camSprintf(s,_T("Compression type\t= %d\r\n"),Type); 00299 (*pStr) += s; 00300 camSprintf(s,_T("Compression version\t= %d.%d\r\n"),MajorVersion,MinorVersion); 00301 (*pStr) += s; 00302 break; 00303 } 00304 case TAG_ENDCOMPRESSION: 00305 { 00306 // Show what a compression off record looks like 00307 // Read the number of bytes read 00308 UINT32 Checksum = 0L; 00309 pRecord->ReadUINT32(&Checksum); 00310 camSprintf(s,_T("Compression checksum\t= %d\r\n"),Checksum); 00311 (*pStr) += s; 00312 UINT32 BytesRead = 0L; 00313 pRecord->ReadUINT32(&BytesRead); 00314 camSprintf(s,_T("Compression bytes read\t= %d\r\n"),BytesRead); 00315 (*pStr) += s; 00316 break; 00317 } 00318 } 00319 00320 return; 00321 } 00322 #endif 00323 00324 //#endif // NEW_NATIVE_FILTER 00325