зеркало из https://github.com/mozilla/gecko-dev.git
Turn on pluggable dialogs (second part of checkin, first part Bug 135441)
Bug 115136 r=dcone sr=attinasi
This commit is contained in:
Родитель
f892cf2211
Коммит
28f4973b1b
|
@ -63,14 +63,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: Init(void)
|
||||||
NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||||
nsIPrintSettings* aPrintSettings,
|
nsIPrintSettings* aPrintSettings,
|
||||||
nsIDeviceContextSpec *&aNewSpec,
|
nsIDeviceContextSpec *&aNewSpec,
|
||||||
PRBool aQuiet)
|
PRBool aIsPrintPreview)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||||
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(aPrintSettings, aQuiet);
|
rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aIsPrintPreview);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
aNewSpec = devSpec;
|
aNewSpec = devSpec;
|
||||||
NS_ADDREF(aNewSpec);
|
NS_ADDREF(aNewSpec);
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||||
nsIPrintSettings* aPrintSettings,
|
nsIPrintSettings* aPrintSettings,
|
||||||
nsIDeviceContextSpec *&aNewSpec,
|
nsIDeviceContextSpec *&aNewSpec,
|
||||||
PRBool aQuiet);
|
PRBool aIsPrintPreview);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~nsDeviceContextSpecFactoryOS2();
|
~nsDeviceContextSpecFactoryOS2();
|
||||||
|
|
|
@ -28,12 +28,7 @@
|
||||||
#include "nsIPref.h"
|
#include "nsIPref.h"
|
||||||
#include "prenv.h" /* for PR_GetEnv */
|
#include "prenv.h" /* for PR_GetEnv */
|
||||||
|
|
||||||
#include "nsIDOMWindow.h"
|
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIDialogParamBlock.h"
|
|
||||||
#include "nsISupportsPrimitives.h"
|
|
||||||
#include "nsIWindowWatcher.h"
|
|
||||||
#include "nsIDOMWindowInternal.h"
|
|
||||||
#include "nsUnicharUtils.h"
|
#include "nsUnicharUtils.h"
|
||||||
|
|
||||||
PRINTDLG nsDeviceContextSpecOS2::PrnDlg;
|
PRINTDLG nsDeviceContextSpecOS2::PrnDlg;
|
||||||
|
@ -259,13 +254,13 @@ NS_IMPL_RELEASE(nsDeviceContextSpecOS2)
|
||||||
* toolkits including:
|
* toolkits including:
|
||||||
* - GTK+-toolkit:
|
* - GTK+-toolkit:
|
||||||
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
|
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
|
||||||
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
|
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aPrintPreview )
|
||||||
* - Xlib-toolkit:
|
* - Xlib-toolkit:
|
||||||
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
|
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
|
||||||
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
|
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aPrintPreview )
|
||||||
* - Qt-toolkit:
|
* - Qt-toolkit:
|
||||||
* 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 aPrintPreview )
|
||||||
*
|
*
|
||||||
* ** Please update the other toolkits when changing this function.
|
* ** Please update the other toolkits when changing this function.
|
||||||
*/
|
*/
|
||||||
|
@ -276,129 +271,57 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
|
||||||
mPrintSettings = aPS;
|
mPrintSettings = aPS;
|
||||||
NS_ASSERTION(aPS, "Must have a PrintSettings!");
|
NS_ASSERTION(aPS, "Must have a PrintSettings!");
|
||||||
|
|
||||||
// if there is a current selection then enable the "Selection" radio button
|
|
||||||
if (aPS != nsnull) {
|
|
||||||
PRBool isOn;
|
|
||||||
aPS->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
|
|
||||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
|
||||||
(void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PRBool canPrint = PR_FALSE;
|
|
||||||
|
|
||||||
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !aQuiet ) {
|
if (aPS) {
|
||||||
rv = NS_ERROR_FAILURE;
|
PRBool tofile = PR_FALSE;
|
||||||
// create a nsISupportsArray of the parameters
|
PRInt32 copies = 1;
|
||||||
// being passed to the window
|
PRUnichar *printer = nsnull;
|
||||||
nsCOMPtr<nsISupportsArray> array;
|
PRUnichar *printfile = nsnull;
|
||||||
NS_NewISupportsArray(getter_AddRefs(array));
|
|
||||||
if (!array) return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPrintSettings> ps = aPS;
|
mPrintSettings->GetPrinterName(&printer);
|
||||||
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
|
mPrintSettings->GetToFileName(&printfile);
|
||||||
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
|
mPrintSettings->GetPrintToFile(&tofile);
|
||||||
array->AppendElement(psSupports);
|
mPrintSettings->GetNumCopies(&copies);
|
||||||
|
|
||||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
|
if ((copies == 0) || (copies > 999)) {
|
||||||
if (ioParamBlock) {
|
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||||
ioParamBlock->SetInt(0, 0);
|
return NS_ERROR_FAILURE;
|
||||||
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
|
|
||||||
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
|
|
||||||
|
|
||||||
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"));
|
|
||||||
if (wwatch) {
|
|
||||||
nsCOMPtr<nsIDOMWindow> active;
|
|
||||||
wwatch->GetActiveWindow(getter_AddRefs(active));
|
|
||||||
nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
|
||||||
rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.xul",
|
|
||||||
"_blank", "chrome,modal,centerscreen", array,
|
|
||||||
getter_AddRefs(newWindow));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (printfile != nsnull) {
|
||||||
PRInt32 buttonPressed = 0;
|
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
|
||||||
ioParamBlock->GetInt(0, &buttonPressed);
|
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
|
||||||
if (buttonPressed == 1)
|
|
||||||
canPrint = PR_TRUE;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
|
||||||
return NS_ERROR_ABORT;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return NS_ERROR_ABORT;
|
|
||||||
} else {
|
|
||||||
canPrint = PR_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canPrint) {
|
|
||||||
if (aPS) {
|
|
||||||
PRBool tofile = PR_FALSE;
|
|
||||||
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
|
|
||||||
PRInt32 fromPage = 1;
|
|
||||||
PRInt32 toPage = 1;
|
|
||||||
PRInt32 copies = 1;
|
|
||||||
PRUnichar *printer = nsnull;
|
|
||||||
PRUnichar *printfile = nsnull;
|
|
||||||
|
|
||||||
mPrintSettings->GetPrinterName(&printer);
|
|
||||||
mPrintSettings->GetPrintRange(&printRange);
|
|
||||||
mPrintSettings->GetToFileName(&printfile);
|
|
||||||
mPrintSettings->GetPrintToFile(&tofile);
|
|
||||||
mPrintSettings->GetStartPageRange(&fromPage);
|
|
||||||
mPrintSettings->GetEndPageRange(&toPage);
|
|
||||||
mPrintSettings->GetNumCopies(&copies);
|
|
||||||
|
|
||||||
if ((copies == 0) || (copies > 999)) {
|
|
||||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (printfile != nsnull) {
|
|
||||||
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
|
|
||||||
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
|
|
||||||
}
|
|
||||||
if (printer != nsnull)
|
|
||||||
strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());
|
|
||||||
|
|
||||||
mPrData.toPrinter = !tofile;
|
|
||||||
mPrData.copies = copies;
|
|
||||||
|
|
||||||
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
const nsAFlatString& printerUCS2 = NS_ConvertUTF8toUCS2(mPrData.printer);
|
|
||||||
int numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
|
|
||||||
if (numPrinters) {
|
|
||||||
for(int i = 0; (i < numPrinters) && !mQueue; i++) {
|
|
||||||
if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(printerUCS2, nsCaseInsensitiveStringComparator()))) {
|
|
||||||
SetupDevModeFromSettings(i, aPS);
|
|
||||||
mQueue = PrnDlg.SetPrinterQueue(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (printfile != nsnull)
|
|
||||||
nsMemory::Free(printfile);
|
|
||||||
|
|
||||||
if (printer != nsnull)
|
|
||||||
nsMemory::Free(printer);
|
|
||||||
}
|
}
|
||||||
|
if (printer != nsnull)
|
||||||
|
strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());
|
||||||
|
|
||||||
|
mPrData.toPrinter = !tofile;
|
||||||
|
mPrData.copies = copies;
|
||||||
|
|
||||||
|
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
const nsAFlatString& printerUCS2 = NS_ConvertUTF8toUCS2(mPrData.printer);
|
||||||
|
int numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
|
||||||
|
if (numPrinters) {
|
||||||
|
for(int i = 0; (i < numPrinters) && !mQueue; i++) {
|
||||||
|
if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(printerUCS2, nsCaseInsensitiveStringComparator()))) {
|
||||||
|
SetupDevModeFromSettings(i, aPS);
|
||||||
|
mQueue = PrnDlg.SetPrinterQueue(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printfile != nsnull)
|
||||||
|
nsMemory::Free(printfile);
|
||||||
|
|
||||||
|
if (printer != nsnull)
|
||||||
|
nsMemory::Free(printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||||
|
|
|
@ -132,14 +132,10 @@ public:
|
||||||
/**
|
/**
|
||||||
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
|
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
|
||||||
* @update dc 2/16/98
|
* @update dc 2/16/98
|
||||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
* @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview
|
||||||
* in obtaining device context spec. if nsnull is passed in for
|
|
||||||
* the aOldSpec, this will typically result in getting a device
|
|
||||||
* context spec for the default output device (i.e. default
|
|
||||||
* printer).
|
|
||||||
* @return error status
|
* @return error status
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||||
|
|
||||||
NS_IMETHOD ClosePrintManager();
|
NS_IMETHOD ClosePrintManager();
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче