gfx/src/qt/nsDeviceContextSpecQT.cpp - Revision 1.17

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

gfx/src/qt/nsDeviceContextSpecQT.cpp,1.17
.
Disk File
Skipping to line 37. 
 *
.
 *
 * ***** END LICENSE BLOCK ***** */
.
 * ***** END LICENSE BLOCK ***** */
 
.
 
#include "nsDeviceContextSpecQT.h"
.
#include "nsDeviceContextSpecQT.h"
#include "nsRenderingContextQT.h"
.
#include "nsRenderingContextQT.h"
 
.
 
#include "nsCOMPtr.h"
.
 
#include "nsReadableUtils.h"
.
 
#include "nsIServiceManager.h"
.
 
#include "nsIPrintOptions.h"
.
 
#include "nsGfxCIID.h"
.
 
 
.
 
#include "nsIPref.h"
.
#include "nsIPref.h"
#include "prenv.h" /* for PR_GetEnv */
.
#include "prenv.h" /* for PR_GetEnv */
 
.
 
#include "nsIDOMWindowInternal.h"
.
#include "nsIDOMWindowInternal.h"
 
.
#include "nsIServiceManager.h" 
#include "nsIDialogParamBlock.h"
.
#include "nsIDialogParamBlock.h"
#include "nsISupportsPrimitives.h"
.
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
.
#include "nsIWindowWatcher.h"
 
.
 
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
.
#include "nsReadableUtils.h"
 
.
#include "nsISupportsArray.h"
 
.
 
#include <qapplication.h>
.
#include <qapplication.h>
 
.
 
//JCG #define DBG_JCG 1
.
//JCG #define DBG_JCG 1
 
.
 
Skipping to line 128. 
/** -------------------------------------------------------
.
/** -------------------------------------------------------
 *  Initialize the nsDeviceContextSpecQT
.
 *  Initialize the nsDeviceContextSpecQT
 *  @update   dc 2/15/98
.
 *  @update   dc 2/15/98
 *  @update   syd 3/2/99
.
 *  @update   syd 3/2/99
 */
.
 */
NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
 
.
NS_IMETHODIMP nsDeviceContextSpecQT::Init(nsIPrintSettings* aPS, PRBool aQuiet
)
{
.
{
  nsresult  rv = NS_ERROR_FAILURE;
.
  nsresult  rv = NS_ERROR_FAILURE;
  nsCOMPtr<nsIPrintOptions> printService(do_GetService(kPrintOptionsCID, &rv))
;
.
  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) {
    PRBool isOn;
.
    PRBool isOn;
    printService->GetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectio
nRB,
.
    aPS->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB,
 
                                  &isOn);
.
                                  &isOn);
    nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
.
    nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
    if (NS_SUCCEEDED(rv) && pPrefs) {
.
    if (NS_SUCCEEDED(rv) && pPrefs) {
      (void)pPrefs->SetBoolPref("print.selection_radio_enabled",isOn);
.
      (void)pPrefs->SetBoolPref("print.selection_radio_enabled",isOn);
    }
.
    }
Skipping to line 148. 
  char *path;
.
  char *path;
  PRBool reversed = PR_FALSE;
.
  PRBool reversed = PR_FALSE;
  PRBool color = PR_FALSE;
.
  PRBool color = PR_FALSE;
  PRBool tofile = PR_FALSE;
.
  PRBool tofile = PR_FALSE;
  PRInt16 printRange = nsIPrintOptions::kRangeAllPages;
.
  PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
  PRInt32 paper_size = NS_LETTER_SIZE;
.
  PRInt32 paper_size = NS_LETTER_SIZE;
  PRInt32 orientation    = NS_PORTRAIT;
.
  PRInt32 orientation    = NS_PORTRAIT;
  PRInt32 fromPage = 1;
.
  PRInt32 fromPage = 1;
  PRInt32 toPage = 1;
.
  PRInt32 toPage = 1;
  PRUnichar *command = nsnull;
.
  PRUnichar *command = nsnull;
Skipping to line 160. 
  double dright = 0.5;
.
  double dright = 0.5;
  double dtop = 0.5;
.
  double dtop = 0.5;
  double dbottom = 0.5;
.
  double dbottom = 0.5;
 
.
 
  rv = NS_ERROR_FAILURE;
.
  rv = NS_ERROR_FAILURE;
  nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/e
mbedcomp/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/e
mbedcomp/dialogparam;1"));
  if (ioParamBlock)
.
  if (ioParamBlock) {
    paramBlockWrapper = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRA
CTID);
.
    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/wi
ndow-watcher;1"));
.
    nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/wi
ndow-watcher;1"));
    if (wwatch) {
.
    if (wwatch) {
 
.
 
      nsCOMPtr<nsIDOMWindowInternal> parent;
.
 
      nsCOMPtr<nsIDOMWindow> active;
.
      nsCOMPtr<nsIDOMWindow> active;
      wwatch->GetActiveWindow(getter_AddRefs(active));
.
      wwatch->GetActiveWindow(getter_AddRefs(active));    
      if (active) {
.
      nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
        active->QueryInterface(NS_GET_IID(nsIDOMWindowInternal), getter_AddRef
s(parent));
.
 
 
      }
.
 
 
.
 
      nsCOMPtr<nsIDOMWindow> newWindow;
.
      nsCOMPtr<nsIDOMWindow> newWindow;
      rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.xul
",
.
      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;
Skipping to line 202. 
    if (buttonPressed == 0) {
.
    if (buttonPressed == 1) {
      if (printService) {
.
      if (aPS) {
	printService->GetPrintReversed(&reversed);
.
	aPS->GetPrintReversed(&reversed);
	printService->GetPrintInColor(&color);
.
	aPS->GetPrintInColor(&color);
	printService->GetPaperSize(&paper_size);
.
	aPS->GetPaperSize(&paper_size);
        printService->GetOrientation(&orientation);
.
        aPS->GetOrientation(&orientation);
	printService->GetPrintCommand(&command);
.
	aPS->GetPrintCommand(&command);
	printService->GetPrintRange(&printRange);
.
	aPS->GetPrintRange(&printRange);
	printService->GetToFileName(&printfile);
.
	aPS->GetToFileName(&printfile);
	printService->GetPrintToFile(&tofile);
.
	aPS->GetPrintToFile(&tofile);
	printService->GetStartPageRange(&fromPage);
.
	aPS->GetStartPageRange(&fromPage);
	printService->GetEndPageRange(&toPage);
.
	aPS->GetEndPageRange(&toPage);
	printService->GetMarginTop(&dtop);
.
	aPS->GetMarginTop(&dtop);
	printService->GetMarginLeft(&dleft);
.
	aPS->GetMarginLeft(&dleft);
	printService->GetMarginBottom(&dbottom);
.
	aPS->GetMarginBottom(&dbottom);
	printService->GetMarginRight(&dright);
.
	aPS->GetMarginRight(&dright);
 
.
 
	if (command != nsnull && printfile != nsnull) {
.
	if (command != nsnull && printfile != nsnull) {
	  // convert Unicode strings to cstrings
.
	  // convert Unicode strings to cstrings
	  nsAutoString cmdStr;
.
	  nsAutoString cmdStr;
	  nsAutoString printFileStr;
.
	  nsAutoString printFileStr;
Skipping to line 276. 
{
.
{
  aToPrinter = mPrData.toPrinter;
.
  aToPrinter = mPrData.toPrinter;
  return NS_OK;
.
  return NS_OK;
}
.
}
 
.
 
NS_IMETHODIMP nsDeviceContextSpecQT::GetPrinter (char **aPrinter)
.
NS_IMETHODIMP nsDeviceContextSpecQT::GetPrinterName (char **aPrinter)
{
.
{
   *aPrinter = &mPrData.printer[0];
.
   *aPrinter = &mPrData.printer[0];
   return NS_OK;
.
   return NS_OK;
}
.
}
 
.