From 24eade8c01af1834a5d04be8baeb61c5fe092cc9 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Tue, 7 Feb 2006 01:14:47 +0000 Subject: [PATCH] Bug 223243 margins pref no longer works patch by jblanco@us.ibm.com (Jessica Blanco) r=mkaply sr=dbaron --- widget/src/xpwidgets/nsPrintOptionsImpl.cpp | 13 ++++++++----- widget/src/xpwidgets/nsPrintOptionsImpl.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp index 6fdabdf3c7f..5373087c3c3 100644 --- a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp +++ b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp @@ -383,13 +383,13 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUi nscoord halfInch = NS_INCHES_TO_TWIPS(0.5); nsMargin margin; margin.SizeTo(halfInch, halfInch, halfInch, halfInch); - ReadInchesToTwipsPref(GetPrefName(kMarginTop, aPrefName), margin.top); + ReadInchesToTwipsPref(GetPrefName(kMarginTop, aPrefName), margin.top, kMarginTop); DUMP_INT(kReadStr, kMarginTop, margin.top); - ReadInchesToTwipsPref(GetPrefName(kMarginLeft, aPrefName), margin.left); + ReadInchesToTwipsPref(GetPrefName(kMarginLeft, aPrefName), margin.left, kMarginLeft); DUMP_INT(kReadStr, kMarginLeft, margin.left); - ReadInchesToTwipsPref(GetPrefName(kMarginBottom, aPrefName), margin.bottom); + ReadInchesToTwipsPref(GetPrefName(kMarginBottom, aPrefName), margin.bottom, kMarginBottom); DUMP_INT(kReadStr, kMarginBottom, margin.bottom); - ReadInchesToTwipsPref(GetPrefName(kMarginRight, aPrefName), margin.right); + ReadInchesToTwipsPref(GetPrefName(kMarginRight, aPrefName), margin.right, kMarginRight); DUMP_INT(kReadStr, kMarginRight, margin.right); aPS->SetMarginInTwips(margin); } @@ -1141,7 +1141,8 @@ nsresult nsPrintOptions::WritePrefDouble(const char * aPrefId, //--------------------------------------------------- void nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, - nscoord& aTwips) + nscoord& aTwips, + const char * aMarginPref) { if (!mPrefBranch) { return; @@ -1149,6 +1150,8 @@ void nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, char * str = nsnull; nsresult rv = mPrefBranch->GetCharPref(aPrefId, &str); + if (NS_FAILED(rv) || !str) + rv = mPrefBranch->GetCharPref(aMarginPref, &str); if (NS_SUCCEEDED(rv) && str) { nsAutoString justStr; justStr.AssignWithConversion(str); diff --git a/widget/src/xpwidgets/nsPrintOptionsImpl.h b/widget/src/xpwidgets/nsPrintOptionsImpl.h index 6001a169344..651949682af 100644 --- a/widget/src/xpwidgets/nsPrintOptionsImpl.h +++ b/widget/src/xpwidgets/nsPrintOptionsImpl.h @@ -49,7 +49,7 @@ protected: void WriteBitFieldPref(const char * aPrefId, PRInt32 anOption); void ReadJustification(const char * aPrefId, PRInt16& aJust, PRInt16 aInitValue); void WriteJustification(const char * aPrefId, PRInt16 aJust); - void ReadInchesToTwipsPref(const char * aPrefId, nscoord& aTwips); + void ReadInchesToTwipsPref(const char * aPrefId, nscoord& aTwips, const char * aMarginPref); void WriteInchesFromTwipsPref(const char * aPrefId, nscoord aTwips); nsresult ReadPrefString(const char * aPrefId, nsString& aString);