gfx/src/os2/nsDeviceContextSpecOS2.cpp - Revision 1.5

There were 18 changes made.
Legend
   Added lines
   Changed lines
   Removed lines

gfx/src/os2/nsDeviceContextSpecOS2.cpp,1.5
.
Disk File
Skipping to line 19. 
 *   Pierre Phaneuf <pp@ludusdesign.com>
.
 *   Pierre Phaneuf <pp@ludusdesign.com>
 *
.
 *
 */
.
 */
 
.
 
#include "nsDeviceContextSpecOS2.h"
.
#include "nsDeviceContextSpecOS2.h"
 
.
 
#include "nsCOMPtr.h"
.
 
#include "nsIServiceManager.h"
.
 
#include "nsIPrintOptions.h"
.
 
#include "nsGfxCIID.h"
.
 
#include "nsGfxDefs.h"
.
 
#include "nsReadableUtils.h"
.
#include "nsReadableUtils.h"
 
.
#include "nsISupportsArray.h"
 
.
 
#include "nsIPref.h"
.
#include "nsIPref.h"
#include "prenv.h" /* for PR_GetEnv */
.
#include "prenv.h" /* for PR_GetEnv */
 
.
 
#include "nsIDOMWindow.h"
.
#include "nsIDOMWindow.h"
Skipping to line 33. 
#include "nsIDialogParamBlock.h"
.
#include "nsIDialogParamBlock.h"
#include "nsISupportsPrimitives.h"
.
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
.
#include "nsIWindowWatcher.h"
#include "nsIDOMWindowInternal.h"
.
#include "nsIDOMWindowInternal.h"
 
.
 
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
.
 
 
.
 
nsStringArray* nsDeviceContextSpecOS2::globalPrinterList = nsnull;
.
nsStringArray* nsDeviceContextSpecOS2::globalPrinterList = nsnull;
int nsDeviceContextSpecOS2::globalNumPrinters = 0;
.
int nsDeviceContextSpecOS2::globalNumPrinters = 0;
PRINTDLG nsDeviceContextSpecOS2::PrnDlg;
.
PRINTDLG nsDeviceContextSpecOS2::PrnDlg;
 
.
 
/** -------------------------------------------------------
.
/** -------------------------------------------------------
Skipping to line 153. 
 *   file:     mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
.
 *   file:     mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
 *   function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
.
 *   function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
 * 
.
 * 
 * ** Please update the other toolkits when changing this function.
.
 * ** Please update the other toolkits when changing this function.
 */
.
 */
NS_IMETHODIMP nsDeviceContextSpecOS2::Init(PRBool aQuiet)
 
.
NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuie
t)
{
.
{
  nsresult rv = NS_ERROR_FAILURE;
.
  nsresult rv = NS_ERROR_FAILURE;
 
.
 
  nsCOMPtr<nsIPrintOptions> printService(do_GetService(kPrintOptionsCID, &rv))
;
.
  mPrintSettings = aPS;
 
  NS_ASSERTION(nsnull != printService, "No print service.");
.
  NS_ASSERTION(aPS, "Must have a PrintSettings!");
  
.
 
  // if there is a current selection then enable the "Selection" radio button
.
  // if there is a current selection then enable the "Selection" radio button
  if (NS_SUCCEEDED(rv) && printService) {
.
  if (aPS != nsnull) {
    PRBool isOn;
.
    PRBool isOn;
    printService->GetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectio
nRB, &isOn);
.
    aPS->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
 
    nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
.
    nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
    if (NS_SUCCEEDED(rv)) {
.
    if (NS_SUCCEEDED(rv)) {
      (void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
.
      (void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
    }
.
    }
  }
.
  }
Skipping to line 175. 
  char      *path;
.
  char      *path;
  PRBool     canPrint       = PR_FALSE;
.
  PRBool     canPrint       = PR_FALSE;
  PRBool     tofile         = PR_FALSE;
.
  PRBool     tofile         = PR_FALSE;
  PRInt16    printRange     = nsIPrintOptions::kRangeAllPages;
.
  PRInt16    printRange     = nsIPrintSettings::kRangeAllPages;
  PRInt32    fromPage       = 1;
.
  PRInt32    fromPage       = 1;
  PRInt32    toPage         = 1;
.
  PRInt32    toPage         = 1;
  PRInt32    copies         = 1;
.
  PRInt32    copies         = 1;
  PRUnichar *printer        = nsnull;
.
  PRUnichar *printer        = nsnull;
  PRUnichar *printfile      = nsnull;
.
  PRUnichar *printfile      = nsnull;
Skipping to line 188. 
  if( globalNumPrinters && !globalPrinterList->Count() ) 
.
  if( globalNumPrinters && !globalPrinterList->Count() ) 
     return NS_ERROR_OUT_OF_MEMORY;
.
     return NS_ERROR_OUT_OF_MEMORY;
 
.
 
  if ( !aQuiet ) {
.
  if ( !aQuiet ) {
    rv = NS_ERROR_FAILURE;
.
    rv = NS_ERROR_FAILURE;
    nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org
/embedcomp/dialogparam;1"));
.
    // create a nsISupportsArray of the parameters 
 
 
.
    // being passed to the window
 
.
    nsCOMPtr<nsISupportsArray> array;
 
.
    NS_NewISupportsArray(getter_AddRefs(array));
 
.
    if (!array) return NS_ERROR_FAILURE;
 
.
 
 
.
    nsCOMPtr<nsIPrintSettings> ps = aPS;
 
.
    nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
 
.
    NS_ASSERTION(psSupports, "PrintSettings must be a supports");
 
.
    array->AppendElement(psSupports);
 
.
 
    nsCOMPtr<nsISupportsInterfacePointer> paramBlockWrapper;
 
.
    nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org
/embedcomp/dialogparam;1"));
    if (ioParamBlock)
.
    if (ioParamBlock) {
      paramBlockWrapper = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONT
RACTID);
.
      ioParamBlock->SetInt(0, 0);
 
 
.
      nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
    if (paramBlockWrapper) {
.
      NS_ASSERTION(blkSupps, "IOBlk must be a supports");
      paramBlockWrapper->SetData(ioParamBlock);
.
 
      paramBlockWrapper->SetDataIID(&NS_GET_IID(nsIDialogParamBlock));
.
      array->AppendElement(blkSupps);
 
.
      nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
 
.
      NS_ASSERTION(array, "array must be a supports");
 
.
 
      nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/
window-watcher;1"));
.
      nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/
window-watcher;1"));
      if (wwatch) {
.
      if (wwatch) {
 
.
 
        nsCOMPtr<nsIDOMWindow> active;
.
        nsCOMPtr<nsIDOMWindow> active;
        wwatch->GetActiveWindow(getter_AddRefs(active));
.
        wwatch->GetActiveWindow(getter_AddRefs(active));    
        nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
.
        nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
 
.
 
        nsCOMPtr<nsIDOMWindow> newWindow;
.
        nsCOMPtr<nsIDOMWindow> newWindow;
        rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.x
ul",
.
        rv = wwatch->OpenWindow(parent, aChromeURL,
 
                      "_blank", "chrome,modal", paramBlockWrapper,
.
              "_blank", "chrome,modal,centerscreen", array,
                      getter_AddRefs(newWindow));
.
              getter_AddRefs(newWindow));
      }
.
      }
    }
.
    }
 
.
 
    if (NS_SUCCEEDED(rv)) {
.
    if (NS_SUCCEEDED(rv)) {
      PRInt32 buttonPressed = 0;
.
      PRInt32 buttonPressed = 0;
      ioParamBlock->GetInt(0, &buttonPressed);
.
      ioParamBlock->GetInt(0, &buttonPressed);
      if (buttonPressed == 0) 
.
      if (buttonPressed == 1) 
        canPrint = PR_TRUE;
.
        canPrint = PR_TRUE;
      else 
.
      else 
        {
.
        {
           FreeGlobalPrinters();
.
           FreeGlobalPrinters();
           return NS_ERROR_ABORT;
.
           return NS_ERROR_ABORT;
Skipping to line 238. 
  } else {
.
  } else {
    canPrint = PR_TRUE;
.
    canPrint = PR_TRUE;
  }
.
  }
 
.
 
  if (canPrint) {
.
  if (canPrint) {
    if (printService) {
.
    if (mPrintSettings) {
      printService->GetPrinter(&printer);
.
      mPrintSettings->GetPrinterName(&printer);
      printService->GetPrintRange(&printRange);
.
      mPrintSettings->GetPrintRange(&printRange);
      printService->GetToFileName(&printfile);
.
      mPrintSettings->GetToFileName(&printfile);
      printService->GetPrintToFile(&tofile);
.
      mPrintSettings->GetPrintToFile(&tofile);
      printService->GetStartPageRange(&fromPage);
.
      mPrintSettings->GetStartPageRange(&fromPage);
      printService->GetEndPageRange(&toPage);
.
      mPrintSettings->GetEndPageRange(&toPage);
      printService->GetNumCopies(&copies);
.
      mPrintSettings->GetNumCopies(&copies);
 
.
 
      if ((copies == 0)  ||  (copies > 999)) {
.
      if ((copies == 0)  ||  (copies > 999)) {
         FreeGlobalPrinters();
.
         FreeGlobalPrinters();
         return NS_ERROR_FAILURE;
.
         return NS_ERROR_FAILURE;
      }
.
      }
Skipping to line 291. 
{
.
{
  aToPrinter = mPrData.toPrinter;
.
  aToPrinter = mPrData.toPrinter;
  return NS_OK;
.
  return NS_OK;
}
.
}
 
.
 
NS_IMETHODIMP nsDeviceContextSpecOS2 :: GetPrinter ( char **aPrinter )
.
NS_IMETHODIMP nsDeviceContextSpecOS2 :: GetPrinterName ( char **aPrinter )
{
.
{
   *aPrinter = &mPrData.printer[0];
.
   *aPrinter = &mPrData.printer[0];
   return NS_OK;
.
   return NS_OK;
}
.
}
 
.
 
Skipping to line 376. 
  *aResult = array;
.
  *aResult = array;
 
.
 
  return NS_OK;
.
  return NS_OK;
}
.
}
 
.
 
NS_IMETHODIMP nsPrinterEnumeratorOS2::DisplayPropertiesDlg(const PRUnichar *aP
rinter)
.
NS_IMETHODIMP nsPrinterEnumeratorOS2::DisplayPropertiesDlg(const PRUnichar *aP
rinter, nsIPrintSettings *aPrintSettings)
{
.
{
   for(int i = 0; i < nsDeviceContextSpecOS2::globalNumPrinters; i++) {
.
   for(int i = 0; i < nsDeviceContextSpecOS2::globalNumPrinters; i++) {
     if (!(nsDeviceContextSpecOS2::globalPrinterList->StringAt(i)->CompareWith
Conversion(aPrinter, TRUE, -1))) {
.
     if (!(nsDeviceContextSpecOS2::globalPrinterList->StringAt(i)->CompareWith
Conversion(aPrinter, TRUE, -1))) {
        if ( nsDeviceContextSpecOS2::PrnDlg.ShowProperties(i) ) 
.
        if ( nsDeviceContextSpecOS2::PrnDlg.ShowProperties(i) ) 
           return NS_OK;
.
           return NS_OK;