Back to index

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

List of all members.

Public Member Functions

 nsEPSObjectXp (const unsigned char *aData, unsigned long aDataLength)
 
Constructor
nsresult GetStatus ()
 

void GetBoundingBox (PRFloat64 &aBBllx, PRFloat64 &aBBlly, PRFloat64 &aBBurx, PRFloat64 &aBBury)
 
Return Bounding box coordinates: lower left x, lower left y, upper right x, upper right y.
void AppendTo (nsACString &aDestBuffer)
 
Append the EPS object to the provided string object.

Static Public Member Functions

static PRBool IsEPSF (const unsigned char *aData, unsigned long aDataLength)

Private Member Functions

void Parse ()
void Reset ()
PRBool EPSFFgets (nsACString &aBuffer)

Private Attributes

nsresult mStatus
const char * mData
unsigned long mDataLength
const char * mCurrPos
PRFloat64 mBBllx
PRFloat64 mBBlly
PRFloat64 mBBurx
PRFloat64 mBBury

Detailed Description

Definition at line 1509 of file nsXPrintContext.cpp.


Constructor & Destructor Documentation

nsEPSObjectXp::nsEPSObjectXp ( const unsigned char *  aData,
unsigned long  aDataLength 
) [inline]


Constructor

Definition at line 1514 of file nsXPrintContext.cpp.

                                                                           :
        mStatus(NS_ERROR_INVALID_ARG),
        mData(nsnull),
        mDataLength(0UL),
        mCurrPos(nsnull),
        mBBllx(0.0),
        mBBlly(0.0),
        mBBurx(0.0),
        mBBury(0.0)
      {
        mData       = NS_REINTERPRET_CAST(const char*, aData);
        mDataLength = aDataLength;

        NS_PRECONDITION(aData != nsnull,   "aData == nsnull");
        NS_PRECONDITION(aDataLength > 0UL, "No data");    

        Reset();
        Parse();
      }

Here is the call graph for this function:


Member Function Documentation

void nsEPSObjectXp::AppendTo ( nsACString &  aDestBuffer) [inline]


Append the EPS object to the provided string object.

Definition at line 1569 of file nsXPrintContext.cpp.

      {
        nsCAutoString line;
        PRBool        inPreview = PR_FALSE;

        Reset();
        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 */
          aDestBuffer.Append(line.get(), line.Length());
          aDestBuffer.Append(NS_LITERAL_CSTRING("\n"));
        }
      }

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsEPSObjectXp::EPSFFgets ( nsACString &  aBuffer) [inline, private]

Definition at line 1622 of file nsXPrintContext.cpp.

      {
        aBuffer.Truncate();
        
        if (!mCurrPos)
          return PR_FALSE;
        
        while (1) {
          int ch = *mCurrPos++;
          if ('\n' == ch) {
            /* Eat any following carriage return */
            ch = *mCurrPos++;
            if ((mCurrPos < (mData + mDataLength)) && ('\r' != ch))
              mCurrPos--;
            return PR_TRUE;
          }
          else if ('\r' == ch) {
            /* Eat any following line feed */
            ch = *mCurrPos++;
            if ((mCurrPos < (mData + mDataLength)) && ('\n' != ch))
              mCurrPos--;
            return PR_TRUE;
          }
          else if (mCurrPos >= (mData + mDataLength)) {
            /* 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:

void nsEPSObjectXp::GetBoundingBox ( PRFloat64 aBBllx,
PRFloat64 aBBlly,
PRFloat64 aBBurx,
PRFloat64 aBBury 
) [inline]


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

Definition at line 1555 of file nsXPrintContext.cpp.

      {
        aBBllx = mBBllx;
        aBBlly = mBBlly;
        aBBurx = mBBurx;
        aBBury = mBBury;
      };

Here is the caller graph for this function:


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 1549 of file nsXPrintContext.cpp.

{ return mStatus; };

Here is the caller graph for this function:

static PRBool nsEPSObjectXp::IsEPSF ( const unsigned char *  aData,
unsigned long  aDataLength 
) [inline, static]

Definition at line 1535 of file nsXPrintContext.cpp.

      {
        /* First line (assuming a single line of PostScript line is not longer
         * than 256 chars) should usually look like "%!PS-Adobe-3.0 EPSF-3.0"
         * (version numbers may be different) */
        return (PL_strnstr(NS_REINTERPRET_CAST(const char*, aData), " EPSF-", PR_MIN(aDataLength, 256)) != nsnull);
      }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsEPSObjectXp::Parse ( ) [inline, private]

Definition at line 1602 of file nsXPrintContext.cpp.

      {
        nsCAutoString line;

        Reset();   
        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:

void nsEPSObjectXp::Reset ( void  ) [inline, private]

Definition at line 1617 of file nsXPrintContext.cpp.

      {
        mCurrPos = mData;
      }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1597 of file nsXPrintContext.cpp.

Definition at line 1597 of file nsXPrintContext.cpp.

Definition at line 1597 of file nsXPrintContext.cpp.

Definition at line 1597 of file nsXPrintContext.cpp.

const char* nsEPSObjectXp::mCurrPos [private]

Definition at line 1596 of file nsXPrintContext.cpp.

const char* nsEPSObjectXp::mData [private]

Definition at line 1594 of file nsXPrintContext.cpp.

unsigned long nsEPSObjectXp::mDataLength [private]

Definition at line 1595 of file nsXPrintContext.cpp.

Definition at line 1593 of file nsXPrintContext.cpp.


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