Corel4EPSFilter Class Reference

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

#include <coreleps.h>

Inheritance diagram for Corel4EPSFilter:

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

Public Member Functions

 Corel4EPSFilter ()
 Constructor for a Corel4EPSFilter object. The object should be initialised before use.
BOOL Init ()
 Initialise an Corel4EPSFilter 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 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 Corel4Commands []

Private Member Functions

 CC_DECLARE_DYNAMIC (Corel4EPSFilter)

Detailed Description

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

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

Definition at line 198 of file coreleps.h.


Constructor & Destructor Documentation

Corel4EPSFilter::Corel4EPSFilter  ) 
 

Constructor for a Corel4EPSFilter 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 1434 of file coreleps.cpp.

01435 {
01436     // Set up filter description.
01437     FilterID = FILTERID_COREL4_EPS;
01438     ImportMsgID = _R(IDT_IMPORTMSG_COREL4);
01439 
01440 #ifndef STANDALONE
01441     Flags.CanImport = TRUE;
01442     Flags.CanExport = FALSE;
01443 #else
01444     Flags.CanImport = FALSE;
01445     Flags.CanExport = FALSE;
01446 #endif
01447 }


Member Function Documentation

Corel4EPSFilter::CC_DECLARE_DYNAMIC Corel4EPSFilter   )  [private]
 

INT32 Corel4EPSFilter::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 1489 of file coreleps.cpp.

01490 {
01491     // Check the first line in EPS file
01492     if (camStrncmp((char *) pFileHeader, "%!PS-Adobe-2.0 EPSF-2.0", 23) != 0)
01493     {
01494         // Incorrect version of EPS header line - we don't want this
01495         return 0;
01496     }
01497 
01498     // !PS-Adobe line is ok...
01499 
01500     // Scan first 20 lines for Corel 4.x's unique(ish) line
01501     // (If you have no prolog, then it won't be there)
01502     istrstream HeaderFile((char *) pFileHeader, HeaderSize);
01503     char Buffer[200];
01504     BOOL HaveCreatorString = FALSE;
01505 
01506     UINT32 Lines = 0;
01507     while ((Lines < 20) && !HeaderFile.eof())
01508     {
01509         HeaderFile.getline(Buffer, 200);
01510         Lines++;
01511 
01512         if (camStrncmp(Buffer, "%%BeginResource: procset wCorel4Dict", 36) == 0)
01513             // This must be Corel 4.0 EPS
01514             return 10;
01515 
01516         if ((camStrncmp(Buffer, "%%Creator:", 10) == 0) && (camStrclen(Buffer) <= 12))
01517         {
01518             // Blank Creator comment - this could be Corel 4.0 EPS
01519             if (IsUserName("Tim"))
01520                 TRACE( _T("Found blank creator field\n"));
01521 
01522             // Return 6 rather than 5 so we're just above the other EPS filters in terms
01523             // of compatibility, because a blank Creator comment is a reasonably good
01524             // sign thatthis file came from Corel 4.
01525             return 6;
01526         }
01527         
01528         if ((camStrncmp(Buffer, "%%Creator: CorelDRAW!", 21) == 0) && (camStrclen(Buffer) <= 23))
01529         {
01530             // yep, that's the one
01531             HaveCreatorString = TRUE;
01532         }
01533 
01534         if(camStrncmp(Buffer, "/wCorel5Dict", 12) == 0 && HaveCreatorString)
01535         {
01536             // it's a Corel5 file
01537             return 10;
01538         }
01539 
01540     }
01541 
01542     // Corel 4.0 doesn't put anything in the Creator comment field - return
01543     // 5 to indicate we're interested, but not sure.
01544     return 5;
01545 
01546 }

char * Corel4EPSFilter::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 1764 of file coreleps.cpp.

01765 {
01766     INT32 i = 0;
01767     while (Corel4Commands[i].Cmd != EPSC_Invalid)
01768     {
01769         if (Corel4Commands[i].Cmd == Cmd)
01770             return Corel4Commands[i].CmdStr;
01771 
01772         // Try next command
01773         i++;
01774     }
01775 
01776     // Couldn't find it - default to base class method
01777     return CorelEPSFilter::GetEPSCommand(Cmd);
01778 }

BOOL Corel4EPSFilter::Init void   )  [virtual]
 

Initialise an Corel4EPSFilter 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 1462 of file coreleps.cpp.

01463 {
01464     // Get the OILFilter object
01465     pOILFilter = new Corel4EPSOILFilter(this);
01466     if (pOILFilter == NULL)
01467         return FALSE;
01468 
01469     // Load the description strings
01470     FilterName.Load(_R(IDT_CORELEPS_FILTERNAME));
01471     FilterInfo.Load(_R(IDT_CORELEPS_FILTERINFO));
01472 
01473     // All ok
01474     return TRUE;
01475 }

void Corel4EPSFilter::LookUpToken  )  [protected, virtual]
 

Compare the current token against the Corel 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 1560 of file coreleps.cpp.

01561 {
01562 //  // Not interested in comments
01563 //  if (Token == EPSC_Comment)
01564 //      return;
01565 
01566     if(Token == EPSC_Comment)
01567     {
01568         // is it one of the clipping things?
01569         if(camStrncmp(TokenBuf, "%SetClippingRegion", 17) == 0)
01570             Token = EPSC_q;
01571         else if(camStrncmp(TokenBuf, "%ClearClipping", 13) == 0)
01572             Token = EPSC_Q; 
01573 
01574         return;
01575     }
01576 
01577     // Check to see if it is a keyword - cycle through the array of keyword names and
01578     // compare against our token (could use a hash table?)
01579     INT32 i = 0;
01580     while (Corel4Commands[i].Cmd != EPSC_Invalid)
01581     {
01582         if (camStrcmp(TokenBuf, Corel4Commands[i].CmdStr) == 0)
01583         {
01584             // Found the token - set the token variable and return success
01585             Token = Corel4Commands[i].Cmd;
01586             return;
01587         }
01588         // Try next command
01589         i++;
01590     }
01591 
01592     // Did not find this token - try base class
01593     CorelEPSFilter::LookUpToken();
01594 }

BOOL Corel4EPSFilter::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 1610 of file coreleps.cpp.

01611 {
01612     // Variables used to extract operands from the stack
01613     PColourCMYK Col;
01614     DocCoord    Coords[3];
01615     TintType    Tint = TINT_NONE;
01616     double      Padding, RotateX, RotateY;
01617 
01618     // Decode the command, and execute it...
01619     switch (Token)
01620     {
01621         case EPSC_cd4_0x:
01622             Tint = TINT_COREL;
01623         case EPSC_cd4_0k:
01624             // Get the grad fill parameters
01625             if (!Stack.Pop(&RotateY) || !Stack.Pop(&RotateX) ||
01626                 !Stack.Pop(&Padding) || !Stack.Pop(&GradFillInfo.FillType) ||
01627                 !Stack.Pop(&GradFillInfo.Angle) || !Stack.Discard(3))
01628                 goto EPSError;
01629 
01630             // Convert angle to sane value
01631 //          GradFillInfo.Angle = GradFillInfo.Angle;
01632 
01633             // Convert values from floating point to integer
01634             GradFillInfo.EdgePad = (INT32) (Padding * 100.0);
01635             GradFillInfo.RotateX = (INT32) (RotateX * 100.0);
01636             GradFillInfo.RotateY = (INT32) (RotateY * 100.0);
01637 
01638             if (Stack.GetType() != EPSTYPE_COMMAND)
01639             {
01640                 if (IsUserName("Tim"))
01641                     TRACE( _T("@x/@k: Expected ArrayEnd, found '%s'\n"), TokenBuf);
01642                 goto EPSError;
01643             }
01644             
01645             EPSCommand Cmd;
01646             Stack.PopCmd(&Cmd);
01647             if (Cmd != EPSC_ArrayEnd)
01648             {
01649                 if (IsUserName("Tim"))
01650                     TRACE( _T("@x/@k: Expected ArrayEnd, found '%s'\n"), GetEPSCommand(Cmd));
01651                 goto EPSError;
01652             }
01653 
01654             // Discard the steps parameter 
01655             if (!Stack.Discard())
01656                 goto EPSError;
01657 
01658             // Get the end colour.
01659             if (!Stack.PopColour(&Col, Tint))
01660                 // Invalid colour operands
01661                 goto EPSError;
01662             EndColour.SetCMYKValue(&Col);
01663 
01664             // Discard some strange parameter I don't yet understand
01665             if (!Stack.Discard())
01666                 goto EPSError;
01667 
01668             // Get the start colour.
01669             if (!Stack.PopColour(&Col, Tint))
01670                 // Invalid colour operands
01671                 goto EPSError;
01672             StartColour.SetCMYKValue(&Col);
01673 
01674             // Discard the array end symbol
01675             if (Stack.IsEmpty())
01676             {
01677                 // Run out of operands!
01678                 if (IsUserName("Tim"))
01679                     TRACE( _T("@x/@k: Run out of operands\n"));
01680                 goto EPSError;
01681             }
01682                 
01683             if (Stack.GetType() != EPSTYPE_COMMAND)
01684             {
01685                 if (IsUserName("Tim"))
01686                     TRACE( _T("@x/@k: Expected ArrayStart but found '%s'\n"), TokenBuf);
01687                 goto EPSError;
01688             }
01689             else
01690             {
01691                 EPSCommand Cmd = Stack.ReadCmd();
01692                 if (!Stack.PopCmd(&Cmd) || Cmd != EPSC_ArrayStart)
01693                 {
01694                     if (IsUserName("Tim"))
01695                         TRACE( _T("@x/@k: Expected ArrayStart, found '%s'\n"), GetEPSCommand(Cmd));
01696                     goto EPSError;
01697                 }
01698             }
01699 
01700             GradFill = TRUE;
01701 
01702             break;
01703             
01704         case EPSC_eoclip:
01705             // add clip thingy operator...
01706             EPSFlags.PathIsHidden = TRUE;
01707             Token = EPSC_W;
01708             return EPSFilter::ProcessToken();
01709             break;
01710 
01711         case EPSC_cd5_0gs:
01712             return Import_gsave();
01713             break;
01714 
01715         case EPSC_cd5_0gr:
01716             return Import_grestore();
01717             break;
01718 
01719         case EPSC_cd5_0np:
01720             // newpath... blank current if necessary
01721             if(pInkPath !=0)
01722             {
01723                 if(!pInkPath->ClearPath())
01724                     return FALSE;
01725             }
01726             break;
01727 
01728         default:
01729             return CorelEPSFilter::ProcessToken();
01730             break;
01731     }
01732 
01733 
01734     // No errors encountered while parsing this token and its operands.
01735     return TRUE;
01736     
01737     
01738     // Error handlers:
01739     
01740 EPSError:
01741     HandleEPSError();
01742     return FALSE;
01743 #if 0
01744 NoMemory:
01745     HandleNoMemory();
01746     return FALSE;
01747 #endif
01748 }


Member Data Documentation

CommandMap Corel4EPSFilter::Corel4Commands [static, protected]
 

Initial value:

{
    EPSC_cd4_0k,        "@k",
    EPSC_cd4_0x,        "@x",
    EPSC_eoclip,        "eoclip",
    EPSC_cd5_0gs,       "@gs",
    EPSC_cd5_0gr,       "@gr",
    EPSC_cd5_0np,       "@np",

    
    EPSC_Invalid,       "Invalid"
}

Definition at line 213 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