rechrect.cpp

Go to the documentation of this file.
00001 // $Id: rechrect.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 >   rechrect.cpp
00101 
00102     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00103     Created:    06/06/96
00104     Purpose:    Implementation of class to handle loading of rectangle records from the new
00105                 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 "rechrect.h"
00120 
00121 // to match the declare in the header file
00122 CC_IMPLEMENT_DYNAMIC(RectangleRecordHandler, RegularShapeRecordHandler);
00123 
00124 /********************************************************************************************
00125 
00126 >   UINT32* RectangleRecordHandler::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* RectangleRecordHandler::GetTagList()
00139 {
00140     static UINT32 TagList[] = {TAG_RECTANGLE_SIMPLE,
00141                                 TAG_RECTANGLE_SIMPLE_REFORMED,
00142                                 TAG_RECTANGLE_SIMPLE_STELLATED,
00143                                 TAG_RECTANGLE_SIMPLE_STELLATED_REFORMED,
00144                                 TAG_RECTANGLE_SIMPLE_ROUNDED,
00145                                 TAG_RECTANGLE_SIMPLE_ROUNDED_REFORMED,
00146                                 TAG_RECTANGLE_SIMPLE_ROUNDED_STELLATED,
00147                                 TAG_RECTANGLE_SIMPLE_ROUNDED_STELLATED_REFORMED,
00148                                 TAG_RECTANGLE_COMPLEX,
00149                                 TAG_RECTANGLE_COMPLEX_REFORMED,
00150                                 TAG_RECTANGLE_COMPLEX_STELLATED,
00151                                 TAG_RECTANGLE_COMPLEX_STELLATED_REFORMED,
00152                                 TAG_RECTANGLE_COMPLEX_ROUNDED,
00153                                 TAG_RECTANGLE_COMPLEX_ROUNDED_REFORMED,
00154                                 TAG_RECTANGLE_COMPLEX_ROUNDED_STELLATED,
00155                                 TAG_RECTANGLE_COMPLEX_ROUNDED_STELLATED_REFORMED,
00156                                 CXFRH_TAG_LIST_END};
00157     return &TagList[0];
00158 }
00159 
00160 /********************************************************************************************
00161 
00162 >   BOOL RectangleRecordHandler::HandleRecord(CXaraFileRecord * pCXaraFileRecord)
00163 
00164     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00165     Created:    06/06/96
00166     Inputs:     pCXaraFileRecord - CXaraFileRecord object to read
00167     Returns:    TRUE if successful, FALSE otherwise
00168     Purpose:    Handles ellipse type records for the new file format
00169 
00170 ********************************************************************************************/
00171 
00172 BOOL RectangleRecordHandler::HandleRecord(CXaraFileRecord *pCXaraFileRecord)
00173 {
00174     BOOL ok;
00175 
00176     switch (pCXaraFileRecord->GetTag())
00177     {
00178         case TAG_RECTANGLE_SIMPLE
00179                 : ok = ReadRectangleSimple(pCXaraFileRecord); break;
00180         case TAG_RECTANGLE_SIMPLE_REFORMED
00181                 : ok = ReadRectangleSimpleReformed(pCXaraFileRecord); break;
00182         case TAG_RECTANGLE_SIMPLE_STELLATED
00183                 : ok = ReadRectangleSimpleStellated(pCXaraFileRecord); break;
00184         case TAG_RECTANGLE_SIMPLE_STELLATED_REFORMED
00185                 : ok = ReadRectangleSimpleStellatedReformed(pCXaraFileRecord); break;
00186         case TAG_RECTANGLE_SIMPLE_ROUNDED
00187                 : ok = ReadRectangleSimpleRounded(pCXaraFileRecord); break;
00188         case TAG_RECTANGLE_SIMPLE_ROUNDED_REFORMED
00189                 : ok = ReadRectangleSimpleRoundedReformed(pCXaraFileRecord); break;
00190         case TAG_RECTANGLE_SIMPLE_ROUNDED_STELLATED
00191                 : ok = ReadRectangleSimpleRoundedStellated(pCXaraFileRecord); break;
00192         case TAG_RECTANGLE_SIMPLE_ROUNDED_STELLATED_REFORMED
00193                 : ok = ReadRectangleSimpleRoundedStellatedReformed(pCXaraFileRecord); break;
00194         case TAG_RECTANGLE_COMPLEX
00195                 : ok = ReadRectangleComplex(pCXaraFileRecord); break;
00196         case TAG_RECTANGLE_COMPLEX_REFORMED
00197                 : ok = ReadRectangleComplexReformed(pCXaraFileRecord); break;
00198         case TAG_RECTANGLE_COMPLEX_STELLATED
00199                 : ok = ReadRectangleComplexStellated(pCXaraFileRecord); break;
00200         case TAG_RECTANGLE_COMPLEX_STELLATED_REFORMED
00201                 : ok = ReadRectangleComplexStellatedReformed(pCXaraFileRecord); break;
00202         case TAG_RECTANGLE_COMPLEX_ROUNDED
00203                 : ok = ReadRectangleComplexRounded(pCXaraFileRecord); break;
00204         case TAG_RECTANGLE_COMPLEX_ROUNDED_REFORMED
00205                 : ok = ReadRectangleComplexRoundedReformed(pCXaraFileRecord); break;
00206         case TAG_RECTANGLE_COMPLEX_ROUNDED_STELLATED
00207                 : ok = ReadRectangleComplexRoundedStellated(pCXaraFileRecord); break;
00208         case TAG_RECTANGLE_COMPLEX_ROUNDED_STELLATED_REFORMED
00209                 : ok = ReadRectangleComplexRoundedStellatedReformed(pCXaraFileRecord); break;
00210         default
00211                 : ok = ReadShapeInvalid(pCXaraFileRecord); break;
00212     }
00213     
00214     return ok;
00215 }
00216 
00217 /********************************************************************************************
00218 
00219 >   const INT32 RectangleRecordHandler::NumberOfSides;
00220 
00221     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 
00222     Created:    11/06/96
00223     Purpose:    Holds the number of sides a rectangle has - errm, 4.
00224 
00225 ********************************************************************************************/
00226 
00227 const INT32 RectangleRecordHandler::NumberOfSides = 4;
00228 
00229 /********************************************************************************************
00230 
00231 >   BOOL RectangleRecordHandler::ReadRectangleSimple(CXaraFileRecord *pCXaraFileRecord)
00232     BOOL RectangleRecordHandler::ReadRectangleSimpleReformed(CXaraFileRecord *pCXaraFileRecord)
00233     BOOL RectangleRecordHandler::ReadRectangleSimpleStellated(CXaraFileRecord *pCXaraFileRecord)
00234     BOOL RectangleRecordHandler::ReadRectangleSimpleRounded(CXaraFileRecord *pCXaraFileRecord)
00235     BOOL RectangleRecordHandler::ReadRectangleSimpleRoundedStellated(CXaraFileRecord *pCXaraFileRecord)
00236     BOOL RectangleRecordHandler::ReadRectangleComplex(CXaraFileRecord *pCXaraFileRecord)
00237     BOOL RectangleRecordHandler::ReadRectangleComplexStellated(CXaraFileRecord *pCXaraFileRecord)
00238     BOOL RectangleRecordHandler::ReadRectangleComplexRounded(CXaraFileRecord *pCXaraFileRecord)
00239     BOOL RectangleRecordHandler::ReadRectangleComplexRoundedStellated(CXaraFileRecord *pCXaraFileRecord)
00240 
00241     Author:     Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
00242     Created:    06/06/96
00243     Inputs:     pCXaraFileRecord - pointer to the record to read
00244     Returns:    TRUE if successfull, false otherwise
00245     Purpose:    Reads in an rectangle record
00246 
00247 ********************************************************************************************/
00248 
00249 BOOL RectangleRecordHandler::ReadRectangleSimple(CXaraFileRecord *pCXaraFileRecord)
00250 {
00251     BOOL ok = TRUE;
00252 
00253     NodeRegularShape * pRectangle;
00254     DocCoord CentrePoint;
00255     INT32 Height;
00256     INT32 Width;
00257 
00258     pRectangle = new NodeRegularShape;
00259 
00260     if (ok) ok = SetupShape(pRectangle);
00261     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00262 
00263     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00264     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00265 
00266     if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00267     if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00268     if (ok) ok = SetHeightAndWidth(pRectangle, Height, Width);
00269 
00270     if (ok) ok = InvalidateCache(pRectangle);
00271     if (ok) ok = InsertNode(pRectangle);
00272 
00273     return ok;
00274 }
00275 
00276 BOOL RectangleRecordHandler::ReadRectangleSimpleReformed(CXaraFileRecord *pCXaraFileRecord)
00277 {
00278     BOOL ok = TRUE;
00279 
00280     NodeRegularShape *pRectangle;
00281     DocCoord CentrePoint;
00282     INT32 Width;
00283     INT32 Height;
00284 
00285     pRectangle = new NodeRegularShape;
00286 
00287     if (ok) ok = SetupShape(pRectangle);
00288     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00289 
00290     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00291     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00292 
00293     if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00294     if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00295     if (ok) ok = SetHeightAndWidth(pRectangle, Height, Width);
00296 
00297     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath1));
00298 
00299     if (ok) ok = InvalidateCache(pRectangle);
00300     if (ok) ok = InsertNode(pRectangle);
00301     
00302     return ok;
00303 }
00304 
00305 BOOL RectangleRecordHandler::ReadRectangleSimpleStellated(CXaraFileRecord *pCXaraFileRecord)
00306 {
00307     BOOL ok = TRUE;
00308 
00309     NodeRegularShape * pRectangle;
00310     DocCoord CentrePoint;
00311     INT32 Height;
00312     INT32 Width;
00313     double StellationRadius;
00314     double StellationOffset;
00315 
00316     pRectangle = new NodeRegularShape;
00317 
00318     if (ok) ok = SetupShape(pRectangle);
00319     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00320     if (ok) ok = SetIsStellated(pRectangle, TRUE);
00321 
00322     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00323     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00324 
00325     if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00326     if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00327     if (ok) ok = SetHeightAndWidth(pRectangle, Height, Width);
00328 
00329     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00330     if (ok) ok = SetStellationRadius(pRectangle, StellationRadius);
00331 
00332     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00333     if (ok) ok = SetStellationOffset(pRectangle, StellationOffset);
00334 
00335     if (ok) ok = InvalidateCache(pRectangle);
00336     if (ok) ok = InsertNode(pRectangle);
00337 
00338     return ok;
00339 }
00340 
00341 BOOL RectangleRecordHandler::ReadRectangleSimpleStellatedReformed(CXaraFileRecord *pCXaraFileRecord)
00342 {
00343     BOOL ok = TRUE;
00344 
00345     NodeRegularShape * pRectangle;
00346     DocCoord CentrePoint;
00347     INT32 Height;
00348     INT32 Width;
00349     double StellationRadius;
00350     double StellationOffset;
00351 
00352     pRectangle = new NodeRegularShape;
00353 
00354     if (ok) ok = SetupShape(pRectangle);
00355     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00356     if (ok) ok = SetIsStellated(pRectangle, TRUE);
00357 
00358     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00359     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00360 
00361     if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00362     if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00363     if (ok) ok = SetHeightAndWidth(pRectangle, Height, Width);
00364 
00365     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00366     if (ok) ok = SetStellationRadius(pRectangle, StellationRadius);
00367 
00368     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00369     if (ok) ok = SetStellationOffset(pRectangle, StellationOffset);
00370 
00371     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath1));
00372     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath2));
00373 
00374     if (ok) ok = InvalidateCache(pRectangle);
00375     if (ok) ok = InsertNode(pRectangle);
00376 
00377     return ok;
00378 }
00379 
00380 BOOL RectangleRecordHandler::ReadRectangleSimpleRounded(CXaraFileRecord *pCXaraFileRecord)
00381 {
00382     BOOL ok = TRUE;
00383 
00384     NodeRegularShape * pRectangle;
00385     DocCoord CentrePoint;
00386     INT32 Height;
00387     INT32 Width;
00388     double Curvature;
00389     
00390     pRectangle = new NodeRegularShape;
00391 
00392 
00393     if (ok) ok = SetupShape(pRectangle);
00394     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00395     if (ok) ok = SetIsRounded(pRectangle, TRUE);
00396 
00397     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00398     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00399 
00400     if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00401     if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00402     if (ok) ok = SetHeightAndWidth(pRectangle, Height, Width);
00403 
00404     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Curvature);
00405     if (ok) ok = SetCurvature(pRectangle, Curvature);
00406 
00407     if (ok) ok = InvalidateCache(pRectangle);
00408     if (ok) ok = InsertNode(pRectangle);
00409 
00410     return ok;
00411 }
00412 
00413 BOOL RectangleRecordHandler::ReadRectangleSimpleRoundedReformed(CXaraFileRecord *pCXaraFileRecord)
00414 {
00415     BOOL ok = TRUE;
00416 
00417     NodeRegularShape * pRectangle;
00418     DocCoord CentrePoint;
00419     INT32 Height;
00420     INT32 Width;
00421     double Curvature;
00422     
00423     pRectangle = new NodeRegularShape;
00424 
00425 
00426     if (ok) ok = SetupShape(pRectangle);
00427     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00428     if (ok) ok = SetIsRounded(pRectangle, TRUE);
00429 
00430     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00431     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00432 
00433     if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00434     if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00435     if (ok) ok = SetHeightAndWidth(pRectangle, Height, Width);
00436 
00437     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Curvature);
00438     if (ok) ok = SetCurvature(pRectangle, Curvature);
00439 
00440     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath1));
00441 
00442     if (ok) ok = InvalidateCache(pRectangle);
00443     if (ok) ok = InsertNode(pRectangle);
00444 
00445     return ok;
00446 }
00447 
00448 BOOL RectangleRecordHandler::ReadRectangleSimpleRoundedStellated(CXaraFileRecord *pCXaraFileRecord)
00449 {
00450     BOOL ok = TRUE;
00451 
00452     NodeRegularShape * pRectangle;
00453     DocCoord CentrePoint;
00454     INT32 Height;
00455     INT32 Width;
00456     double StellationRadius;
00457     double StellationOffset;
00458     double PrimaryCurvature;
00459     double SecondaryCurvature;
00460     
00461     pRectangle = new NodeRegularShape;
00462 
00463     if (ok) ok = SetupShape(pRectangle);
00464     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00465     if (ok) ok = SetIsRounded(pRectangle, TRUE);
00466     if (ok) ok = SetIsStellated(pRectangle, TRUE);
00467 
00468     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00469     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00470 
00471     if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00472     if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00473     if (ok) ok = SetHeightAndWidth(pRectangle, Height, Width);
00474 
00475     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00476     if (ok) ok = SetStellationRadius(pRectangle, StellationRadius);
00477 
00478     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00479     if (ok) ok = SetStellationOffset(pRectangle, StellationOffset);
00480 
00481     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&PrimaryCurvature);
00482     if (ok) ok = SetPrimaryCurvature(pRectangle, PrimaryCurvature);
00483 
00484     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&SecondaryCurvature);
00485     if (ok) ok = SetSecondaryCurvature(pRectangle, SecondaryCurvature);
00486 
00487     if (ok) ok = InvalidateCache(pRectangle);
00488     if (ok) ok = InsertNode(pRectangle);
00489 
00490     return ok;
00491 }
00492 
00493 BOOL RectangleRecordHandler::ReadRectangleSimpleRoundedStellatedReformed(CXaraFileRecord *pCXaraFileRecord)
00494 {
00495     BOOL ok = TRUE;
00496 
00497     NodeRegularShape * pRectangle;
00498     DocCoord CentrePoint;
00499     INT32 Height;
00500     INT32 Width;
00501     double StellationRadius;
00502     double StellationOffset;
00503     double PrimaryCurvature;
00504     double SecondaryCurvature;
00505     
00506     pRectangle = new NodeRegularShape;
00507 
00508     if (ok) ok = SetupShape(pRectangle);
00509     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00510     if (ok) ok = SetIsRounded(pRectangle, TRUE);
00511     if (ok) ok = SetIsStellated(pRectangle, TRUE);
00512 
00513     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00514     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00515 
00516     if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00517     if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00518     if (ok) ok = SetHeightAndWidth(pRectangle, Height, Width);
00519 
00520     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00521     if (ok) ok = SetStellationRadius(pRectangle, StellationRadius);
00522 
00523     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00524     if (ok) ok = SetStellationOffset(pRectangle, StellationOffset);
00525 
00526     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&PrimaryCurvature);
00527     if (ok) ok = SetPrimaryCurvature(pRectangle, PrimaryCurvature);
00528 
00529     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&SecondaryCurvature);
00530     if (ok) ok = SetSecondaryCurvature(pRectangle, SecondaryCurvature);
00531 
00532     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath1));
00533     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath2));
00534     
00535     if (ok) ok = InvalidateCache(pRectangle);
00536     if (ok) ok = InsertNode(pRectangle);
00537 
00538     return ok;
00539 }
00540 
00541 BOOL RectangleRecordHandler::ReadRectangleComplex(CXaraFileRecord *pCXaraFileRecord)
00542 {
00543     BOOL ok = TRUE;
00544 
00545     NodeRegularShape * pRectangle;
00546     DocCoord CentrePoint;
00547     DocCoord MajorAxis;
00548     DocCoord MinorAxis;
00549     
00550     pRectangle = new NodeRegularShape;
00551 
00552     if (ok) ok = SetupShape(pRectangle);
00553     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00554 
00555     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00556     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00557 
00558     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00559     if (ok) ok = SetMajorAxis(pRectangle, MajorAxis);
00560 
00561     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00562     if (ok) ok = SetMinorAxis(pRectangle, MinorAxis);
00563 
00564     if (ok) ok = InvalidateCache(pRectangle);
00565     if (ok) ok = InsertNode(pRectangle);
00566 
00567     return ok;
00568 }
00569 
00570 BOOL RectangleRecordHandler::ReadRectangleComplexReformed(CXaraFileRecord *pCXaraFileRecord)
00571 {
00572     BOOL ok = TRUE;
00573 
00574     NodeRegularShape * pRectangle;
00575     DocCoord MajorAxis;
00576     DocCoord MinorAxis;
00577     Matrix TransformMatrix;
00578     
00579     pRectangle = new NodeRegularShape;
00580 
00581     if (ok) ok = SetupShape(pRectangle);
00582     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00583 
00584     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00585     if (ok) ok = SetMajorAxis(pRectangle, MajorAxis);
00586 
00587     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00588     if (ok) ok = SetMinorAxis(pRectangle, MinorAxis);
00589 
00590     if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00591     if (ok) ok = SetTransformMatrix(pRectangle, TransformMatrix);
00592 
00593     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath1));
00594 
00595     if (ok) ok = InvalidateCache(pRectangle);
00596     if (ok) ok = InsertNode(pRectangle);
00597 
00598     return ok;
00599 }
00600 
00601 BOOL RectangleRecordHandler::ReadRectangleComplexStellated(CXaraFileRecord *pCXaraFileRecord)
00602 {
00603     BOOL ok = TRUE;
00604 
00605     NodeRegularShape * pRectangle;
00606     DocCoord CentrePoint;
00607     DocCoord MajorAxis;
00608     DocCoord MinorAxis;
00609     double StellationRadius;
00610     double StellationOffset;
00611 
00612     pRectangle = new NodeRegularShape;
00613 
00614     if (ok) ok = SetupShape(pRectangle);
00615     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00616     if (ok) ok = SetIsStellated(pRectangle, TRUE);
00617 
00618     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00619     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00620 
00621     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00622     if (ok) ok = SetMajorAxis(pRectangle, MajorAxis);
00623 
00624     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00625     if (ok) ok = SetMinorAxis(pRectangle, MinorAxis);
00626 
00627     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00628     if (ok) ok = SetStellationRadius(pRectangle, StellationRadius);
00629 
00630     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00631     if (ok) ok = SetStellationOffset(pRectangle, StellationOffset);
00632 
00633     if (ok) ok = InvalidateCache(pRectangle);
00634     if (ok) ok = InsertNode(pRectangle);
00635 
00636     return ok;
00637 }
00638 
00639 BOOL RectangleRecordHandler::ReadRectangleComplexStellatedReformed(CXaraFileRecord *pCXaraFileRecord)
00640 {
00641     BOOL ok = TRUE;
00642 
00643     NodeRegularShape * pRectangle;
00644     DocCoord MajorAxis;
00645     DocCoord MinorAxis;
00646     Matrix TransformMatrix;
00647     double StellationRadius;
00648     double StellationOffset;
00649 
00650     pRectangle = new NodeRegularShape;
00651 
00652     if (ok) ok = SetupShape(pRectangle);
00653     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00654     if (ok) ok = SetIsStellated(pRectangle, TRUE);
00655 
00656     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00657     if (ok) ok = SetMajorAxis(pRectangle, MajorAxis);
00658 
00659     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00660     if (ok) ok = SetMinorAxis(pRectangle, MinorAxis);
00661 
00662     if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00663     if (ok) ok = SetTransformMatrix(pRectangle, TransformMatrix);
00664 
00665     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00666     if (ok) ok = SetStellationRadius(pRectangle, StellationRadius);
00667 
00668     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00669     if (ok) ok = SetStellationOffset(pRectangle, StellationOffset);
00670 
00671     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath1));
00672     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath2));
00673 
00674     if (ok) ok = InvalidateCache(pRectangle);
00675     if (ok) ok = InsertNode(pRectangle);
00676 
00677     return ok;
00678 }
00679 
00680 BOOL RectangleRecordHandler::ReadRectangleComplexRounded(CXaraFileRecord *pCXaraFileRecord)
00681 {
00682     BOOL ok = TRUE;
00683 
00684     NodeRegularShape * pRectangle;
00685     DocCoord CentrePoint;
00686     DocCoord MajorAxis;
00687     DocCoord MinorAxis;
00688     double Curvature;
00689     
00690     pRectangle = new NodeRegularShape;
00691 
00692     if (ok) ok = SetupShape(pRectangle);
00693     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00694     if (ok) ok = SetIsRounded(pRectangle, TRUE);
00695 
00696     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00697     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00698 
00699     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00700     if (ok) ok = SetMajorAxis(pRectangle, MajorAxis);
00701 
00702     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00703     if (ok) ok = SetMinorAxis(pRectangle, MinorAxis);
00704 
00705     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Curvature);
00706     if (ok) ok = SetCurvature(pRectangle, Curvature);
00707 
00708     if (ok) ok = InvalidateCache(pRectangle);
00709     if (ok) ok = InsertNode(pRectangle);
00710 
00711     return ok;
00712 }
00713 
00714 BOOL RectangleRecordHandler::ReadRectangleComplexRoundedReformed(CXaraFileRecord *pCXaraFileRecord)
00715 {
00716     BOOL ok = TRUE;
00717 
00718     NodeRegularShape * pRectangle;
00719     DocCoord MajorAxis;
00720     DocCoord MinorAxis;
00721     Matrix TransformMatrix;
00722     double Curvature;
00723     
00724     pRectangle = new NodeRegularShape;
00725 
00726     if (ok) ok = SetupShape(pRectangle);
00727     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00728     if (ok) ok = SetIsRounded(pRectangle, TRUE);
00729 
00730     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00731     if (ok) ok = SetMajorAxis(pRectangle, MajorAxis);
00732 
00733     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00734     if (ok) ok = SetMinorAxis(pRectangle, MinorAxis);
00735 
00736     if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00737     if (ok) ok = SetTransformMatrix(pRectangle, TransformMatrix);
00738 
00739     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Curvature);
00740     if (ok) ok = SetCurvature(pRectangle, Curvature);
00741 
00742     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath1));
00743 
00744     if (ok) ok = InvalidateCache(pRectangle);
00745     if (ok) ok = InsertNode(pRectangle);
00746 
00747     return ok;
00748 }
00749 
00750 BOOL RectangleRecordHandler::ReadRectangleComplexRoundedStellated(CXaraFileRecord *pCXaraFileRecord)
00751 {
00752     BOOL ok = TRUE;
00753 
00754     NodeRegularShape * pRectangle;
00755     DocCoord CentrePoint;
00756     DocCoord MajorAxis;
00757     DocCoord MinorAxis;
00758     double StellationRadius;
00759     double StellationOffset;
00760     double PrimaryCurvature;
00761     double SecondaryCurvature;
00762     
00763     pRectangle = new NodeRegularShape;
00764 
00765     if (ok) ok = SetupShape(pRectangle);
00766     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00767     if (ok) ok = SetIsRounded(pRectangle, TRUE);
00768     if (ok) ok = SetIsStellated(pRectangle, TRUE);
00769 
00770     if (ok) ok = pCXaraFileRecord->ReadCoord(&CentrePoint);
00771     if (ok) ok = SetCentrePoint(pRectangle, CentrePoint);
00772 
00773     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00774     if (ok) ok = SetMajorAxis(pRectangle, MajorAxis);
00775 
00776     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00777     if (ok) ok = SetMinorAxis(pRectangle, MinorAxis);
00778 
00779     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00780     if (ok) ok = SetStellationRadius(pRectangle, StellationRadius);
00781 
00782     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00783     if (ok) ok = SetStellationOffset(pRectangle, StellationOffset);
00784 
00785     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&PrimaryCurvature);
00786     if (ok) ok = SetPrimaryCurvature(pRectangle, PrimaryCurvature);
00787 
00788     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&SecondaryCurvature);
00789     if (ok) ok = SetSecondaryCurvature(pRectangle, SecondaryCurvature);
00790 
00791     if (ok) ok = InvalidateCache(pRectangle);
00792     if (ok) ok = InsertNode(pRectangle);
00793 
00794     return ok;
00795 }
00796 
00797 BOOL RectangleRecordHandler::ReadRectangleComplexRoundedStellatedReformed(CXaraFileRecord *pCXaraFileRecord)
00798 {
00799     BOOL ok = TRUE;
00800 
00801     NodeRegularShape * pRectangle;
00802     DocCoord MajorAxis;
00803     DocCoord MinorAxis;
00804     Matrix TransformMatrix;
00805     double StellationRadius;
00806     double StellationOffset;
00807     double PrimaryCurvature;
00808     double SecondaryCurvature;
00809     
00810     pRectangle = new NodeRegularShape;
00811 
00812     if (ok) ok = SetupShape(pRectangle);
00813     if (ok) ok = SetNumberOfSides(pRectangle, NumberOfSides);
00814     if (ok) ok = SetIsRounded(pRectangle, TRUE);
00815     if (ok) ok = SetIsStellated(pRectangle, TRUE);
00816 
00817     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MajorAxis,0,0);
00818     if (ok) ok = SetMajorAxis(pRectangle, MajorAxis);
00819 
00820     if (ok) ok = pCXaraFileRecord->ReadCoordTrans(&MinorAxis,0,0);
00821     if (ok) ok = SetMinorAxis(pRectangle, MinorAxis);
00822 
00823     if (ok) ok = pCXaraFileRecord->ReadMatrix(&TransformMatrix);
00824     if (ok) ok = SetTransformMatrix(pRectangle, TransformMatrix);
00825 
00826     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationRadius);
00827     if (ok) ok = SetStellationRadius(pRectangle, StellationRadius);
00828 
00829     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&StellationOffset);
00830     if (ok) ok = SetStellationOffset(pRectangle, StellationOffset);
00831 
00832     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&PrimaryCurvature);
00833     if (ok) ok = SetPrimaryCurvature(pRectangle, PrimaryCurvature);
00834 
00835     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&SecondaryCurvature);
00836     if (ok) ok = SetSecondaryCurvature(pRectangle, SecondaryCurvature);
00837 
00838     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath1));
00839     if (ok) ok = pCXaraFileRecord->ReadPath(&(pRectangle->EdgePath2));
00840     
00841     if (ok) ok = InvalidateCache(pRectangle);
00842     if (ok) ok = InsertNode(pRectangle);
00843 
00844     return ok;
00845 }
00846 
00847 /********************************************************************************************
00848 
00849 >   void GetRecordDescriptionText(CXaraFileRecord* pCXaraFileRecord,StringBase* Str);
00850 
00851 
00852     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00853     Created:    20/08/96
00854     Inputs:     pCXaraFileRecord - CXaraFileRecord holding the record in question
00855                 Str - StringBase to add our information to
00856     Returns:    -
00857     Purpose:    Returns textual information on this record
00858 
00859 ********************************************************************************************/
00860 
00861 #ifdef XAR_TREE_DIALOG
00862 void RectangleRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord, StringBase *pStr)
00863 {
00864     if (pRecord != NULL && pStr != NULL)
00865     {
00866         // Call base class first
00867         // This outputs the tag and size
00868         CamelotRecordHandler::GetRecordDescriptionText(pRecord,pStr);
00869 
00870         switch (pRecord->GetTag())
00871         {
00872             case TAG_RECTANGLE_SIMPLE :
00873             case TAG_RECTANGLE_SIMPLE_REFORMED :
00874             case TAG_RECTANGLE_SIMPLE_STELLATED :
00875             case TAG_RECTANGLE_SIMPLE_STELLATED_REFORMED :
00876             case TAG_RECTANGLE_SIMPLE_ROUNDED :
00877             case TAG_RECTANGLE_SIMPLE_ROUNDED_REFORMED :
00878             case TAG_RECTANGLE_SIMPLE_ROUNDED_STELLATED :
00879             case TAG_RECTANGLE_SIMPLE_ROUNDED_STELLATED_REFORMED :
00880                 (*pStr) += _T("Rectangle simple\r\n\r\n");
00881                 DescribeRectangleSimple(pRecord, pStr);
00882                 break;
00883 
00884             case TAG_RECTANGLE_COMPLEX :
00885             case TAG_RECTANGLE_COMPLEX_STELLATED :
00886             case TAG_RECTANGLE_COMPLEX_ROUNDED :
00887             case TAG_RECTANGLE_COMPLEX_ROUNDED_STELLATED :
00888                 (*pStr) += _T("Rectangle complex\r\n\r\n");
00889                 DescribeRectangleComplex(pRecord, pStr);
00890                 break;
00891 
00892             case TAG_RECTANGLE_COMPLEX_REFORMED :
00893             case TAG_RECTANGLE_COMPLEX_STELLATED_REFORMED :
00894             case TAG_RECTANGLE_COMPLEX_ROUNDED_REFORMED :
00895             case TAG_RECTANGLE_COMPLEX_ROUNDED_STELLATED_REFORMED :
00896                 (*pStr) += _T("Rectangle complex reformed\r\n\r\n");
00897                 DescribeRectangleComplexReformed(pRecord, pStr);
00898                 break;
00899 
00900             default : DescribeInvalid(pRecord, pStr); break;
00901         }
00902     }
00903 }
00904 
00905 void RectangleRecordHandler::DescribeRectangleSimple(CXaraFileRecord *pRecord, StringBase *pStr)
00906 {
00907     if (pRecord == NULL || pStr == NULL)
00908         return;
00909 
00910     DocCoord CentrePoint;
00911     INT32 Height;
00912     INT32 Width;
00913 
00914     TCHAR s[256];
00915 
00916     BOOL ok = TRUE;
00917     if (ok) ok = pRecord->ReadCoord(&CentrePoint);
00918     if (ok) ok = pRecord->ReadINT32(&Width);
00919     if (ok) ok = pRecord->ReadINT32(&Height);
00920 
00921     camSprintf(s,_T("Centre point\t= %d, %d\r\n"),CentrePoint.x,CentrePoint.y);
00922     (*pStr) += s;
00923     camSprintf(s,_T("Width\t\t= %d\r\n"),Width);
00924     (*pStr) += s;
00925     camSprintf(s,_T("Height\t\t= %d\r\n"),Height);
00926     (*pStr) += s;
00927 }
00928 
00929 void RectangleRecordHandler::DescribeRectangleComplex(CXaraFileRecord *pRecord, StringBase *pStr)
00930 {
00931     if (pRecord == NULL || pStr == NULL)
00932         return;
00933 
00934     DocCoord CentrePoint;
00935     DocCoord MajorAxis;
00936     DocCoord MinorAxis;
00937     TCHAR s[256];
00938 
00939     BOOL ok = TRUE;
00940 
00941     if (ok) ok = pRecord->ReadCoord(&CentrePoint);
00942     if (ok) ok = pRecord->ReadCoordTrans(&MajorAxis,0,0);
00943     if (ok) ok = pRecord->ReadCoordTrans(&MinorAxis,0,0);
00944 
00945     camSprintf(s,_T("Centre point\t= %d, %d\r\n"),CentrePoint.x,CentrePoint.y);
00946     (*pStr) += s;
00947     camSprintf(s,_T("Major axis\t\t= %d, %d\r\n"),MajorAxis.x,MajorAxis.y);
00948     (*pStr) += s;
00949     camSprintf(s,_T("Minor axis\t\t= %d, %d\r\n"),MinorAxis.x,MinorAxis.y);
00950     (*pStr) += s;
00951 }
00952 
00953 void RectangleRecordHandler::DescribeRectangleComplexReformed(CXaraFileRecord *pRecord, StringBase *pStr)
00954 {
00955     if (pRecord == NULL || pStr == NULL)
00956         return;
00957 
00958     DocCoord MajorAxis;
00959     DocCoord MinorAxis;
00960     TCHAR s[256];
00961 
00962     BOOL ok = TRUE;
00963 
00964     if (ok) ok = pRecord->ReadCoordTrans(&MajorAxis,0,0);
00965     if (ok) ok = pRecord->ReadCoordTrans(&MinorAxis,0,0);
00966 
00967     camSprintf(s,_T("Major axis\t\t= %d, %d\r\n"),MajorAxis.x,MajorAxis.y);
00968     (*pStr) += s;
00969     camSprintf(s,_T("Minor axis\t\t= %d, %d\r\n"),MinorAxis.x,MinorAxis.y);
00970     (*pStr) += s;
00971 }
00972 
00973 void RectangleRecordHandler::DescribeInvalid(CXaraFileRecord *pRecord, StringBase *pStr)
00974 {
00975     if (pRecord == NULL || pStr == NULL)
00976         return;
00977 
00978     (*pStr) += _T("Invalid rectangle\r\n");
00979 }
00980 #endif
00981 
00982 

Generated on Sat Nov 10 03:46:42 2007 for Camelot by  doxygen 1.4.4