|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsPrintSettingsImpl.h" |
|
7 #include "nsReadableUtils.h" |
|
8 #include "nsIPrintSession.h" |
|
9 |
|
10 #define DEFAULT_MARGIN_WIDTH 0.5 |
|
11 |
|
12 NS_IMPL_ISUPPORTS(nsPrintSettings, nsIPrintSettings) |
|
13 |
|
14 /** --------------------------------------------------- |
|
15 * See documentation in nsPrintSettingsImpl.h |
|
16 * @update 6/21/00 dwc |
|
17 */ |
|
18 nsPrintSettings::nsPrintSettings() : |
|
19 mPrintOptions(0L), |
|
20 mPrintRange(kRangeAllPages), |
|
21 mStartPageNum(1), |
|
22 mEndPageNum(1), |
|
23 mScaling(1.0), |
|
24 mPrintBGColors(false), |
|
25 mPrintBGImages(false), |
|
26 mPrintFrameTypeUsage(kUseInternalDefault), |
|
27 mPrintFrameType(kFramesAsIs), |
|
28 mHowToEnableFrameUI(kFrameEnableNone), |
|
29 mIsCancelled(false), |
|
30 mPrintSilent(false), |
|
31 mPrintPreview(false), |
|
32 mShrinkToFit(true), |
|
33 mShowPrintProgress(true), |
|
34 mPrintPageDelay(50), |
|
35 mPaperData(0), |
|
36 mPaperSizeType(kPaperSizeDefined), |
|
37 mPaperWidth(8.5), |
|
38 mPaperHeight(11.0), |
|
39 mPaperSizeUnit(kPaperSizeInches), |
|
40 mPrintReversed(false), |
|
41 mPrintInColor(true), |
|
42 mOrientation(kPortraitOrientation), |
|
43 mDownloadFonts(false), |
|
44 mNumCopies(1), |
|
45 mPrintToFile(false), |
|
46 mOutputFormat(kOutputFormatNative), |
|
47 mIsInitedFromPrinter(false), |
|
48 mIsInitedFromPrefs(false), |
|
49 mPersistMarginBoxSettings(true) |
|
50 { |
|
51 |
|
52 /* member initializers and constructor code */ |
|
53 int32_t marginWidth = NS_INCHES_TO_INT_TWIPS(DEFAULT_MARGIN_WIDTH); |
|
54 mMargin.SizeTo(marginWidth, marginWidth, marginWidth, marginWidth); |
|
55 mEdge.SizeTo(0, 0, 0, 0); |
|
56 mUnwriteableMargin.SizeTo(0,0,0,0); |
|
57 |
|
58 mPrintOptions = kPrintOddPages | kPrintEvenPages; |
|
59 |
|
60 mHeaderStrs[0].AssignLiteral("&T"); |
|
61 mHeaderStrs[2].AssignLiteral("&U"); |
|
62 |
|
63 mFooterStrs[0].AssignLiteral("&PT"); // Use &P (Page Num Only) or &PT (Page Num of Page Total) |
|
64 mFooterStrs[2].AssignLiteral("&D"); |
|
65 |
|
66 } |
|
67 |
|
68 /** --------------------------------------------------- |
|
69 * See documentation in nsPrintSettingsImpl.h |
|
70 * @update 6/21/00 dwc |
|
71 */ |
|
72 nsPrintSettings::nsPrintSettings(const nsPrintSettings& aPS) |
|
73 { |
|
74 *this = aPS; |
|
75 } |
|
76 |
|
77 /** --------------------------------------------------- |
|
78 * See documentation in nsPrintSettingsImpl.h |
|
79 * @update 6/21/00 dwc |
|
80 */ |
|
81 nsPrintSettings::~nsPrintSettings() |
|
82 { |
|
83 } |
|
84 |
|
85 /* [noscript] attribute nsIPrintSession printSession; */ |
|
86 NS_IMETHODIMP nsPrintSettings::GetPrintSession(nsIPrintSession **aPrintSession) |
|
87 { |
|
88 NS_ENSURE_ARG_POINTER(aPrintSession); |
|
89 *aPrintSession = nullptr; |
|
90 |
|
91 nsCOMPtr<nsIPrintSession> session = do_QueryReferent(mSession); |
|
92 if (!session) |
|
93 return NS_ERROR_NOT_INITIALIZED; |
|
94 *aPrintSession = session; |
|
95 NS_ADDREF(*aPrintSession); |
|
96 return NS_OK; |
|
97 } |
|
98 NS_IMETHODIMP nsPrintSettings::SetPrintSession(nsIPrintSession *aPrintSession) |
|
99 { |
|
100 // Clearing it by passing nullptr is not allowed. That's why we |
|
101 // use a weak ref so that it doesn't have to be cleared. |
|
102 NS_ENSURE_ARG(aPrintSession); |
|
103 |
|
104 mSession = do_GetWeakReference(aPrintSession); |
|
105 if (!mSession) { |
|
106 // This may happen if the implementation of this object does |
|
107 // not support weak references - programmer error. |
|
108 NS_ERROR("Could not get a weak reference from aPrintSession"); |
|
109 return NS_ERROR_FAILURE; |
|
110 } |
|
111 return NS_OK; |
|
112 } |
|
113 |
|
114 /* attribute long startPageRange; */ |
|
115 NS_IMETHODIMP nsPrintSettings::GetStartPageRange(int32_t *aStartPageRange) |
|
116 { |
|
117 //NS_ENSURE_ARG_POINTER(aStartPageRange); |
|
118 *aStartPageRange = mStartPageNum; |
|
119 return NS_OK; |
|
120 } |
|
121 NS_IMETHODIMP nsPrintSettings::SetStartPageRange(int32_t aStartPageRange) |
|
122 { |
|
123 mStartPageNum = aStartPageRange; |
|
124 return NS_OK; |
|
125 } |
|
126 |
|
127 /* attribute long endPageRange; */ |
|
128 NS_IMETHODIMP nsPrintSettings::GetEndPageRange(int32_t *aEndPageRange) |
|
129 { |
|
130 //NS_ENSURE_ARG_POINTER(aEndPageRange); |
|
131 *aEndPageRange = mEndPageNum; |
|
132 return NS_OK; |
|
133 } |
|
134 NS_IMETHODIMP nsPrintSettings::SetEndPageRange(int32_t aEndPageRange) |
|
135 { |
|
136 mEndPageNum = aEndPageRange; |
|
137 return NS_OK; |
|
138 } |
|
139 |
|
140 /* attribute boolean printReversed; */ |
|
141 NS_IMETHODIMP nsPrintSettings::GetPrintReversed(bool *aPrintReversed) |
|
142 { |
|
143 //NS_ENSURE_ARG_POINTER(aPrintReversed); |
|
144 *aPrintReversed = mPrintReversed; |
|
145 return NS_OK; |
|
146 } |
|
147 NS_IMETHODIMP nsPrintSettings::SetPrintReversed(bool aPrintReversed) |
|
148 { |
|
149 mPrintReversed = aPrintReversed; |
|
150 return NS_OK; |
|
151 } |
|
152 |
|
153 /* attribute boolean printInColor; */ |
|
154 NS_IMETHODIMP nsPrintSettings::GetPrintInColor(bool *aPrintInColor) |
|
155 { |
|
156 //NS_ENSURE_ARG_POINTER(aPrintInColor); |
|
157 *aPrintInColor = mPrintInColor; |
|
158 return NS_OK; |
|
159 } |
|
160 NS_IMETHODIMP nsPrintSettings::SetPrintInColor(bool aPrintInColor) |
|
161 { |
|
162 mPrintInColor = aPrintInColor; |
|
163 return NS_OK; |
|
164 } |
|
165 |
|
166 /* attribute short orientation; */ |
|
167 NS_IMETHODIMP nsPrintSettings::GetOrientation(int32_t *aOrientation) |
|
168 { |
|
169 NS_ENSURE_ARG_POINTER(aOrientation); |
|
170 *aOrientation = mOrientation; |
|
171 return NS_OK; |
|
172 } |
|
173 NS_IMETHODIMP nsPrintSettings::SetOrientation(int32_t aOrientation) |
|
174 { |
|
175 mOrientation = aOrientation; |
|
176 return NS_OK; |
|
177 } |
|
178 |
|
179 /* attribute wstring colorspace; */ |
|
180 NS_IMETHODIMP nsPrintSettings::GetColorspace(char16_t * *aColorspace) |
|
181 { |
|
182 NS_ENSURE_ARG_POINTER(aColorspace); |
|
183 if (!mColorspace.IsEmpty()) { |
|
184 *aColorspace = ToNewUnicode(mColorspace); |
|
185 } else { |
|
186 *aColorspace = nullptr; |
|
187 } |
|
188 return NS_OK; |
|
189 } |
|
190 NS_IMETHODIMP nsPrintSettings::SetColorspace(const char16_t * aColorspace) |
|
191 { |
|
192 if (aColorspace) { |
|
193 mColorspace = aColorspace; |
|
194 } else { |
|
195 mColorspace.SetLength(0); |
|
196 } |
|
197 return NS_OK; |
|
198 } |
|
199 |
|
200 /* attribute wstring resolutionname; */ |
|
201 NS_IMETHODIMP nsPrintSettings::GetResolutionName(char16_t * *aResolutionName) |
|
202 { |
|
203 NS_ENSURE_ARG_POINTER(aResolutionName); |
|
204 if (!mResolutionName.IsEmpty()) { |
|
205 *aResolutionName = ToNewUnicode(mResolutionName); |
|
206 } else { |
|
207 *aResolutionName = nullptr; |
|
208 } |
|
209 return NS_OK; |
|
210 } |
|
211 NS_IMETHODIMP nsPrintSettings::SetResolutionName(const char16_t * aResolutionName) |
|
212 { |
|
213 if (aResolutionName) { |
|
214 mResolutionName = aResolutionName; |
|
215 } else { |
|
216 mResolutionName.SetLength(0); |
|
217 } |
|
218 return NS_OK; |
|
219 } |
|
220 |
|
221 /* attribute wstring resolution; */ |
|
222 NS_IMETHODIMP nsPrintSettings::GetResolution(int32_t *aResolution) |
|
223 { |
|
224 NS_ENSURE_ARG_POINTER(aResolution); |
|
225 *aResolution = mResolution; |
|
226 return NS_OK; |
|
227 } |
|
228 NS_IMETHODIMP nsPrintSettings::SetResolution(const int32_t aResolution) |
|
229 { |
|
230 mResolution = aResolution; |
|
231 return NS_OK; |
|
232 } |
|
233 |
|
234 /* attribute wstring duplex; */ |
|
235 NS_IMETHODIMP nsPrintSettings::GetDuplex(int32_t *aDuplex) |
|
236 { |
|
237 NS_ENSURE_ARG_POINTER(aDuplex); |
|
238 *aDuplex = mDuplex; |
|
239 return NS_OK; |
|
240 } |
|
241 NS_IMETHODIMP nsPrintSettings::SetDuplex(const int32_t aDuplex) |
|
242 { |
|
243 mDuplex = aDuplex; |
|
244 return NS_OK; |
|
245 } |
|
246 |
|
247 /* attribute boolean downloadFonts; */ |
|
248 NS_IMETHODIMP nsPrintSettings::GetDownloadFonts(bool *aDownloadFonts) |
|
249 { |
|
250 //NS_ENSURE_ARG_POINTER(aDownloadFonts); |
|
251 *aDownloadFonts = mDownloadFonts; |
|
252 return NS_OK; |
|
253 } |
|
254 NS_IMETHODIMP nsPrintSettings::SetDownloadFonts(bool aDownloadFonts) |
|
255 { |
|
256 mDownloadFonts = aDownloadFonts; |
|
257 return NS_OK; |
|
258 } |
|
259 |
|
260 /* attribute wstring printer; */ |
|
261 NS_IMETHODIMP nsPrintSettings::GetPrinterName(char16_t * *aPrinter) |
|
262 { |
|
263 NS_ENSURE_ARG_POINTER(aPrinter); |
|
264 |
|
265 *aPrinter = ToNewUnicode(mPrinter); |
|
266 NS_ENSURE_TRUE(*aPrinter, NS_ERROR_OUT_OF_MEMORY); |
|
267 |
|
268 return NS_OK; |
|
269 } |
|
270 |
|
271 NS_IMETHODIMP nsPrintSettings::SetPrinterName(const char16_t * aPrinter) |
|
272 { |
|
273 if (!aPrinter || !mPrinter.Equals(aPrinter)) { |
|
274 mIsInitedFromPrinter = false; |
|
275 mIsInitedFromPrefs = false; |
|
276 } |
|
277 |
|
278 mPrinter.Assign(aPrinter); |
|
279 return NS_OK; |
|
280 } |
|
281 |
|
282 /* attribute long numCopies; */ |
|
283 NS_IMETHODIMP nsPrintSettings::GetNumCopies(int32_t *aNumCopies) |
|
284 { |
|
285 NS_ENSURE_ARG_POINTER(aNumCopies); |
|
286 *aNumCopies = mNumCopies; |
|
287 return NS_OK; |
|
288 } |
|
289 NS_IMETHODIMP nsPrintSettings::SetNumCopies(int32_t aNumCopies) |
|
290 { |
|
291 mNumCopies = aNumCopies; |
|
292 return NS_OK; |
|
293 } |
|
294 |
|
295 /* attribute wstring printCommand; */ |
|
296 NS_IMETHODIMP nsPrintSettings::GetPrintCommand(char16_t * *aPrintCommand) |
|
297 { |
|
298 //NS_ENSURE_ARG_POINTER(aPrintCommand); |
|
299 *aPrintCommand = ToNewUnicode(mPrintCommand); |
|
300 return NS_OK; |
|
301 } |
|
302 NS_IMETHODIMP nsPrintSettings::SetPrintCommand(const char16_t * aPrintCommand) |
|
303 { |
|
304 if (aPrintCommand) { |
|
305 mPrintCommand = aPrintCommand; |
|
306 } else { |
|
307 mPrintCommand.SetLength(0); |
|
308 } |
|
309 return NS_OK; |
|
310 } |
|
311 |
|
312 /* attribute boolean printToFile; */ |
|
313 NS_IMETHODIMP nsPrintSettings::GetPrintToFile(bool *aPrintToFile) |
|
314 { |
|
315 //NS_ENSURE_ARG_POINTER(aPrintToFile); |
|
316 *aPrintToFile = mPrintToFile; |
|
317 return NS_OK; |
|
318 } |
|
319 NS_IMETHODIMP nsPrintSettings::SetPrintToFile(bool aPrintToFile) |
|
320 { |
|
321 mPrintToFile = aPrintToFile; |
|
322 return NS_OK; |
|
323 } |
|
324 |
|
325 /* attribute wstring toFileName; */ |
|
326 NS_IMETHODIMP nsPrintSettings::GetToFileName(char16_t * *aToFileName) |
|
327 { |
|
328 //NS_ENSURE_ARG_POINTER(aToFileName); |
|
329 *aToFileName = ToNewUnicode(mToFileName); |
|
330 return NS_OK; |
|
331 } |
|
332 NS_IMETHODIMP nsPrintSettings::SetToFileName(const char16_t * aToFileName) |
|
333 { |
|
334 if (aToFileName) { |
|
335 mToFileName = aToFileName; |
|
336 } else { |
|
337 mToFileName.SetLength(0); |
|
338 } |
|
339 return NS_OK; |
|
340 } |
|
341 |
|
342 /* attribute short outputFormat; */ |
|
343 NS_IMETHODIMP nsPrintSettings::GetOutputFormat(int16_t *aOutputFormat) |
|
344 { |
|
345 NS_ENSURE_ARG_POINTER(aOutputFormat); |
|
346 *aOutputFormat = mOutputFormat; |
|
347 return NS_OK; |
|
348 } |
|
349 NS_IMETHODIMP nsPrintSettings::SetOutputFormat(int16_t aOutputFormat) |
|
350 { |
|
351 mOutputFormat = aOutputFormat; |
|
352 return NS_OK; |
|
353 } |
|
354 |
|
355 /* attribute long printPageDelay; */ |
|
356 NS_IMETHODIMP nsPrintSettings::GetPrintPageDelay(int32_t *aPrintPageDelay) |
|
357 { |
|
358 *aPrintPageDelay = mPrintPageDelay; |
|
359 return NS_OK; |
|
360 } |
|
361 NS_IMETHODIMP nsPrintSettings::SetPrintPageDelay(int32_t aPrintPageDelay) |
|
362 { |
|
363 mPrintPageDelay = aPrintPageDelay; |
|
364 return NS_OK; |
|
365 } |
|
366 |
|
367 /* attribute boolean isInitializedFromPrinter; */ |
|
368 NS_IMETHODIMP nsPrintSettings::GetIsInitializedFromPrinter(bool *aIsInitializedFromPrinter) |
|
369 { |
|
370 NS_ENSURE_ARG_POINTER(aIsInitializedFromPrinter); |
|
371 *aIsInitializedFromPrinter = (bool)mIsInitedFromPrinter; |
|
372 return NS_OK; |
|
373 } |
|
374 NS_IMETHODIMP nsPrintSettings::SetIsInitializedFromPrinter(bool aIsInitializedFromPrinter) |
|
375 { |
|
376 mIsInitedFromPrinter = (bool)aIsInitializedFromPrinter; |
|
377 return NS_OK; |
|
378 } |
|
379 |
|
380 /* attribute boolean isInitializedFromPrefs; */ |
|
381 NS_IMETHODIMP nsPrintSettings::GetIsInitializedFromPrefs(bool *aInitializedFromPrefs) |
|
382 { |
|
383 NS_ENSURE_ARG_POINTER(aInitializedFromPrefs); |
|
384 *aInitializedFromPrefs = (bool)mIsInitedFromPrefs; |
|
385 return NS_OK; |
|
386 } |
|
387 NS_IMETHODIMP nsPrintSettings::SetIsInitializedFromPrefs(bool aInitializedFromPrefs) |
|
388 { |
|
389 mIsInitedFromPrefs = (bool)aInitializedFromPrefs; |
|
390 return NS_OK; |
|
391 } |
|
392 |
|
393 /* attribute boolean persistMarginBoxSettings; */ |
|
394 NS_IMETHODIMP nsPrintSettings::GetPersistMarginBoxSettings(bool *aPersistMarginBoxSettings) |
|
395 { |
|
396 NS_ENSURE_ARG_POINTER(aPersistMarginBoxSettings); |
|
397 *aPersistMarginBoxSettings = mPersistMarginBoxSettings; |
|
398 return NS_OK; |
|
399 } |
|
400 NS_IMETHODIMP nsPrintSettings::SetPersistMarginBoxSettings(bool aPersistMarginBoxSettings) |
|
401 { |
|
402 mPersistMarginBoxSettings = aPersistMarginBoxSettings; |
|
403 return NS_OK; |
|
404 } |
|
405 |
|
406 /* attribute double marginTop; */ |
|
407 NS_IMETHODIMP nsPrintSettings::GetMarginTop(double *aMarginTop) |
|
408 { |
|
409 NS_ENSURE_ARG_POINTER(aMarginTop); |
|
410 *aMarginTop = NS_TWIPS_TO_INCHES(mMargin.top); |
|
411 return NS_OK; |
|
412 } |
|
413 NS_IMETHODIMP nsPrintSettings::SetMarginTop(double aMarginTop) |
|
414 { |
|
415 mMargin.top = NS_INCHES_TO_INT_TWIPS(float(aMarginTop)); |
|
416 return NS_OK; |
|
417 } |
|
418 |
|
419 /* attribute double marginLeft; */ |
|
420 NS_IMETHODIMP nsPrintSettings::GetMarginLeft(double *aMarginLeft) |
|
421 { |
|
422 NS_ENSURE_ARG_POINTER(aMarginLeft); |
|
423 *aMarginLeft = NS_TWIPS_TO_INCHES(mMargin.left); |
|
424 return NS_OK; |
|
425 } |
|
426 NS_IMETHODIMP nsPrintSettings::SetMarginLeft(double aMarginLeft) |
|
427 { |
|
428 mMargin.left = NS_INCHES_TO_INT_TWIPS(float(aMarginLeft)); |
|
429 return NS_OK; |
|
430 } |
|
431 |
|
432 /* attribute double marginBottom; */ |
|
433 NS_IMETHODIMP nsPrintSettings::GetMarginBottom(double *aMarginBottom) |
|
434 { |
|
435 NS_ENSURE_ARG_POINTER(aMarginBottom); |
|
436 *aMarginBottom = NS_TWIPS_TO_INCHES(mMargin.bottom); |
|
437 return NS_OK; |
|
438 } |
|
439 NS_IMETHODIMP nsPrintSettings::SetMarginBottom(double aMarginBottom) |
|
440 { |
|
441 mMargin.bottom = NS_INCHES_TO_INT_TWIPS(float(aMarginBottom)); |
|
442 return NS_OK; |
|
443 } |
|
444 |
|
445 /* attribute double marginRight; */ |
|
446 NS_IMETHODIMP nsPrintSettings::GetMarginRight(double *aMarginRight) |
|
447 { |
|
448 NS_ENSURE_ARG_POINTER(aMarginRight); |
|
449 *aMarginRight = NS_TWIPS_TO_INCHES(mMargin.right); |
|
450 return NS_OK; |
|
451 } |
|
452 NS_IMETHODIMP nsPrintSettings::SetMarginRight(double aMarginRight) |
|
453 { |
|
454 mMargin.right = NS_INCHES_TO_INT_TWIPS(float(aMarginRight)); |
|
455 return NS_OK; |
|
456 } |
|
457 |
|
458 /* attribute double edgeTop; */ |
|
459 NS_IMETHODIMP nsPrintSettings::GetEdgeTop(double *aEdgeTop) |
|
460 { |
|
461 NS_ENSURE_ARG_POINTER(aEdgeTop); |
|
462 *aEdgeTop = NS_TWIPS_TO_INCHES(mEdge.top); |
|
463 return NS_OK; |
|
464 } |
|
465 NS_IMETHODIMP nsPrintSettings::SetEdgeTop(double aEdgeTop) |
|
466 { |
|
467 mEdge.top = NS_INCHES_TO_INT_TWIPS(float(aEdgeTop)); |
|
468 return NS_OK; |
|
469 } |
|
470 |
|
471 /* attribute double edgeLeft; */ |
|
472 NS_IMETHODIMP nsPrintSettings::GetEdgeLeft(double *aEdgeLeft) |
|
473 { |
|
474 NS_ENSURE_ARG_POINTER(aEdgeLeft); |
|
475 *aEdgeLeft = NS_TWIPS_TO_INCHES(mEdge.left); |
|
476 return NS_OK; |
|
477 } |
|
478 NS_IMETHODIMP nsPrintSettings::SetEdgeLeft(double aEdgeLeft) |
|
479 { |
|
480 mEdge.left = NS_INCHES_TO_INT_TWIPS(float(aEdgeLeft)); |
|
481 return NS_OK; |
|
482 } |
|
483 |
|
484 /* attribute double edgeBottom; */ |
|
485 NS_IMETHODIMP nsPrintSettings::GetEdgeBottom(double *aEdgeBottom) |
|
486 { |
|
487 NS_ENSURE_ARG_POINTER(aEdgeBottom); |
|
488 *aEdgeBottom = NS_TWIPS_TO_INCHES(mEdge.bottom); |
|
489 return NS_OK; |
|
490 } |
|
491 NS_IMETHODIMP nsPrintSettings::SetEdgeBottom(double aEdgeBottom) |
|
492 { |
|
493 mEdge.bottom = NS_INCHES_TO_INT_TWIPS(float(aEdgeBottom)); |
|
494 return NS_OK; |
|
495 } |
|
496 |
|
497 /* attribute double edgeRight; */ |
|
498 NS_IMETHODIMP nsPrintSettings::GetEdgeRight(double *aEdgeRight) |
|
499 { |
|
500 NS_ENSURE_ARG_POINTER(aEdgeRight); |
|
501 *aEdgeRight = NS_TWIPS_TO_INCHES(mEdge.right); |
|
502 return NS_OK; |
|
503 } |
|
504 NS_IMETHODIMP nsPrintSettings::SetEdgeRight(double aEdgeRight) |
|
505 { |
|
506 mEdge.right = NS_INCHES_TO_INT_TWIPS(float(aEdgeRight)); |
|
507 return NS_OK; |
|
508 } |
|
509 |
|
510 /* attribute double unwriteableMarginTop; */ |
|
511 NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginTop(double *aUnwriteableMarginTop) |
|
512 { |
|
513 NS_ENSURE_ARG_POINTER(aUnwriteableMarginTop); |
|
514 *aUnwriteableMarginTop = NS_TWIPS_TO_INCHES(mUnwriteableMargin.top); |
|
515 return NS_OK; |
|
516 } |
|
517 NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginTop(double aUnwriteableMarginTop) |
|
518 { |
|
519 if (aUnwriteableMarginTop >= 0.0) { |
|
520 mUnwriteableMargin.top = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginTop); |
|
521 } |
|
522 return NS_OK; |
|
523 } |
|
524 |
|
525 /* attribute double unwriteableMarginLeft; */ |
|
526 NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginLeft(double *aUnwriteableMarginLeft) |
|
527 { |
|
528 NS_ENSURE_ARG_POINTER(aUnwriteableMarginLeft); |
|
529 *aUnwriteableMarginLeft = NS_TWIPS_TO_INCHES(mUnwriteableMargin.left); |
|
530 return NS_OK; |
|
531 } |
|
532 NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginLeft(double aUnwriteableMarginLeft) |
|
533 { |
|
534 if (aUnwriteableMarginLeft >= 0.0) { |
|
535 mUnwriteableMargin.left = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginLeft); |
|
536 } |
|
537 return NS_OK; |
|
538 } |
|
539 |
|
540 /* attribute double unwriteableMarginBottom; */ |
|
541 NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginBottom(double *aUnwriteableMarginBottom) |
|
542 { |
|
543 NS_ENSURE_ARG_POINTER(aUnwriteableMarginBottom); |
|
544 *aUnwriteableMarginBottom = NS_TWIPS_TO_INCHES(mUnwriteableMargin.bottom); |
|
545 return NS_OK; |
|
546 } |
|
547 NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginBottom(double aUnwriteableMarginBottom) |
|
548 { |
|
549 if (aUnwriteableMarginBottom >= 0.0) { |
|
550 mUnwriteableMargin.bottom = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginBottom); |
|
551 } |
|
552 return NS_OK; |
|
553 } |
|
554 |
|
555 /* attribute double unwriteableMarginRight; */ |
|
556 NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginRight(double *aUnwriteableMarginRight) |
|
557 { |
|
558 NS_ENSURE_ARG_POINTER(aUnwriteableMarginRight); |
|
559 *aUnwriteableMarginRight = NS_TWIPS_TO_INCHES(mUnwriteableMargin.right); |
|
560 return NS_OK; |
|
561 } |
|
562 NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginRight(double aUnwriteableMarginRight) |
|
563 { |
|
564 if (aUnwriteableMarginRight >= 0.0) { |
|
565 mUnwriteableMargin.right = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginRight); |
|
566 } |
|
567 return NS_OK; |
|
568 } |
|
569 |
|
570 /* attribute double scaling; */ |
|
571 NS_IMETHODIMP nsPrintSettings::GetScaling(double *aScaling) |
|
572 { |
|
573 NS_ENSURE_ARG_POINTER(aScaling); |
|
574 *aScaling = mScaling; |
|
575 return NS_OK; |
|
576 } |
|
577 |
|
578 NS_IMETHODIMP nsPrintSettings::SetScaling(double aScaling) |
|
579 { |
|
580 mScaling = aScaling; |
|
581 return NS_OK; |
|
582 } |
|
583 |
|
584 /* attribute boolean printBGColors; */ |
|
585 NS_IMETHODIMP nsPrintSettings::GetPrintBGColors(bool *aPrintBGColors) |
|
586 { |
|
587 NS_ENSURE_ARG_POINTER(aPrintBGColors); |
|
588 *aPrintBGColors = mPrintBGColors; |
|
589 return NS_OK; |
|
590 } |
|
591 NS_IMETHODIMP nsPrintSettings::SetPrintBGColors(bool aPrintBGColors) |
|
592 { |
|
593 mPrintBGColors = aPrintBGColors; |
|
594 return NS_OK; |
|
595 } |
|
596 |
|
597 /* attribute boolean printBGImages; */ |
|
598 NS_IMETHODIMP nsPrintSettings::GetPrintBGImages(bool *aPrintBGImages) |
|
599 { |
|
600 NS_ENSURE_ARG_POINTER(aPrintBGImages); |
|
601 *aPrintBGImages = mPrintBGImages; |
|
602 return NS_OK; |
|
603 } |
|
604 NS_IMETHODIMP nsPrintSettings::SetPrintBGImages(bool aPrintBGImages) |
|
605 { |
|
606 mPrintBGImages = aPrintBGImages; |
|
607 return NS_OK; |
|
608 } |
|
609 |
|
610 /* attribute long printRange; */ |
|
611 NS_IMETHODIMP nsPrintSettings::GetPrintRange(int16_t *aPrintRange) |
|
612 { |
|
613 NS_ENSURE_ARG_POINTER(aPrintRange); |
|
614 *aPrintRange = mPrintRange; |
|
615 return NS_OK; |
|
616 } |
|
617 NS_IMETHODIMP nsPrintSettings::SetPrintRange(int16_t aPrintRange) |
|
618 { |
|
619 mPrintRange = aPrintRange; |
|
620 return NS_OK; |
|
621 } |
|
622 |
|
623 /* attribute wstring docTitle; */ |
|
624 NS_IMETHODIMP nsPrintSettings::GetTitle(char16_t * *aTitle) |
|
625 { |
|
626 NS_ENSURE_ARG_POINTER(aTitle); |
|
627 if (!mTitle.IsEmpty()) { |
|
628 *aTitle = ToNewUnicode(mTitle); |
|
629 } else { |
|
630 *aTitle = nullptr; |
|
631 } |
|
632 return NS_OK; |
|
633 } |
|
634 NS_IMETHODIMP nsPrintSettings::SetTitle(const char16_t * aTitle) |
|
635 { |
|
636 if (aTitle) { |
|
637 mTitle = aTitle; |
|
638 } else { |
|
639 mTitle.SetLength(0); |
|
640 } |
|
641 return NS_OK; |
|
642 } |
|
643 |
|
644 /* attribute wstring docURL; */ |
|
645 NS_IMETHODIMP nsPrintSettings::GetDocURL(char16_t * *aDocURL) |
|
646 { |
|
647 NS_ENSURE_ARG_POINTER(aDocURL); |
|
648 if (!mURL.IsEmpty()) { |
|
649 *aDocURL = ToNewUnicode(mURL); |
|
650 } else { |
|
651 *aDocURL = nullptr; |
|
652 } |
|
653 return NS_OK; |
|
654 } |
|
655 NS_IMETHODIMP nsPrintSettings::SetDocURL(const char16_t * aDocURL) |
|
656 { |
|
657 if (aDocURL) { |
|
658 mURL = aDocURL; |
|
659 } else { |
|
660 mURL.SetLength(0); |
|
661 } |
|
662 return NS_OK; |
|
663 } |
|
664 |
|
665 /** --------------------------------------------------- |
|
666 * See documentation in nsPrintSettingsImpl.h |
|
667 * @update 1/12/01 rods |
|
668 */ |
|
669 NS_IMETHODIMP |
|
670 nsPrintSettings::GetPrintOptions(int32_t aType, bool *aTurnOnOff) |
|
671 { |
|
672 NS_ENSURE_ARG_POINTER(aTurnOnOff); |
|
673 *aTurnOnOff = mPrintOptions & aType ? true : false; |
|
674 return NS_OK; |
|
675 } |
|
676 /** --------------------------------------------------- |
|
677 * See documentation in nsPrintSettingsImpl.h |
|
678 * @update 1/12/01 rods |
|
679 */ |
|
680 NS_IMETHODIMP |
|
681 nsPrintSettings::SetPrintOptions(int32_t aType, bool aTurnOnOff) |
|
682 { |
|
683 if (aTurnOnOff) { |
|
684 mPrintOptions |= aType; |
|
685 } else { |
|
686 mPrintOptions &= ~aType; |
|
687 } |
|
688 return NS_OK; |
|
689 } |
|
690 |
|
691 /** --------------------------------------------------- |
|
692 * See documentation in nsPrintSettingsImpl.h |
|
693 * @update 1/12/01 rods |
|
694 */ |
|
695 NS_IMETHODIMP |
|
696 nsPrintSettings::GetPrintOptionsBits(int32_t *aBits) |
|
697 { |
|
698 NS_ENSURE_ARG_POINTER(aBits); |
|
699 *aBits = mPrintOptions; |
|
700 return NS_OK; |
|
701 } |
|
702 |
|
703 /* attribute wstring docTitle; */ |
|
704 nsresult |
|
705 nsPrintSettings::GetMarginStrs(char16_t * *aTitle, |
|
706 nsHeaderFooterEnum aType, |
|
707 int16_t aJust) |
|
708 { |
|
709 NS_ENSURE_ARG_POINTER(aTitle); |
|
710 *aTitle = nullptr; |
|
711 if (aType == eHeader) { |
|
712 switch (aJust) { |
|
713 case kJustLeft: *aTitle = ToNewUnicode(mHeaderStrs[0]);break; |
|
714 case kJustCenter: *aTitle = ToNewUnicode(mHeaderStrs[1]);break; |
|
715 case kJustRight: *aTitle = ToNewUnicode(mHeaderStrs[2]);break; |
|
716 } //switch |
|
717 } else { |
|
718 switch (aJust) { |
|
719 case kJustLeft: *aTitle = ToNewUnicode(mFooterStrs[0]);break; |
|
720 case kJustCenter: *aTitle = ToNewUnicode(mFooterStrs[1]);break; |
|
721 case kJustRight: *aTitle = ToNewUnicode(mFooterStrs[2]);break; |
|
722 } //switch |
|
723 } |
|
724 return NS_OK; |
|
725 } |
|
726 |
|
727 nsresult |
|
728 nsPrintSettings::SetMarginStrs(const char16_t * aTitle, |
|
729 nsHeaderFooterEnum aType, |
|
730 int16_t aJust) |
|
731 { |
|
732 NS_ENSURE_ARG_POINTER(aTitle); |
|
733 if (aType == eHeader) { |
|
734 switch (aJust) { |
|
735 case kJustLeft: mHeaderStrs[0] = aTitle;break; |
|
736 case kJustCenter: mHeaderStrs[1] = aTitle;break; |
|
737 case kJustRight: mHeaderStrs[2] = aTitle;break; |
|
738 } //switch |
|
739 } else { |
|
740 switch (aJust) { |
|
741 case kJustLeft: mFooterStrs[0] = aTitle;break; |
|
742 case kJustCenter: mFooterStrs[1] = aTitle;break; |
|
743 case kJustRight: mFooterStrs[2] = aTitle;break; |
|
744 } //switch |
|
745 } |
|
746 return NS_OK; |
|
747 } |
|
748 |
|
749 /* attribute wstring Header String Left */ |
|
750 NS_IMETHODIMP nsPrintSettings::GetHeaderStrLeft(char16_t * *aTitle) |
|
751 { |
|
752 return GetMarginStrs(aTitle, eHeader, kJustLeft); |
|
753 } |
|
754 NS_IMETHODIMP nsPrintSettings::SetHeaderStrLeft(const char16_t * aTitle) |
|
755 { |
|
756 return SetMarginStrs(aTitle, eHeader, kJustLeft); |
|
757 } |
|
758 |
|
759 /* attribute wstring Header String Center */ |
|
760 NS_IMETHODIMP nsPrintSettings::GetHeaderStrCenter(char16_t * *aTitle) |
|
761 { |
|
762 return GetMarginStrs(aTitle, eHeader, kJustCenter); |
|
763 } |
|
764 NS_IMETHODIMP nsPrintSettings::SetHeaderStrCenter(const char16_t * aTitle) |
|
765 { |
|
766 return SetMarginStrs(aTitle, eHeader, kJustCenter); |
|
767 } |
|
768 |
|
769 /* attribute wstring Header String Right */ |
|
770 NS_IMETHODIMP nsPrintSettings::GetHeaderStrRight(char16_t * *aTitle) |
|
771 { |
|
772 return GetMarginStrs(aTitle, eHeader, kJustRight); |
|
773 } |
|
774 NS_IMETHODIMP nsPrintSettings::SetHeaderStrRight(const char16_t * aTitle) |
|
775 { |
|
776 return SetMarginStrs(aTitle, eHeader, kJustRight); |
|
777 } |
|
778 |
|
779 |
|
780 /* attribute wstring Footer String Left */ |
|
781 NS_IMETHODIMP nsPrintSettings::GetFooterStrLeft(char16_t * *aTitle) |
|
782 { |
|
783 return GetMarginStrs(aTitle, eFooter, kJustLeft); |
|
784 } |
|
785 NS_IMETHODIMP nsPrintSettings::SetFooterStrLeft(const char16_t * aTitle) |
|
786 { |
|
787 return SetMarginStrs(aTitle, eFooter, kJustLeft); |
|
788 } |
|
789 |
|
790 /* attribute wstring Footer String Center */ |
|
791 NS_IMETHODIMP nsPrintSettings::GetFooterStrCenter(char16_t * *aTitle) |
|
792 { |
|
793 return GetMarginStrs(aTitle, eFooter, kJustCenter); |
|
794 } |
|
795 NS_IMETHODIMP nsPrintSettings::SetFooterStrCenter(const char16_t * aTitle) |
|
796 { |
|
797 return SetMarginStrs(aTitle, eFooter, kJustCenter); |
|
798 } |
|
799 |
|
800 /* attribute wstring Footer String Right */ |
|
801 NS_IMETHODIMP nsPrintSettings::GetFooterStrRight(char16_t * *aTitle) |
|
802 { |
|
803 return GetMarginStrs(aTitle, eFooter, kJustRight); |
|
804 } |
|
805 NS_IMETHODIMP nsPrintSettings::SetFooterStrRight(const char16_t * aTitle) |
|
806 { |
|
807 return SetMarginStrs(aTitle, eFooter, kJustRight); |
|
808 } |
|
809 |
|
810 /* attribute short printFrameTypeUsage; */ |
|
811 NS_IMETHODIMP nsPrintSettings::GetPrintFrameTypeUsage(int16_t *aPrintFrameTypeUsage) |
|
812 { |
|
813 NS_ENSURE_ARG_POINTER(aPrintFrameTypeUsage); |
|
814 *aPrintFrameTypeUsage = mPrintFrameTypeUsage; |
|
815 return NS_OK; |
|
816 } |
|
817 NS_IMETHODIMP nsPrintSettings::SetPrintFrameTypeUsage(int16_t aPrintFrameTypeUsage) |
|
818 { |
|
819 mPrintFrameTypeUsage = aPrintFrameTypeUsage; |
|
820 return NS_OK; |
|
821 } |
|
822 |
|
823 /* attribute long printFrameType; */ |
|
824 NS_IMETHODIMP nsPrintSettings::GetPrintFrameType(int16_t *aPrintFrameType) |
|
825 { |
|
826 NS_ENSURE_ARG_POINTER(aPrintFrameType); |
|
827 *aPrintFrameType = (int32_t)mPrintFrameType; |
|
828 return NS_OK; |
|
829 } |
|
830 NS_IMETHODIMP nsPrintSettings::SetPrintFrameType(int16_t aPrintFrameType) |
|
831 { |
|
832 mPrintFrameType = aPrintFrameType; |
|
833 return NS_OK; |
|
834 } |
|
835 |
|
836 /* attribute boolean printSilent; */ |
|
837 NS_IMETHODIMP nsPrintSettings::GetPrintSilent(bool *aPrintSilent) |
|
838 { |
|
839 NS_ENSURE_ARG_POINTER(aPrintSilent); |
|
840 *aPrintSilent = mPrintSilent; |
|
841 return NS_OK; |
|
842 } |
|
843 NS_IMETHODIMP nsPrintSettings::SetPrintSilent(bool aPrintSilent) |
|
844 { |
|
845 mPrintSilent = aPrintSilent; |
|
846 return NS_OK; |
|
847 } |
|
848 |
|
849 /* attribute boolean shrinkToFit; */ |
|
850 NS_IMETHODIMP nsPrintSettings::GetShrinkToFit(bool *aShrinkToFit) |
|
851 { |
|
852 NS_ENSURE_ARG_POINTER(aShrinkToFit); |
|
853 *aShrinkToFit = mShrinkToFit; |
|
854 return NS_OK; |
|
855 } |
|
856 NS_IMETHODIMP nsPrintSettings::SetShrinkToFit(bool aShrinkToFit) |
|
857 { |
|
858 mShrinkToFit = aShrinkToFit; |
|
859 return NS_OK; |
|
860 } |
|
861 |
|
862 /* attribute boolean showPrintProgress; */ |
|
863 NS_IMETHODIMP nsPrintSettings::GetShowPrintProgress(bool *aShowPrintProgress) |
|
864 { |
|
865 NS_ENSURE_ARG_POINTER(aShowPrintProgress); |
|
866 *aShowPrintProgress = mShowPrintProgress; |
|
867 return NS_OK; |
|
868 } |
|
869 NS_IMETHODIMP nsPrintSettings::SetShowPrintProgress(bool aShowPrintProgress) |
|
870 { |
|
871 mShowPrintProgress = aShowPrintProgress; |
|
872 return NS_OK; |
|
873 } |
|
874 |
|
875 /* attribute wstring paperName; */ |
|
876 NS_IMETHODIMP nsPrintSettings::GetPaperName(char16_t * *aPaperName) |
|
877 { |
|
878 NS_ENSURE_ARG_POINTER(aPaperName); |
|
879 if (!mPaperName.IsEmpty()) { |
|
880 *aPaperName = ToNewUnicode(mPaperName); |
|
881 } else { |
|
882 *aPaperName = nullptr; |
|
883 } |
|
884 return NS_OK; |
|
885 } |
|
886 NS_IMETHODIMP nsPrintSettings::SetPaperName(const char16_t * aPaperName) |
|
887 { |
|
888 if (aPaperName) { |
|
889 mPaperName = aPaperName; |
|
890 } else { |
|
891 mPaperName.SetLength(0); |
|
892 } |
|
893 return NS_OK; |
|
894 } |
|
895 |
|
896 /* attribute wstring plexName; */ |
|
897 NS_IMETHODIMP nsPrintSettings::GetPlexName(char16_t * *aPlexName) |
|
898 { |
|
899 NS_ENSURE_ARG_POINTER(aPlexName); |
|
900 if (!mPlexName.IsEmpty()) { |
|
901 *aPlexName = ToNewUnicode(mPlexName); |
|
902 } else { |
|
903 *aPlexName = nullptr; |
|
904 } |
|
905 return NS_OK; |
|
906 } |
|
907 NS_IMETHODIMP nsPrintSettings::SetPlexName(const char16_t * aPlexName) |
|
908 { |
|
909 if (aPlexName) { |
|
910 mPlexName = aPlexName; |
|
911 } else { |
|
912 mPlexName.SetLength(0); |
|
913 } |
|
914 return NS_OK; |
|
915 } |
|
916 |
|
917 /* attribute boolean howToEnableFrameUI; */ |
|
918 NS_IMETHODIMP nsPrintSettings::GetHowToEnableFrameUI(int16_t *aHowToEnableFrameUI) |
|
919 { |
|
920 NS_ENSURE_ARG_POINTER(aHowToEnableFrameUI); |
|
921 *aHowToEnableFrameUI = mHowToEnableFrameUI; |
|
922 return NS_OK; |
|
923 } |
|
924 NS_IMETHODIMP nsPrintSettings::SetHowToEnableFrameUI(int16_t aHowToEnableFrameUI) |
|
925 { |
|
926 mHowToEnableFrameUI = aHowToEnableFrameUI; |
|
927 return NS_OK; |
|
928 } |
|
929 |
|
930 /* attribute long isCancelled; */ |
|
931 NS_IMETHODIMP nsPrintSettings::GetIsCancelled(bool *aIsCancelled) |
|
932 { |
|
933 NS_ENSURE_ARG_POINTER(aIsCancelled); |
|
934 *aIsCancelled = mIsCancelled; |
|
935 return NS_OK; |
|
936 } |
|
937 NS_IMETHODIMP nsPrintSettings::SetIsCancelled(bool aIsCancelled) |
|
938 { |
|
939 mIsCancelled = aIsCancelled; |
|
940 return NS_OK; |
|
941 } |
|
942 |
|
943 /* attribute double paperWidth; */ |
|
944 NS_IMETHODIMP nsPrintSettings::GetPaperWidth(double *aPaperWidth) |
|
945 { |
|
946 NS_ENSURE_ARG_POINTER(aPaperWidth); |
|
947 *aPaperWidth = mPaperWidth; |
|
948 return NS_OK; |
|
949 } |
|
950 NS_IMETHODIMP nsPrintSettings::SetPaperWidth(double aPaperWidth) |
|
951 { |
|
952 mPaperWidth = aPaperWidth; |
|
953 return NS_OK; |
|
954 } |
|
955 |
|
956 /* attribute double paperHeight; */ |
|
957 NS_IMETHODIMP nsPrintSettings::GetPaperHeight(double *aPaperHeight) |
|
958 { |
|
959 NS_ENSURE_ARG_POINTER(aPaperHeight); |
|
960 *aPaperHeight = mPaperHeight; |
|
961 return NS_OK; |
|
962 } |
|
963 NS_IMETHODIMP nsPrintSettings::SetPaperHeight(double aPaperHeight) |
|
964 { |
|
965 mPaperHeight = aPaperHeight; |
|
966 return NS_OK; |
|
967 } |
|
968 |
|
969 /* attribute short PaperSizeUnit; */ |
|
970 NS_IMETHODIMP nsPrintSettings::GetPaperSizeUnit(int16_t *aPaperSizeUnit) |
|
971 { |
|
972 NS_ENSURE_ARG_POINTER(aPaperSizeUnit); |
|
973 *aPaperSizeUnit = mPaperSizeUnit; |
|
974 return NS_OK; |
|
975 } |
|
976 NS_IMETHODIMP nsPrintSettings::SetPaperSizeUnit(int16_t aPaperSizeUnit) |
|
977 { |
|
978 mPaperSizeUnit = aPaperSizeUnit; |
|
979 return NS_OK; |
|
980 } |
|
981 |
|
982 /* attribute short PaperSizeType; */ |
|
983 NS_IMETHODIMP nsPrintSettings::GetPaperSizeType(int16_t *aPaperSizeType) |
|
984 { |
|
985 NS_ENSURE_ARG_POINTER(aPaperSizeType); |
|
986 *aPaperSizeType = mPaperSizeType; |
|
987 return NS_OK; |
|
988 } |
|
989 NS_IMETHODIMP nsPrintSettings::SetPaperSizeType(int16_t aPaperSizeType) |
|
990 { |
|
991 mPaperSizeType = aPaperSizeType; |
|
992 return NS_OK; |
|
993 } |
|
994 |
|
995 /* attribute short PaperData; */ |
|
996 NS_IMETHODIMP nsPrintSettings::GetPaperData(int16_t *aPaperData) |
|
997 { |
|
998 NS_ENSURE_ARG_POINTER(aPaperData); |
|
999 *aPaperData = mPaperData; |
|
1000 return NS_OK; |
|
1001 } |
|
1002 NS_IMETHODIMP nsPrintSettings::SetPaperData(int16_t aPaperData) |
|
1003 { |
|
1004 mPaperData = aPaperData; |
|
1005 return NS_OK; |
|
1006 } |
|
1007 |
|
1008 /** --------------------------------------------------- |
|
1009 * See documentation in nsPrintOptionsImpl.h |
|
1010 * @update 6/21/00 dwc |
|
1011 * @update 1/12/01 rods |
|
1012 */ |
|
1013 NS_IMETHODIMP |
|
1014 nsPrintSettings::SetMarginInTwips(nsIntMargin& aMargin) |
|
1015 { |
|
1016 mMargin = aMargin; |
|
1017 return NS_OK; |
|
1018 } |
|
1019 |
|
1020 NS_IMETHODIMP |
|
1021 nsPrintSettings::SetEdgeInTwips(nsIntMargin& aEdge) |
|
1022 { |
|
1023 mEdge = aEdge; |
|
1024 return NS_OK; |
|
1025 } |
|
1026 |
|
1027 // NOTE: Any subclass implementation of this function should make sure |
|
1028 // to check for negative margin values in aUnwriteableMargin (which |
|
1029 // would indicate that we should use the system default unwriteable margin.) |
|
1030 NS_IMETHODIMP |
|
1031 nsPrintSettings::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) |
|
1032 { |
|
1033 if (aUnwriteableMargin.top >= 0) { |
|
1034 mUnwriteableMargin.top = aUnwriteableMargin.top; |
|
1035 } |
|
1036 if (aUnwriteableMargin.left >= 0) { |
|
1037 mUnwriteableMargin.left = aUnwriteableMargin.left; |
|
1038 } |
|
1039 if (aUnwriteableMargin.bottom >= 0) { |
|
1040 mUnwriteableMargin.bottom = aUnwriteableMargin.bottom; |
|
1041 } |
|
1042 if (aUnwriteableMargin.right >= 0) { |
|
1043 mUnwriteableMargin.right = aUnwriteableMargin.right; |
|
1044 } |
|
1045 return NS_OK; |
|
1046 } |
|
1047 |
|
1048 /** --------------------------------------------------- |
|
1049 * See documentation in nsPrintOptionsImpl.h |
|
1050 * @update 6/21/00 dwc |
|
1051 */ |
|
1052 NS_IMETHODIMP |
|
1053 nsPrintSettings::GetMarginInTwips(nsIntMargin& aMargin) |
|
1054 { |
|
1055 aMargin = mMargin; |
|
1056 return NS_OK; |
|
1057 } |
|
1058 |
|
1059 NS_IMETHODIMP |
|
1060 nsPrintSettings::GetEdgeInTwips(nsIntMargin& aEdge) |
|
1061 { |
|
1062 aEdge = mEdge; |
|
1063 return NS_OK; |
|
1064 } |
|
1065 |
|
1066 NS_IMETHODIMP |
|
1067 nsPrintSettings::GetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) |
|
1068 { |
|
1069 aUnwriteableMargin = mUnwriteableMargin; |
|
1070 return NS_OK; |
|
1071 } |
|
1072 |
|
1073 /** --------------------------------------------------- |
|
1074 * Stub - platform-specific implementations can use this function. |
|
1075 */ |
|
1076 NS_IMETHODIMP |
|
1077 nsPrintSettings::SetupSilentPrinting() |
|
1078 { |
|
1079 return NS_OK; |
|
1080 } |
|
1081 |
|
1082 /** --------------------------------------------------- |
|
1083 * See documentation in nsPrintOptionsImpl.h |
|
1084 */ |
|
1085 NS_IMETHODIMP |
|
1086 nsPrintSettings::GetEffectivePageSize(double *aWidth, double *aHeight) |
|
1087 { |
|
1088 if (mPaperSizeUnit == kPaperSizeInches) { |
|
1089 *aWidth = NS_INCHES_TO_TWIPS(float(mPaperWidth)); |
|
1090 *aHeight = NS_INCHES_TO_TWIPS(float(mPaperHeight)); |
|
1091 } else { |
|
1092 *aWidth = NS_MILLIMETERS_TO_TWIPS(float(mPaperWidth)); |
|
1093 *aHeight = NS_MILLIMETERS_TO_TWIPS(float(mPaperHeight)); |
|
1094 } |
|
1095 if (kLandscapeOrientation == mOrientation) { |
|
1096 double temp = *aWidth; |
|
1097 *aWidth = *aHeight; |
|
1098 *aHeight = temp; |
|
1099 } |
|
1100 return NS_OK; |
|
1101 } |
|
1102 |
|
1103 NS_IMETHODIMP |
|
1104 nsPrintSettings::GetPageRanges(nsTArray<int32_t> &aPages) |
|
1105 { |
|
1106 aPages.Clear(); |
|
1107 return NS_OK; |
|
1108 } |
|
1109 |
|
1110 nsresult |
|
1111 nsPrintSettings::_Clone(nsIPrintSettings **_retval) |
|
1112 { |
|
1113 nsPrintSettings* printSettings = new nsPrintSettings(*this); |
|
1114 return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts |
|
1115 } |
|
1116 |
|
1117 /* nsIPrintSettings clone (); */ |
|
1118 NS_IMETHODIMP |
|
1119 nsPrintSettings::Clone(nsIPrintSettings **_retval) |
|
1120 { |
|
1121 NS_ENSURE_ARG_POINTER(_retval); |
|
1122 return _Clone(_retval); |
|
1123 } |
|
1124 |
|
1125 /* void assign (in nsIPrintSettings aPS); */ |
|
1126 nsresult |
|
1127 nsPrintSettings::_Assign(nsIPrintSettings *aPS) |
|
1128 { |
|
1129 nsPrintSettings *ps = static_cast<nsPrintSettings*>(aPS); |
|
1130 *this = *ps; |
|
1131 return NS_OK; |
|
1132 } |
|
1133 |
|
1134 /* void assign (in nsIPrintSettings aPS); */ |
|
1135 NS_IMETHODIMP |
|
1136 nsPrintSettings::Assign(nsIPrintSettings *aPS) |
|
1137 { |
|
1138 NS_ENSURE_ARG(aPS); |
|
1139 return _Assign(aPS); |
|
1140 } |
|
1141 |
|
1142 //------------------------------------------- |
|
1143 nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs) |
|
1144 { |
|
1145 if (this == &rhs) { |
|
1146 return *this; |
|
1147 } |
|
1148 |
|
1149 mStartPageNum = rhs.mStartPageNum; |
|
1150 mEndPageNum = rhs.mEndPageNum; |
|
1151 mMargin = rhs.mMargin; |
|
1152 mEdge = rhs.mEdge; |
|
1153 mUnwriteableMargin = rhs.mUnwriteableMargin; |
|
1154 mScaling = rhs.mScaling; |
|
1155 mPrintBGColors = rhs.mPrintBGColors; |
|
1156 mPrintBGImages = rhs.mPrintBGImages; |
|
1157 mPrintRange = rhs.mPrintRange; |
|
1158 mTitle = rhs.mTitle; |
|
1159 mURL = rhs.mURL; |
|
1160 mHowToEnableFrameUI = rhs.mHowToEnableFrameUI; |
|
1161 mIsCancelled = rhs.mIsCancelled; |
|
1162 mPrintFrameTypeUsage = rhs.mPrintFrameTypeUsage; |
|
1163 mPrintFrameType = rhs.mPrintFrameType; |
|
1164 mPrintSilent = rhs.mPrintSilent; |
|
1165 mShrinkToFit = rhs.mShrinkToFit; |
|
1166 mShowPrintProgress = rhs.mShowPrintProgress; |
|
1167 mPaperName = rhs.mPaperName; |
|
1168 mPlexName = rhs.mPlexName; |
|
1169 mPaperSizeType = rhs.mPaperSizeType; |
|
1170 mPaperData = rhs.mPaperData; |
|
1171 mPaperWidth = rhs.mPaperWidth; |
|
1172 mPaperHeight = rhs.mPaperHeight; |
|
1173 mPaperSizeUnit = rhs.mPaperSizeUnit; |
|
1174 mPrintReversed = rhs.mPrintReversed; |
|
1175 mPrintInColor = rhs.mPrintInColor; |
|
1176 mOrientation = rhs.mOrientation; |
|
1177 mPrintCommand = rhs.mPrintCommand; |
|
1178 mNumCopies = rhs.mNumCopies; |
|
1179 mPrinter = rhs.mPrinter; |
|
1180 mPrintToFile = rhs.mPrintToFile; |
|
1181 mToFileName = rhs.mToFileName; |
|
1182 mOutputFormat = rhs.mOutputFormat; |
|
1183 mPrintPageDelay = rhs.mPrintPageDelay; |
|
1184 |
|
1185 for (int32_t i=0;i<NUM_HEAD_FOOT;i++) { |
|
1186 mHeaderStrs[i] = rhs.mHeaderStrs[i]; |
|
1187 mFooterStrs[i] = rhs.mFooterStrs[i]; |
|
1188 } |
|
1189 |
|
1190 return *this; |
|
1191 } |
|
1192 |