00001 // $Id: exphint.cpp 1688 2006-08-10 12:05:20Z gerry $ 00002 // $$ 00003 // 00004 // Export hint class 00005 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00006 ================================XARAHEADERSTART=========================== 00007 00008 Xara LX, a vector drawing and manipulation program. 00009 Copyright (C) 1993-2006 Xara Group Ltd. 00010 Copyright on certain contributions may be held in joint with their 00011 respective authors. See AUTHORS file for details. 00012 00013 LICENSE TO USE AND MODIFY SOFTWARE 00014 ---------------------------------- 00015 00016 This file is part of Xara LX. 00017 00018 Xara LX is free software; you can redistribute it and/or modify it 00019 under the terms of the GNU General Public License version 2 as published 00020 by the Free Software Foundation. 00021 00022 Xara LX and its component source files are distributed in the hope 00023 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00024 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00025 See the GNU General Public License for more details. 00026 00027 You should have received a copy of the GNU General Public License along 00028 with Xara LX (see the file GPL in the root directory of the 00029 distribution); if not, write to the Free Software Foundation, Inc., 51 00030 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00031 00032 00033 ADDITIONAL RIGHTS 00034 ----------------- 00035 00036 Conditional upon your continuing compliance with the GNU General Public 00037 License described above, Xara Group Ltd grants to you certain additional 00038 rights. 00039 00040 The additional rights are to use, modify, and distribute the software 00041 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00042 library and any other such library that any version of Xara LX relased 00043 by Xara Group Ltd requires in order to compile and execute, including 00044 the static linking of that library to XaraLX. In the case of the 00045 "CDraw" library, you may satisfy obligation under the GNU General Public 00046 License to provide source code by providing a binary copy of the library 00047 concerned and a copy of the license accompanying it. 00048 00049 Nothing in this section restricts any of the rights you have under 00050 the GNU General Public License. 00051 00052 00053 SCOPE OF LICENSE 00054 ---------------- 00055 00056 This license applies to this program (XaraLX) and its constituent source 00057 files only, and does not necessarily apply to other Xara products which may 00058 in part share the same code base, and are subject to their own licensing 00059 terms. 00060 00061 This license does not apply to files in the wxXtra directory, which 00062 are built into a separate library, and are subject to the wxWindows 00063 license contained within that directory in the file "WXXTRA-LICENSE". 00064 00065 This license does not apply to the binary libraries (if any) within 00066 the "libs" directory, which are subject to a separate license contained 00067 within that directory in the file "LIBS-LICENSE". 00068 00069 00070 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00071 ---------------------------------------------- 00072 00073 Subject to the terms of the GNU Public License (see above), you are 00074 free to do whatever you like with your modifications. However, you may 00075 (at your option) wish contribute them to Xara's source tree. You can 00076 find details of how to do this at: 00077 http://www.xaraxtreme.org/developers/ 00078 00079 Prior to contributing your modifications, you will need to complete our 00080 contributor agreement. This can be found at: 00081 http://www.xaraxtreme.org/developers/contribute/ 00082 00083 Please note that Xara will not accept modifications which modify any of 00084 the text between the start and end of this header (marked 00085 XARAHEADERSTART and XARAHEADEREND). 00086 00087 00088 MARKS 00089 ----- 00090 00091 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00092 designs are registered or unregistered trademarks, design-marks, and/or 00093 service marks of Xara Group Ltd. All rights in these marks are reserved. 00094 00095 00096 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00097 http://www.xara.com/ 00098 00099 =================================XARAHEADEREND============================ 00100 */ 00101 00102 /* 00103 */ 00104 00105 #include "camtypes.h" 00106 #include "exphint.h" 00107 00108 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00109 #include "cxftags.h" 00110 //#include "filtrres.h" 00111 00112 // An implement to match the Declare in the .h file. 00113 CC_IMPLEMENT_MEMDUMP(ExportHint, CC_CLASS_MEMDUMP); 00114 CC_IMPLEMENT_DYNAMIC(ExportHintRecordHandler, CamelotRecordHandler); 00115 00116 // This will get Camelot to display the filename and linenumber of any memory allocations 00117 // that are not released at program exit 00118 // Declare smart memory handling in Debug builds 00119 #define new CAM_DEBUG_NEW 00120 00121 /******************************************************************************************** 00122 00123 > ExportHint::ExportHint() 00124 00125 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00126 Created: 21/07/97 00127 Purpose: Default constructor 00128 SeeAlso: - 00129 00130 ********************************************************************************************/ 00131 00132 ExportHint::ExportHint() 00133 { 00134 m_Type = HINTTYPE_BAD; 00135 m_Width = 0; 00136 m_Height = 0; 00137 m_BPP = 0; 00138 00139 // The contructor of the string should ensure this but... 00140 m_sOptions.Empty(); 00141 } 00142 00143 00144 /******************************************************************************************** 00145 00146 > ExportHint::ExportHint(const ExportHint& other) 00147 00148 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00149 Created: 21/07/97 00150 Purpose: Copy constructor 00151 SeeAlso: - 00152 00153 ********************************************************************************************/ 00154 00155 ExportHint::ExportHint(const ExportHint& other) 00156 { 00157 // Use the assignment operator 00158 *(this) = other; 00159 } 00160 00161 00162 /******************************************************************************************** 00163 00164 > const ExportHint& ExportHint::operator=(const ExportHint& other) 00165 00166 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00167 Created: 21/07/97 00168 Purpose: Assignment operator 00169 SeeAlso: - 00170 00171 ********************************************************************************************/ 00172 00173 const ExportHint& ExportHint::operator=(const ExportHint& other) 00174 { 00175 m_Type = other.m_Type; 00176 m_Width = other.m_Width; 00177 m_Height = other.m_Height; 00178 m_BPP = other.m_BPP; 00179 m_sOptions = other.m_sOptions; 00180 00181 return(*this); 00182 } 00183 00184 00185 00186 /******************************************************************************************** 00187 00188 > BOOL ExportHint::InitFromRecord(CXaraFileRecord* pRecord) 00189 00190 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00191 Created: 21/07/97 00192 Purpose: Initialises the hint from a Flare record 00193 SeeAlso: - 00194 00195 ********************************************************************************************/ 00196 00197 BOOL ExportHint::InitFromRecord(CXaraFileRecord* pRecord) 00198 { 00199 String_256 sOptions; 00200 00201 BOOL ok = pRecord->ReadUINT32(&m_Type); 00202 if (ok) ok = pRecord->ReadUINT32(&m_Width); 00203 if (ok) ok = pRecord->ReadUINT32(&m_Height); 00204 if (ok) ok = pRecord->ReadUINT32(&m_BPP); 00205 if (ok) ok = pRecord->ReadASCII(sOptions, 256); 00206 00207 m_sOptions = sOptions; 00208 00209 return(ok); 00210 } 00211 00212 00213 00214 /******************************************************************************************** 00215 00216 > BOOL ExportHint::WriteExportHintRecord(BaseCamelotFilter* pFilter) 00217 00218 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00219 Created: 21/07/97 00220 Purpose: Writes the hint to a Flare record 00221 SeeAlso: - 00222 00223 ********************************************************************************************/ 00224 00225 BOOL ExportHint::WriteExportHintRecord(BaseCamelotFilter* pFilter) 00226 { 00227 // If the hint hasn't been set then don't save it 00228 if (m_Type == HINTTYPE_BAD) 00229 return(TRUE); 00230 00231 // Add a description of the TAG_EXPORT_HINT record 00232 pFilter->AddTagDescription(TAG_EXPORT_HINT, _R(IDS_TAG_EXPORT_HINT)); 00233 00234 BOOL ok = TRUE; 00235 // Create a record (variable length) 00236 CXaraFileRecord Rec(TAG_EXPORT_HINT); 00237 ok = Rec.Init(); 00238 00239 if (ok) ok = Rec.WriteUINT32(m_Type); 00240 if (ok) ok = Rec.WriteUINT32(m_Width); 00241 if (ok) ok = Rec.WriteUINT32(m_Height); 00242 if (ok) ok = Rec.WriteUINT32(m_BPP); 00243 if (ok) ok = Rec.WriteASCII(m_sOptions); 00244 00245 INT32 RecNum = 0; 00246 if (ok) RecNum = pFilter->Write(&Rec); // Write the record 00247 if (RecNum == 0) 00248 ok = FALSE; 00249 00250 return(ok); 00251 } 00252 00253 00254 /******************************************************************************************** 00255 00256 > virtual UINT32* ExportHintRecordHandler::GetTagList() 00257 00258 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00259 Created: 21/07/97 00260 Returns: Ptr to a list of tag values, terminated by CXFRH_TAG_LIST_END 00261 Purpose: Provides the record handler system with a list of records handled by this 00262 handler 00263 00264 ********************************************************************************************/ 00265 00266 UINT32* ExportHintRecordHandler::GetTagList() 00267 { 00268 static const UINT32 TagList[] = {TAG_EXPORT_HINT, CXFRH_TAG_LIST_END}; 00269 00270 return (UINT32*)&TagList; 00271 } 00272 00273 00274 /******************************************************************************************** 00275 00276 > virtual BOOL ExportHintRecordHandler::HandleRecord(CXaraFileRecord* pRecord) 00277 00278 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00279 Created: 21/07/97 00280 Inputs: pCXaraFileRecord = ptr to record to handle 00281 Returns: TRUE if handled successfuly 00282 FALSE otherwise 00283 00284 ********************************************************************************************/ 00285 00286 BOOL ExportHintRecordHandler::HandleRecord(CXaraFileRecord* pRecord) 00287 { 00288 ERROR2IF(pRecord == NULL, FALSE, "pCXaraFileRecord is NULL"); 00289 ERROR2IF(pRecord->GetTag() != TAG_EXPORT_HINT, FALSE, "I don't handle this tag type"); 00290 00291 BaseCamelotFilter* const pFilter = GetBaseCamelotFilter(); 00292 ERROR2IF(pFilter == NULL, FALSE, "No filter in ExportHint::HandleRecord"); 00293 00294 Document* pDocument = pFilter->GetDocument(); 00295 ERROR2IF(pDocument == NULL, FALSE, "No Document in ExportHint::HandleRecord"); 00296 00297 ExportHint* pHint = pDocument->GetExportHint(); 00298 ERROR2IF(pHint == NULL, FALSE, "No ExportHint in ExportHint::HandleRecord"); 00299 00300 return(pHint->InitFromRecord(pRecord)); 00301 } 00302 00303 00304 #ifdef XAR_TREE_DIALOG 00305 /******************************************************************************************** 00306 00307 > virtual void ExportHintRecordHandler::GetRecordDescriptionText( 00308 CXaraFileRecord* pRecord, StringBase* pStr) 00309 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00310 Created: 21/07/97 00311 Inputs: pRecord - ptr to a record 00312 pStr - ptr to string to update 00313 Purpose: Provides descriptve text for debug dialog 00314 00315 ********************************************************************************************/ 00316 00317 void ExportHintRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord,StringBase* pStr) 00318 { 00319 if (pStr == NULL || pRecord == NULL) 00320 { 00321 TRACE( _T("ExportHintRecordHandler::GetRecordDescriptionText - NULL Args\n")); 00322 return; 00323 } 00324 if (pRecord->GetTag() != TAG_EXPORT_HINT) 00325 { 00326 TRACE( _T("ExportHintRecordHandler::GetRecordDescriptionText - Incorrect record\n")); 00327 return; 00328 } 00329 00330 // Call base class first 00331 CamelotRecordHandler::GetRecordDescriptionText(pRecord, pStr); 00332 00333 UINT32 Type; 00334 UINT32 Width; 00335 UINT32 Height; 00336 UINT32 BPP; 00337 String_256 sOptions; 00338 String_16 sNumber; 00339 00340 BOOL ok = pRecord->ReadUINT32(&Type); 00341 if (ok) ok = pRecord->ReadUINT32(&Width); 00342 if (ok) ok = pRecord->ReadUINT32(&Height); 00343 if (ok) ok = pRecord->ReadUINT32(&BPP); 00344 if (ok) ok = pRecord->ReadASCII(sOptions, 256); 00345 00346 if (ok) 00347 { 00348 *pStr += TEXT("Type = "); 00349 ok = Convert::LongToString(Type, &sNumber); 00350 if (ok) *pStr += sNumber; 00351 if (ok) *pStr += _T("\r\n"); 00352 } 00353 if (ok) 00354 { 00355 *pStr += TEXT("Width = "); 00356 ok = Convert::LongToString(Width, &sNumber); 00357 if (ok) *pStr += sNumber; 00358 if (ok) *pStr += _T("\r\n"); 00359 } 00360 if (ok) 00361 { 00362 *pStr += TEXT("Height = "); 00363 ok = Convert::LongToString(Height, &sNumber); 00364 if (ok) *pStr += sNumber; 00365 if (ok) *pStr += _T("\r\n"); 00366 } 00367 if (ok) 00368 { 00369 *pStr += TEXT("BPP = "); 00370 ok = Convert::LongToString(BPP, &sNumber); 00371 if (ok) *pStr += sNumber; 00372 if (ok) *pStr += _T("\r\n"); 00373 } 00374 if (ok) 00375 { 00376 *pStr += TEXT("Options = "); 00377 if (ok) *pStr += sOptions; 00378 if (ok) *pStr += _T("\r\n"); 00379 } 00380 } 00381 00382 00383 /******************************************************************************************** 00384 00385 > virtual void ExportHintRecordHandler::GetTagText(UINT32 Tag,String_256& Str) 00386 00387 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00388 Created: 21/07/97 00389 Inputs: Tag - the tag value 00390 Outputs: Str - place to put textual description of the tag 00391 Purpose: Returns the tag description in the string 00392 00393 ********************************************************************************************/ 00394 00395 void ExportHintRecordHandler::GetTagText(UINT32 Tag, String_256& Str) 00396 { 00397 Str = TEXT("TAG_EXPORT_HINT"); 00398 } 00399 #endif // _DEBUG