mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Back out patch from bug 324072 to fix bug bug 326363 and avoid unnecessary API changes.
This commit is contained in:
parent
273d4b1fbd
commit
25b3c8b15a
@ -753,7 +753,7 @@ const long NSFindPanelActionSetFindString = 7;
|
||||
if (mUseGlobalPrintSettings) {
|
||||
psService->GetGlobalPrintSettings(&mPrintSettings);
|
||||
if (mPrintSettings)
|
||||
psService->InitPrintSettingsFromPrefs(mPrintSettings,
|
||||
psService->InitPrintSettingsFromPrefs(mPrintSettings, PR_FALSE,
|
||||
nsIPrintSettings::kInitSaveNativeData);
|
||||
}
|
||||
else
|
||||
|
@ -3594,6 +3594,7 @@ nsGlobalWindow::Print()
|
||||
if (printerName)
|
||||
printSettingsService->InitPrintSettingsFromPrinter(printerName, printSettings);
|
||||
printSettingsService->InitPrintSettingsFromPrefs(printSettings,
|
||||
PR_TRUE,
|
||||
nsIPrintSettings::kInitSaveAll);
|
||||
} else {
|
||||
printSettingsService->GetNewPrintSettings(getter_AddRefs(printSettings));
|
||||
|
@ -283,7 +283,7 @@ function setPrinterDefaultsForSelectedPrinter()
|
||||
gPrintService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings);
|
||||
|
||||
// now augment them with any values from last time
|
||||
gPrintService.initPrintSettingsFromPrefs(gPrintSettings, gPrintSettingsInterface.kInitSaveAll);
|
||||
gPrintService.initPrintSettingsFromPrefs(gPrintSettings, true, gPrintSettingsInterface.kInitSaveAll);
|
||||
|
||||
if (gDoDebug) {
|
||||
dump("pagesetup/setPrinterDefaultsForSelectedPrinter: printerName='"+gPrintSettings.printerName+"', orientation='"+gPrintSettings.orientation+"'\n");
|
||||
|
@ -154,7 +154,7 @@ var PrintUtils = {
|
||||
// First get any defaults from the printer
|
||||
aPSSVC.initPrintSettingsFromPrinter(aPrintSettings.printerName, aPrintSettings);
|
||||
// now augment them with any values from last time
|
||||
aPSSVC.initPrintSettingsFromPrefs(aPrintSettings, aPrintSettings.kInitSaveAll);
|
||||
aPSSVC.initPrintSettingsFromPrefs(aPrintSettings, true, aPrintSettings.kInitSaveAll);
|
||||
},
|
||||
|
||||
getPrintSettings: function ()
|
||||
|
@ -209,7 +209,7 @@ function setPrinterDefaultsForSelectedPrinter()
|
||||
printService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings);
|
||||
|
||||
// now augment them with any values from last time
|
||||
printService.initPrintSettingsFromPrefs(gPrintSettings, gPrintSetInterface.kInitSaveAll);
|
||||
printService.initPrintSettingsFromPrefs(gPrintSettings, true, gPrintSetInterface.kInitSaveAll);
|
||||
|
||||
if (doDebug) {
|
||||
dump("setPrinterDefaultsForSelectedPrinter: printerName='"+gPrintSettings.printerName+"', paperName='"+gPrintSettings.paperName+"'\n");
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
interface nsIPrintSettings;
|
||||
|
||||
[scriptable, uuid(1a64316f-402d-4b0d-a434-ba419dbe539e)]
|
||||
[scriptable, uuid(841387C8-72E6-484b-9296-BF6EEA80D58A)]
|
||||
interface nsIPrintSettingsService : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -72,7 +72,7 @@ interface nsIPrintSettingsService : nsISupports
|
||||
readonly attribute nsIPrintSettings newPrintSettings;
|
||||
|
||||
/**
|
||||
* The name of the last printer used, or else the system default printer.
|
||||
* The name of the default printer
|
||||
*/
|
||||
readonly attribute wstring defaultPrinterName;
|
||||
|
||||
@ -90,23 +90,21 @@ interface nsIPrintSettingsService : nsISupports
|
||||
* Reads PrintSettings values from Prefs,
|
||||
* the values to be read are indicated by the "flags" arg.
|
||||
*
|
||||
* aPrintSettings should be initialized with the name of a printer. First
|
||||
* it reads in the PrintSettings from the last print job. Then it uses the
|
||||
* PrinterName in the PrinterSettings to read any settings that were saved
|
||||
* First it reads in the "generic" set of PrintSetings not associated with any printer
|
||||
* then it uses the PrinterName in the PrinterSettings to read any settings that were saved
|
||||
* just for that printer.
|
||||
*
|
||||
* aPS - PrintSettings to have its settings read
|
||||
* aFlags - indicates which prefs to read, see nsIPrintSettings.idl for the
|
||||
* const values.
|
||||
* aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix
|
||||
* aFlags - indicates which prefs to read, see nsIPrintSettings.idl for the const values.
|
||||
*
|
||||
* Items not read:
|
||||
* startPageRange, endPageRange, scaling, printRange, title
|
||||
* docURL, howToEnableFrameUI, isCancelled, printFrameTypeUsage
|
||||
* printFrameType, printSilent, shrinkToFit, numCopies,
|
||||
* printerName
|
||||
* printFrameType, printSilent, shrinkToFit, numCopies
|
||||
*
|
||||
*/
|
||||
void initPrintSettingsFromPrefs(in nsIPrintSettings aPrintSettings, in unsigned long aFlags);
|
||||
void initPrintSettingsFromPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags);
|
||||
|
||||
/**
|
||||
* Writes PrintSettings values to Prefs,
|
||||
|
@ -80,12 +80,8 @@ nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsXPIDLString printerName;
|
||||
rv = GetDefaultPrinterName(getter_Copies(printerName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
(*_retval)->SetPrinterName(printerName.get());
|
||||
|
||||
(void)InitPrintSettingsFromPrefs(*_retval, nsIPrintSettings::kInitSaveAll);
|
||||
(void)InitPrintSettingsFromPrefs(*_retval, PR_FALSE,
|
||||
nsIPrintSettings::kInitSaveAll);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ex: set tabstop=8 softtabstop=2 shiftwidth=2 expandtab: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -580,6 +579,13 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
|
||||
}
|
||||
}
|
||||
|
||||
if (aFlags & nsIPrintSettings::kInitSavePrinterName) {
|
||||
if (GETSTRPREF(kPrinterName, str)) {
|
||||
aPS->SetPrinterName(str.get());
|
||||
DUMP_STR(kReadStr, kPrinterName, str.get());
|
||||
}
|
||||
}
|
||||
|
||||
if (aFlags & nsIPrintSettings::kInitSavePrintToFile) {
|
||||
if (GETBOOLPREF(kPrintToFile, &b)) {
|
||||
aPS->SetPrintToFile(b);
|
||||
@ -841,12 +847,10 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName,
|
||||
}
|
||||
}
|
||||
|
||||
// Only the general version of this pref is saved
|
||||
if ((aFlags & nsIPrintSettings::kInitSavePrinterName)
|
||||
&& aPrinterName.IsEmpty()) {
|
||||
if (aFlags & nsIPrintSettings::kInitSavePrinterName) {
|
||||
if (NS_SUCCEEDED(aPS->GetPrinterName(&uStr))) {
|
||||
DUMP_STR(kWriteStr, kPrinterName, uStr);
|
||||
WritePrefString(uStr, kPrinterName);
|
||||
WritePrefString(uStr, GetPrefName(kPrinterName, aPrinterName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -942,13 +946,8 @@ nsresult nsPrintOptions::_CreatePrintSettings(nsIPrintSettings **_retval)
|
||||
NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*_retval = printSettings); // ref count
|
||||
|
||||
nsXPIDLString printerName;
|
||||
nsresult rv = GetDefaultPrinterName(getter_Copies(printerName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
(*_retval)->SetPrinterName(printerName.get());
|
||||
|
||||
(void)InitPrintSettingsFromPrefs(*_retval, nsIPrintSettings::kInitSaveAll);
|
||||
(void)InitPrintSettingsFromPrefs(*_retval, PR_FALSE,
|
||||
nsIPrintSettings::kInitSaveAll);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -985,32 +984,6 @@ nsPrintOptions::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName)
|
||||
&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Look up the printer from the last print job
|
||||
nsAutoString lastPrinterName;
|
||||
ReadPrefString(kPrinterName, lastPrinterName);
|
||||
if (!lastPrinterName.IsEmpty()) {
|
||||
// Verify it's still a valid printer
|
||||
PRUnichar **printers;
|
||||
PRUint32 ctPrinters;
|
||||
rv = prtEnum->EnumeratePrinters(&ctPrinters, &printers);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRBool isValid = PR_FALSE;
|
||||
for (PRUint32 ii = ctPrinters; ii--; ) {
|
||||
if (lastPrinterName.Equals(printers[ii])) {
|
||||
isValid = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(ctPrinters, printers);
|
||||
if (isValid) {
|
||||
*aDefaultPrinterName = ToNewUnicode(lastPrinterName);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// There is no last printer preference, or it doesn't name a valid printer.
|
||||
// Return the default from the printer enumeration.
|
||||
return prtEnum->GetDefaultPrinterName(aDefaultPrinterName);
|
||||
}
|
||||
|
||||
@ -1114,7 +1087,7 @@ nsPrintOptions::GetPrinterPrefInt(nsIPrintSettings *aPrintSettings,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintOptions::InitPrintSettingsFromPrefs(nsIPrintSettings* aPS,
|
||||
PRUint32 aFlags)
|
||||
PRBool aUsePNP, PRUint32 aFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPS);
|
||||
|
||||
@ -1132,13 +1105,11 @@ nsPrintOptions::InitPrintSettingsFromPrefs(nsIPrintSettings* aPS,
|
||||
|
||||
// Get the Printer Name from the PrintSettings
|
||||
// to use as a prefix for Pref Names
|
||||
rv = GetAdjustedPrinterName(aPS, PR_TRUE, prtName);
|
||||
rv = GetAdjustedPrinterName(aPS, aUsePNP, prtName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (prtName.IsEmpty()) {
|
||||
NS_WARNING("Caller should supply a printer name.");
|
||||
if (prtName.IsEmpty())
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Now read any printer specific prefs
|
||||
rv = ReadPrefs(aPS, prtName, aFlags);
|
||||
@ -1417,7 +1388,8 @@ Tester::Tester()
|
||||
printf("------------------------------------------------\n");
|
||||
printf("%d) %s -> 0x%X\n", i, gSettings[i].mName, gSettings[i].mFlag);
|
||||
printService->SavePrintSettingsToPrefs(ps, PR_TRUE, gSettings[i].mFlag);
|
||||
printService->InitPrintSettingsFromPrefs(ps, gSettings[i].mFlag);
|
||||
printService->InitPrintSettingsFromPrefs(ps, PR_TRUE,
|
||||
gSettings[i].mFlag);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ var PrintUtils = {
|
||||
// First get any defaults from the printer
|
||||
aPrintService.initPrintSettingsFromPrinter(aPrintSettings.printerName, aPrintSettings);
|
||||
// now augment them with any values from last time
|
||||
aPrintService.initPrintSettingsFromPrefs(aPrintSettings, aPrintSettings.kInitSaveAll);
|
||||
aPrintService.initPrintSettingsFromPrefs(aPrintSettings, true, aPrintSettings.kInitSaveAll);
|
||||
},
|
||||
|
||||
getPrintSettings: function ()
|
||||
|
@ -283,7 +283,7 @@ function setPrinterDefaultsForSelectedPrinter()
|
||||
gPrintService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings);
|
||||
|
||||
// now augment them with any values from last time
|
||||
gPrintService.initPrintSettingsFromPrefs(gPrintSettings, gPrintSettingsInterface.kInitSaveAll);
|
||||
gPrintService.initPrintSettingsFromPrefs(gPrintSettings, true, gPrintSettingsInterface.kInitSaveAll);
|
||||
|
||||
if (gDoDebug) {
|
||||
dump("pagesetup/setPrinterDefaultsForSelectedPrinter: printerName='"+gPrintSettings.printerName+"', orientation='"+gPrintSettings.orientation+"'\n");
|
||||
|
@ -209,7 +209,7 @@ function setPrinterDefaultsForSelectedPrinter()
|
||||
printService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings);
|
||||
|
||||
// now augment them with any values from last time
|
||||
printService.initPrintSettingsFromPrefs(gPrintSettings, gPrintSetInterface.kInitSaveAll);
|
||||
printService.initPrintSettingsFromPrefs(gPrintSettings, true, gPrintSetInterface.kInitSaveAll);
|
||||
|
||||
if (doDebug) {
|
||||
dump("setPrinterDefaultsForSelectedPrinter: printerName='"+gPrintSettings.printerName+"', paperName='"+gPrintSettings.paperName+"'\n");
|
||||
|
Loading…
Reference in New Issue
Block a user