AI8EPSFilter Class Reference

Allows us to import Adobe Illustrator 8.0 files. (at the time of writing only the version 7.0 documentation was available so some omissions are inevitable). More...

#include <ai8_eps.h>

Inheritance diagram for AI8EPSFilter:

AI5EPSFilter AIEPSFilter EPSFilter VectorFilter Filter ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 AI8EPSFilter ()
 Default constructor, which sets the class details.
virtual ~AI8EPSFilter ()
 Default destructor. Cleans up all instantiated data for the class.
virtual BOOL Init ()
 Since the constructor can't fail, it does things that the constructor can't do.
virtual INT32 EPSHeaderIsOk (ADDR pFileHeader, UINT32 HeaderSize)
 Checks to see if the EPS comment headers specify that this is an AI generated EPS file, as required.
virtual void LookUpToken ()
 Compare the current token against the AI keywords to see if it is one of them.
virtual BOOL ProcessToken ()
 Checks if we're looking at the version 8.0 layer token otherwise delegates to the base class.

Protected Member Functions

virtual BOOL DecodeLayer (void)
 Inserts a layer into the tree.

Private Member Functions

 CC_DECLARE_DYNAMIC (AI8EPSFilter)

Detailed Description

Allows us to import Adobe Illustrator 8.0 files. (at the time of writing only the version 7.0 documentation was available so some omissions are inevitable).

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/00

Definition at line 120 of file ai8_eps.h.


Constructor & Destructor Documentation

AI8EPSFilter::AI8EPSFilter  ) 
 

Default constructor, which sets the class details.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/00

Definition at line 133 of file ai8_eps.cpp.

00134 {
00135     // Set up filter descriptions.
00136     FilterNameID = _R(IDT_AI8EPS_FILTERNAME);
00137     FilterInfoID = _R(IDT_AI8EPS_FILTERINFO);
00138     ImportMsgID  = _R(IDT_IMPORTMSG_AI8);
00139 
00140     FilterID = FILTERID_AI8EPS;
00141 
00142     // This filter only supports import
00143     Flags.CanImport = TRUE;
00144     Flags.CanExport = FALSE;
00145 }

AI8EPSFilter::~AI8EPSFilter  )  [virtual]
 

Default destructor. Cleans up all instantiated data for the class.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/00

Definition at line 158 of file ai8_eps.cpp.

00159 {
00160     // Currently, nothing needs to be done.
00161 }


Member Function Documentation

AI8EPSFilter::CC_DECLARE_DYNAMIC AI8EPSFilter   )  [private]
 

BOOL AI8EPSFilter::DecodeLayer void   )  [protected, virtual]
 

Inserts a layer into the tree.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/5/00
Parameters:
- [INPUTS]
Returns:
TRUE - The command was processed. FALSE - It wasn't used by this filter.

Reimplemented from AI5EPSFilter.

Definition at line 385 of file ai8_eps.cpp.

00386 {
00387     // If there's still an active layer, the LB token has been missed out, so throw an EPS
00388     // error message.
00389     if ( mpLayerProc != NULL )
00390     {
00391         return FALSE;
00392     }
00393 
00394     // Create the new layer processor.
00395     mpLayerProc = new AILayerProcessor;
00396 
00397     ERROR2IF( mpLayerProc == NULL, FALSE, "Insufficient memory to create layer processor.");
00398 
00399     // Insert the layer into the tree.
00400     return mpLayerProc->DecodeAI8Lb ( *this );
00401 }

INT32 AI8EPSFilter::EPSHeaderIsOk ADDR  pFileHeader,
UINT32  HeaderSize
[virtual]
 

Checks to see if the EPS comment headers specify that this is an AI generated EPS file, as required.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/00
Returns:
TRUE if the header is ok and import should proceed, FALSE if not.
The header for AI8.0 begins....

!PS-Adobe-3.0 %Creator: Adobe Illustrator(R) 8.0 %AI8_CreatorVersion: 8

Reimplemented from AI5EPSFilter.

Definition at line 220 of file ai8_eps.cpp.

00221 {
00222     UINT32  Lines   = 0;
00223     TCHAR   *Buffer = NULL;
00224 
00225     // !PS-Adobe line is ok - check creator line...
00226     CCMemTextFile HeaderFile ( reinterpret_cast<char *> ( pFileHeader ), HeaderSize );
00227 
00228     if( HeaderFile.IsMemFileInited () == FALSE || HeaderFile.InitLexer () == FALSE )
00229     {
00230         HeaderFile.close();
00231         return 0;
00232     }
00233 
00234     // Graeme (28/6/00) - Adobe have changed their file format, and so the first line can
00235     // now be a %PDF directive. Therefore look for this directive in the first twenty
00236     // lines.
00237     while ( ( Lines < 100 ) && !HeaderFile.eof () )
00238     {
00239         // Get the current line from the file.
00240         HeaderFile.GetLineToken();
00241         Buffer = const_cast<TCHAR *> ( HeaderFile.GetTokenBuf () );
00242 
00243         // Ensure that it's OK.
00244         ERROR2IF(Buffer == 0, 0, "Returned buffer from lex file == 0");
00245 
00246         // Increment the line counter.
00247         Lines++;
00248 
00249         if (camStrncmp(Buffer, _T("%!PS-Adobe"), 10) == 0)
00250         {
00251             // Now find the %%Creator string.
00252             while ((Lines < 100) && !HeaderFile.eof())
00253             {
00254                 HeaderFile.GetLineToken();
00255                 Buffer = const_cast<TCHAR *> ( HeaderFile.GetTokenBuf() );
00256                 ERROR2IF(Buffer == 0, 0, "Returned buffer from lex file == 0");
00257                 Lines++;
00258 
00259                 // Return TRUE if this file was created by Illustrator, or has been exported in 
00260                 // Illustrator format.
00261                 if (camStrncmp(Buffer, _T("%%Creator: Adobe Illustrator(R) 8"), 33) == 0)
00262                 {
00263                     // We definitely want this.
00264                     HeaderFile.close();
00265                     return 10;
00266                 }
00267 
00268                 // Check to see if it's from Illustrator 9. If you're writing a dedicated AI9
00269                 // filter, then you really should remove this code.
00270                 else if (camStrncmp(Buffer, _T("%%Creator: Adobe Illustrator(R) 9"), 33) == 0)
00271                 {
00272                     // We probably want this. Note: I'm returning 9 because a native AI9
00273                     // filter would return 10, and if this code is left in, it will be
00274                     // ignored.
00275                     HeaderFile.close();
00276                     return 9;
00277                 }
00278 
00279                 if (camStrncmp(Buffer, _T("%%Creator:"), 10) == 0)
00280                 {
00281                     // Found the creator line - does it contain the word Illustrator?
00282                     if (camStrstr( (const TCHAR*)Buffer, _T("Illustrator(R) 8")) != NULL)
00283                     {
00284                         HeaderFile.close();
00285                         return 10;
00286                     }
00287                     
00288                     // Try to see if it's Illustrator 9. Again, remove this code when you're
00289                     // writing a dedicated AI9 filter.
00290                     else if (camStrstr( (const TCHAR*)Buffer, _T("Illustrator(R) 9")) != NULL)
00291                     {
00292                         HeaderFile.close();
00293                         return 9;
00294                     }
00295 
00296                     // Not an AI file.
00297                     else
00298                     {
00299                         break;
00300                     }
00301                 }
00302 
00303                 // If we find the compression token then stop the search as we don't want to
00304                 // start looking in the compressed data!
00305                 if (camStrncmp(Buffer, _T("%%Compression:"), 14)==0)
00306                     break;
00307             }
00308 
00309             // Remember to close the file before returning.
00310             HeaderFile.close();
00311 
00312             // Didn't find a suitable Creator line, but the EPS line was ok, so return
00313             // that we're interested, but not sure.
00314             return 5;
00315         }
00316 
00317         // If we find the compression token then stop the search as we don't want to start
00318         // looking in the compressed data!
00319         if (camStrncmp(Buffer, _T("%%Compression:"), 14)==0)
00320             break;
00321     }
00322 
00323     // Remember to close the file before returning.
00324     HeaderFile.close();
00325     
00326     // This file type isn't suitable.
00327     return 0;
00328 }

BOOL AI8EPSFilter::Init void   )  [virtual]
 

Since the constructor can't fail, it does things that the constructor can't do.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/00
Returns:
TRUE if the filter was initialised ok, FALSE otherwise.

Reimplemented from AI5EPSFilter.

Definition at line 177 of file ai8_eps.cpp.

00178 {
00179     // Get the OILFilter object
00180     pOILFilter = new AI8EPSOILFilter(this);
00181     if (pOILFilter == NULL)
00182         return FALSE;
00183 
00184     // Load the description strings
00185     FilterName.Load(FilterNameID);
00186     FilterInfo.Load(FilterInfoID);
00187 
00188     // All ok
00189     return TRUE;
00190 }

void AI8EPSFilter::LookUpToken  )  [virtual]
 

Compare the current token against the AI keywords to see if it is one of them.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/00
Currently 8.0 checks only for its version of the layer operator which differs from previous versions.

Reimplemented from AI5EPSFilter.

Definition at line 345 of file ai8_eps.cpp.

00346 {
00347     // Currently I do not have documentation for the AI 8 tokens, and so am passing the
00348     // token directly to the base class.
00349     AI5EPSFilter::LookUpToken();
00350 }

BOOL AI8EPSFilter::ProcessToken  )  [virtual]
 

Checks if we're looking at the version 8.0 layer token otherwise delegates to the base class.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/00

Reimplemented from AI5EPSFilter.

Definition at line 364 of file ai8_eps.cpp.

00365 {
00366     // Graeme (8/5/00) - The only AI8 token that we're handling at the moment is Lb,
00367     // which is a modified version of the AI5 Lb token. As such, all responsibility
00368     // for token processing is being passed to the base class.
00369     return AI5EPSFilter::ProcessToken();
00370 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:49:52 2007 for Camelot by  doxygen 1.4.4