Bug 315687 - Sanity check paper size prefs created before bug 309988 was fixed. r=vladimir, sr=pavlov.

This commit is contained in:
kherron%fmailbox.com 2007-07-15 12:27:59 +00:00
Родитель f0cb98ced8
Коммит d8000a902c
12 изменённых файлов: 71 добавлений и 152 удалений

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

@ -60,7 +60,6 @@ nsPrintSettings::nsPrintSettings() :
mPrintOptions(0L),
mPrintReversed(PR_FALSE),
mPrintInColor(PR_TRUE),
mPaperSize(kLetterPaperSize),
mOrientation(kPortraitOrientation),
mPrintToFile(PR_FALSE),
mPrintFrameType(kFramesAsIs),
@ -144,19 +143,6 @@ NS_IMETHODIMP nsPrintSettings::SetPrintInColor(PRBool aPrintInColor)
return NS_OK;
}
/* attribute short paperSize; */
NS_IMETHODIMP nsPrintSettings::GetPaperSize(PRInt32 *aPaperSize)
{
//NS_ENSURE_ARG_POINTER(aPaperSize);
*aPaperSize = mPaperSize;
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::SetPaperSize(PRInt32 aPaperSize)
{
mPaperSize = aPaperSize;
return NS_OK;
}
/* attribute short orientation; */
NS_IMETHODIMP nsPrintSettings::GetOrientation(PRInt32 *aOrientation)
{

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

@ -92,7 +92,6 @@ protected:
PRBool mPrintReversed;
PRBool mPrintInColor; // a false means grayscale
PRInt32 mPaperSize; // see page size consts
PRInt32 mOrientation; // see orientation consts
nsString mPrintCommand;
PRBool mPrintToFile;

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

@ -406,11 +406,7 @@ function onAccept()
saveToPrefs = gPrefs.getBoolPref("print.save_print_settings");
if (saveToPrefs && printService != null) {
var flags = gPrintSetInterface.kInitSavePaperSizeType |
gPrintSetInterface.kInitSavePaperSizeUnit |
gPrintSetInterface.kInitSavePaperWidth |
gPrintSetInterface.kInitSavePaperHeight |
gPrintSetInterface.kInitSavePaperName |
var flags = gPrintSetInterface.kInitSavePaperSize |
gPrintSetInterface.kInitSaveColorSpace |
gPrintSetInterface.kInitSaveInColor |
gPrintSetInterface.kInitSaveResolutionName |

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

@ -201,7 +201,6 @@ function createPaperArrayFromDefaults()
obj.width = paperWidths[i];
obj.height = paperHeights[i];
obj.inches = paperInches[i];
obj.paperSize = paperEnums[i]; // deprecated
/* Calculate the width/height in millimeters */
if (paperInches[i]) {
@ -238,7 +237,6 @@ function createPaperArrayFromPrinterFeatures()
obj.width_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".width_mm");
obj.height_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".height_mm");
obj.inches = gPrefs.getBoolPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".is_inch");
obj.paperSize = 666; // deprecated
/* Calculate the width/height in paper's native units (either inches or millimeters) */
if (obj.inches) {
@ -909,7 +907,6 @@ function onAccept()
print_resolution_name = gResolutionArray[resolutionSelectedInx].name;
print_colorspace = gColorspaceArray[colorspaceSelectedInx].name;
gPrintSettings.paperSize = gPaperArray[paperSelectedInx].paperSize; // deprecated
gPrintSettings.paperSizeType = print_paper_type;
gPrintSettings.paperSizeUnit = print_paper_unit;
gPrintSettings.paperWidth = print_paper_width;
@ -944,7 +941,6 @@ function onAccept()
if (doDebug) {
dump("onAccept******************************\n");
dump("paperSize "+gPrintSettings.paperSize+" (deprecated)\n");
dump("paperSizeType "+print_paper_type+" (should be 1)\n");
dump("paperSizeUnit "+print_paper_unit+"\n");
dump("paperWidth "+print_paper_width+"\n");

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

@ -1 +1 @@
Clobbering to unbreak sessionstore from changes in bug 386635.
Trying to get win32 tinderboxen to accept nsIPrintSettings uuid change.

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

@ -58,7 +58,7 @@ interface nsIPrintSession;
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(f1094df6-ce0e-42c9-9847-2f663172c38d)]
[scriptable, uuid(b1b5e3cc-a52c-4325-a7f6-e1ac6fac19a5)]
interface nsIPrintSettings : nsISupports
{
@ -75,12 +75,12 @@ interface nsIPrintSettings : nsISupports
const unsigned long kInitSaveBGColors = 0x00000080;
const unsigned long kInitSaveBGImages = 0x00000100;
const unsigned long kInitSavePaperSize = 0x00000200;
const unsigned long kInitSavePaperName = 0x00000400;
const unsigned long kInitSavePaperSizeUnit = 0x00000800;
const unsigned long kInitSavePaperSizeType = 0x00001000;
/* Flag 0x00000400 is unused */
/* Flag 0x00000800 is unused */
/* Flag 0x00001000 is unused */
const unsigned long kInitSavePaperData = 0x00002000;
const unsigned long kInitSavePaperWidth = 0x00004000;
const unsigned long kInitSavePaperHeight = 0x00008000;
/* Flag 0x00004000 is unused */
/* Flag 0x00008000 is unused */
const unsigned long kInitSaveReversed = 0x00010000;
const unsigned long kInitSaveInColor = 0x00020000;
@ -249,7 +249,6 @@ interface nsIPrintSettings : nsISupports
attribute boolean printReversed;
attribute boolean printInColor; /* a false means grayscale */
attribute long paperSize; /* see page size consts */
attribute long orientation; /* see orientation consts */
attribute wstring printCommand;
attribute long numCopies;

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

@ -243,7 +243,6 @@ Tester::Tester()
ps->SetPaperSizeUnit(nsIPrintSettings::kPaperSizeMillimeters);
ps->SetPrintReversed(PR_TRUE);
ps->SetPrintInColor(PR_TRUE);
ps->SetPaperSize(5);
ps->SetOrientation(nsIPrintSettings::kLandscapeOrientation);
ps->SetPrintCommand(NS_ConvertUTF8toUTF16("Command").get());
ps->SetNumCopies(2);

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

@ -86,8 +86,6 @@ static const char kPrintFooterStrCenter[] = "print_footercenter";
static const char kPrintFooterStrRight[] = "print_footerright";
// Additional Prefs
static const char kPrintPaperSize[] = "print_paper_size"; // deprecated
static const char kPrintReversed[] = "print_reversed";
static const char kPrintInColor[] = "print_in_color";
static const char kPrintPaperName[] = "print_paper_name";
@ -302,6 +300,40 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
) \
)
// Paper size prefs are read as a group
if (aFlags & nsIPrintSettings::kInitSavePaperSize) {
PRInt32 sizeUnit, sizeType;
double width, height;
PRBool success = GETINTPREF(kPrintPaperSizeUnit, &sizeUnit)
&& GETINTPREF(kPrintPaperSizeType, &sizeType)
&& GETDBLPREF(kPrintPaperWidth, width)
&& GETDBLPREF(kPrintPaperHeight, height)
&& GETSTRPREF(kPrintPaperName, str);
// Bug 315687: Sanity check paper size to avoid paper size values in
// mm when the size unit flag is inches. The value 100 is arbitrary
// and can be changed.
if (success) {
success = (sizeUnit == nsIPrintSettings::kPaperSizeInches)
&& (width < 100.0)
&& (height < 100.0);
}
if (success) {
aPS->SetPaperSizeUnit(sizeUnit);
DUMP_INT(kReadStr, kPrintPaperSizeUnit, sizeUnit);
aPS->SetPaperSizeType(sizeType);
DUMP_INT(kReadStr, kPrintPaperSizeType, sizeType);
aPS->SetPaperWidth(width);
DUMP_DBL(kReadStr, kPrintPaperWidth, width);
aPS->SetPaperHeight(height);
DUMP_DBL(kReadStr, kPrintPaperHeight, height);
aPS->SetPaperName(str.get());
DUMP_STR(kReadStr, kPrintPaperName, str.get());
}
}
if (aFlags & nsIPrintSettings::kInitSaveOddEvenPages) {
if (GETBOOLPREF(kPrintEvenPages, &b)) {
aPS->SetPrintOptions(nsIPrintSettings::kPrintEvenPages, b);
@ -372,13 +404,6 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperSize) {
if (GETINTPREF(kPrintPaperSize, &iVal)) { // this has been deprecated
aPS->SetPaperSize(iVal);
DUMP_INT(kReadStr, kPrintPaperSize, iVal);
}
}
if (aFlags & nsIPrintSettings::kInitSaveReversed) {
if (GETBOOLPREF(kPrintReversed, &b)) {
aPS->SetPrintReversed(b);
@ -393,13 +418,6 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperName) {
if (GETSTRPREF(kPrintPaperName, str)) {
aPS->SetPaperName(str.get());
DUMP_STR(kReadStr, kPrintPaperName, str.get());
}
}
if (aFlags & nsIPrintSettings::kInitSavePlexName) {
if (GETSTRPREF(kPrintPlexName, str)) {
aPS->SetPlexName(str.get());
@ -407,20 +425,6 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperSizeUnit) {
if (GETINTPREF(kPrintPaperSizeUnit, &iVal)) {
aPS->SetPaperSizeUnit(iVal);
DUMP_INT(kReadStr, kPrintPaperSizeUnit, iVal);
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperSizeType) {
if (GETINTPREF(kPrintPaperSizeType, &iVal)) {
aPS->SetPaperSizeType(iVal);
DUMP_INT(kReadStr, kPrintPaperSizeType, iVal);
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperData) {
if (GETINTPREF(kPrintPaperData, &iVal)) {
aPS->SetPaperData(iVal);
@ -428,20 +432,6 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperWidth) {
if (GETDBLPREF(kPrintPaperWidth, dbl)) {
aPS->SetPaperWidth(dbl);
DUMP_DBL(kReadStr, kPrintPaperWidth, dbl);
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperHeight) {
if (GETDBLPREF(kPrintPaperHeight, dbl)) {
aPS->SetPaperHeight(dbl);
DUMP_DBL(kReadStr, kPrintPaperHeight, dbl);
}
}
if (aFlags & nsIPrintSettings::kInitSaveColorspace) {
if (GETSTRPREF(kPrintColorspace, str)) {
aPS->SetColorspace(str.get());
@ -547,6 +537,34 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName,
}
}
// Paper size prefs are saved as a group
if (aFlags & nsIPrintSettings::kInitSavePaperSize) {
PRInt16 sizeUnit, sizeType;
double width, height;
PRUnichar *name;
if (
NS_SUCCEEDED(aPS->GetPaperSizeUnit(&sizeUnit)) &&
NS_SUCCEEDED(aPS->GetPaperSizeType(&sizeType)) &&
NS_SUCCEEDED(aPS->GetPaperWidth(&width)) &&
NS_SUCCEEDED(aPS->GetPaperHeight(&height)) &&
NS_SUCCEEDED(aPS->GetPaperName(&name))
) {
DUMP_INT(kWriteStr, kPrintPaperSizeUnit, sizeUnit);
mPrefBranch->SetIntPref(GetPrefName(kPrintPaperSizeUnit, aPrinterName),
PRInt32(sizeUnit));
DUMP_INT(kWriteStr, kPrintPaperSizeType, sizeType);
mPrefBranch->SetIntPref(GetPrefName(kPrintPaperSizeType, aPrinterName),
PRInt32(sizeType));
DUMP_DBL(kWriteStr, kPrintPaperWidth, width);
WritePrefDouble(GetPrefName(kPrintPaperWidth, aPrinterName), width);
DUMP_DBL(kWriteStr, kPrintPaperHeight, height);
WritePrefDouble(GetPrefName(kPrintPaperHeight, aPrinterName), height);
DUMP_STR(kWriteStr, kPrintPaperName, name);
WritePrefString(name, GetPrefName(kPrintPaperName, aPrinterName));
}
}
PRBool b;
PRUnichar* uStr;
PRInt32 iVal;
@ -627,14 +645,6 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName,
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperSize) {
if (NS_SUCCEEDED(aPS->GetPaperSize(&iVal))) {
DUMP_INT(kWriteStr, kPrintPaperSize, iVal);
mPrefBranch->SetIntPref(GetPrefName(kPrintPaperSize, aPrinterName), iVal);
// this has been deprecated
}
}
if (aFlags & nsIPrintSettings::kInitSaveReversed) {
if (NS_SUCCEEDED(aPS->GetPrintReversed(&b))) {
DUMP_BOOL(kWriteStr, kPrintReversed, b);
@ -649,13 +659,6 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName,
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperName) {
if (NS_SUCCEEDED(aPS->GetPaperName(&uStr))) {
DUMP_STR(kWriteStr, kPrintPaperName, uStr);
WritePrefString(uStr, GetPrefName(kPrintPaperName, aPrinterName));
}
}
if (aFlags & nsIPrintSettings::kInitSavePlexName) {
if (NS_SUCCEEDED(aPS->GetPlexName(&uStr))) {
DUMP_STR(kWriteStr, kPrintPlexName, uStr);
@ -663,22 +666,6 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName,
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperSizeUnit) {
if (NS_SUCCEEDED(aPS->GetPaperSizeUnit(&iVal16))) {
DUMP_INT(kWriteStr, kPrintPaperSizeUnit, iVal16);
mPrefBranch->SetIntPref(GetPrefName(kPrintPaperSizeUnit, aPrinterName),
PRInt32(iVal16));
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperSizeType) {
if (NS_SUCCEEDED(aPS->GetPaperSizeType(&iVal16))) {
DUMP_INT(kWriteStr, kPrintPaperSizeType, iVal16);
mPrefBranch->SetIntPref(GetPrefName(kPrintPaperSizeType, aPrinterName),
PRInt32(iVal16));
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperData) {
if (NS_SUCCEEDED(aPS->GetPaperData(&iVal16))) {
DUMP_INT(kWriteStr, kPrintPaperData, iVal16);
@ -687,20 +674,6 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName,
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperWidth) {
if (NS_SUCCEEDED(aPS->GetPaperWidth(&dbl))) {
DUMP_DBL(kWriteStr, kPrintPaperWidth, dbl);
WritePrefDouble(GetPrefName(kPrintPaperWidth, aPrinterName), dbl);
}
}
if (aFlags & nsIPrintSettings::kInitSavePaperHeight) {
if (NS_SUCCEEDED(aPS->GetPaperHeight(&dbl))) {
DUMP_DBL(kWriteStr, kPrintPaperHeight, dbl);
WritePrefDouble(GetPrefName(kPrintPaperHeight, aPrinterName), dbl);
}
}
if (aFlags & nsIPrintSettings::kInitSaveColorspace) {
if (NS_SUCCEEDED(aPS->GetColorspace(&uStr))) {
DUMP_STR(kWriteStr, kPrintColorspace, uStr);
@ -1244,7 +1217,6 @@ Tester::Tester()
ps->SetPaperSizeUnit(nsIPrintSettings::kPaperSizeMillimeters);
ps->SetPrintReversed(PR_TRUE);
ps->SetPrintInColor(PR_TRUE);
ps->SetPaperSize(5);
ps->SetOrientation(nsIPrintSettings::kLandscapeOrientation);
ps->SetPrintCommand(NS_ConvertUTF8toUTF16("Command").get());
ps->SetNumCopies(2);
@ -1270,13 +1242,8 @@ Tester::Tester()
{kPrintBGImages, nsIPrintSettings::kInitSaveBGImages},
{kPrintShrinkToFit, nsIPrintSettings::kInitSaveShrinkToFit},
{kPrintPaperSize, nsIPrintSettings::kInitSavePaperSize},
{kPrintPaperName, nsIPrintSettings::kInitSavePaperName},
{kPrintPlexName, nsIPrintSettings::kInitSavePlexName},
{kPrintPaperSizeUnit, nsIPrintSettings::kInitSavePaperSizeUnit},
{kPrintPaperSizeType, nsIPrintSettings::kInitSavePaperSizeType},
{kPrintPaperData, nsIPrintSettings::kInitSavePaperData},
{kPrintPaperWidth, nsIPrintSettings::kInitSavePaperWidth},
{kPrintPaperHeight, nsIPrintSettings::kInitSavePaperHeight},
{kPrintReversed, nsIPrintSettings::kInitSaveReversed},
{kPrintInColor, nsIPrintSettings::kInitSaveInColor},
{kPrintColorspace, nsIPrintSettings::kInitSaveColorspace},

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

@ -191,19 +191,6 @@ NS_IMETHODIMP nsPrintSettings::SetPrintInColor(PRBool aPrintInColor)
return NS_OK;
}
/* attribute short paperSize; */
NS_IMETHODIMP nsPrintSettings::GetPaperSize(PRInt32 *aPaperSize)
{
//NS_ENSURE_ARG_POINTER(aPaperSize);
*aPaperSize = mPaperSize;
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::SetPaperSize(PRInt32 aPaperSize)
{
mPaperSize = aPaperSize;
return NS_OK;
}
/* attribute short orientation; */
NS_IMETHODIMP nsPrintSettings::GetOrientation(PRInt32 *aOrientation)
{
@ -999,7 +986,6 @@ nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs)
mPaperSizeUnit = rhs.mPaperSizeUnit;
mPrintReversed = rhs.mPrintReversed;
mPrintInColor = rhs.mPrintInColor;
mPaperSize = rhs.mPaperSize;
mOrientation = rhs.mOrientation;
mPrintCommand = rhs.mPrintCommand;
mNumCopies = rhs.mNumCopies;

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

@ -118,7 +118,6 @@ protected:
PRBool mPrintReversed;
PRBool mPrintInColor; // a false means grayscale
PRInt32 mPaperSize; // see page size consts
PRInt32 mOrientation; // see orientation consts
nsString mColorspace;
nsString mResolutionName;

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

@ -405,11 +405,7 @@ function onAccept()
saveToPrefs = gPrefs.getBoolPref("print.save_print_settings");
if (saveToPrefs && printService != null) {
var flags = gPrintSetInterface.kInitSavePaperSizeType |
gPrintSetInterface.kInitSavePaperSizeUnit |
gPrintSetInterface.kInitSavePaperWidth |
gPrintSetInterface.kInitSavePaperHeight |
gPrintSetInterface.kInitSavePaperName |
var flags = gPrintSetInterface.kInitSavePaperSize |
gPrintSetInterface.kInitSaveColorSpace |
gPrintSetInterface.kInitSaveInColor |
gPrintSetInterface.kInitSaveResolutionName |

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

@ -200,7 +200,6 @@ function createPaperArrayFromDefaults()
obj.width = paperWidths[i];
obj.height = paperHeights[i];
obj.inches = paperInches[i];
obj.paperSize = paperEnums[i]; // deprecated
/* Calculate the width/height in millimeters */
if (paperInches[i]) {
@ -237,7 +236,6 @@ function createPaperArrayFromPrinterFeatures()
obj.width_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".width_mm");
obj.height_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".height_mm");
obj.inches = gPrefs.getBoolPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".is_inch");
obj.paperSize = 666; // deprecated
/* Calculate the width/height in paper's native units (either inches or millimeters) */
if (obj.inches) {
@ -908,7 +906,6 @@ function onAccept()
print_resolution_name = gResolutionArray[resolutionSelectedInx].name;
print_colorspace = gColorspaceArray[colorspaceSelectedInx].name;
gPrintSettings.paperSize = gPaperArray[paperSelectedInx].paperSize; // deprecated
gPrintSettings.paperSizeType = print_paper_type;
gPrintSettings.paperSizeUnit = print_paper_unit;
gPrintSettings.paperWidth = print_paper_width;
@ -943,7 +940,6 @@ function onAccept()
if (doDebug) {
dump("onAccept******************************\n");
dump("paperSize "+gPrintSettings.paperSize+" (deprecated)\n");
dump("paperSizeType "+print_paper_type+" (should be 1)\n");
dump("paperSizeUnit "+print_paper_unit+"\n");
dump("paperWidth "+print_paper_width+"\n");