зеркало из https://github.com/mozilla/pjs.git
Switch public interfaces from nsIPrintOptions to nsIPrintSettings
Enabling XP Print Dialog for Windows Enabling XP Print Progress Dialog Enabling XP Page Setup Dialog Fixing nsPrintPreviewContext to use nsIPrintPreviewContext Bug 113917 r=dcone sr=attinasi
This commit is contained in:
Родитель
5b16999340
Коммит
37b493159f
|
@ -61,6 +61,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: Init(void)
|
||||||
//XXX this method needs to do what the API says...
|
//XXX this method needs to do what the API says...
|
||||||
|
|
||||||
NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||||
|
nsIPrintSettings* aPrintSettings,
|
||||||
nsIDeviceContextSpec *&aNewSpec,
|
nsIDeviceContextSpec *&aNewSpec,
|
||||||
PRBool aQuiet)
|
PRBool aQuiet)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +70,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: CreateDeviceContextSpec(nsIWidget
|
||||||
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
|
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aQuiet);
|
rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aQuiet);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
aNewSpec = devSpec;
|
aNewSpec = devSpec;
|
||||||
NS_ADDREF(aNewSpec);
|
NS_ADDREF(aNewSpec);
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD Init(void);
|
NS_IMETHOD Init(void);
|
||||||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||||
|
nsIPrintSettings* aPrintSettings,
|
||||||
nsIDeviceContextSpec *&aNewSpec,
|
nsIDeviceContextSpec *&aNewSpec,
|
||||||
PRBool aQuiet);
|
PRBool aQuiet);
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,8 @@
|
||||||
|
|
||||||
#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 */
|
||||||
|
@ -39,10 +35,9 @@
|
||||||
#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;
|
||||||
|
|
||||||
/** -------------------------------------------------------
|
/** -------------------------------------------------------
|
||||||
|
@ -114,7 +109,7 @@ int nsDeviceContextSpecOS2::InitializeGlobalPrinters ()
|
||||||
{
|
{
|
||||||
globalNumPrinters = PrnDlg.GetNumPrinters();
|
globalNumPrinters = PrnDlg.GetNumPrinters();
|
||||||
if (!globalNumPrinters)
|
if (!globalNumPrinters)
|
||||||
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAIULABLE;
|
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
|
||||||
|
|
||||||
globalPrinterList = new nsStringArray();
|
globalPrinterList = new nsStringArray();
|
||||||
if (!globalPrinterList)
|
if (!globalPrinterList)
|
||||||
|
@ -161,17 +156,17 @@ void nsDeviceContextSpecOS2::FreeGlobalPrinters ()
|
||||||
*
|
*
|
||||||
* ** 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 aQuiet)
|
||||||
{
|
{
|
||||||
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::kPrintOptionsEnableSelectionRB, &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);
|
||||||
|
@ -181,7 +176,7 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(PRBool aQuiet)
|
||||||
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;
|
||||||
|
@ -190,39 +185,50 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(PRBool aQuiet)
|
||||||
|
|
||||||
if( !globalPrinterList )
|
if( !globalPrinterList )
|
||||||
if (InitializeGlobalPrinters())
|
if (InitializeGlobalPrinters())
|
||||||
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAIULABLE;
|
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
|
||||||
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;
|
||||||
|
// 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<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
|
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
|
||||||
|
if (ioParamBlock) {
|
||||||
|
ioParamBlock->SetInt(0, 0);
|
||||||
|
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
|
||||||
|
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
|
||||||
|
|
||||||
nsCOMPtr<nsISupportsInterfacePointer> paramBlockWrapper;
|
array->AppendElement(blkSupps);
|
||||||
if (ioParamBlock)
|
nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
|
||||||
paramBlockWrapper = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID);
|
NS_ASSERTION(array, "array must be a supports");
|
||||||
|
|
||||||
if (paramBlockWrapper) {
|
|
||||||
paramBlockWrapper->SetData(ioParamBlock);
|
|
||||||
paramBlockWrapper->SetDataIID(&NS_GET_IID(nsIDialogParamBlock));
|
|
||||||
|
|
||||||
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.xul",
|
rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.xul",
|
||||||
"_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
|
||||||
{
|
{
|
||||||
|
@ -235,14 +241,14 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(PRBool aQuiet)
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
@ -288,7 +294,7 @@ NS_IMETHODIMP nsDeviceContextSpecOS2 :: GetToPrinter( PRBool &aToPrinter )
|
||||||
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;
|
||||||
|
@ -335,8 +341,20 @@ nsPrinterEnumeratorOS2::nsPrinterEnumeratorOS2()
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorOS2, nsIPrinterEnumerator)
|
NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorOS2, nsIPrinterEnumerator)
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrintersExtended(PRUint32* aCount, PRUnichar*** aResult)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG(aCount);
|
||||||
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
|
*aCount = 0;
|
||||||
|
*aResult = nsnull;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
|
NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
|
||||||
{
|
{
|
||||||
|
NS_ENSURE_ARG(aCount);
|
||||||
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
|
|
||||||
if (aCount)
|
if (aCount)
|
||||||
*aCount = 0;
|
*aCount = 0;
|
||||||
else
|
else
|
||||||
|
@ -373,7 +391,7 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrinters(PRUint32* aCount, PRUnic
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsPrinterEnumeratorOS2::DisplayPropertiesDlg(const PRUnichar *aPrinter)
|
NS_IMETHODIMP nsPrinterEnumeratorOS2::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < nsDeviceContextSpecOS2::globalNumPrinters; i++) {
|
for(int i = 0; i < nsDeviceContextSpecOS2::globalNumPrinters; i++) {
|
||||||
if (!(nsDeviceContextSpecOS2::globalPrinterList->StringAt(i)->CompareWithConversion(aPrinter, TRUE, -1))) {
|
if (!(nsDeviceContextSpecOS2::globalPrinterList->StringAt(i)->CompareWithConversion(aPrinter, TRUE, -1))) {
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
|
|
||||||
#include "nsIDeviceContextSpec.h"
|
#include "nsIDeviceContextSpec.h"
|
||||||
#include "nsIPrintOptions.h"
|
#include "nsIPrintOptions.h"
|
||||||
|
#include "nsIPrintSettings.h"
|
||||||
#include "nsVoidArray.h"
|
#include "nsVoidArray.h"
|
||||||
#ifdef USE_XPRINT
|
#ifdef USE_XPRINT
|
||||||
#include "nsIDeviceContextSpecXPrint.h"
|
#include "nsIDeviceContextSpecXPrint.h"
|
||||||
|
@ -131,13 +132,13 @@ public:
|
||||||
* printer).
|
* printer).
|
||||||
* @return error status
|
* @return error status
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD Init(PRBool aQuiet);
|
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
||||||
|
|
||||||
NS_IMETHOD ClosePrintManager();
|
NS_IMETHOD ClosePrintManager();
|
||||||
|
|
||||||
NS_IMETHOD GetToPrinter( PRBool &aToPrinter );
|
NS_IMETHOD GetToPrinter( PRBool &aToPrinter );
|
||||||
|
|
||||||
NS_IMETHOD GetPrinter ( char **aPrinter );
|
NS_IMETHOD GetPrinterName ( char **aPrinter );
|
||||||
|
|
||||||
NS_IMETHOD GetCopies ( int &aCopies );
|
NS_IMETHOD GetCopies ( int &aCopies );
|
||||||
|
|
||||||
|
@ -147,23 +148,23 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetPRTQUEUE(PRTQUEUE *&p);
|
NS_IMETHOD GetPRTQUEUE(PRTQUEUE *&p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
|
||||||
|
* @update dc 2/16/98
|
||||||
|
*/
|
||||||
|
virtual ~nsDeviceContextSpecOS2();
|
||||||
|
|
||||||
static nsStringArray *globalPrinterList;
|
static nsStringArray *globalPrinterList;
|
||||||
static int globalNumPrinters;
|
static int globalNumPrinters;
|
||||||
static PRINTDLG PrnDlg;
|
static PRINTDLG PrnDlg;
|
||||||
int InitializeGlobalPrinters();
|
int InitializeGlobalPrinters();
|
||||||
void FreeGlobalPrinters();
|
void FreeGlobalPrinters();
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
|
|
||||||
* @update dc 2/16/98
|
|
||||||
*/
|
|
||||||
virtual ~nsDeviceContextSpecOS2();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
OS2PrData mPrData;
|
OS2PrData mPrData;
|
||||||
PRTQUEUE *mQueue;
|
PRTQUEUE *mQueue;
|
||||||
|
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
Загрузка…
Ссылка в новой задаче