CamelotNativeEPSFilter Class Reference

This filter will be almost the same as Camelot EPS, only it will hold a little more information and store data slightly more efficiently. Mainly, it will save out bitmaps as binary. It won't really be valid EPS as it will not always be ascii. The Native file format is being done this way as it will take little or no effort to do this. More...

#include <nativeps.h>

Inheritance diagram for CamelotNativeEPSFilter:

CamelotEPSFilter ArtWorksEPSFilter EPSFilter VectorFilter Filter ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 CamelotNativeEPSFilter ()
 Constructor for the Native save/load filter.
 ~CamelotNativeEPSFilter ()
 Tidies up when the filter is destroyed. Mostly takes care of the bitmap pool references that may have been built during the import.
BOOL Init ()
 Initalises the Filter ready for use. Will fail if it can not get enough memory to work with.
BOOL PrepareToExport (CCLexFile *pFile, Spread *pSpread)
 Gets things ready for the export. Creates the render region to do all the exporting with.
virtual EPSExportDCCreateExportDC ()
 Creates a new export DC (NativeExportDC) ready to export the Native file to.
virtual BOOL ExportBitmap (KernelBitmap &)
 Export a bitmap to a Camelot EPS file. This does one of 2 things. If we are in the middle of exporting the bitmap pool it will save out all the bitmap data, just as CamelotEPS does. If we are not in the bitmap pool it will simply save out a reference to the bitmap in the pool.
BOOL PrepareToImport ()
 See base class.
virtual INT32 ImportBinary (ADDR pData, INT32 Length)
 Reads the binary data out of the file and puts it into the buffer supplied. It also makes checks to see if the appropriate chars are found surounding the Binary stream.
virtual BOOL ProcessFilterComment ()
 This deals with the page info held in comments in the EPS stream.
virtual void CleanUpAfterImport (BOOL Successful)
 Happens at the end of the import to allow the filters to clean up after themselves.
BitmapFilterSupport GetBitmapSupportLevel ()
 Determine how well this filter supports bitmaps when exporting.
virtual void BitmapPoolAttach (KernelBitmap *pBitmap)
 Makes a reference to the bitmap so that it can be used throughout the eps file with repeating the data.
double SmartGetBuildNumber ()
 Determines a monotomic build version number based on BuildVersionNumber which unfortunately jumps to v1.00/a/b/c/d but these are mapped back to real build numbers. v1.00/a/b/c/d all have BuildVersionNumbers of 1.00 and are all descended from an isolated liniage based on 0.586 so all map to this number Note: Only guaranteed for build versions greater than 0.586!
double GetBuildNumber ()

Static Public Member Functions

static BOOL SetNativeCompression (BOOL NewState)
 Set the prefernece as to whether we are to compress the native files or not.
static BOOL GetNativeCompression ()
 Set the prefernece as to whether we are to compress the native files or not.

Public Attributes

BOOL IsSavingBitmapPool

Static Public Attributes

static BOOL CompressNative = TRUE
 Flag for whether we compress the native files saved from Xara Studio. True means do compress the files.

Protected Member Functions

virtual void LookUpToken ()
 Look up one of the tokens used by the Camelot Native EPS file format.
virtual BOOL ProcessToken ()
 Deals with the current token. This function deals with tokens that are specific to the Camelot Native EPS format, or different from Camelot EPS.
INT32 EPSHeaderIsOk (ADDR pFileHeader, UINT32 HeaderSize)
 Checks to see if the EPS comment headers specify that this is an Camelot Native file, as required.
virtual BOOL GetExportOptions ()
 Allows the user to be prompted to get information for export. This overriden version returns True so that nothing happens. Scope: Protected.
virtual BOOL ReadBitmap ()
 Reads in a bitmap. If it is a Type 0 bitmap (ie one with all its data) it will ask the base class to import it. If it is a Type 1 bitmap it will look up the reference in the bitmap pool and use that.
virtual BOOL SetFileCompressionState (BOOL NewState)
 Set a new file compression status into action.
virtual BOOL GetFileCompressionState ()
 Get the current file compression state. True if compressing.

Protected Attributes

INT32 BitmapCount
INT32 PendingBitmapNum
KernelBitmapRefBitmapPoolRefs
BOOL OldImportWithLayers
BOOL OldOpenWithLayers
INT32 CompressionType
BOOL CompressionOn
double FileVersionNumber
double BuildVersionNumber
INT32 OldMinLineWidth

Static Protected Attributes

static CommandMap NativeCommands []

Private Member Functions

 CC_DECLARE_DYNAMIC (CamelotNativeEPSFilter)

Detailed Description

This filter will be almost the same as Camelot EPS, only it will hold a little more information and store data slightly more efficiently. Mainly, it will save out bitmaps as binary. It won't really be valid EPS as it will not always be ascii. The Native file format is being done this way as it will take little or no effort to do this.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/12/94

Definition at line 132 of file nativeps.h.


Constructor & Destructor Documentation

CamelotNativeEPSFilter::CamelotNativeEPSFilter  ) 
 

Constructor for the Native save/load filter.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/12/94

Definition at line 208 of file nativeps.cpp.

00209 {
00210     // Set up filter descriptions.
00211     FilterNameID = _R(IDS_NATIVE_EPS_FILTERNAME);
00212     FilterInfoID = _R(IDS_NATIVE_EPS_FILTERINFO);
00213     ImportMsgID  = _R(IDS_IMPORTMSG_NATIVE_EPS);
00214     ExportMsgID  = _R(IDS_EXPORTMSG_NATIVE_EPS);
00215 
00216     FilterID = FILTERID_NATIVE_EPS;
00217 
00218 #ifndef STANDALONE
00219     Flags.CanImport = TRUE;
00220     //WEBSTER-Martin-27/01/97
00221 #ifdef WEBSTER
00222     Flags.CanExport = FALSE;
00223 #else
00224     Flags.CanExport = FALSE;
00225 #endif //WEBSTER
00226 #else
00227     Flags.CanImport = TRUE;
00228     Flags.CanExport = FALSE;
00229 #endif
00230 
00231     // We don't want to re-position Camelot files because they should be ok and
00232     // Charles gets upset if his drawings move.
00233     AdjustOrigin = FALSE;
00234 
00235     // Prepare the bitmap pool data
00236     IsSavingBitmapPool = FALSE;
00237     BitmapCount = 0;
00238     BitmapPoolRefs = NULL;
00239     PendingBitmapNum = 0;
00240 
00241     // A flag to store the Value of the ImportWithLayers flag in
00242     OldImportWithLayers = TRUE;
00243     OldOpenWithLayers = TRUE;
00244 
00245     // Items to handle the file compression
00246     CompressionType = 0;    // type of compression in use (0 at present)
00247     CompressionOn = FALSE;  // on/off flag
00248 
00249     FileVersionNumber = 0.0;
00250     BuildVersionNumber = 0.0;
00251 }

CamelotNativeEPSFilter::~CamelotNativeEPSFilter  ) 
 

Tidies up when the filter is destroyed. Mostly takes care of the bitmap pool references that may have been built during the import.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/1/95

Definition at line 267 of file nativeps.cpp.

00268 {
00269     // Get rid of the bitmap references if we have any
00270     if (BitmapPoolRefs != NULL)
00271         delete [] BitmapPoolRefs;
00272 }


Member Function Documentation

void CamelotNativeEPSFilter::BitmapPoolAttach KernelBitmap pBitmap  )  [virtual]
 

Makes a reference to the bitmap so that it can be used throughout the eps file with repeating the data.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/1/95
Parameters:
pBitmap - The bitmap to attach [INPUTS]

Reimplemented from CamelotEPSFilter.

Definition at line 1134 of file nativeps.cpp.

01135 {
01136     // Make sure we have some refs and its in range
01137     if ((BitmapPoolRefs!=NULL) && (PendingBitmapNum < BitmapCount))
01138     {
01139         // yep, so attach the bitmap to the reference
01140         BitmapPoolRefs[PendingBitmapNum].Attach(pBitmap, GetDocument());
01141 
01142         if (BitmapPoolRefs[PendingBitmapNum].GetBitmap() != pBitmap)
01143         {
01144             // It didn't use the bitmap we gave it, so we can delete it
01145             delete pBitmap;
01146         }
01147 
01148     }
01149 }

CamelotNativeEPSFilter::CC_DECLARE_DYNAMIC CamelotNativeEPSFilter   )  [private]
 

void CamelotNativeEPSFilter::CleanUpAfterImport BOOL  Successful  )  [virtual]
 

Happens at the end of the import to allow the filters to clean up after themselves.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/1/95
Parameters:
Successful - TRUE if the import went OK, FALSE if it failed [INPUTS]

Reimplemented from CamelotEPSFilter.

Definition at line 1091 of file nativeps.cpp.

01092 {
01093     // Call the base class
01094     CamelotEPSFilter::CleanUpAfterImport(Successful);
01095 
01096     // restore the old min line width
01097     MinLineWidth = OldMinLineWidth;
01098 
01099     // Get rid of the bitmap references if we have any
01100     // This will cause all bitmaps that were loaded, but are not used to be thrown away
01101     if (BitmapPoolRefs != NULL)
01102         delete [] BitmapPoolRefs;
01103 
01104     // Ready for the next one
01105     BitmapPoolRefs = NULL;
01106 
01107     // Put the Import with layers flag back as it was
01108     ImportWithLayers = OldImportWithLayers;
01109     OpenWithLayers = OldOpenWithLayers;
01110 
01111     // Flag this as an old format document
01112     if (TheDocument && Successful)
01113     {
01114         // But only flag it if we are opening the document rather than importing into an exisiting one
01115         if (!TheDocument->IsImporting())
01116             TheDocument->SetLoadedAsVersion1File(TRUE);
01117     }
01118 }

EPSExportDC * CamelotNativeEPSFilter::CreateExportDC  )  [virtual]
 

Creates a new export DC (NativeExportDC) ready to export the Native file to.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/12/94
Returns:
Pointer to a new ExportDC.

Reimplemented from EPSFilter.

Definition at line 1474 of file nativeps.cpp.

01475 {
01476 #if !defined(EXCLUDE_FROM_RALPH)
01477     return new NativeExportDC(this);
01478 #else
01479     return NULL;
01480 #endif
01481 }

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

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

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/12/94
Returns:
0 - 10. 0 means not interested in this file, 10 means I know all about this file.

Reimplemented from CamelotEPSFilter.

Definition at line 963 of file nativeps.cpp.

00964 {
00965     // This function is NOT unicode
00966 
00967     // Check the first line in EPS file
00968     if (strncmp((char *) pFileHeader, "%!PS-Adobe-2.0 EPSF-1.2", 23) != 0)
00969     {
00970         // Incorrect version of EPS header line - we don't want this
00971         return 0;
00972     }
00973 
00974     // !PS-Adobe line is ok - check creator line...
00975     std::istringstream HeaderFile((char *) pFileHeader, ios_base::in /* HeaderSize*/);
00976     char Buffer[200];
00977 
00978     UINT32 Lines = 0;
00979     while ((Lines < 20) && !HeaderFile.eof())
00980     {
00981         HeaderFile.getline(Buffer, 200);
00982         Lines++;
00983 
00984         // if the file is native camelot, return indicating strong 'interest'!
00985         if (strncmp(Buffer, "%%Creator: Xara Studio (Native)", 31) == 0)
00986             return 10;
00987 
00988         // If we find the compression token then stop the search as we don't want to start
00989         // looking in the compressed data!
00990         if (strncmp(Buffer, "%%Compression:", 14)==0)
00991             break;
00992     }
00993 
00994     // Didn't find a suitable Creator line. Since this is not really an eps filter it
00995     // will claim to know nothing about it. Camelot EPS will have a go at this file
00996     // but we can not really try.
00997     return 0;
00998 }

BOOL CamelotNativeEPSFilter::ExportBitmap KernelBitmap TheBitmap  )  [virtual]
 

Export a bitmap to a Camelot EPS file. This does one of 2 things. If we are in the middle of exporting the bitmap pool it will save out all the bitmap data, just as CamelotEPS does. If we are not in the bitmap pool it will simply save out a reference to the bitmap in the pool.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/1/95
Parameters:
TheBitmap - the bitmap to export [INPUTS]
Returns:
TRUE if the bitmap was exported ok (or if it wasn't exported because the file format does not support it; FALSE if an error occured.

Errors: Usual disk/file errors.

See also:
Filter::ExportBitmap

Reimplemented from CamelotEPSFilter.

Definition at line 1577 of file nativeps.cpp.

01578 {
01579 #if !defined(EXCLUDE_FROM_RALPH)
01580     // If this is the bitmap pool, then save out some data
01581     if (IsSavingBitmapPool)
01582     {
01583         TRACEUSER( "Rik", _T("In the bitmap pool, so saving out real data\n"));
01584         return CamelotEPSFilter::ExportBitmap(TheBitmap);
01585     }
01586 
01587     // If we get here then we must be saving out a reference to a bitmap saved earlier in the pool
01588     TRACEUSER( "Rik", _T("Trying to save a reference to a bitmap\n"));
01589     
01590     // Try and find the bitmap in the bitmap pool
01591     // Get the document that we are saving
01592     Document* pDoc = GetDocument();
01593     if (pDoc==NULL)
01594         return FALSE;
01595 
01596     // Find the doccomponent with the list of bitmaps in it
01597     DocComponent* DocBitmapList = pDoc->GetDocComponent(CC_RUNTIME_CLASS(BitmapListComponent));
01598     if (DocBitmapList==NULL)
01599         return FALSE;
01600 
01601     ExportedBitmaps* pBitmapExportPool = ((BitmapListComponent*)DocBitmapList)->GetBitmapExportPool();
01602     ERROR3IF(pBitmapExportPool == NULL, "No BitmapExportPool in CamelotNativeEPSFilter::ExportBitmap");
01603     if (pBitmapExportPool==NULL)
01604         return FALSE;
01605 
01606     INT32 BitmapPoolNum = -1;
01607 
01608     // Get ready to look for our bitmap
01609     class ExportBitmap* pExportBitmap = pBitmapExportPool->GetBitmap(&TheBitmap);
01610     // The 'class' statement is because this filter has a function called 'ExportBitmap'
01611 
01612     ERROR3IF(pExportBitmap == NULL, "Couldn't find the bitmap in the pool in CamelotNativeEPSFilter::ExportBitmap");
01613 
01614     if (pExportBitmap)
01615     {
01616         BitmapPoolNum = pExportBitmap->RecordNumber;
01617     }
01618     
01619     // Did we find it
01620     if (BitmapPoolNum >= 0)
01621     {
01622         // Export the number of the bitmap
01623         ExportDCPtr->OutputValue((UINT32) BitmapPoolNum);
01624 
01625         // Bitmap type is always 1 to represent a reference (0 is an actual bitmap)
01626         ExportDCPtr->OutputToken(_T("1"));
01627 
01628         // Write out the bitmap start token
01629         ExportDCPtr->OutputToken(_T("csbm"));
01630         ExportDCPtr->OutputNewLine();
01631 
01632         // Write out the bitmap end token
01633         ExportDCPtr->OutputToken(_T("cebm"));
01634         ExportDCPtr->OutputNewLine();
01635 
01636         // All ok
01637         return TRUE;
01638     }
01639 #endif
01640     // Did not find the bitmap
01641     return FALSE;
01642 }

BitmapFilterSupport CamelotNativeEPSFilter::GetBitmapSupportLevel  )  [virtual]
 

Determine how well this filter supports bitmaps when exporting.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/01/95
Returns:
IndirectedBitmapSupport - This filter supports bitmap indirection; i.e. a bitmap pool of some type is saved and then this can be referenced in the file.

Reimplemented from ArtWorksEPSFilter.

Definition at line 1658 of file nativeps.cpp.

01659 {
01660     return IndirectedBitmapSupport;
01661 }

double CamelotNativeEPSFilter::GetBuildNumber  )  [inline]
 

Definition at line 160 of file nativeps.h.

00160 { return BuildVersionNumber; }

BOOL CamelotNativeEPSFilter::GetExportOptions  )  [protected, virtual]
 

Allows the user to be prompted to get information for export. This overriden version returns True so that nothing happens. Scope: Protected.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> HUmphrys
Date:
22/12/95
Parameters:
- [INPUTS]
Returns:
TRUE if OK, FALSE if user pressed Cancel.

Reimplemented from CamelotEPSFilter.

Definition at line 1498 of file nativeps.cpp.

01499 {
01500     // Overide the CamelotEPS form so that we do nothing again i.e. just return TRUE
01501     return TRUE;
01502 }

BOOL CamelotNativeEPSFilter::GetFileCompressionState  )  [protected, virtual]
 

Get the current file compression state. True if compressing.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/5/95
Returns:
The current state of the file compression.

Definition at line 379 of file nativeps.cpp.

00380 {
00381     return CompressionOn;
00382 }

BOOL CamelotNativeEPSFilter::GetNativeCompression  )  [static]
 

Set the prefernece as to whether we are to compress the native files or not.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/5/95
Parameters:
New state for native file compression, TRUE if want on, FALSE if want off. [INPUTS]
Returns:
The old state of the compression.

Definition at line 342 of file nativeps.cpp.

00343 {
00344     return CompressNative;
00345 }   

INT32 CamelotNativeEPSFilter::ImportBinary ADDR  pData,
INT32  Length
[virtual]
 

Reads the binary data out of the file and puts it into the buffer supplied. It also makes checks to see if the appropriate chars are found surounding the Binary stream.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/12/94
Parameters:
Length - the number of bytes to read, in terms of binary data imported, as [INPUTS] opposed to how many bytes the file format takes to represent this binary data.
pData - the buffer to put the data into. [OUTPUTS]
Returns:
TRUE if it imported the specified number of bytes correctly; FALSE if not.

Errors: File input errors; EOF

See also:
Filter::ImportBinary

Reimplemented from EPSFilter.

Definition at line 1240 of file nativeps.cpp.

01241 {
01242     // read chars until we get a >
01243     INT32 CountDown = 50;
01244     TCHAR Ch;
01245     do {
01246         // Read a TCHAR
01247         if (EPSFile->read(&Ch, 1).fail())
01248         {
01249             HandleEPSError();
01250             return FALSE;
01251         }
01252 
01253         // Count it
01254         CountDown--;
01255     } while ((CountDown>0) && (Ch!='>'));
01256 
01257     // See if we found it
01258     if (CountDown==0)
01259     {
01260         HandleEPSError();
01261         return FALSE;
01262     }
01263     
01264     // Read binary section
01265     if (EPSFile->read(pData, Length).fail())
01266     {
01267         HandleEPSError();
01268         return FALSE;
01269     }
01270 
01271     // Read TCHAR and check that it is a <
01272     if (EPSFile->read(&Ch, 1).fail())
01273     {
01274         HandleEPSError();
01275         return FALSE;
01276     }
01277 
01278     if (Ch!='<')
01279     {
01280         HandleEPSError();
01281         return FALSE;       
01282     }
01283 
01284     // Find out how much of the file we have read
01285     INT32 CharsRead = EPSFile->GetCharsRead();
01286     if (CharsRead > (LastProgressUpdate + 2048))
01287     {
01288         if (!ContinueSlowJob(CharsRead))
01289         {
01290             // Abort operation - make sure nodes are deleted and not added to the tree.
01291             ERROR(_R(IDT_IMPORT_USERABORT), FALSE);
01292         }
01293         else
01294         {
01295             LastProgressUpdate = CharsRead;
01296         }
01297     }
01298 
01299     // Re-sync the tokeniser
01300     EPSFile->GetLine();
01301     EPSFile->GetCh();
01302 
01303     // Must have worked
01304     return TRUE;
01305 }

BOOL CamelotNativeEPSFilter::Init void   )  [virtual]
 

Initalises the Filter ready for use. Will fail if it can not get enough memory to work with.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/12/94
Returns:
TRUE if it worked, FALSE if it failed

Reimplemented from CamelotEPSFilter.

Definition at line 289 of file nativeps.cpp.

00290 {
00291     // Get the OILFilter object
00292     pOILFilter = new NativeEPSOILFilter(this);
00293     if (pOILFilter == NULL)
00294         return FALSE;
00295 
00296     // Load the description strings
00297     FilterName.Load(FilterNameID);
00298     FilterInfo.Load(FilterInfoID);
00299 
00300     // Preference to turn native file compression on or off
00301     if (Camelot.DeclareSection(_T("Filters"), 10))
00302     {
00303         Camelot.DeclarePref( NULL, _T("CompressNative"), &CompressNative, 0, 1 );
00304     }
00305 
00306     // All ok
00307     return TRUE;
00308 }

void CamelotNativeEPSFilter::LookUpToken  )  [protected, virtual]
 

Look up one of the tokens used by the Camelot Native EPS file format.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/1/95

Reimplemented from CamelotEPSFilter.

Definition at line 395 of file nativeps.cpp.

00396 {
00397     // Not interested in comments
00398     if (Token == EPSC_Comment)
00399         return;
00400 
00401     // Check to see if it is a keyword - cycle through the array of keyword names and
00402     // compare against our token (could use a hash table?)
00403     INT32 i = 0;
00404     while (NativeCommands[i].Cmd != EPSC_Invalid)
00405     {
00406         if (camStrcmp(TokenBuf, NativeCommands[i].CmdStr) == 0)
00407         {
00408             // Found the token - set the token variable and return success
00409             Token = NativeCommands[i].Cmd;
00410             return;
00411         }
00412         
00413         // Try next command
00414         i++;
00415     }
00416 
00417     // Did not find this token - pass on to base class.
00418     CamelotEPSFilter::LookUpToken();
00419 }

BOOL CamelotNativeEPSFilter::PrepareToExport CCLexFile pFile,
Spread pSpread
[virtual]
 

Gets things ready for the export. Creates the render region to do all the exporting with.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/12/94
Parameters:
pFile - the path name [INPUTS] pSpread - The spread to save
Returns:
TRUE if it worked, FALSE if it failed

Reimplemented from CamelotEPSFilter.

Definition at line 1519 of file nativeps.cpp.

01520 {
01521 #if !defined(EXCLUDE_FROM_RALPH)
01522     // Use base class to do most of it
01523     if (!CamelotEPSFilter::PrepareToExport(pFile, pSpread)) return FALSE;
01524 
01525     // Try and create a render region if we are really a
01526     // Native filter and not something derived from it
01527     if (IS_A(this, CamelotNativeEPSFilter))
01528     {
01529         // Don't care about clip regions when exporting - create a null region.
01530         DocRect NullClipRect;
01531         NullClipRect.MakeEmpty();
01532 
01533         // Don't use rendering matrix when exporting EPS as it uses fractional coordinates.
01534         Matrix Identity;
01535 
01536         // Don't use view scale; set to 1
01537         FIXED16 Scale(1);
01538 
01539         // Create the render region
01540         ExportRegion = new NativeRenderRegion(NullClipRect, Identity, Scale);
01541         if (ExportRegion == NULL) return FALSE;
01542 
01543         // use the first docview
01544         DocView * pDocView = TheDocument->GetFirstDocView();
01545         // fallback - help no docviews
01546         if ((!pDocView) || (!pDocView->IsKindOf(CC_RUNTIME_CLASS(DocView))))
01547             pDocView = DocView::GetSelected(); // help! use selected docview
01548 
01549         // Attach to the right device.
01550         ExportRegion->AttachDevice(pDocView, ExportDCPtr->GetDC(), pSpread);
01551     }
01552 #endif
01553     // Thats it
01554     return TRUE;
01555 }

BOOL CamelotNativeEPSFilter::PrepareToImport  )  [virtual]
 

See base class.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/12/94
Returns:
TRUE if filter initialised ok; FALSE if not.

Errors: See base class.

See also:
EPSFilter::PrepareToImport;

Reimplemented from CamelotEPSFilter.

Definition at line 1014 of file nativeps.cpp.

01015 {
01016     // Note the old state so we can put it back at the end
01017     OldImportWithLayers = Filter::ImportWithLayers;
01018     OldOpenWithLayers = Filter::OpenWithLayers;
01019 
01020     // Neville 7/8/97 - Layers are bad in Webster as they conflict with frames
01021 #ifndef WEBSTER
01022     // We always wanted to import with layers in the native filter
01023     // Nowadays, its a bit more complicated
01024     // If we are during template loading then always load the layers
01025     if (TheDocument->IsTemplateLoading())
01026     {
01027         ImportWithLayers = TRUE;
01028         OpenWithLayers = TRUE;
01029     }
01030     else
01031     {
01032         // Otherwise if we are in:-
01033         // - a framed document then remove all layers from importing
01034         // - a layered document then import with layers
01035         if (TheDocument->IsImporting())
01036         {
01037             ERROR2IF(ImportInfo.pSpread == NULL,FALSE,"CamelotNativeEPSFilter::PrepareToImport No spread");
01038             Layer * pFrame = ImportInfo.pSpread->FindFirstFrameLayer();
01039             if (pFrame == NULL)
01040                 ImportWithLayers = TRUE;    // Layered = allow layers
01041             else
01042                 ImportWithLayers = FALSE;   // Framed = disallow layers
01043         }
01044         else
01045             ImportWithLayers = TRUE;
01046         OpenWithLayers = TRUE;          // Always open with layers
01047     }
01048 #else
01049     // If we are during template loading then always load the layers
01050     if (TheDocument->IsTemplateLoading())
01051     {
01052         ImportWithLayers = TRUE;
01053         OpenWithLayers = TRUE;
01054     }
01055     else    // Otherwise remove all layers from importing
01056     {
01057         ImportWithLayers = FALSE;
01058         OpenWithLayers = FALSE;
01059     }
01060 #endif // WEBSTER */
01061 
01062     // reset version numbers so files without this info have numbers 0.0
01063     FileVersionNumber  = 0.0;
01064     BuildVersionNumber = 0.0;
01065 
01066     // Initialise base class first.
01067     if (!CamelotEPSFilter::PrepareToImport())
01068         return FALSE;
01069 
01070     // set min line width to zero and store old value
01071     OldMinLineWidth = MinLineWidth;
01072     MinLineWidth = 0;
01073     
01074     return TRUE;
01075 }

BOOL CamelotNativeEPSFilter::ProcessFilterComment  )  [virtual]
 

This deals with the page info held in comments in the EPS stream.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/12/94
Returns:
TRUE if it finds something it likes, FALSE if not

Reimplemented from EPSFilter.

Definition at line 1319 of file nativeps.cpp.

01320 {
01321     // read the build version number of the app which saved this file
01322     if (camStrncmp(TokenBuf, _T("%%Creator: Xara Studio (Native)"), 31) == 0)
01323     {
01324         return TRUE;
01325     }
01326 
01327     // Go and have a look at the token buffer and see if it is our special
01328     // file version comment. If so, then extract the version number from it. 
01329     if (camStrncmp(TokenBuf, _T("%%File version:"), 15)==0)
01330     {
01331         TCHAR* pVersion = &(((TCHAR*)TokenBuf)[15]);
01332         double Version=0.0;
01333         camSscanf(pVersion, _T("%lf"), &Version);
01334         TRACEUSER( "Neville", _T("Native file version = %f\n"), Version);
01335         FileVersionNumber = Version;
01336         // Must stop later file versions loading back into this version.
01337         if (Version > ReadNativeVersion)
01338         {
01339             InformWarning(_R(IDW_FILEISWRONGVERSION));
01340             // flag the error state
01341             EPSFlags.EPSErrorEncountered = TRUE;
01342             // set the user has cancelled the error message so that this one is not reported
01343             Error::SetError(_R(IDN_USER_CANCELLED), 0);
01344 
01345             // We recokonised the token but it is invalid
01346             return TRUE;
01347         }
01348     }
01349     
01350     // Go and have a look at the token buffer and see if it is our special
01351     // compression comment
01352     if (camStrncmp(TokenBuf, _T("%%Compression:"), 14)==0)
01353     {
01354 //#ifdef STANDALONE
01355 //      // First release of the file viewer will not have the native file compression
01356 //      // loading code in. Therefore, we must abort if the compression tokens are
01357 //      // encountered.
01358 //      //if (FileVersionNumber < 0.500)
01359 //      InformWarning(_R(IDW_FILEISCOMPRESSED));
01360 //      // flag the error state
01361 //      EPSFlags.EPSErrorEncountered = TRUE;
01362 //      // set the user has cancelled the error message so that this one is not reported
01363 //      Error::SetError(_R(IDN_USER_CANCELLED), 0);
01364 //
01365 //      // We recokonised the token but it is invalid
01366 //      return TRUE;
01367 //#endif
01368         TCHAR* pType = &(((TCHAR*)TokenBuf)[14]);
01369         camSscanf(pType, _T("%d"), &CompressionType);
01370         TRACEUSER( "Neville", _T("CamelotNativeEPSFilter::ProcessFilterComment compression type %d\n"), CompressionType);
01371 
01372         // We have found our compression token so turn compression on
01373         BOOL ok = EPSFile->SetCompression(TRUE);
01374         if (!ok)
01375         {
01376             // We had a problem starting up the decompressor
01377             // flag the error state
01378             EPSFlags.EPSErrorEncountered = TRUE;
01379             // set up a useful error message, this one seems to say that we ran out of memory
01380             // and this is the most likely reason why
01381             Error::SetError(_R(IDT_EPS_NOMEMORY), 0);
01382             // We recokonised the token but it is invalid
01383             return TRUE;
01384         }
01385 
01386         return TRUE;
01387     }
01388     if (camStrncmp(TokenBuf, _T("%%Compression info:"), 19)==0)
01389     {
01390         TCHAR* pVersion = &(((TCHAR*)TokenBuf)[19]);
01391         double CompVersion=0.0;
01392         camSscanf(pVersion, _T("%lf"), &CompVersion);
01393         TRACEUSER( "Neville", _T("Compression version = %f\n"), CompVersion);
01394         double StreamVersion = GZipFile::GetStreamVersionNo();
01395         // If the version stored in the file is later than the one in the stream class
01396         // then we cannot cope with this data, so error.
01397         if (CompVersion > StreamVersion)
01398         {
01399             InformWarning(_R(IDW_FILEISCOMPRESSED));
01400             // flag the error state
01401             EPSFlags.EPSErrorEncountered = TRUE;
01402             // set the user has cancelled the error message so that this one is not reported
01403             Error::SetError(_R(IDN_USER_CANCELLED), 0);
01404             // We recokonised the token but it is invalid
01405             return TRUE;
01406         }
01407 
01408         return TRUE;
01409     }
01410     if (camStrncmp(TokenBuf, _T("%%EndCompression:"), 17)==0)
01411     {
01412         // We have found our compression token so turn compression on
01413         BOOL ok = EPSFile->SetCompression(FALSE);
01414         if (!ok)
01415         {
01416             // We had a problem stoping up the decompressor
01417             // flag the error state
01418             EPSFlags.EPSErrorEncountered = TRUE;
01419             // We will assume that an error has been set up. At present, the only one
01420             // most likely is a CRC error.
01421             // We recokonised the token but it is invalid
01422             return TRUE;
01423         }
01424 
01425         return TRUE;
01426     }
01427     if (camStrncmp(TokenBuf, _T("%%EndCompressionInfo:"), 21)==0)
01428     {
01429         return TRUE;
01430     }
01431       
01432     // Go and have a look at the token buffer and see if it looks like bitmap count
01433     if (camStrncmp(TokenBuf, _T("%%BitmapPoolCount"), 17)==0)
01434     {
01435         TCHAR* pCount = &(((TCHAR*)TokenBuf)[17]);
01436         camSscanf(pCount, _T("%d"), &BitmapCount);
01437         TRACEUSER( "Rik", _T("%d\n"), BitmapCount);
01438 
01439         // There are no bitmaps in this file
01440         if (BitmapCount==0)
01441             return TRUE;
01442 
01443         // Make sure that we have not already found one of these
01444         if (BitmapPoolRefs!=NULL)
01445             ERROR3("Bitmap Pool already in use!");
01446 
01447         // Allocate a few references to bitmaps
01448         BitmapPoolRefs = new KernelBitmapRef[BitmapCount];
01449         return TRUE;
01450     }
01451 
01452     // Check for any text comments
01453     if (camStrncmp(TokenBuf, _T("%%XSScript"), 10)==0)
01454     {
01455         TextComment[0]=2;
01456         return TRUE;
01457     }
01458 
01459     return FALSE;
01460 }

BOOL CamelotNativeEPSFilter::ProcessToken  )  [protected, virtual]
 

Deals with the current token. This function deals with tokens that are specific to the Camelot Native EPS format, or different from Camelot EPS.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/1/95
Returns:
TRUE if it was able to process the token, FALSE if not.

Reimplemented from CamelotEPSFilter.

Definition at line 434 of file nativeps.cpp.

00435 {
00436     ArrowRec    Arrow;
00437     double      ArrowWidth;
00438     double      ArrowHeight;
00439     INT32       ArrowID;
00440 
00441     DashRec     Dash;
00442     INT32       DashID;
00443     DashPatternAttribute* pDash;
00444 
00445     // Decode the command, and execute it...
00446     switch (Token)
00447     {
00448         // Bitmap Pool Token
00449         case EPSC_cbmp:
00450         {
00451             INT32 PoolType;
00452 
00453             // Find out what type of bitmap pool thing this is (currently 0 is only valid option)
00454             if ((!Stack.Pop(&PoolType)) || (PoolType!=0))
00455                 goto EPSError;
00456 
00457             // get the bitmap number
00458             if (!Stack.Pop(&PendingBitmapNum))
00459                 goto EPSError;
00460 
00461             // Next thing will be a pool item
00462             TRACEUSER( "Rik", _T("Got a Bitmap pool item....\n"));
00463             m_PendingBitmap = PENDING_BITMAP_POOLITEM;
00464             break;
00465         }
00466 
00467         // Stroke transparency
00468         case EPSC_cst:
00469             INT32 TranspType, Transp;
00470 
00471             // Get transparency type...
00472             if (!Stack.Pop(&TranspType))
00473                 goto EPSError;
00474 
00475             // Get line transparency value
00476             if (!Stack.Pop(&Transp))
00477                 goto EPSError;
00478 
00479             TRACEUSER( "Will", _T("Importing Line transp, Val=%d, Type=%d\n"),Transp, TranspType);
00480 
00481             if (!SetLineTransp((UINT32)TranspType, (UINT32)Transp))
00482                 goto NoMemory;
00483             break;
00484                               
00485         // Start Arrow head
00486         case EPSC_csah:
00487             if (!Stack.Pop(&ArrowHeight))
00488                 goto EPSError;
00489 
00490             if (!Stack.Pop(&ArrowWidth))
00491                 goto EPSError;
00492 
00493             if (!Stack.Pop(&ArrowID))
00494                 goto EPSError;
00495 
00496             TRACEUSER( "Will", _T("Importing StartArrow, ID=%d\n"),ArrowID);
00497             
00498             if (!Arrow.CreateStockArrow((StockArrow)ArrowID))
00499                 goto NoMemory;
00500 
00501             Arrow.SetArrowSize(FIXED16(ArrowWidth), FIXED16(ArrowHeight));
00502 
00503             if (!SetStartArrow(Arrow))
00504                 goto NoMemory;
00505             break;
00506 
00507         // End Arrow head
00508         case EPSC_ceah:
00509             if (!Stack.Pop(&ArrowHeight))
00510                 goto EPSError;
00511 
00512             if (!Stack.Pop(&ArrowWidth))
00513                 goto EPSError;
00514 
00515             if (!Stack.Pop(&ArrowID))
00516                 goto EPSError;
00517 
00518             TRACEUSER( "Will", _T("Importing EndArrow, ID=%d\n"),ArrowID);
00519             
00520             if (!Arrow.CreateStockArrow((StockArrow)ArrowID))
00521                 goto NoMemory;
00522 
00523             Arrow.SetArrowSize(FIXED16(ArrowWidth), FIXED16(ArrowHeight));
00524 
00525             if (!SetEndArrow(Arrow))
00526                 goto NoMemory;
00527             break;
00528 
00529         // Dash Patterns
00530         case EPSC_cdp:
00531             if (!Stack.Pop(&DashID))
00532                 goto EPSError;
00533 
00534             TRACEUSER( "Will", _T("Importing Dash Pattern, ID=%d\n"),DashID);
00535             
00536             pDash = new DashPatternAttribute;
00537             if (pDash == NULL)
00538                 goto NoMemory;
00539 
00540             if (!pDash->SetStockDashPattern((StockDash)DashID))
00541                 goto NoMemory;
00542 
00543             Dash = pDash->DashPattern;
00544             delete pDash;
00545 
00546             if (!SetDashPattern(Dash))
00547                 goto NoMemory;
00548             break;
00549 
00550         // Transparency fills.
00551         case EPSC_cxt:
00552         {
00553             DocCoord StartPoint, EndPoint, EndPoint2;
00554             INT32 StartTransp, EndTransp, TranspType;
00555             INT32 FillType;
00556             INT32 Tileable;
00557 
00558             // Used for fractal fills
00559             INT32 Seed;
00560             double Graininess, Gravity, Squash;
00561             UINT32 DPI;
00562 
00563             // Get fill type
00564             if (!Stack.Pop(&FillType))
00565                 goto EPSError;
00566 
00567             TRACEUSER( "Will", _T("Importing Transp Fill, Type=%d\n"),FillType);
00568 
00569             // Read in transparency type and levels...
00570             if (FillType != TRANSPFILL_NONE)
00571             {
00572                 // Get transparency type...
00573                 if (!Stack.Pop(&TranspType))
00574                     goto EPSError;
00575 
00576                 if ((FillType != TRANSPFILL_TEXTURE) && (FillType != TRANSPFILL_FRACTAL))
00577                 {           
00578                     // Get second transparency level if there is one.
00579                     switch (FillType)
00580                     {
00581                         case TRANSPFILL_LINEAR:
00582                         case TRANSPFILL_ELLIPTICAL:
00583                         case TRANSPFILL_CIRCULAR:
00584                         case TRANSPFILL_CONICAL:
00585                         case TRANSPFILL_NEWLINEAR:
00586                         case TRANSPFILL_NEWTEXTURE:
00587                         case TRANSPFILL_NEWFRACTAL:
00588                             if (!Stack.Pop(&EndTransp))
00589                                 goto EPSError;
00590                             break;
00591                     
00592                         default:
00593                             // This is a valid situation - no second transparency level.
00594                             break;
00595                     }
00596 
00597                     // Get first transparency level
00598                     if (!Stack.Pop(&StartTransp))
00599                         goto EPSError;
00600                 }
00601                 
00602             }
00603 
00604 
00605             if (FillType == TRANSPFILL_FRACTAL || FillType == TRANSPFILL_NEWFRACTAL)
00606             {
00607                 // If it's a fractal fill type, discard the 'sub-type' parameter (should 
00608                 // always be zero or one currently!)
00609                 INT32 SubType;
00610 
00611                 if (!Stack.Pop(&SubType))
00612                     goto EPSError;
00613 
00614                 // Default to no tiling
00615                 Tileable = FALSE;
00616 
00617                 // Work out the sub-type, either it has no tileable flag, or it does,
00618                 // or it's a type that is not supported.
00619                 if (SubType != 0)
00620                 {
00621                     if (SubType == 1)
00622                     {
00623                         // Get the tileable flag
00624                         if (!Stack.Pop(&Tileable))
00625                             goto EPSError;
00626                     }
00627                     else
00628                     {
00629                         ERROR2RAW("Bad fractal fill sub-type");
00630                         goto EPSError;
00631                     }
00632                 }
00633 
00634                 // Now get the fractal parameters:
00635                 if (!Stack.Pop(&DPI) ||
00636                     !Stack.Pop(&Squash) ||
00637                     !Stack.Pop(&Gravity) ||
00638                     !Stack.Pop(&Graininess) ||
00639                     !Stack.Pop(&Seed))
00640                 {
00641                     // Error in fractal parameteres
00642                     goto EPSError;
00643                 }
00644             }
00645 
00646             // For elliptical & texture/fractal fills, get the second end-point of the fill
00647             if ((FillType == TRANSPFILL_ELLIPTICAL) || 
00648                 (FillType == TRANSPFILL_TEXTURE) ||
00649                 (FillType == TRANSPFILL_FRACTAL) ||
00650                 (FillType == TRANSPFILL_NEWTEXTURE) ||
00651                 (FillType == TRANSPFILL_NEWFRACTAL) ||
00652                 (FillType == TRANSPFILL_NEWLINEAR))
00653             {
00654                 if (!Stack.PopCoordPair(&EndPoint2))
00655                     goto EPSError;
00656             }
00657             
00658             // Get start and end positions for variable transparency fills
00659             if ((FillType == TRANSPFILL_ELLIPTICAL) || 
00660                 (FillType == TRANSPFILL_CIRCULAR)   ||
00661                 (FillType == TRANSPFILL_LINEAR) ||
00662                 (FillType == TRANSPFILL_CONICAL)    ||
00663                 (FillType == TRANSPFILL_TEXTURE)    ||
00664                 (FillType == TRANSPFILL_FRACTAL)    ||
00665                 (FillType == TRANSPFILL_NEWLINEAR)  ||
00666                 (FillType == TRANSPFILL_NEWFRACTAL) ||
00667                 (FillType == TRANSPFILL_NEWTEXTURE))
00668             {
00669                 if (!Stack.PopCoordPair(&EndPoint) || !Stack.PopCoordPair(&StartPoint))
00670                     goto EPSError;
00671             }
00672 
00673             switch (FillType)
00674             {
00675                 // Decode Camelot EPS transparency fill codes
00676                 case TRANSPFILL_NONE:
00677                     if (!SetNoTranspFill())
00678                         goto NoMemory;
00679                     break;
00680 
00681                 case TRANSPFILL_FLAT:
00682                     if (!SetFlatTranspFill(TranspType, StartTransp))
00683                         goto NoMemory;
00684                     break;
00685 
00686                 case TRANSPFILL_LINEAR:
00687                     if (!SetLinearTranspFill(TranspType, StartTransp, EndTransp,
00688                                              StartPoint, EndPoint))
00689                         goto NoMemory;
00690                     break;
00691 
00692                 case TRANSPFILL_NEWLINEAR:
00693                     if (!SetLinearTranspFill(TranspType, StartTransp, EndTransp,
00694                                              StartPoint, EndPoint, &EndPoint2))
00695                         goto NoMemory;
00696                     break;
00697 
00698                 case TRANSPFILL_ELLIPTICAL:
00699                     if (!SetRadialTranspFill(TranspType, StartTransp, EndTransp,
00700                                              StartPoint, EndPoint, EndPoint2))
00701                         goto NoMemory;
00702                     break;
00703 
00704                 case TRANSPFILL_CIRCULAR:
00705                     if (!SetRadialTranspFill(TranspType, StartTransp, EndTransp,
00706                                              StartPoint, EndPoint))
00707                         goto NoMemory;
00708                     break;
00709 
00710                 case TRANSPFILL_CONICAL:
00711                     if (!SetConicalTranspFill(TranspType, StartTransp, EndTransp,
00712                                               StartPoint, EndPoint))
00713                         goto NoMemory;
00714                     break;
00715 
00716                 case TRANSPFILL_TEXTURE:
00717                     m_PendingBitmap = PENDING_BITMAP_TRANSPFILL;
00718                     BitmapAttrs.Coords[0] = StartPoint;
00719                     BitmapAttrs.Coords[1] = EndPoint;
00720                     BitmapAttrs.Coords[2] = EndPoint2;
00721                     BitmapAttrs.TranspType = TranspType;
00722                     BitmapAttrs.Transp      = 0;
00723                     BitmapAttrs.EndTransp   = 255;
00724                     break;
00725 
00726                 case TRANSPFILL_NEWTEXTURE:
00727                     m_PendingBitmap = PENDING_BITMAP_TRANSPFILL;
00728                     BitmapAttrs.Coords[0] = StartPoint;
00729                     BitmapAttrs.Coords[1] = EndPoint;
00730                     BitmapAttrs.Coords[2] = EndPoint2;
00731                     BitmapAttrs.TranspType = TranspType;
00732                     BitmapAttrs.Transp      = StartTransp;
00733                     BitmapAttrs.EndTransp   = EndTransp;
00734                     break;
00735 
00736                 case TRANSPFILL_FRACTAL:
00737                     if (!SetFractalTranspFill(TranspType, StartPoint, EndPoint, EndPoint2,
00738                                               Seed, Graininess, Gravity, Squash, DPI, 
00739                                               Tileable))
00740                         goto NoMemory;
00741                     break;
00742 
00743                 case TRANSPFILL_NEWFRACTAL:
00744                     if (!SetFractalTranspFill(TranspType, StartPoint, EndPoint, EndPoint2,
00745                                               Seed, Graininess, Gravity, Squash, DPI, 
00746                                               Tileable, StartTransp, EndTransp))
00747                         goto NoMemory;
00748                     break;
00749 
00750                 default:
00751                     ENSURE(FALSE, "Unknown fill type found!");
00752                     break;  // Don't know this fill type
00753             }
00754 
00755             break;
00756         }
00757 
00758         case EPSC_cxmt:
00759         {
00760             INT32 MappingType;
00761             INT32 Repeat;
00762 
00763             // Get fill mapping type (should always be 0)
00764             if (!Stack.Pop(&MappingType))
00765                 goto EPSError;
00766 
00767             if (MappingType != 0)
00768             {
00769                 ERROR2RAW("Bad mapping type in EPS");
00770                 goto EPSError;
00771             }
00772 
00773             // Get proper fill mapping type (should be 1, 2 or 3)
00774             if (!Stack.Pop(&Repeat))
00775                 goto EPSError;
00776 
00777             if ((Repeat < 1) || (Repeat > 3))
00778             {
00779                 ERROR2RAW("Bad mapping type in EPS");
00780                 goto EPSError;
00781             }
00782 
00783             // Call base class to use it
00784             if (Token == EPSC_cxm)
00785             {
00786                 if (!SetLinearFillMapping(Repeat))
00787                     goto NoMemory;
00788             }
00789             else
00790             {
00791                 if (!SetLinearTranspFillMapping(Repeat))
00792                     goto NoMemory;
00793             }
00794 
00795             break;
00796         }
00797 
00798         case EPSC_ctf:
00799         {
00800             // <FontName> ctf
00801             String_64 FName;
00802 
00803             if (!Stack.Pop(&FName))
00804                 goto EPSError;
00805             FName.SwapChar('-',' ');
00806 
00807             if ((FONTMANAGER->CacheNamedFont(&FName, EPSFilter::ClassOfFont) == ILLEGALFHANDLE))
00808                 goto EPSError;
00809 
00810             if (!SetTextTypeFace(&FName, EPSFilter::ClassOfFont))
00811                 goto EPSError;
00812 
00813             // Reset the font class to true type.
00814             EPSFilter::ClassOfFont = FC_TRUETYPE;
00815 
00816             break;
00817         }
00818 
00819         case EPSC_ctb:
00820         {
00821             // <0|1> ctb
00822             INT32 Bold;
00823             if (!Stack.Pop(&Bold))
00824                 goto EPSError;
00825 
00826             BOOL Boldon = (Bold==1);
00827             // Build any style definitions we need
00828             if (FontFlags.Bold)
00829             {
00830                 if (!SetTextBoldFont(Boldon))
00831                     goto EPSError;
00832             }
00833             else
00834             {
00835                 if (!SetTextBold(Boldon))
00836                     goto EPSError;
00837             }
00838             // Turn it off again
00839             FontFlags.Bold = FALSE;
00840             break;
00841         }           
00842 
00843         case EPSC_cti:
00844         {
00845             // <0|1> cti
00846             INT32 Italic;
00847             if (!Stack.Pop(&Italic))
00848                 goto EPSError;
00849 
00850             BOOL ItalicOn = (Italic==1);
00851             // Build any style definitions we need
00852             if (FontFlags.Italic)
00853             {
00854                 if (!SetTextItalicFont(ItalicOn))
00855                     goto EPSError;
00856             }
00857             else
00858             {
00859                 if (!SetTextItalic(ItalicOn))
00860                     goto EPSError;
00861             }
00862             FontFlags.Italic = FALSE;
00863             break;
00864         }           
00865 
00866         case EPSC_cts:
00867         {
00868             // <absolute millipoint rise> <absolute millipoint pointsize> cts
00869             INT32 rise,ptsize;
00870 
00871             if (!Stack.Pop(&ptsize))
00872                 goto EPSError;
00873                 
00874             if (!Stack.Pop(&rise))
00875                 goto EPSError;
00876 
00877             if (!SetTextScript(rise,ptsize))
00878                 goto EPSError;
00879 
00880             break;
00881         }
00882 
00883 
00884         case EPSC_ctp:
00885         {
00886             // <absolute millipoint size> ctp
00887             INT32 ptsize;
00888 
00889             if (!Stack.Pop(&ptsize))
00890                 goto EPSError;
00891 
00892             if (!SetTextSize(ptsize))
00893                 goto EPSError;
00894 
00895             break;
00896         }
00897 
00898         case EPSC_ctls:
00899         {
00900             INT32 type;
00901             if (!Stack.Pop(&type))
00902                 goto EPSError;
00903 
00904             switch (type)
00905             {
00906                 case 0:
00907                 {   
00908                     MILLIPOINT linespace;
00909                     if (!Stack.Pop(&linespace))
00910                         goto EPSError;
00911                     
00912                     if (!SetTextLineSpacing(1,0,linespace,0))
00913                         goto EPSError;
00914                     break;
00915                 }
00916 
00917                 case 1:
00918                 {
00919                     double proportional;
00920                     if (!Stack.Pop(&proportional))
00921                         goto EPSError;
00922 
00923                     if (!SetTextLineSpacing(2,0,0,proportional))
00924                         goto EPSError;
00925                     break;
00926                 }
00927             }
00928             break;
00929         }
00930 
00931         default:
00932             // Token not understood - pass on to base class
00933             return CamelotEPSFilter::ProcessToken();
00934     }
00935 
00936     // All seemed to work OK
00937     return TRUE;
00938 
00939 // Error handlers
00940 EPSError:
00941     HandleEPSError();
00942     return FALSE;
00943 
00944 NoMemory:
00945     HandleNoMemory();
00946     return FALSE;
00947 }

BOOL CamelotNativeEPSFilter::ReadBitmap  )  [protected, virtual]
 

Reads in a bitmap. If it is a Type 0 bitmap (ie one with all its data) it will ask the base class to import it. If it is a Type 1 bitmap it will look up the reference in the bitmap pool and use that.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/1/95
Returns:
TRUE if it worked, FALSE if it found an error

Reimplemented from CamelotEPSFilter.

Definition at line 1166 of file nativeps.cpp.

01167 {
01168     TRACEUSER( "Rik", _T("ReadBitmap...\n"));
01169     // Find out what kind of bitmap it is - always type 0 or 1 at present.
01170     INT32 BitmapType;
01171     if (!Stack.Pop(&BitmapType))
01172     {
01173         // Error - not enough operands
01174         HandleEPSError();
01175         return FALSE;
01176     }
01177 
01178     // if it is the old type 0 bitmap get the base class to do all the work
01179     if (BitmapType == 0)
01180     {
01181         // Need to push the type back on the stack again ready for the base class to read it
01182         TRACEUSER( "Rik", _T("Bitmap with data (in the pool I hope)\n"));
01183         Stack.Push(BitmapType);
01184         return CamelotEPSFilter::ReadBitmap();
01185     }
01186 
01187     // OK, see if we have a type we do not know about
01188     if (BitmapType != 1)
01189     {
01190         // Error - Bad Type
01191         HandleEPSError();
01192         return FALSE;
01193     }
01194     
01195     // Right, we have a type 1 bitmap....
01196     INT32 BitmapIndex = 0;
01197     
01198     // Read in info on the bitmap (ie, which bitmap from the pool do we want) ...
01199     if ((!Stack.Pop(&BitmapIndex)) /*|| (BitmapIndex >= BitmapCount)*/)
01200     {
01201         // Error - not enough operands
01202         HandleEPSError();
01203         return FALSE;
01204     }
01205 
01206     // ... and make sure that is in the range of bitmaps we have.
01207     // If the Index is out of range then use the Last one rather than just erroring.
01208     if (BitmapIndex >= BitmapCount)
01209         BitmapIndex = (BitmapCount-1);
01210 
01211     TRACEUSER( "Rik", _T("Bitmap reference found - refers to bitmap %d\n"), BitmapIndex);
01212 
01213     // Want to find bitmap 'BitmapIndex' and set pBitmap to point at it
01214     pBitmap = BitmapPoolRefs[BitmapIndex].GetBitmap();
01215     return TRUE;
01216 }

BOOL CamelotNativeEPSFilter::SetFileCompressionState BOOL  NewState  )  [protected, virtual]
 

Set a new file compression status into action.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/5/95
Parameters:
New state for file compression, TRUE if want on, FALSE if want off. [INPUTS]
Returns:
True if succesful or False if not.

Definition at line 359 of file nativeps.cpp.

00360 {
00361     TRACEUSER( "Neville", _T("CamelotNativeEPSFilter::SetFileCompressionState new state= %d\n"),NewState);
00362 
00363     CompressionOn = NewState;
00364 
00365     return TRUE;
00366 }

BOOL CamelotNativeEPSFilter::SetNativeCompression BOOL  NewState  )  [static]
 

Set the prefernece as to whether we are to compress the native files or not.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/5/95
Parameters:
New state for native file compression, TRUE if want on, FALSE if want off. [INPUTS]
Returns:
The old state of the compression.

Definition at line 322 of file nativeps.cpp.

00323 {
00324 //  BOOL OldState = CompressNative;
00325     CompressNative = NewState;
00326     return CompressNative;
00327 }

double CamelotNativeEPSFilter::SmartGetBuildNumber  ) 
 

Determines a monotomic build version number based on BuildVersionNumber which unfortunately jumps to v1.00/a/b/c/d but these are mapped back to real build numbers. v1.00/a/b/c/d all have BuildVersionNumbers of 1.00 and are all descended from an isolated liniage based on 0.586 so all map to this number Note: Only guaranteed for build versions greater than 0.586!

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/10/95
Returns:
Build version number

Definition at line 1677 of file nativeps.cpp.

01678 {
01679     double BuildNumber = GetBuildNumber();
01680     if (BuildNumber==1.00)
01681         BuildNumber = 0.586;
01682     return BuildNumber;
01683 }


Member Data Documentation

INT32 CamelotNativeEPSFilter::BitmapCount [protected]
 

Definition at line 174 of file nativeps.h.

KernelBitmapRef* CamelotNativeEPSFilter::BitmapPoolRefs [protected]
 

Definition at line 176 of file nativeps.h.

double CamelotNativeEPSFilter::BuildVersionNumber [protected]
 

Definition at line 192 of file nativeps.h.

BOOL CamelotNativeEPSFilter::CompressionOn [protected]
 

Definition at line 186 of file nativeps.h.

INT32 CamelotNativeEPSFilter::CompressionType [protected]
 

Definition at line 185 of file nativeps.h.

BOOL CamelotNativeEPSFilter::CompressNative = TRUE [static]
 

Flag for whether we compress the native files saved from Xara Studio. True means do compress the files.

Preference: CompressNative Section: Filters Range: 0 to 1

See also:
-

Definition at line 200 of file nativeps.h.

double CamelotNativeEPSFilter::FileVersionNumber [protected]
 

Definition at line 191 of file nativeps.h.

BOOL CamelotNativeEPSFilter::IsSavingBitmapPool
 

Definition at line 157 of file nativeps.h.

CommandMap CamelotNativeEPSFilter::NativeCommands [static, protected]
 

Initial value:

{
    
    { EPSC_cbmp,    _T("cbmp") },

    
    { EPSC_Invalid, _T("Invalid") }
}

Definition at line 182 of file nativeps.h.

BOOL CamelotNativeEPSFilter::OldImportWithLayers [protected]
 

Definition at line 179 of file nativeps.h.

INT32 CamelotNativeEPSFilter::OldMinLineWidth [protected]
 

Definition at line 194 of file nativeps.h.

BOOL CamelotNativeEPSFilter::OldOpenWithLayers [protected]
 

Definition at line 180 of file nativeps.h.

INT32 CamelotNativeEPSFilter::PendingBitmapNum [protected]
 

Definition at line 175 of file nativeps.h.


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