Add the new pluggable dialog work, in build, not used

BUg 135441 r=dcone,pink sr=attinasi
This commit is contained in:
rods%netscape.com 2006-02-16 21:32:04 +00:00
Родитель 961aadec60
Коммит a2ae252306
4 изменённых файлов: 63 добавлений и 66 удалений

Просмотреть файл

@ -63,14 +63,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: Init(void)
NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet)
PRBool aIsPrintPreview)
{
nsresult rv;
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aQuiet);
rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aIsPrintPreview);
if (NS_SUCCEEDED(rv)) {
aNewSpec = devSpec;
NS_ADDREF(aNewSpec);

Просмотреть файл

@ -54,7 +54,7 @@ public:
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet);
PRBool aIsPrintPreview);
protected:
~nsDeviceContextSpecFactoryOS2();

Просмотреть файл

@ -28,12 +28,7 @@
#include "nsIPref.h"
#include "prenv.h" /* for PR_GetEnv */
#include "nsIDOMWindow.h"
#include "nsIServiceManager.h"
#include "nsIDialogParamBlock.h"
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindowInternal.h"
#include "nsUnicharUtils.h"
PRINTDLG nsDeviceContextSpecOS2::PrnDlg;
@ -259,17 +254,17 @@ NS_IMPL_RELEASE(nsDeviceContextSpecOS2)
* toolkits including:
* - GTK+-toolkit:
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aPrintPreview)
* - Xlib-toolkit:
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aPrintPreview)
* - Qt-toolkit:
* 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.
*/
NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aPrintPreview)
{
nsresult rv = NS_ERROR_FAILURE;
@ -286,65 +281,46 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
}
}
PRBool canPrint = PR_FALSE;
char *path;
PRBool tofile = PR_FALSE;
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
PRInt32 fromPage = 1;
PRInt32 toPage = 1;
PRInt32 copies = 1;
PRUnichar *printer = nsnull;
PRUnichar *printfile = nsnull;
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
if ( !aQuiet ) {
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;
if (mPrintSettings) {
mPrintSettings->GetPrinterName(&printer);
mPrintSettings->GetPrintRange(&printRange);
mPrintSettings->GetToFileName(&printfile);
mPrintSettings->GetPrintToFile(&tofile);
mPrintSettings->GetStartPageRange(&fromPage);
mPrintSettings->GetEndPageRange(&toPage);
mPrintSettings->GetNumCopies(&copies);
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"));
if (ioParamBlock) {
ioParamBlock->SetInt(0, 0);
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 ((copies == 0) || (copies > 999)) {
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_FAILURE;
}
if (NS_SUCCEEDED(rv)) {
PRInt32 buttonPressed = 0;
ioParamBlock->GetInt(0, &buttonPressed);
if (buttonPressed == 1)
canPrint = PR_TRUE;
else
{
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_ABORT;
}
} else
return NS_ERROR_ABORT;
} else {
canPrint = PR_TRUE;
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());
}
<<<<<<< nsDeviceContextSpecOS2.cpp
mPrData.toPrinter = !tofile;
mPrData.copies = copies;
=======
if (canPrint) {
if (aPS) {
PRBool tofile = PR_FALSE;
@ -377,7 +353,13 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
mPrData.toPrinter = !tofile;
mPrData.copies = copies;
>>>>>>> 1.12
<<<<<<< nsDeviceContextSpecOS2.cpp
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv))
return rv;
=======
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv))
return rv;
@ -392,7 +374,25 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
}
}
}
>>>>>>> 1.12
<<<<<<< nsDeviceContextSpecOS2.cpp
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())))
mQueue = PrnDlg.SetPrinterQueue(i);
}
}
if (printfile != nsnull)
nsMemory::Free(printfile);
if (printer != nsnull)
nsMemory::Free(printer);
=======
if (printfile != nsnull)
nsMemory::Free(printfile);
@ -400,6 +400,7 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
nsMemory::Free(printer);
}
}
>>>>>>> 1.12
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return rv;

Просмотреть файл

@ -132,14 +132,10 @@ public:
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 2/16/98
* @param aQuiet if PR_TRUE, prevent the need for user intervention
* 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).
* @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview
* @return error status
*/
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
NS_IMETHOD ClosePrintManager();