Closed Bug 151628 Opened 22 years ago Closed 22 years ago

API - Freeze - nsIPrintSettings needs assignment method

Categories

(Core :: Printing: Output, defect, P1)

x86
Windows 2000
defect

Tracking

()

VERIFIED FIXED
mozilla1.0.1

People

(Reporter: rods, Assigned: rods)

Details

(Keywords: topembed+, Whiteboard: [ADT2])

Attachments

(2 files, 1 obsolete file)

Attached patch patchSplinter Review
Add "Assign" method to nsIPrintSettings to assign values from one PS to another.
Status: NEW → ASSIGNED
Keywords: topembed
Target Milestone: --- → mozilla1.0.1
Comment on attachment 87559 [details] [diff] [review] patch +// Assignment helper macros +#define AssignDBL(_name) \ +if (NS_SUCCEEDED(aPS->Get##_name(&dbl))) { \ ... There's a few of these macros, please rename them so that they match the normal macro naming convention ni mozilla, i.e. all upper case, so in stead of AssignDBL(), make it ASSIGN_DBL(), otherwise the call-sites look too much like they're calling functions. - In nsPrintSettingsMac::AssignObj(): + if (psMac) { + if (mPrintRecord) + ::DisposeHandle((Handle)mPrintRecord); Stick to 2-space indentation. - In nsPrintSettingsX::AssignObj() + NS_ENSURE_ARG_POINTER(aPS); + + nsCOMPtr<nsIPrintSettingsX> psX = do_QueryInterface(aPS); + if (psX) { + if (mPageFormat != kPMNoPageFormat) { + ::PMDisposePageFormat(mPageFormat); + mPageFormat = kPMNoPageFormat; + } + + psX->GetPMPageFormat(&mPageFormat); + psX->GetPMPrintSettings(&mPrintSettings); + + } Why the empty line above this closing brace? + + return NS_ERROR_FAILURE; +} Why not start out with: + nsCOMPtr<nsIPrintSettingsX> psX = do_QueryInterface(aPS); + if (!psX) { + return NS_ERROR_FAILURE; + } and then go on with the normal code...? Then you can loose the NS_ENSURE_ARG_POINTER() too. - In nsPrintSettingsWin::AssignObj(): + if (mDeviceName) nsCRT::free(mDeviceName); + if (mDriverName) nsCRT::free(mDriverName); + if (mDevMode) free(mDevMode); This looks inconsistent, why not nsCRT::free(mDevMode)? And please split those if's onto two lines, and add braces while you're at it. Oh, and same thing here, check for the bad input first and return the error early in stead of putting all the code inside an if. sr=jst if you fix that.
Attachment #87559 - Flags: superreview+
Attached patch alt. patch (obsolete) — Splinter Review
This is an alternative patch that uses an assignment operator.
Attachment #87951 - Attachment is obsolete: true
This is the correct alt. patch that uses the assigment operator
Comment on attachment 87952 [details] [diff] [review] alternative patch r=ccarlen
Attachment #87952 - Flags: review+
Comment on attachment 87952 [details] [diff] [review] alternative patch sr=jst, but don't you want nsPrintSettings& operator=(const nsPrintSettings& rhs); to be virtual to make sure the right one is called regardless of the type of the reference you happen to have to one of these things when you call that operator?
Attachment #87952 - Flags: superreview+
The other platforms need it fixed
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
topembed+. This is needed to freeze the printing API's.
Keywords: topembedtopembed+
Priority: -- → P1
Keywords: adt1.0.1
I added virtual to the assignment operator per jst's suggestion.
Verified on trunk 06/20/02 Win2K, Linux. I checked Page Setup functionality, no regressions.
Status: RESOLVED → VERIFIED
Whiteboard: [Need Impact]
adt: This is a low risk patch that is needed for embedding only. This change is needed before we can freeze the printing API's. Without this change the printing API's will remain unfrozen.
Whiteboard: [Need Impact] → [ADT2]
please checkin to the 1.0.1 branch. once there, remove the "mozilla1.0.1+" keyword and add the "fixed1.0.1" keyword.
Attachment #87952 - Flags: approval+
ADT: Although the patch is large, the important part of the change is just adding the the argument to the call. The rest of the patch, the "Assign" method and copy constructor which made it large, will be used on on the trunk very shortly, but is not used on the branch. So the patch is still low risk.
This bug appears to have gotten branch landing approval on 6/25 - any chance it's going to land there soon?
Adding adt1.0.1+ on behalf of adt. Please check into the Mozilla branch asap.
Keywords: adt1.0.1adt1.0.1+
1.0.1 driver aproval still stnads.
fixed on branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: