Back to index

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

#include <nsDeviceContextSpecOS2.h>

Collaboration diagram for PRINTDLG:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PRINTDLG ()
 ~PRINTDLG ()
void RefreshPrintQueue ()
ULONG GetNumPrinters ()
void GetPrinter (ULONG printerNdx, char **printerName)
PRTQUEUESetPrinterQueue (ULONG printerNdx)
LONG GetPrintDriverSize (ULONG printerNdx)
PDRIVDATA GetPrintDriver (ULONG printerNdx)
HDC GetDCHandle (ULONG printerNdx)
char * GetDriverType (ULONG printerNdx)
BOOL ShowProperties (ULONG printerNdx)

Private Attributes

ULONG mQueueCount
PRTQUEUEmPQBuf [MAX_PRINT_QUEUES]

Detailed Description

Definition at line 75 of file nsDeviceContextSpecOS2.h.


Constructor & Destructor Documentation

Definition at line 683 of file nsDeviceContextSpecOS2.cpp.

{
  mQueueCount = 0;

  ULONG TotalQueues = 0;
  ULONG MemNeeded = 0;
  SPLERR rc;
  
  rc = ::SplEnumQueue(NULL, 3, NULL, 0, &mQueueCount, &TotalQueues, &MemNeeded, NULL);
  PRQINFO3* pPQI3Buf = (PRQINFO3*) malloc (MemNeeded);
  rc = ::SplEnumQueue(NULL, 3, pPQI3Buf, MemNeeded, &mQueueCount, &TotalQueues, &MemNeeded, NULL);

  if (mQueueCount > MAX_PRINT_QUEUES)
    mQueueCount = MAX_PRINT_QUEUES;

  ULONG defaultQueue = 0;
  for (ULONG cnt = 0; cnt < mQueueCount; cnt++) {
    if (pPQI3Buf[cnt].fsType & PRQ3_TYPE_APPDEFAULT)
      defaultQueue = cnt;
    mPQBuf[cnt] = new PRTQUEUE(&pPQI3Buf[cnt]);
  }

  // move the entry for the default printer to index 0 (if necessary)
  if (defaultQueue > 0) {
    PRTQUEUE* temp = mPQBuf[0];
    mPQBuf[0] = mPQBuf[defaultQueue];
    mPQBuf[defaultQueue] = temp;
  }

  free(pPQI3Buf);
}

Definition at line 715 of file nsDeviceContextSpecOS2.cpp.

{
  for (ULONG index = 0; index < mQueueCount; index++)
    delete mPQBuf[index];
}

Member Function Documentation

HDC PRINTDLG::GetDCHandle ( ULONG  printerNdx)

Definition at line 824 of file nsDeviceContextSpecOS2.cpp.

{
    HDC hdc = 0;
    DEVOPENSTRUC dop;

    dop.pszLogAddress      = 0; 
    dop.pszDriverName      = (char *)mPQBuf[printerNdx]->DriverName();
    dop.pdriv              = mPQBuf[printerNdx]->PQI3().pDriverData;
    dop.pszDataType        = 0; 
    dop.pszComment         = 0;
    dop.pszQueueProcName   = 0;     
    dop.pszQueueProcParams = 0;   
    dop.pszSpoolerParams   = 0;     
    dop.pszNetworkParams   = 0;     

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

Here is the call graph for this function:

Here is the caller graph for this function:

char * PRINTDLG::GetDriverType ( ULONG  printerNdx)

Definition at line 843 of file nsDeviceContextSpecOS2.cpp.

{
  return (char *)mPQBuf[printerNdx]->DriverName ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 782 of file nsDeviceContextSpecOS2.cpp.

{
   return mQueueCount;
}
PDRIVDATA PRINTDLG::GetPrintDriver ( ULONG  printerNdx)

Definition at line 816 of file nsDeviceContextSpecOS2.cpp.

{
   if (printerNdx >= mQueueCount)
      return NULL;

   return mPQBuf[printerNdx]->PQI3().pDriverData;
}

Here is the call graph for this function:

Definition at line 811 of file nsDeviceContextSpecOS2.cpp.

{
   return mPQBuf[printerNdx]->PQI3().pDriverData->cb;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PRINTDLG::GetPrinter ( ULONG  printerNdx,
char **  printerName 
)

Definition at line 787 of file nsDeviceContextSpecOS2.cpp.

{
   if (printerNdx >= mQueueCount)
      return;
 
   nsCAutoString pName(mPQBuf[printerNdx]->QueueName());
 
   pName.ReplaceChar('\r', ' ');
   pName.StripChars("\n");
   *printerName = ToNewCString(pName);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 721 of file nsDeviceContextSpecOS2.cpp.

{
  ULONG newQueueCount = 0;
  ULONG TotalQueues = 0;
  ULONG MemNeeded = 0;
  SPLERR rc;
  
  rc = ::SplEnumQueue(NULL, 3, NULL, 0, &newQueueCount, &TotalQueues, &MemNeeded, NULL);
  PRQINFO3* pPQI3Buf = (PRQINFO3*)malloc(MemNeeded);
  rc = ::SplEnumQueue(NULL, 3, pPQI3Buf, MemNeeded, &newQueueCount, &TotalQueues, &MemNeeded, NULL);

  if (newQueueCount > MAX_PRINT_QUEUES)
    newQueueCount = MAX_PRINT_QUEUES;

  PRTQUEUE* tmpBuf[MAX_PRINT_QUEUES];

  ULONG defaultQueue = 0;
  for (ULONG cnt = 0; cnt < newQueueCount; cnt++) {
    if (pPQI3Buf[cnt].fsType & PRQ3_TYPE_APPDEFAULT)
      defaultQueue = cnt;

    BOOL found = FALSE;
    for (ULONG index = 0; index < mQueueCount && !found; index++) {
       //Compare printer from requeried list with what's already in Mozilla's printer list(mPQBuf)
       //If printer is already there, use current properties; otherwise create a new printer in list
       if (mPQBuf[index] != 0) {
         if ((strcmp(pPQI3Buf[cnt].pszPrinters, mPQBuf[index]->PrinterName()) == 0) && 
             (strcmp(pPQI3Buf[cnt].pszDriverName, mPQBuf[index]->PQI3().pszDriverName) == 0)) {
           found = TRUE;
           tmpBuf[cnt] = mPQBuf[index];
           mPQBuf[index] = 0;
         }
       }
    }
    if (!found) 
       tmpBuf[cnt] = new PRTQUEUE(&pPQI3Buf[cnt]); 
  }

  for (ULONG index = 0; index < newQueueCount; index++) {
    if (mPQBuf[index] != 0)
      delete(mPQBuf[index]);
    mPQBuf[index] = tmpBuf[index];
  }

  if (mQueueCount > newQueueCount)
    for (ULONG index = newQueueCount; index < mQueueCount; index++)
       if (mPQBuf[index] != 0)
         delete(mPQBuf[index]);

  mQueueCount = newQueueCount;

  // move the entry for the default printer to index 0 (if necessary)
  if (defaultQueue > 0) {
    PRTQUEUE* temp = mPQBuf[0];
    mPQBuf[0] = mPQBuf[defaultQueue];
    mPQBuf[defaultQueue] = temp;
  }

  free(pPQI3Buf);
}

Definition at line 799 of file nsDeviceContextSpecOS2.cpp.

{
   PRTQUEUE *pPQ = NULL;

   if (printerNdx >= mQueueCount)
      return NULL;

   pPQ = mPQBuf[printerNdx];

   return new PRTQUEUE(*pPQ);
}

Definition at line 848 of file nsDeviceContextSpecOS2.cpp.

{
    BOOL          rc = FALSE;
    LONG          devrc = FALSE;
    PDRIVDATA     pOldDrivData;
    PDRIVDATA     pNewDrivData = NULL;
    LONG          buflen;

/* check size of buffer required for job properties */
    buflen = DevPostDeviceModes( 0 /*hab*/,
                                 NULL,
                                 mPQBuf[printerNdx]->DriverName (),
                                 mPQBuf[printerNdx]->DeviceName (),
                                 mPQBuf[printerNdx]->PrinterName (),
                                 DPDM_POSTJOBPROP);

/* return error to caller */
    if (buflen <= 0)
        return(buflen);

/* allocate some memory for larger job properties and */
/* return error to caller */

    if (buflen != mPQBuf[printerNdx]->PQI3().pDriverData->cb)
    {
        if (DosAllocMem((PPVOID)&pNewDrivData,buflen,fALLOC))
            return(FALSE); // DPDM_ERROR
    
/* copy over old data so driver can use old job */
/* properties as base for job properties dialog */
        pOldDrivData = mPQBuf[printerNdx]->PQI3().pDriverData;
        mPQBuf[printerNdx]->PQI3().pDriverData = pNewDrivData;
        memcpy( (PSZ)pNewDrivData, (PSZ)pOldDrivData, pOldDrivData->cb );
    }

/* display job properties dialog and get updated */
/* job properties from driver */

    devrc = DevPostDeviceModes( 0 /*hab*/,
                                mPQBuf[printerNdx]->PQI3().pDriverData,
                                mPQBuf[printerNdx]->DriverName (),
                                mPQBuf[printerNdx]->DeviceName (),
                                mPQBuf[printerNdx]->PrinterName (),
                                DPDM_POSTJOBPROP);
    rc = (devrc != DPDM_ERROR);
    return rc;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 92 of file nsDeviceContextSpecOS2.h.

Definition at line 91 of file nsDeviceContextSpecOS2.h.


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