Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsEPSObjectPS Class Reference

#include <nsEPSObjectPS.h>

List of all members.

Public Member Functions

 nsEPSObjectPS (FILE *aFile)
 
Constructor
nsresult GetStatus ()
 

PRFloat64 GetBoundingBoxLLX ()
 
Return Bounding box coordinates: lower left x, lower left y, upper right x, upper right y.
PRFloat64 GetBoundingBoxLLY ()
PRFloat64 GetBoundingBoxURX ()
PRFloat64 GetBoundingBoxURY ()
nsresult WriteTo (FILE *aDest)
 
Write the EPS object to the provided file stream.

Private Member Functions

void Parse ()
 
Parse the EPSF and initialize the object accordingly.
PRBool EPSFFgets (nsACString &aBuffer)
 
Read one line from the file handle into the buffer, following rules for EPS data.

Private Attributes

nsresult mStatus
FILEmEPSF
PRFloat64 mBBllx
PRFloat64 mBBlly
PRFloat64 mBBurx
PRFloat64 mBBury

Detailed Description

Definition at line 49 of file nsEPSObjectPS.h.


Constructor & Destructor Documentation


Constructor

Definition at line 55 of file nsEPSObjectPS.cpp.

                                        :
  mStatus(NS_ERROR_INVALID_ARG),
  mEPSF(aFile),
  mBBllx(0.0),
  mBBlly(0.0),
  mBBurx(0.0),
  mBBury(0.0)
{
  NS_PRECONDITION(aFile != nsnull,   "aFile == nsnull");
  NS_PRECONDITION(0 == fseek(aFile, 0L, SEEK_SET), "File isn't seekable");    
  Parse();
}

Here is the call graph for this function:


Member Function Documentation

PRBool nsEPSObjectPS::EPSFFgets ( nsACString &  aBuffer) [private]


Read one line from the file handle into the buffer, following rules for EPS data.

The line terminator is not copied into the buffer.

EPS file lines must be less than 256 characters, not including line terminators. Lines may be terminated by CR, LF, CRLF, or LFCR. See EPSF spec, section 2.9, "Miscellaneous Constraints".

Parameters:
aBufferBuffer in which to place the EPSF text.
aBufSizSize of aBuffer
aSrcFILE opened for reading
Returns:
PR_TRUE if a line could be read into aBuffer successfully. PR_FALSE if EOF or an I/O error was encountered without reading any data, or if the line being read is too large for the buffer.

Definition at line 86 of file nsEPSObjectPS.cpp.

{
  aBuffer.Truncate();
  while (1) {
    int ch = getc(mEPSF);
    if ('\n' == ch) {
      /* Eat any following carriage return */
      ch = getc(mEPSF);
      if ((EOF != ch) && ('\r' != ch))
        ungetc(ch, mEPSF);
      return PR_TRUE;
    }
    else if ('\r' == ch) {
      /* Eat any following line feed */
      ch = getc(mEPSF);
      if ((EOF != ch) && ('\n' != ch))
        ungetc(ch, mEPSF);
      return PR_TRUE;
    }
    else if (EOF == ch) {
      /* If we read any text before the EOF, return true. */
      return !aBuffer.IsEmpty();
    }

    /* Normal case */
    aBuffer.Append((char)ch);
  }
}

Here is the caller graph for this function:


Return Bounding box coordinates: lower left x, lower left y, upper right x, upper right y.

Definition at line 67 of file nsEPSObjectPS.h.

{ return mBBllx; };

Definition at line 68 of file nsEPSObjectPS.h.

{ return mBBlly; };

Definition at line 69 of file nsEPSObjectPS.h.

{ return mBBurx; };

Definition at line 70 of file nsEPSObjectPS.h.

{ return mBBury; };


Returns:
the result code from parsing the EPS data. If the return value is not NS_OK, the EPS object is invalid and should not be used further.

Definition at line 61 of file nsEPSObjectPS.h.

{ return mStatus; };

Here is the caller graph for this function:

void nsEPSObjectPS::Parse ( ) [private]


Parse the EPSF and initialize the object accordingly.

Definition at line 121 of file nsEPSObjectPS.cpp.

{
  nsCAutoString line;

  NS_PRECONDITION(nsnull != mEPSF, "No file");

  rewind(mEPSF);
  while (EPSFFgets(line)) {
    if (PR_sscanf(line.get(), "%%%%BoundingBox: %lf %lf %lf %lf",
                  &mBBllx, &mBBlly, &mBBurx, &mBBury) == 4) {
      mStatus = NS_OK;
      return;
    }
  }
  mStatus = NS_ERROR_INVALID_ARG;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Write the EPS object to the provided file stream.


Write the EPSF to the specified file handle.

Returns:
NS_OK if the EPS was written successfully, or a suitable error code.
NS_OK if the entire EPSF was written without error, or else a suitable error code.

Definition at line 145 of file nsEPSObjectPS.cpp.

{
  NS_PRECONDITION(NS_SUCCEEDED(mStatus), "Bad status");

  nsCAutoString line;
  PRBool        inPreview = PR_FALSE;

  rewind(mEPSF);
  while (EPSFFgets(line)) {
    if (inPreview) {
      /* filter out the print-preview section */
      if (StringBeginsWith(line, NS_LITERAL_CSTRING("%%EndPreview")))
          inPreview = PR_FALSE;
      continue;
    }
    else if (StringBeginsWith(line, NS_LITERAL_CSTRING("%%BeginPreview:"))){
      inPreview = PR_TRUE;
      continue;
    }

    /* Output the EPSF with this platform's line terminator */
    fwrite(line.get(), line.Length(), 1, aDest);
    putc('\n', aDest);
  }
  return NS_OK;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 82 of file nsEPSObjectPS.h.

Definition at line 82 of file nsEPSObjectPS.h.

Definition at line 82 of file nsEPSObjectPS.h.

Definition at line 82 of file nsEPSObjectPS.h.

Definition at line 81 of file nsEPSObjectPS.h.

Definition at line 80 of file nsEPSObjectPS.h.


The documentation for this class was generated from the following files: