ai_layer.cpp

Go to the documentation of this file.
00001 // $Id: ai_layer.cpp 1282 2006-06-09 09:46:49Z alex $
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 #include "camtypes.h"
00099 //#include "ccobject.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00100 #include "ai5_eps.h"
00101 #include "ai_layer.h"
00102 
00103 CC_IMPLEMENT_DYNAMIC ( AILayerProcessor, CCObject )
00104 
00105 /********************************************************************************************
00106 
00107 >   AILayerProcessor::AILayerProcessor ( void )
00108 
00109     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00110     Created:    16/4/00
00111     Purpose:    Default constructor.
00112     SeeAlso:    AILayerProcessor::~AILayerProcessor ()
00113 
00114 ********************************************************************************************/
00115 
00116 AILayerProcessor::AILayerProcessor ( void )
00117 {
00118     // Initialise all member variables to their default state.
00119     mLayerName.Empty ();            // Clear the layer name string.
00120     mIsLocked       = FALSE;        // Set the layer locked flag to FALSE.
00121     mIsPrintable    = FALSE;        // Set the layer printable flag to FALSE.
00122     mIsVisible      = FALSE;        // Set the layer visible flag to FALSE.
00123 }
00124 
00125 /********************************************************************************************
00126 
00127 >   AILayerProcessor::~AILayerProcessor ( void )
00128 
00129     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00130     Created:    16/4/00
00131     Purpose:    Default destructor.
00132     SeeAlso:    AILayerProcessor::AILayerProcessor ()
00133 
00134 ********************************************************************************************/
00135 
00136 AILayerProcessor::~AILayerProcessor ( void )
00137 {
00138     // Nothing needs to be done.
00139 }
00140 
00141 /********************************************************************************************
00142 
00143 >   BOOL AILayerProcessor::DecodeAI5Lb ( AI5EPSFilter   &Filter )
00144 
00145     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00146     Created:    16/4/00
00147     Inputs:     pFilter - A pointer to the AI5EPSFilter being used for the export.
00148     Returns:    TRUE    - Success.
00149                 FALSE   - An error has occurred.
00150     Purpose:    Extracts the layer information from the Lb record. The AI file format allows
00151                 for more fine-grained control over the layers than the Camelot version, and
00152                 so much of it is rejected.
00153     SeeAlso:    AILayerProcessor::DecodeLB (), AILayerProcessor::DecodeLn (),
00154                 AI5EPSFilter::ProcessToken()
00155 
00156 ********************************************************************************************/
00157 
00158 BOOL AILayerProcessor::DecodeAI5Lb ( AI5EPSFilter   &Filter )
00159 {
00160     INT32   IsVisible   = 0;
00161     INT32   IsLocked    = 0;
00162     INT32   IsPrintable = 0;
00163     
00164     // Pop the information off the stack.
00165     if ( !Filter.GetStack ().Discard ( 6 )          ||  // Discard the unused data on the stack.
00166          !Filter.GetStack ().Pop ( &IsPrintable )   ||  // Extract whether it's printable.
00167          !Filter.GetStack ().Pop ( &IsLocked )      ||  // Extract whether the layer is locked.
00168          !Filter.GetStack ().Discard ( 1 )          ||  // Discard the unused flag.
00169          !Filter.GetStack ().Pop ( &IsVisible ) )       // Extract the layer visibility data.
00170     {
00171         // There has been a problem extracting the data. Return a FALSE value to inform the
00172         // AIEPS filter.
00173         return FALSE;
00174     }
00175 
00176     // Set up the layer state flags from the information in the Lb operator. The default
00177     // state is false, so only one branch needs to be evaluated.
00178     if ( !IsLocked )
00179     {
00180         mIsLocked       = TRUE;                         // Set the layer locked flag to TRUE.
00181     }
00182 
00183     if ( IsPrintable )
00184     {
00185         mIsPrintable    = TRUE;                         // Set the printable flag to TRUE.
00186     }
00187     
00188     if ( IsVisible )
00189     {
00190         mIsVisible      = TRUE;                         // Set the visible flag to TRUE.
00191     }
00192 
00193     // Success.
00194     return TRUE;
00195 }
00196 
00197 /********************************************************************************************
00198 
00199 >   BOOL AILayerProcessor::DecodeAI8Lb ( AI5EPSFilter   &Filter )
00200 
00201     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00202     Created:    16/4/00
00203     Inputs:     pFilter - A pointer to the AI5EPSFilter being used for the export.
00204     Returns:    TRUE    - Success.
00205                 FALSE   - An error has occurred.
00206     Purpose:    The syntax of the Lb operator has changed in AI8, and this function is
00207                 intended to handle the newer version.
00208     SeeAlso:    AILayerProcessor::DecodeAI5Lb (), AILayerProcessor::DecodeLB ()
00209                 AILayerProcessor::DecodeLn (), AI8EPSFilter::ProcessToken ()
00210 
00211 ********************************************************************************************/
00212 
00213 BOOL AILayerProcessor::DecodeAI8Lb ( AI5EPSFilter   &Filter )
00214 {
00215     INT32   IsVisible   = 0;
00216     INT32   IsLocked    = 0;
00217     INT32   IsPrintable = 0;
00218     
00219     // Pop the information off the stack.
00220     if ( !Filter.GetStack ().Discard ( 9 )          ||  // Discard the unused data on the stack.
00221          !Filter.GetStack ().Pop ( &IsPrintable )   ||  // Extract whether it's printable.
00222          !Filter.GetStack ().Pop ( &IsLocked )      ||  // Extract whether the layer is locked.
00223          !Filter.GetStack ().Discard ( 1 )          ||  // Discard the unused flag.
00224          !Filter.GetStack ().Pop ( &IsVisible ) )       // Extract the layer visibility data.
00225     {
00226         // There has been a problem extracting the data. Return a FALSE value to inform the
00227         // AIEPS filter.
00228         return FALSE;
00229     }
00230 
00231     // Set up the layer state flags from the information in the Lb operator. The default
00232     // state is false, so only one branch needs to be evaluated.
00233     if ( !IsLocked )
00234     {
00235         mIsLocked       = TRUE;                         // Set the layer locked flag to TRUE.
00236     }
00237 
00238     if ( IsPrintable )
00239     {
00240         mIsPrintable    = TRUE;                         // Set the printable flag to TRUE.
00241     }
00242     
00243     if ( IsVisible )
00244     {
00245         mIsVisible      = TRUE;                         // Set the visible flag to TRUE.
00246     }
00247 
00248     // Success.
00249     return TRUE;
00250 }
00251 
00252 /********************************************************************************************
00253 
00254 >   BOOL AILayerProcessor::DecodeLB ( AI5EPSFilter  &Filter )
00255 
00256     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00257     Created:    16/4/00
00258     Inputs:     pFilter - A pointer to the AI5EPSFilter being used for the export.
00259     Returns:    TRUE    - Success.
00260                 FALSE   - An error has occurred.
00261     Purpose:    Processes the LB command, which is the end of layer indicator.
00262     SeeAlso:    AILayerProcessor::DecodeLb (), AI5EPSFilter::ProcessToken()
00263 
00264 ********************************************************************************************/
00265 
00266 BOOL AILayerProcessor::DecodeLB ( AI5EPSFilter  &Filter )
00267 {
00268     // Push the insert point in the tree up a level, so that any future layers are inserted
00269     // in the correct place. This is done automatically by the EPSFilter class, so this
00270     // method is redundant.
00271     return TRUE;
00272 }
00273 
00274 /********************************************************************************************
00275 
00276 >   BOOL AILayerProcessor::DecodeLn ( AI5EPSFilter  &Filter )
00277 
00278     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00279     Created:    16/4/00
00280     Inputs:     pFilter - A pointer to the AI5EPSFilter being used for the export.
00281     Returns:    TRUE    - Success.
00282                 FALSE   - An error has occurred.
00283     Purpose:    Processes the Ln command, which is used to set the layer's name.
00284     SeeAlso:    AILayerProcessor::DecodeLb (), AI5EPSFilter::ProcessToken()
00285 
00286 ********************************************************************************************/
00287 
00288 BOOL AILayerProcessor::DecodeLn ( AI5EPSFilter  &Filter )
00289 {
00290     // Pop the layer's name off the stack, and store it in the mLayerName member variable.
00291     if ( !Filter.GetStack ().Pop ( &mLayerName ) )
00292     {
00293         // There's been a problem, so inform the filter that invoked this command.
00294         return FALSE;
00295     }
00296 
00297     // Create a new layer using the stored information.
00298     return Filter.CreateLayer ( mLayerName, mIsLocked, mIsPrintable, mIsVisible );
00299 }

Generated on Sat Nov 10 03:44:09 2007 for Camelot by  doxygen 1.4.4