Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
nsDeviceContextSpecX Class Reference

#include <nsDeviceContextSpecX.h>

Inheritance diagram for nsDeviceContextSpecX:
Inheritance graph
[legend]
Collaboration diagram for nsDeviceContextSpecX:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsDeviceContextSpecX ()
 Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord dc 12/02/98.
NS_DECL_ISUPPORTS NS_IMETHOD Init (nsIPrintSettings *aPS, PRBool aIsPrintPreview)
 Initialize the nsDeviceContextSpecMac for use.
NS_IMETHOD PrintManagerOpen (PRBool *aIsOpen)
 This will tell if the printmanager is currently open dc 12/03/98.
NS_IMETHOD ClosePrintManager ()
 Closes the printmanager if it is open.
NS_IMETHOD BeginDocument (PRUnichar *aTitle, PRUnichar *aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
NS_IMETHOD EndDocument ()
NS_IMETHOD AbortDocument ()
NS_IMETHOD BeginPage ()
NS_IMETHOD EndPage ()
NS_IMETHOD GetPrinterResolution (double *aResolution)
NS_IMETHOD GetPageRect (double *aTop, double *aLeft, double *aBottom, double *aRight)

Protected Member Functions

virtual ~nsDeviceContextSpecX ()
 Destuct a nsDeviceContextSpecMac, this will release the printrecord dc 12/02/98.

Protected Attributes

PMPrintSession mPrintSession
PMPageFormat mPageFormat
PMPrintSettings mPrintSettings
CGrafPtr mSavedPort
PRBool mBeganPrinting

Detailed Description

Definition at line 48 of file nsDeviceContextSpecX.h.


Constructor & Destructor Documentation

Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord dc 12/02/98.


Construct the nsDeviceContextSpecX dc 12/02/98

Definition at line 55 of file nsDeviceContextSpecX.cpp.

: mPrintSession(0)
, mPageFormat(kPMNoPageFormat)
, mPrintSettings(kPMNoPrintSettings)
, mSavedPort(0)
, mBeganPrinting(PR_FALSE)
{
}

Destuct a nsDeviceContextSpecMac, this will release the printrecord dc 12/02/98.


Destroy the nsDeviceContextSpecX dc 12/02/98

Definition at line 68 of file nsDeviceContextSpecX.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 146 of file nsDeviceContextSpecX.cpp.

{
    return EndDocument();
}

Here is the call graph for this function:

NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument ( PRUnichar aTitle,
PRUnichar aPrintToFileName,
PRInt32  aStartPage,
PRInt32  aEndPage 
) [virtual]

Implements nsIPrintingContext.

Definition at line 115 of file nsDeviceContextSpecX.cpp.

{
    if (aTitle) {
      CFStringRef cfString = ::CFStringCreateWithCharacters(NULL, aTitle, nsCRT::strlen(aTitle));
      if (cfString) {
        ::PMSetJobNameCFString(mPrintSettings, cfString);
        ::CFRelease(cfString);
      }
    }

    OSStatus status;
    status = ::PMSetFirstPage(mPrintSettings, aStartPage, false);
    NS_ASSERTION(status == noErr, "PMSetFirstPage failed");
    status = ::PMSetLastPage(mPrintSettings, aEndPage, false);
    NS_ASSERTION(status == noErr, "PMSetLastPage failed");

    status = ::PMSessionBeginDocument(mPrintSession, mPrintSettings, mPageFormat);
    if (status != noErr) return NS_ERROR_ABORT;
    
    return NS_OK;
}

Here is the call graph for this function:

Implements nsIPrintingContext.

Definition at line 151 of file nsDeviceContextSpecX.cpp.

{
    OSStatus status = ::PMSessionBeginPage(mPrintSession, mPageFormat, NULL);
    if (status != noErr) return NS_ERROR_ABORT;
    
    ::GetPort(&mSavedPort);
    void *graphicsContext;
    status = ::PMSessionGetGraphicsContext(mPrintSession, kPMGraphicsContextQuickdraw, &graphicsContext);
    if (status != noErr)
      return NS_ERROR_ABORT;
    ::SetPort((CGrafPtr)graphicsContext);
    return NS_OK;
}

Here is the call graph for this function:

Closes the printmanager if it is open.


Closes the printmanager if it is open.

dc 12/03/98

Returns:
error status

dc 12/03/98

Implements nsIPrintingContext.

Definition at line 110 of file nsDeviceContextSpecX.cpp.

{
       return NS_OK;
}  

Here is the caller graph for this function:

Implements nsIPrintingContext.

Definition at line 140 of file nsDeviceContextSpecX.cpp.

{
    ::PMSessionEndDocument(mPrintSession);
    return NS_OK;
}

Here is the caller graph for this function:

Implements nsIPrintingContext.

Definition at line 165 of file nsDeviceContextSpecX.cpp.

{
    OSStatus status = ::PMSessionEndPage(mPrintSession);
    if (mSavedPort)
    {
        ::SetPort(mSavedPort);
        mSavedPort = 0;
    }
    if (status != noErr)
      return NS_ERROR_ABORT;
    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsDeviceContextSpecX::GetPageRect ( double *  aTop,
double *  aLeft,
double *  aBottom,
double *  aRight 
) [virtual]

Implements nsIPrintingContext.

Definition at line 194 of file nsDeviceContextSpecX.cpp.

{
    PMRect pageRect;
    ::PMGetAdjustedPageRect(mPageFormat, &pageRect);
    *aTop = pageRect.top, *aLeft = pageRect.left;
    *aBottom = pageRect.bottom, *aRight = pageRect.right;
    return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecX::GetPrinterResolution ( double *  aResolution) [virtual]

Implements nsIPrintingContext.

Definition at line 178 of file nsDeviceContextSpecX.cpp.

{
    PMPrinter printer;
    OSStatus status = ::PMSessionGetCurrentPrinter(mPrintSession, &printer);
    if (status != noErr)
      return NS_ERROR_FAILURE;
      
    PMResolution defaultResolution;
    status = ::PMPrinterGetPrinterResolution(printer, kPMDefaultResolution, &defaultResolution);
    if (status != noErr)
      return NS_ERROR_FAILURE;
    
    *aResolution = defaultResolution.hRes;
    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsDeviceContextSpecX::Init ( nsIPrintSettings aPS,
PRBool  aIsPrintPreview 
) [virtual]

Initialize the nsDeviceContextSpecMac for use.


Initialize the nsDeviceContextSpecMac dc 12/02/98

This will allocate a printrecord for use dc 12/02/98

Parameters:
aIsPrintPreviewTRUE if doing print preview, FALSE if normal printing.
Returns:
error status

Implements nsIPrintingContext.

Definition at line 79 of file nsDeviceContextSpecX.cpp.

{
  nsresult rv;
    
  nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
  if (!printSettingsX)
    return NS_ERROR_NO_INTERFACE;
  
  rv = printSettingsX->GetNativePrintSession(&mPrintSession);
  if (NS_FAILED(rv))
    return rv;  
  rv = printSettingsX->GetPMPageFormat(&mPageFormat);
  if (NS_FAILED(rv))
    return rv;
  rv = printSettingsX->GetPMPrintSettings(&mPrintSettings);
  if (NS_FAILED(rv))
    return rv;

  return NS_OK;
}

Here is the call graph for this function:

This will tell if the printmanager is currently open dc 12/03/98.

Parameters:
aIsOpenTrue or False depending if the printmanager is open
Returns:
error status

Implements nsIPrintingContext.

Definition at line 100 of file nsDeviceContextSpecX.cpp.

{
    *aIsOpen = mBeganPrinting;
    return NS_OK;
}

Member Data Documentation

Definition at line 111 of file nsDeviceContextSpecX.h.

PMPageFormat nsDeviceContextSpecX::mPageFormat [protected]

Definition at line 108 of file nsDeviceContextSpecX.h.

PMPrintSession nsDeviceContextSpecX::mPrintSession [protected]

Definition at line 107 of file nsDeviceContextSpecX.h.

PMPrintSettings nsDeviceContextSpecX::mPrintSettings [protected]

Definition at line 109 of file nsDeviceContextSpecX.h.

Definition at line 110 of file nsDeviceContextSpecX.h.


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