00001 // $Id: rechellp.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 00100 > rechellp.cpp 00101 00102 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00103 Created: 06/06/96 00104 Purpose: Functions for the class to handle importing ellipse records from 00105 the new file format 00106 00107 ********************************************************************************************/ 00108 00109 #include "camtypes.h" 00110 00111 #include "nodershp.h" 00112 00113 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00114 #include "cxftags.h" 00115 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00116 //#include "cxfrech.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00117 00118 #include "rechrshp.h" 00119 #include "rechellp.h" 00120 00121 // to match the declare in the header file 00122 CC_IMPLEMENT_DYNAMIC(EllipseRecordHandler, RegularShapeRecordHandler); 00123 00124 /******************************************************************************************** 00125 00126 > UINT32* EllipseRecordHandler::GetTagList() 00127 00128 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00129 Created: 06/06/96 00130 Inputs: - 00131 Returns: UINT32* to an array of records handled by this class. The last entry in the 00132 array is CXFRH_TAG_LIST_END 00133 Purpose: Returns an array of records handled by this class. 00134 See Also: EllispeRecordHandler::HandleRecord 00135 00136 ********************************************************************************************/ 00137 00138 UINT32* EllipseRecordHandler::GetTagList() 00139 { 00140 static UINT32 TagList[] = {TAG_ELLIPSE_SIMPLE, 00141 TAG_ELLIPSE_COMPLEX, 00142 CXFRH_TAG_LIST_END}; 00143 return &TagList[0]; 00144 } 00145 00146 /******************************************************************************************** 00147 00148 > BOOL EllispeRecordHandler::HandleRecord(CXaraFileRecord * pCXaraFileRecord) 00149 00150 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00151 Created: 06/06/96 00152 Inputs: pCXaraFileRecord - CXaraFileRecord object to read 00153 Returns: TRUE if successful, FALSE otherwise 00154 Purpose: Handles ellipse type records for the new file format 00155 00156 ********************************************************************************************/ 00157 00158 BOOL EllipseRecordHandler::HandleRecord(CXaraFileRecord *pCXaraFileRecord) 00159 { 00160 BOOL ok; 00161 00162 switch (pCXaraFileRecord->GetTag()) 00163 { 00164 case TAG_ELLIPSE_SIMPLE : ok = ReadEllipseSimple(pCXaraFileRecord); break; 00165 case TAG_ELLIPSE_COMPLEX : ok = ReadEllipseComplex(pCXaraFileRecord); break; 00166 default : ok = ReadShapeInvalid(pCXaraFileRecord); break; 00167 } 00168 00169 return ok; 00170 } 00171 00172 /******************************************************************************************** 00173 00174 > BOOL EllipseRecordHandler::ReadEllipseSimple(pCXaraFileRecord); break; 00175 BOOL EllipseRecordHandler::ReadEllipseComplex(pCXaraFileRecord); break; 00176 00177 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00178 Created: 06/06/96 00179 Inputs: pCXaraFileRecord - pointer to the record to read 00180 Returns: TRUE if successfull, false otherwise 00181 Purpose: Reads in an ellise record 00182 00183 ********************************************************************************************/ 00184 00185 BOOL EllipseRecordHandler::ReadEllipseSimple(CXaraFileRecord *pCXaraFileRecord) 00186 { 00187 BOOL ok = TRUE; 00188 00189 NodeRegularShape * pEllipse; 00190 DocCoord CentrePoint; 00191 INT32 Height; 00192 INT32 Width; 00193 00194 pEllipse = new NodeRegularShape; 00195 00196 if (ok) ok = SetupShape(pEllipse); 00197 if (ok) ok = SetIsCircular(pEllipse, TRUE); 00198 00199 if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint); 00200 if (ok) ok = SetCentrePoint(pEllipse, CentrePoint); 00201 00202 if (ok) ok = pCXaraFileRecord->ReadINT32(&Width); 00203 if (ok) ok = pCXaraFileRecord->ReadINT32(&Height); 00204 if (ok) ok = SetHeightAndWidth(pEllipse, Height, Width); 00205 00206 if (ok) ok = InvalidateCache(pEllipse); 00207 if (ok) ok = InsertNode(pEllipse); 00208 00209 return ok; 00210 } 00211 00212 BOOL EllipseRecordHandler::ReadEllipseComplex(CXaraFileRecord *pCXaraFileRecord) 00213 { 00214 BOOL ok = TRUE; 00215 00216 NodeRegularShape *pEllipse; 00217 DocCoord CentrePoint; 00218 DocCoord MajorAxis; 00219 DocCoord MinorAxis; 00220 00221 pEllipse = new NodeRegularShape; 00222 00223 if (ok) ok = SetupShape(pEllipse); 00224 if (ok) ok = SetIsCircular(pEllipse, TRUE); 00225 00226 if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint); 00227 if (ok) ok = SetCentrePoint(pEllipse, CentrePoint); 00228 00229 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0); 00230 if (ok) ok = SetMajorAxis(pEllipse, MajorAxis); 00231 00232 if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0); 00233 if (ok) ok = SetMinorAxis(pEllipse, MinorAxis); 00234 00235 if (ok) ok = InvalidateCache(pEllipse); 00236 if (ok) ok = InsertNode(pEllipse); 00237 00238 return ok; 00239 } 00240 00241 /******************************************************************************************** 00242 00243 > void GetRecordDescriptionText(CXaraFileRecord* pCXaraFileRecord,StringBase* Str); 00244 00245 00246 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00247 Created: 20/08/96 00248 Inputs: pCXaraFileRecord - CXaraFileRecord holding the record in question 00249 Str - StringBase to add our information to 00250 Returns: - 00251 Purpose: Returns textual information on this record 00252 00253 ********************************************************************************************/ 00254 00255 #ifdef XAR_TREE_DIALOG 00256 void EllipseRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord, StringBase *pStr) 00257 { 00258 if (pRecord != NULL && pStr != NULL) 00259 { 00260 // Call base class first 00261 // This outputs the tag and size 00262 CamelotRecordHandler::GetRecordDescriptionText(pRecord,pStr); 00263 00264 switch (pRecord->GetTag()) 00265 { 00266 case TAG_ELLIPSE_SIMPLE : DescribeEllipseSimple(pRecord, pStr); break; 00267 case TAG_ELLIPSE_COMPLEX : DescribeEllipseComplex(pRecord, pStr); break; 00268 default : DescribeInvalid(pRecord, pStr); break; 00269 } 00270 } 00271 } 00272 00273 void EllipseRecordHandler::DescribeEllipseSimple(CXaraFileRecord *pRecord, StringBase *pStr) 00274 { 00275 if (pRecord == NULL || pStr == NULL) 00276 return; 00277 00278 DocCoord CentrePoint; 00279 INT32 Height; 00280 INT32 Width; 00281 TCHAR s[256]; 00282 00283 BOOL ok = TRUE; 00284 if (ok) ok = pRecord->ReadCoord(&CentrePoint); 00285 if (ok) ok = pRecord->ReadINT32(&Width); 00286 if (ok) ok = pRecord->ReadINT32(&Height); 00287 00288 (*pStr) += _T("Simple ellipse\r\n\r\n"); 00289 00290 camSprintf(s,_T("Centre point\t= %d, %d\r\n"),CentrePoint.x,CentrePoint.y); 00291 (*pStr) += s; 00292 camSprintf(s,_T("Width\t\t= %d\r\n"),Width); 00293 (*pStr) += s; 00294 camSprintf(s,_T("Height\t\t= %d\r\n"),Height); 00295 (*pStr) += s; 00296 } 00297 00298 void EllipseRecordHandler::DescribeEllipseComplex(CXaraFileRecord *pRecord, StringBase *pStr) 00299 { 00300 if (pRecord == NULL || pStr == NULL) 00301 return; 00302 00303 DocCoord CentrePoint; 00304 DocCoord MajorAxis; 00305 DocCoord MinorAxis; 00306 TCHAR s[256]; 00307 00308 BOOL ok = TRUE; 00309 00310 if (ok) ok = pRecord->ReadCoord(&CentrePoint); 00311 if (ok) ok = pRecord->ReadCoordTrans(&MajorAxis,0,0); 00312 if (ok) ok = pRecord->ReadCoordTrans(&MinorAxis,0,0); 00313 00314 (*pStr) += _T("Complex ellipse\r\n\r\n"); 00315 camSprintf(s,_T("Centre point\t= %d, %d\r\n"),CentrePoint.x,CentrePoint.y); 00316 (*pStr) += s; 00317 camSprintf(s,_T("Major axis\t\t= %d, %d\r\n"),MajorAxis.x,MajorAxis.y); 00318 (*pStr) += s; 00319 camSprintf(s,_T("Minor axis\t\t= %d, %d\r\n"),MinorAxis.x,MinorAxis.y); 00320 (*pStr) += s; 00321 } 00322 00323 void EllipseRecordHandler::DescribeInvalid(CXaraFileRecord *pRecord, StringBase *pStr) 00324 { 00325 if (pRecord == NULL || pStr == NULL) 00326 return; 00327 00328 (*pStr) += _T("Invalid ellipse\r\n"); 00329 } 00330 #endif 00331