Back to index

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

#include <nsDeviceContextSpecOS2.h>

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

List of all members.

Public Member Functions

 nsDeviceContextSpecOS2 ()
 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 ClosePrintManager ()
 
Closes the printmanager if it is open.
NS_IMETHOD GetDestination (int &aDestination)
NS_IMETHOD GetPrinterName (char **aPrinter)
NS_IMETHOD GetCopies (int &aCopies)
NS_IMETHOD GetPath (char **aPath)
NS_IMETHOD GetUserCancelled (PRBool &aCancel)
NS_IMETHOD GetPRTQUEUE (PRTQUEUE *&p)
virtual ~nsDeviceContextSpecOS2 ()
 Destuct a nsDeviceContextSpecMac, this will release the printrecord dc 2/16/98.

Static Public Member Functions

static nsresult SetPrintSettingsFromDevMode (nsIPrintSettings *aPrintSettings, ULONG printer)

Static Public Attributes

static PRINTDLG PrnDlg

Protected Attributes

OS2PrData mPrData
PRTQUEUEmQueue
nsCOMPtr< nsIPrintSettingsmPrintSettings

Detailed Description

Definition at line 113 of file nsDeviceContextSpecOS2.h.


Constructor & Destructor Documentation

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


Construct the nsDeviceContextSpecOS2 dc 12/02/98

Definition at line 95 of file nsDeviceContextSpecOS2.cpp.

{
  mQueue = nsnull;
}

Destuct a nsDeviceContextSpecMac, this will release the printrecord dc 2/16/98.


Destroy the nsDeviceContextSpecOS2 dc 2/15/98

Definition at line 104 of file nsDeviceContextSpecOS2.cpp.

Here is the call graph for this function:


Member Function Documentation


Closes the printmanager if it is open.

dc 2/15/98

Definition at line 387 of file nsDeviceContextSpecOS2.cpp.

{
  return NS_OK;
}

Definition at line 365 of file nsDeviceContextSpecOS2.cpp.

{
   aCopies = mPrData.copies;
   return NS_OK;
}

Definition at line 353 of file nsDeviceContextSpecOS2.cpp.

{
  aDestination = mPrData.destination;
  return NS_OK;
}

Definition at line 371 of file nsDeviceContextSpecOS2.cpp.

{
  *aPath = &mPrData.path[0];
  return NS_OK;
}

Definition at line 359 of file nsDeviceContextSpecOS2.cpp.

{
   *aPrinter = &mPrData.printer[0];
   return NS_OK;
}

Definition at line 392 of file nsDeviceContextSpecOS2.cpp.

{
   p = mQueue;
   return NS_OK;
}

Definition at line 377 of file nsDeviceContextSpecOS2.cpp.

{
  aCancel = mPrData.cancel;
  return NS_OK;
}

Initialize the nsDeviceContextSpecMac for use.


Initialize the nsDeviceContextSpecOS2 dc 2/15/98 syd 3/2/99

This will allocate a printrecord for use dc 2/16/98

Parameters:
aIsPrintPreviewif PR_TRUE, creating Spec for PrintPreview
Returns:
error status

gisburn: Please note that this function exists as 1:1 copy in other toolkits including:

** Please update the other toolkits when changing this function.

Definition at line 283 of file nsDeviceContextSpecOS2.cpp.

{
  nsresult rv = NS_ERROR_FAILURE;

  mPrintSettings = aPS;
  NS_ASSERTION(aPS, "Must have a PrintSettings!");

  rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
  if (NS_FAILED(rv)) {
    return rv;
  }
 
  if (aPS) {
    PRBool     tofile         = PR_FALSE;
    PRInt32    copies         = 1;
    PRUnichar *printer        = nsnull;
    PRUnichar *printfile      = nsnull;

    mPrintSettings->GetPrinterName(&printer);
    mPrintSettings->GetToFileName(&printfile);
    mPrintSettings->GetPrintToFile(&tofile);
    mPrintSettings->GetNumCopies(&copies);

    if ((copies == 0)  ||  (copies > 999)) {
       GlobalPrinters::GetInstance()->FreeGlobalPrinters();
       return NS_ERROR_FAILURE;
    }

    if (printfile != nsnull) {
      // ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
      strcpy(mPrData.path,    NS_ConvertUCS2toUTF8(printfile).get());
    }
    if (printer != nsnull) 
      strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());  

    if (aIsPrintPreview) 
      mPrData.destination = printPreview; 
    else if (tofile)  
      mPrData.destination = printToFile;
    else  
      mPrData.destination = printToPrinter;
    mPrData.copies = copies;

    rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
    if (NS_FAILED(rv))
      return rv;

    const nsAFlatString& printerUCS2 = NS_ConvertUTF8toUCS2(mPrData.printer);
    ULONG numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
    if (numPrinters) {
       for(ULONG i = 0; (i < numPrinters) && !mQueue; i++) {
          if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(printerUCS2, nsCaseInsensitiveStringComparator()))) {
             SetupDevModeFromSettings(i, aPS);
             mQueue = PrnDlg.SetPrinterQueue(i);
          }
       }
    }

    if (printfile != nsnull) 
      nsMemory::Free(printfile);
  
    if (printer != nsnull) 
      nsMemory::Free(printer);
  }

  GlobalPrinters::GetInstance()->FreeGlobalPrinters();
  return rv;
}

Here is the call graph for this function:

Definition at line 164 of file nsDeviceContextSpecOS2.cpp.

{
  if (aPrintSettings == nsnull)
    return NS_ERROR_FAILURE;

  int bufferSize = 3 * sizeof(DJP_ITEM);
  PBYTE pDJP_Buffer = new BYTE[bufferSize];
  memset(pDJP_Buffer, 0, bufferSize);
  PDJP_ITEM pDJP = (PDJP_ITEM) pDJP_Buffer;

  HDC hdc = nsDeviceContextSpecOS2::PrnDlg.GetDCHandle(printer);

  //Get Number of Copies from Job Properties
  pDJP->lType = DJP_CURRENT;
  pDJP->cb = sizeof(DJP_ITEM);
  pDJP->ulNumReturned = 1;
  pDJP->ulProperty = DJP_SJ_COPIES;
  pDJP->ulValue = 1;
  pDJP++;

  //Get Orientation from Job Properties
  pDJP->lType = DJP_CURRENT;
  pDJP->cb = sizeof(DJP_ITEM);
  pDJP->ulNumReturned = 1;
  pDJP->ulProperty = DJP_SJ_ORIENTATION;
  pDJP->ulValue = 1;
  pDJP++;

  pDJP->lType = DJP_NONE;
  pDJP->cb = sizeof(DJP_ITEM);
  pDJP->ulNumReturned = 1;
  pDJP->ulProperty = 0;
  pDJP->ulValue = 0;

  LONG driverSize = nsDeviceContextSpecOS2::PrnDlg.GetPrintDriverSize(printer);
  LONG rc = GreEscape(hdc, DEVESC_QUERYJOBPROPERTIES, bufferSize, pDJP_Buffer, 
                      &driverSize, PBYTE(nsDeviceContextSpecOS2::PrnDlg.GetPrintDriver(printer)));

  pDJP = (PDJP_ITEM) pDJP_Buffer;
  if ((rc == DEV_OK) || (rc == DEV_WARNING)) { 
    while (pDJP->lType != DJP_NONE) {
      if ((pDJP->ulProperty == DJP_SJ_ORIENTATION) && (pDJP->lType > 0)){
        if ((pDJP->ulValue == DJP_ORI_PORTRAIT) || (pDJP->ulValue == DJP_ORI_REV_PORTRAIT))
          aPrintSettings->SetOrientation(nsIPrintSettings::kPortraitOrientation);
        else
         aPrintSettings->SetOrientation(nsIPrintSettings::kLandscapeOrientation);
      }
      if ((pDJP->ulProperty == DJP_SJ_COPIES) && (pDJP->lType > 0)){
        aPrintSettings->SetNumCopies(PRInt32(pDJP->ulValue));
      }
      pDJP = DJP_NEXT_STRUCTP(pDJP);
    }
  }
  
  delete [] pDJP_Buffer;
  DevCloseDC(hdc);  
  return NS_OK;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 160 of file nsDeviceContextSpecOS2.h.

Definition at line 162 of file nsDeviceContextSpecOS2.h.

Definition at line 161 of file nsDeviceContextSpecOS2.h.

Definition at line 155 of file nsDeviceContextSpecOS2.h.


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