EPSExportDC Class Reference

Provide a device context for rendering to an EPS file. More...

#include <saveeps.h>

Inheritance diagram for EPSExportDC:

ExportDC KernelDC CCDummyDC CCDC ListItem CCObject SimpleCCObject NativeExportDC List of all members.

Public Member Functions

 EPSExportDC (Filter *)
 Initialise a DC for exporting EPS.
BOOL Init (CCLexFile *)
 Calls the base class Init function and then sets up the DC to throw exceptions when it gets errors as that is how the EPS stuff expects errors to be reported.
virtual BOOL OutputNewLine ()
 Causes a new line to be started in the EPS output file. This is used to give a pleasant appearance to the EPS file - most EPS commands (as opposed to operands) are followed by a new line.
virtual BOOL OutputToken (TCHAR *)
 Outputs a string token to the EPS file. This is the central routine through which the other high-level routines eventually come. The other routines convert their output to a string, which theythen pass on to this routine. A record is kept of the current line width - if it is over 70 characters wide before the token is output, then a new line is output to keep the lines in the EPS file reasonably short. For this reason, it is important not to output strings that contain newline characters, because this routine will not notice, and hence the LineWidth count will be wrong. This routine also ensures that tokens are separated by either a space or a newline, so it is not necessary to output spaces directly to keep the tokens separate - it happens automatically.
virtual BOOL OutputDirect (BYTE *, INT32)
 Send bytes directly to the PostScript stream with no alteration or padding. Used for sending binary/hex data to stream.

Detailed Description

Provide a device context for rendering to an EPS file.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/94
See also:
ExportDC; EPSFilter

Definition at line 280 of file saveeps.h.


Constructor & Destructor Documentation

EPSExportDC::EPSExportDC Filter Parent  ) 
 

Initialise a DC for exporting EPS.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/94
Parameters:
The filter object associated with this export DC. [INPUTS]

Definition at line 2611 of file saveeps.cpp.

02611                                        : ExportDC(Parent)
02612 {
02613 }


Member Function Documentation

BOOL EPSExportDC::Init CCLexFile pFile  ) 
 

Calls the base class Init function and then sets up the DC to throw exceptions when it gets errors as that is how the EPS stuff expects errors to be reported.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/2/95
Parameters:
pFile - The file to attach to the DC [INPUTS]
Returns:
TRUE if all went well, FALSE if not
See also:
ExportDC::Init

Reimplemented from ExportDC.

Definition at line 2631 of file saveeps.cpp.

02632 {
02633     // First get the base class to do its thing
02634     if (!ExportDC::Init(pFile)) return FALSE;
02635 
02636     // now do what I want done.
02637     // We want export files to throw exceptions, and not report errors.
02638     ExportFile->SetThrowExceptions(TRUE);
02639     ExportFile->SetReportErrors(FALSE);
02640     return TRUE;
02641 }

BOOL EPSExportDC::OutputDirect BYTE *  Buf,
INT32  nBytes
[virtual]
 

Send bytes directly to the PostScript stream with no alteration or padding. Used for sending binary/hex data to stream.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/23/95
Parameters:
Buf - the bytes to send to the stream. [INPUTS] nBytes - the number of bytes to send to the stream.
Returns:
TRUE if all the bytes were sent ok; FALSE if not.
See also:
KernelDC::OutputNewLine; KernelDC::OutputToken

Reimplemented from KernelDC.

Definition at line 2755 of file saveeps.cpp.

02756 {
02757     if (ExportFile->write(Buf, nBytes).fail())
02758     {
02759         // Error
02760         return FALSE;
02761     }
02762 
02763     // All ok
02764     return TRUE;
02765 }

BOOL EPSExportDC::OutputNewLine  )  [virtual]
 

Causes a new line to be started in the EPS output file. This is used to give a pleasant appearance to the EPS file - most EPS commands (as opposed to operands) are followed by a new line.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/94
Returns:
TRUE if the data was written ok; FALSE if not => ERROR1
See also:
EPSExportDC; EPSExportDC::OutputToken
Returns:
Errors: Disk/file error => ERROR1

Reimplemented from KernelDC.

Definition at line 2661 of file saveeps.cpp.

02662 {
02663     // Graeme (22-2-00) - Windows uses \r\n as the newline code in its files.
02664     static TCHAR NewLine[] = _T("\r\n");
02665     if (!OutputTCHARAsChar(NewLine, 2))
02666         // Error occured
02667         return FALSE;
02668 
02669     LineWidth = 0;
02670 
02671     // Success
02672     return TRUE;
02673 }

BOOL EPSExportDC::OutputToken TCHAR Str  )  [virtual]
 

Outputs a string token to the EPS file. This is the central routine through which the other high-level routines eventually come. The other routines convert their output to a string, which theythen pass on to this routine. A record is kept of the current line width - if it is over 70 characters wide before the token is output, then a new line is output to keep the lines in the EPS file reasonably short. For this reason, it is important not to output strings that contain newline characters, because this routine will not notice, and hence the LineWidth count will be wrong. This routine also ensures that tokens are separated by either a space or a newline, so it is not necessary to output spaces directly to keep the tokens separate - it happens automatically.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/03/94
Parameters:
Str - the character string to write to the file. [INPUTS]
Returns:
TRUE if the data was written ok; FALSE if not => ERROR1
See also:
EPSExportDC
Returns:
Errors: Disk/file error => ERROR1

Reimplemented from KernelDC.

Definition at line 2702 of file saveeps.cpp.

02703 {
02704     // Special tokens
02705     static TCHAR Space = _T(' ');
02706 
02707     if (LineWidth > 100)
02708     {
02709         // (ChrisG 8/12/00) We now have only one way of writing a newline out. The old method
02710         //  used "/n/r" to write a newline, which doesn't work, while OutputNewLine used "/r/n",
02711         //  which does, Also the max line width has been expanded to 100 characters.
02712         if (OutputNewLine () == FALSE)
02713             // Error
02714             return FALSE;
02715     }
02716 
02717     // Pad with a space (unless at the beginning of the line)
02718     if (LineWidth > 0)
02719     {
02720         if (!OutputTCHARAsChar(&Space, 1))
02721             // Error
02722             return FALSE;
02723         LineWidth++;
02724     }
02725 
02726     // Write the token out to the file
02727     INT32 Len = camStrlen(Str);
02728     if (!OutputTCHARAsChar(Str, Len))
02729         // Error
02730         return FALSE;
02731 
02732     LineWidth += Len;
02733 
02734     // Success
02735     return TRUE;
02736 }


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