Corel3EPSFilter Class Reference

An import filter to import EPS files as saved by Corel Draw! 3.x. More...

#include <coreleps.h>

Inheritance diagram for Corel3EPSFilter:

CorelEPSFilter EPSFilter VectorFilter Filter ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 Corel3EPSFilter ()
 Constructor for a Corel3EPSFilter object. The object should be initialised before use.
BOOL Init ()
 Initialise an Corel3EPSFilter object.
char * GetEPSCommand (EPSCommand Cmd)
 Given an EPS token, return the string representation of it; mainly for debugging purposes.

Protected Member Functions

virtual void LookUpToken ()
 Compare the current token against the Corel 3 specific keywords to see if it is one of them.
virtual BOOL ProcessToken ()
 Processes EPS tokens that are not part of the standard Illustrator set. i.e. this is the function that handles all the Corel EPS operators.
INT32 EPSHeaderIsOk (ADDR pFileHeader, UINT32 HeaderSize)
 Checks to see if the EPS comment headers specify that this is an Corel generated EPS file, as required.

Static Protected Attributes

static CommandMap Corel3Commands []

Private Member Functions

 CC_DECLARE_DYNAMIC (Corel3EPSFilter)

Detailed Description

An import filter to import EPS files as saved by Corel Draw! 3.x.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
08/03/94
See also:
Corel4EPSFilter; CorelEPSFilter

Definition at line 169 of file coreleps.h.


Constructor & Destructor Documentation

Corel3EPSFilter::Corel3EPSFilter  ) 
 

Constructor for a Corel3EPSFilter object. The object should be initialised before use.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/10/93
See also:
EPSFilter::Init

Definition at line 1138 of file coreleps.cpp.

01139 {
01140     // Set up filter description.
01141     FilterID = FILTERID_COREL3_EPS;
01142     ImportMsgID = _R(IDT_IMPORTMSG_COREL3);
01143 
01144 #ifndef STANDALONE
01145     Flags.CanImport = TRUE;
01146     Flags.CanExport = FALSE;
01147 #else
01148     Flags.CanImport = FALSE;
01149     Flags.CanExport = FALSE;
01150 #endif
01151 }


Member Function Documentation

Corel3EPSFilter::CC_DECLARE_DYNAMIC Corel3EPSFilter   )  [private]
 

INT32 Corel3EPSFilter::EPSHeaderIsOk ADDR  pFileHeader,
UINT32  HeaderSize
[protected, virtual]
 

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

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/02/94
Returns:
TRUE if the header is ok and import should proceed, FALSE if not.

Reimplemented from EPSFilter.

Definition at line 1193 of file coreleps.cpp.

01194 {
01195     // Check the first line in EPS file
01196     if (camStrncmp((char *) pFileHeader, "%!PS-Adobe-2.0 EPSF", 19) != 0)
01197     {
01198         // Incorrect version of EPS header line - we don't want this
01199         return 0;
01200     }
01201 
01202     // !PS-Adobe line is ok - check creator line...
01203     istrstream HeaderFile((char *) pFileHeader, HeaderSize);
01204     char Buffer[200];
01205     BOOL HaveCreatorString = FALSE;
01206 
01207     UINT32 Lines = 0;
01208     while ((Lines < 20) && !HeaderFile.eof())
01209     {
01210         HeaderFile.getline(Buffer, 200);
01211         Lines++;
01212 
01213         if (camStrncmp(Buffer, "%%Creator: CorelDRAW!", 21) == 0)
01214         {
01215             HaveCreatorString = TRUE;
01216         }
01217 
01218         // Check for CorelDRAW exported by other packages
01219         if (camStrstr("Corel", Buffer) != NULL)
01220             // Found Corel in the creator line - good chance it's Corel EPS.
01221             return 8;
01222 
01223         if(camStrncmp(Buffer, "/wCorelDict", 11) == 0 && HaveCreatorString == TRUE)
01224         {
01225             // OK, found it
01226             return 10;
01227         }
01228 
01229         // If we find the compression token then stop the search as we don't want to start
01230         // looking in the compressed data!
01231         if (camStrncmp(Buffer, "%%Compression:", 14)==0)
01232             break;
01233     }
01234 
01235     // Didn't find a suitable Creator line, but we found an EPS header line.
01236     return 5;
01237 
01238     // May want to look for this string one day.
01239     #if 0
01240     if (camStrncmp(Buf, "% -------------- POSTSCRIPT PROLOG FOR CORELDRAW 3.X", 52) == 0)
01241         FoundProlog = TRUE;
01242     #endif
01243 }

char * Corel3EPSFilter::GetEPSCommand EPSCommand  Cmd  ) 
 

Given an EPS token, return the string representation of it; mainly for debugging purposes.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/02/94
Parameters:
Cmd - the EPS token, e.g. EPSC_cd_c [INPUTS]
Returns:
Pointer to the string representation of the token, e.g. "@c"

Reimplemented from CorelEPSFilter.

Definition at line 1377 of file coreleps.cpp.

01378 {
01379     INT32 i = 0;
01380     while (Corel3Commands[i].Cmd != EPSC_Invalid)
01381     {
01382         if (Corel3Commands[i].Cmd == Cmd)
01383             return Corel3Commands[i].CmdStr;
01384 
01385         // Try next command
01386         i++;
01387     }
01388 
01389     // Couldn't find it - default to base class method
01390     return CorelEPSFilter::GetEPSCommand(Cmd);
01391 }

BOOL Corel3EPSFilter::Init void   )  [virtual]
 

Initialise an Corel3EPSFilter object.

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

Errors: Will fail if not enough memory to initialise the EPS stack.

See also:
EPSStack

Reimplemented from CorelEPSFilter.

Definition at line 1166 of file coreleps.cpp.

01167 {
01168     // Get the OILFilter object
01169     pOILFilter = new Corel3EPSOILFilter(this);
01170     if (pOILFilter == NULL)
01171         return  FALSE;
01172 
01173     // Load the description strings
01174     FilterName.Load(_R(IDT_CORELEPS_FILTERNAME));
01175     FilterInfo.Load(_R(IDT_CORELEPS_FILTERINFO));
01176 
01177     // All ok
01178     return TRUE;
01179 }

void Corel3EPSFilter::LookUpToken  )  [protected, virtual]
 

Compare the current token against the Corel 3 specific keywords to see if it is one of them.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/02/94
See also:
EPSFilter::DecodeToken

Reimplemented from CorelEPSFilter.

Definition at line 1257 of file coreleps.cpp.

01258 {
01259     // Not interested in comments
01260     if (Token == EPSC_Comment)
01261         return;
01262 
01263     // Check to see if it is a keyword - cycle through the array of keyword names and
01264     // compare against our token (could use a hash table?)
01265     INT32 i = 0;
01266     while (Corel3Commands[i].Cmd != EPSC_Invalid)
01267     {
01268         if (camStrcmp(TokenBuf, Corel3Commands[i].CmdStr) == 0)
01269         {
01270             // Found the token - set the token variable and return success
01271             Token = Corel3Commands[i].Cmd;
01272             return;
01273         }
01274         // Try next command
01275         i++;
01276     }
01277 
01278     // Did not find this token - try base class
01279     CorelEPSFilter::LookUpToken();
01280 }

BOOL Corel3EPSFilter::ProcessToken  )  [protected, virtual]
 

Processes EPS tokens that are not part of the standard Illustrator set. i.e. this is the function that handles all the Corel EPS operators.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/02/94
Returns:
TRUE if token understood and processed ok, FALSE if not.

Errors: Syntax error in EPS, Out of memory.

See also:
EPSFilter::ProcessToken

Reimplemented from CorelEPSFilter.

Definition at line 1296 of file coreleps.cpp.

01297 {
01298     // Variables used to extract operands from the stack
01299     PColourCMYK Col;
01300     DocCoord    Coords[3];
01301     TintType    Tint = TINT_NONE;
01302     FIXEDPOINT  TintVal;
01303     String_64   ColName;
01304     double      Padding, RotateX, RotateY;
01305 
01306     // Decode the command, and execute it...
01307     switch (Token)
01308     {
01309         case EPSC_cd3_0x:
01310             Tint = TINT_COREL;
01311         case EPSC_cd3_0k:
01312             // Get the grad fill parameters.
01313             if (!Stack.Pop(&RotateY) || !Stack.Pop(&RotateX) ||
01314                 !Stack.Pop(&Padding) || !Stack.Pop(&GradFillInfo.FillType) ||
01315                 !Stack.Pop(&GradFillInfo.Angle))
01316                 goto EPSError;
01317             
01318             // Convert values from floating point to integer
01319             GradFillInfo.EdgePad = (INT32) (Padding * 100.0);
01320             GradFillInfo.RotateX = (INT32) (RotateX * 100.0);
01321             GradFillInfo.RotateY = (INT32) (RotateY * 100.0);
01322 
01323             // Get the end colour.
01324             if (!Stack.PopColour(&Col, Tint, &TintVal, &ColName))
01325                 // Invalid colour operands
01326                 goto EPSError;
01327 
01328             GetEPSColour(&EndColour, &Col, Tint, TintVal, &ColName);
01329 //          EndColour.SetCMYKValue(&Col);
01330 
01331             // Get the start colour.
01332             if (!Stack.PopColour(&Col, Tint, &TintVal, &ColName))
01333                 // Invalid colour operands
01334                 goto EPSError;
01335 
01336             GetEPSColour(&StartColour, &Col, Tint, TintVal, &ColName);
01337 //          StartColour.SetCMYKValue(&Col);
01338 
01339             GradFill = TRUE;
01340             break;
01341             
01342         default:
01343             return CorelEPSFilter::ProcessToken();
01344     }
01345 
01346 
01347     // No errors encountered while parsing this token and its operands.
01348     return TRUE;
01349     
01350     
01351     // Error handlers:
01352     
01353 EPSError:
01354     HandleEPSError();
01355     return FALSE;
01356 #if 0
01357 NoMemory:
01358     HandleNoMemory();
01359     return FALSE;
01360 #endif
01361 }


Member Data Documentation

CommandMap Corel3EPSFilter::Corel3Commands [static, protected]
 

Initial value:

{
    EPSC_cd3_0k,        "@k",
    EPSC_cd3_0x,        "@x",

    
    EPSC_Invalid,       "Invalid"
}

Definition at line 184 of file coreleps.h.


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