Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsDeviceContextSpecOS2.cpp File Reference
#include <stdlib.h>
#include "nsDeviceContextSpecOS2.h"
#include "nsReadableUtils.h"
#include "nsISupportsArray.h"
#include "nsIPref.h"
#include "prenv.h"
#include "nsPrintfCString.h"
#include "nsIServiceManager.h"
#include "nsUnicharUtils.h"
#include "nsStringFwd.h"
#include "nsOS2Uni.h"

Go to the source code of this file.

Classes

class  GlobalPrinters
class  PRTQUEUE

Defines

#define SHIFT_PTR(ptr, offset)   ( *((LONG*)&ptr) += offset )

Functions

static NS_DEFINE_IID (kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID)
void SetupDevModeFromSettings (ULONG printer, nsIPrintSettings *aPrintSettings)
HDC PrnOpenDC (PRTQUEUE *pInfo, PSZ pszApplicationName, int copies, int destination, char *file)
BOOL PrnQueryHardcopyCaps (HDC hdc, PHCINFO pHCInfo)
BOOL PrnInitialize (HMODULE hmodResources)
BOOL PrnTerminate ()
BOOL PrnClosePrinter (PRTQUEUE *pPrintQueue)

Variables

static HMODULE hmodRes

Define Documentation

#define SHIFT_PTR (   ptr,
  offset 
)    ( *((LONG*)&ptr) += offset )

Definition at line 593 of file nsDeviceContextSpecOS2.cpp.


Function Documentation

static NS_DEFINE_IID ( kIDeviceContextSpecIID  ,
NS_IDEVICE_CONTEXT_SPEC_IID   
) [static]
BOOL PrnClosePrinter ( PRTQUEUE pPrintQueue)

Definition at line 998 of file nsDeviceContextSpecOS2.cpp.

{
   BOOL rc = FALSE;

   if (pPrintQueue)
   {
      delete pPrintQueue;
      rc = TRUE;
   }

   return rc;
}

Here is the caller graph for this function:

BOOL PrnInitialize ( HMODULE  hmodResources)

Definition at line 986 of file nsDeviceContextSpecOS2.cpp.

{
   hmodRes = hmodResources;
   return TRUE;
}
HDC PrnOpenDC ( PRTQUEUE pInfo,
PSZ  pszApplicationName,
int  copies,
int  destination,
char *  file 
)

Definition at line 900 of file nsDeviceContextSpecOS2.cpp.

{
   HDC hdc = 0;
   PSZ pszLogAddress;
   PSZ pszDataType;
   LONG dcType;
   DEVOPENSTRUC dop;

   if (!pInfo || !pszApplicationName)
      return hdc;

   if ( destination ) {
      pszLogAddress = pInfo->PQI3 ().pszName;
      pszDataType = "PM_Q_STD";
      if ( destination == 2 )
         dcType = OD_METAFILE;
      else
         dcType = OD_QUEUED;
   } else {
      if (file && *file)
         pszLogAddress = (PSZ) file;
      else    
         pszLogAddress = "FILE";
      pszDataType = "PM_Q_RAW";
      dcType = OD_DIRECT;
   } 

   dop.pszLogAddress      = pszLogAddress; 
   dop.pszDriverName      = (char*)pInfo->DriverName ();
   dop.pdriv              = pInfo->PQI3 ().pDriverData;
   dop.pszDataType        = pszDataType; 
   dop.pszComment         = pszApplicationName;
   dop.pszQueueProcName   = pInfo->PQI3 ().pszPrProc;     
   dop.pszQueueProcParams = 0;
   dop.pszSpoolerParams   = 0;     
   dop.pszNetworkParams   = 0;     

   hdc = ::DevOpenDC( 0, dcType, "*", 9, (PDEVOPENDATA) &dop, NULLHANDLE);

#ifdef DEBUG
   if (hdc == 0)
   {
      ULONG ErrorCode = ERRORIDERROR (::WinGetLastError (0));
      printf ("!ERROR! - Can't open DC for printer %04lX\a\n", ErrorCode);
   }   
#endif

   return hdc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL PrnQueryHardcopyCaps ( HDC  hdc,
PHCINFO  pHCInfo 
)

Definition at line 951 of file nsDeviceContextSpecOS2.cpp.

{
   BOOL rc = FALSE;

   if( hdc && pHCInfo)
   {
      PHCINFO pBuffer;
      long    lAvail, i;

      /* query how many forms are available */
      lAvail = ::DevQueryHardcopyCaps( hdc, 0, 0, NULL);

      pBuffer = (PHCINFO) malloc( lAvail * sizeof(HCINFO));

      ::DevQueryHardcopyCaps( hdc, 0, lAvail, pBuffer);

      for( i = 0; i < lAvail; i++)
         if( pBuffer[ i].flAttributes & HCAPS_CURRENT)
         {
            memcpy( pHCInfo, pBuffer + i, sizeof(HCINFO));
            rc = TRUE;
            break;
         }

      free( pBuffer);
   }

   return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 992 of file nsDeviceContextSpecOS2.cpp.

{
   /* nop for now, may do something eventually */
   return TRUE;
}
void SetupDevModeFromSettings ( ULONG  printer,
nsIPrintSettings aPrintSettings 
)

Definition at line 115 of file nsDeviceContextSpecOS2.cpp.

{
  if (aPrintSettings) {
    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);
    char* driver = nsDeviceContextSpecOS2::PrnDlg.GetDriverType(printer);

    // Setup Orientation
    PRInt32 orientation;
    aPrintSettings->GetOrientation(&orientation);
    if (!strcmp(driver, "LASERJET"))
      pDJP->lType = DJP_ALL;
    else
      pDJP->lType = DJP_CURRENT;
    pDJP->cb = sizeof(DJP_ITEM);
    pDJP->ulNumReturned = 1;
    pDJP->ulProperty = DJP_SJ_ORIENTATION;
    pDJP->ulValue = orientation == nsIPrintSettings::kPortraitOrientation?DJP_ORI_PORTRAIT:DJP_ORI_LANDSCAPE;
    pDJP++;

    // Setup Number of Copies
    PRInt32 copies;
    aPrintSettings->GetNumCopies(&copies);
    pDJP->cb = sizeof(DJP_ITEM);
    pDJP->lType = DJP_CURRENT;
    pDJP->ulNumReturned = 1;
    pDJP->ulProperty = DJP_SJ_COPIES;
    pDJP->ulValue = copies;
    pDJP++;

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

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

    delete [] pDJP_Buffer;
    DevCloseDC(hdc);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

HMODULE hmodRes [static]

Definition at line 591 of file nsDeviceContextSpecOS2.cpp.