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/. */
6 #include "nsPrintSettingsImpl.h"
7 #include "nsReadableUtils.h"
8 #include "nsIPrintSession.h"
9 #include "mozilla/RefPtr.h"
11 #define DEFAULT_MARGIN_WIDTH 0.5
13 NS_IMPL_ISUPPORTS(nsPrintSettings
, nsIPrintSettings
)
15 nsPrintSettings::nsPrintSettings()
17 mPrintRange(kRangeAllPages
),
21 mPrintBGColors(false),
22 mPrintBGImages(false),
27 mShowPrintProgress(true),
32 mPaperSizeUnit(kPaperSizeInches
),
33 mPrintReversed(false),
35 mOrientation(kPortraitOrientation
),
40 mOutputFormat(kOutputFormatNative
),
41 mIsInitedFromPrinter(false),
42 mIsInitedFromPrefs(false) {
43 /* member initializers and constructor code */
44 int32_t marginWidth
= NS_INCHES_TO_INT_TWIPS(DEFAULT_MARGIN_WIDTH
);
45 mMargin
.SizeTo(marginWidth
, marginWidth
, marginWidth
, marginWidth
);
46 mEdge
.SizeTo(0, 0, 0, 0);
47 mUnwriteableMargin
.SizeTo(0, 0, 0, 0);
49 mPrintOptions
= kPrintOddPages
| kPrintEvenPages
;
51 mHeaderStrs
[0].AssignLiteral("&T");
52 mHeaderStrs
[2].AssignLiteral("&U");
54 mFooterStrs
[0].AssignLiteral(
55 "&PT"); // Use &P (Page Num Only) or &PT (Page Num of Page Total)
56 mFooterStrs
[2].AssignLiteral("&D");
59 nsPrintSettings::nsPrintSettings(const nsPrintSettings
& aPS
) { *this = aPS
; }
61 nsPrintSettings::~nsPrintSettings() = default;
63 NS_IMETHODIMP
nsPrintSettings::GetPrintSession(
64 nsIPrintSession
** aPrintSession
) {
65 NS_ENSURE_ARG_POINTER(aPrintSession
);
66 *aPrintSession
= nullptr;
68 nsCOMPtr
<nsIPrintSession
> session
= do_QueryReferent(mSession
);
69 if (!session
) return NS_ERROR_NOT_INITIALIZED
;
70 *aPrintSession
= session
;
71 NS_ADDREF(*aPrintSession
);
74 NS_IMETHODIMP
nsPrintSettings::SetPrintSession(nsIPrintSession
* aPrintSession
) {
75 // Clearing it by passing nullptr is not allowed. That's why we
76 // use a weak ref so that it doesn't have to be cleared.
77 NS_ENSURE_ARG(aPrintSession
);
79 mSession
= do_GetWeakReference(aPrintSession
);
81 // This may happen if the implementation of this object does
82 // not support weak references - programmer error.
83 NS_ERROR("Could not get a weak reference from aPrintSession");
84 return NS_ERROR_FAILURE
;
89 NS_IMETHODIMP
nsPrintSettings::GetStartPageRange(int32_t* aStartPageRange
) {
90 // NS_ENSURE_ARG_POINTER(aStartPageRange);
91 *aStartPageRange
= mStartPageNum
;
94 NS_IMETHODIMP
nsPrintSettings::SetStartPageRange(int32_t aStartPageRange
) {
95 mStartPageNum
= aStartPageRange
;
99 NS_IMETHODIMP
nsPrintSettings::GetEndPageRange(int32_t* aEndPageRange
) {
100 // NS_ENSURE_ARG_POINTER(aEndPageRange);
101 *aEndPageRange
= mEndPageNum
;
104 NS_IMETHODIMP
nsPrintSettings::SetEndPageRange(int32_t aEndPageRange
) {
105 mEndPageNum
= aEndPageRange
;
109 NS_IMETHODIMP
nsPrintSettings::GetPrintReversed(bool* aPrintReversed
) {
110 // NS_ENSURE_ARG_POINTER(aPrintReversed);
111 *aPrintReversed
= mPrintReversed
;
114 NS_IMETHODIMP
nsPrintSettings::SetPrintReversed(bool aPrintReversed
) {
115 mPrintReversed
= aPrintReversed
;
119 NS_IMETHODIMP
nsPrintSettings::GetPrintInColor(bool* aPrintInColor
) {
120 // NS_ENSURE_ARG_POINTER(aPrintInColor);
121 *aPrintInColor
= mPrintInColor
;
124 NS_IMETHODIMP
nsPrintSettings::SetPrintInColor(bool aPrintInColor
) {
125 mPrintInColor
= aPrintInColor
;
129 NS_IMETHODIMP
nsPrintSettings::GetOrientation(int32_t* aOrientation
) {
130 NS_ENSURE_ARG_POINTER(aOrientation
);
131 *aOrientation
= mOrientation
;
134 NS_IMETHODIMP
nsPrintSettings::SetOrientation(int32_t aOrientation
) {
135 mOrientation
= aOrientation
;
139 NS_IMETHODIMP
nsPrintSettings::GetResolution(int32_t* aResolution
) {
140 NS_ENSURE_ARG_POINTER(aResolution
);
141 *aResolution
= mResolution
;
144 NS_IMETHODIMP
nsPrintSettings::SetResolution(const int32_t aResolution
) {
145 mResolution
= aResolution
;
149 NS_IMETHODIMP
nsPrintSettings::GetDuplex(int32_t* aDuplex
) {
150 NS_ENSURE_ARG_POINTER(aDuplex
);
154 NS_IMETHODIMP
nsPrintSettings::SetDuplex(const int32_t aDuplex
) {
159 NS_IMETHODIMP
nsPrintSettings::GetPrinterName(nsAString
& aPrinter
) {
164 NS_IMETHODIMP
nsPrintSettings::SetPrinterName(const nsAString
& aPrinter
) {
165 if (!mPrinter
.Equals(aPrinter
)) {
166 mIsInitedFromPrinter
= false;
167 mIsInitedFromPrefs
= false;
170 mPrinter
.Assign(aPrinter
);
174 NS_IMETHODIMP
nsPrintSettings::GetNumCopies(int32_t* aNumCopies
) {
175 NS_ENSURE_ARG_POINTER(aNumCopies
);
176 *aNumCopies
= mNumCopies
;
179 NS_IMETHODIMP
nsPrintSettings::SetNumCopies(int32_t aNumCopies
) {
180 mNumCopies
= aNumCopies
;
184 NS_IMETHODIMP
nsPrintSettings::GetPrintToFile(bool* aPrintToFile
) {
185 // NS_ENSURE_ARG_POINTER(aPrintToFile);
186 *aPrintToFile
= mPrintToFile
;
189 NS_IMETHODIMP
nsPrintSettings::SetPrintToFile(bool aPrintToFile
) {
190 mPrintToFile
= aPrintToFile
;
194 NS_IMETHODIMP
nsPrintSettings::GetToFileName(nsAString
& aToFileName
) {
195 aToFileName
= mToFileName
;
198 NS_IMETHODIMP
nsPrintSettings::SetToFileName(const nsAString
& aToFileName
) {
199 mToFileName
= aToFileName
;
203 NS_IMETHODIMP
nsPrintSettings::GetOutputFormat(int16_t* aOutputFormat
) {
204 NS_ENSURE_ARG_POINTER(aOutputFormat
);
205 *aOutputFormat
= mOutputFormat
;
208 NS_IMETHODIMP
nsPrintSettings::SetOutputFormat(int16_t aOutputFormat
) {
209 mOutputFormat
= aOutputFormat
;
213 NS_IMETHODIMP
nsPrintSettings::GetPrintPageDelay(int32_t* aPrintPageDelay
) {
214 *aPrintPageDelay
= mPrintPageDelay
;
217 NS_IMETHODIMP
nsPrintSettings::SetPrintPageDelay(int32_t aPrintPageDelay
) {
218 mPrintPageDelay
= aPrintPageDelay
;
222 NS_IMETHODIMP
nsPrintSettings::GetIsInitializedFromPrinter(
223 bool* aIsInitializedFromPrinter
) {
224 NS_ENSURE_ARG_POINTER(aIsInitializedFromPrinter
);
225 *aIsInitializedFromPrinter
= (bool)mIsInitedFromPrinter
;
228 NS_IMETHODIMP
nsPrintSettings::SetIsInitializedFromPrinter(
229 bool aIsInitializedFromPrinter
) {
230 mIsInitedFromPrinter
= (bool)aIsInitializedFromPrinter
;
234 NS_IMETHODIMP
nsPrintSettings::GetIsInitializedFromPrefs(
235 bool* aInitializedFromPrefs
) {
236 NS_ENSURE_ARG_POINTER(aInitializedFromPrefs
);
237 *aInitializedFromPrefs
= (bool)mIsInitedFromPrefs
;
240 NS_IMETHODIMP
nsPrintSettings::SetIsInitializedFromPrefs(
241 bool aInitializedFromPrefs
) {
242 mIsInitedFromPrefs
= (bool)aInitializedFromPrefs
;
246 NS_IMETHODIMP
nsPrintSettings::GetMarginTop(double* aMarginTop
) {
247 NS_ENSURE_ARG_POINTER(aMarginTop
);
248 *aMarginTop
= NS_TWIPS_TO_INCHES(mMargin
.top
);
251 NS_IMETHODIMP
nsPrintSettings::SetMarginTop(double aMarginTop
) {
252 mMargin
.top
= NS_INCHES_TO_INT_TWIPS(float(aMarginTop
));
256 NS_IMETHODIMP
nsPrintSettings::GetMarginLeft(double* aMarginLeft
) {
257 NS_ENSURE_ARG_POINTER(aMarginLeft
);
258 *aMarginLeft
= NS_TWIPS_TO_INCHES(mMargin
.left
);
261 NS_IMETHODIMP
nsPrintSettings::SetMarginLeft(double aMarginLeft
) {
262 mMargin
.left
= NS_INCHES_TO_INT_TWIPS(float(aMarginLeft
));
266 NS_IMETHODIMP
nsPrintSettings::GetMarginBottom(double* aMarginBottom
) {
267 NS_ENSURE_ARG_POINTER(aMarginBottom
);
268 *aMarginBottom
= NS_TWIPS_TO_INCHES(mMargin
.bottom
);
271 NS_IMETHODIMP
nsPrintSettings::SetMarginBottom(double aMarginBottom
) {
272 mMargin
.bottom
= NS_INCHES_TO_INT_TWIPS(float(aMarginBottom
));
276 NS_IMETHODIMP
nsPrintSettings::GetMarginRight(double* aMarginRight
) {
277 NS_ENSURE_ARG_POINTER(aMarginRight
);
278 *aMarginRight
= NS_TWIPS_TO_INCHES(mMargin
.right
);
281 NS_IMETHODIMP
nsPrintSettings::SetMarginRight(double aMarginRight
) {
282 mMargin
.right
= NS_INCHES_TO_INT_TWIPS(float(aMarginRight
));
286 NS_IMETHODIMP
nsPrintSettings::GetEdgeTop(double* aEdgeTop
) {
287 NS_ENSURE_ARG_POINTER(aEdgeTop
);
288 *aEdgeTop
= NS_TWIPS_TO_INCHES(mEdge
.top
);
291 NS_IMETHODIMP
nsPrintSettings::SetEdgeTop(double aEdgeTop
) {
292 mEdge
.top
= NS_INCHES_TO_INT_TWIPS(float(aEdgeTop
));
296 NS_IMETHODIMP
nsPrintSettings::GetEdgeLeft(double* aEdgeLeft
) {
297 NS_ENSURE_ARG_POINTER(aEdgeLeft
);
298 *aEdgeLeft
= NS_TWIPS_TO_INCHES(mEdge
.left
);
301 NS_IMETHODIMP
nsPrintSettings::SetEdgeLeft(double aEdgeLeft
) {
302 mEdge
.left
= NS_INCHES_TO_INT_TWIPS(float(aEdgeLeft
));
306 NS_IMETHODIMP
nsPrintSettings::GetEdgeBottom(double* aEdgeBottom
) {
307 NS_ENSURE_ARG_POINTER(aEdgeBottom
);
308 *aEdgeBottom
= NS_TWIPS_TO_INCHES(mEdge
.bottom
);
311 NS_IMETHODIMP
nsPrintSettings::SetEdgeBottom(double aEdgeBottom
) {
312 mEdge
.bottom
= NS_INCHES_TO_INT_TWIPS(float(aEdgeBottom
));
316 NS_IMETHODIMP
nsPrintSettings::GetEdgeRight(double* aEdgeRight
) {
317 NS_ENSURE_ARG_POINTER(aEdgeRight
);
318 *aEdgeRight
= NS_TWIPS_TO_INCHES(mEdge
.right
);
321 NS_IMETHODIMP
nsPrintSettings::SetEdgeRight(double aEdgeRight
) {
322 mEdge
.right
= NS_INCHES_TO_INT_TWIPS(float(aEdgeRight
));
326 NS_IMETHODIMP
nsPrintSettings::GetUnwriteableMarginTop(
327 double* aUnwriteableMarginTop
) {
328 NS_ENSURE_ARG_POINTER(aUnwriteableMarginTop
);
329 *aUnwriteableMarginTop
= NS_TWIPS_TO_INCHES(mUnwriteableMargin
.top
);
332 NS_IMETHODIMP
nsPrintSettings::SetUnwriteableMarginTop(
333 double aUnwriteableMarginTop
) {
334 if (aUnwriteableMarginTop
>= 0.0) {
335 mUnwriteableMargin
.top
= NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginTop
);
340 NS_IMETHODIMP
nsPrintSettings::GetUnwriteableMarginLeft(
341 double* aUnwriteableMarginLeft
) {
342 NS_ENSURE_ARG_POINTER(aUnwriteableMarginLeft
);
343 *aUnwriteableMarginLeft
= NS_TWIPS_TO_INCHES(mUnwriteableMargin
.left
);
346 NS_IMETHODIMP
nsPrintSettings::SetUnwriteableMarginLeft(
347 double aUnwriteableMarginLeft
) {
348 if (aUnwriteableMarginLeft
>= 0.0) {
349 mUnwriteableMargin
.left
= NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginLeft
);
354 NS_IMETHODIMP
nsPrintSettings::GetUnwriteableMarginBottom(
355 double* aUnwriteableMarginBottom
) {
356 NS_ENSURE_ARG_POINTER(aUnwriteableMarginBottom
);
357 *aUnwriteableMarginBottom
= NS_TWIPS_TO_INCHES(mUnwriteableMargin
.bottom
);
360 NS_IMETHODIMP
nsPrintSettings::SetUnwriteableMarginBottom(
361 double aUnwriteableMarginBottom
) {
362 if (aUnwriteableMarginBottom
>= 0.0) {
363 mUnwriteableMargin
.bottom
=
364 NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginBottom
);
369 NS_IMETHODIMP
nsPrintSettings::GetUnwriteableMarginRight(
370 double* aUnwriteableMarginRight
) {
371 NS_ENSURE_ARG_POINTER(aUnwriteableMarginRight
);
372 *aUnwriteableMarginRight
= NS_TWIPS_TO_INCHES(mUnwriteableMargin
.right
);
375 NS_IMETHODIMP
nsPrintSettings::SetUnwriteableMarginRight(
376 double aUnwriteableMarginRight
) {
377 if (aUnwriteableMarginRight
>= 0.0) {
378 mUnwriteableMargin
.right
= NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginRight
);
383 NS_IMETHODIMP
nsPrintSettings::GetScaling(double* aScaling
) {
384 NS_ENSURE_ARG_POINTER(aScaling
);
385 *aScaling
= mScaling
;
389 NS_IMETHODIMP
nsPrintSettings::SetScaling(double aScaling
) {
394 NS_IMETHODIMP
nsPrintSettings::GetPrintBGColors(bool* aPrintBGColors
) {
395 NS_ENSURE_ARG_POINTER(aPrintBGColors
);
396 *aPrintBGColors
= mPrintBGColors
;
399 NS_IMETHODIMP
nsPrintSettings::SetPrintBGColors(bool aPrintBGColors
) {
400 mPrintBGColors
= aPrintBGColors
;
404 NS_IMETHODIMP
nsPrintSettings::GetPrintBGImages(bool* aPrintBGImages
) {
405 NS_ENSURE_ARG_POINTER(aPrintBGImages
);
406 *aPrintBGImages
= mPrintBGImages
;
409 NS_IMETHODIMP
nsPrintSettings::SetPrintBGImages(bool aPrintBGImages
) {
410 mPrintBGImages
= aPrintBGImages
;
414 NS_IMETHODIMP
nsPrintSettings::GetPrintRange(int16_t* aPrintRange
) {
415 NS_ENSURE_ARG_POINTER(aPrintRange
);
416 *aPrintRange
= mPrintRange
;
419 NS_IMETHODIMP
nsPrintSettings::SetPrintRange(int16_t aPrintRange
) {
420 mPrintRange
= aPrintRange
;
424 NS_IMETHODIMP
nsPrintSettings::GetTitle(nsAString
& aTitle
) {
428 NS_IMETHODIMP
nsPrintSettings::SetTitle(const nsAString
& aTitle
) {
433 NS_IMETHODIMP
nsPrintSettings::GetDocURL(nsAString
& aDocURL
) {
437 NS_IMETHODIMP
nsPrintSettings::SetDocURL(const nsAString
& aDocURL
) {
442 /** ---------------------------------------------------
443 * See documentation in nsPrintSettingsImpl.h
444 * @update 1/12/01 rods
447 nsPrintSettings::GetPrintOptions(int32_t aType
, bool* aTurnOnOff
) {
448 NS_ENSURE_ARG_POINTER(aTurnOnOff
);
449 *aTurnOnOff
= mPrintOptions
& aType
? true : false;
452 /** ---------------------------------------------------
453 * See documentation in nsPrintSettingsImpl.h
454 * @update 1/12/01 rods
457 nsPrintSettings::SetPrintOptions(int32_t aType
, bool aTurnOnOff
) {
459 mPrintOptions
|= aType
;
461 mPrintOptions
&= ~aType
;
466 /** ---------------------------------------------------
467 * See documentation in nsPrintSettingsImpl.h
468 * @update 1/12/01 rods
471 nsPrintSettings::GetPrintOptionsBits(int32_t* aBits
) {
472 NS_ENSURE_ARG_POINTER(aBits
);
473 *aBits
= mPrintOptions
;
478 nsPrintSettings::SetPrintOptionsBits(int32_t aBits
) {
479 mPrintOptions
= aBits
;
483 NS_IMETHODIMP
nsPrintSettings::GetHeaderStrLeft(nsAString
& aTitle
) {
484 aTitle
= mHeaderStrs
[0];
487 NS_IMETHODIMP
nsPrintSettings::SetHeaderStrLeft(const nsAString
& aTitle
) {
488 mHeaderStrs
[0] = aTitle
;
492 NS_IMETHODIMP
nsPrintSettings::GetHeaderStrCenter(nsAString
& aTitle
) {
493 aTitle
= mHeaderStrs
[1];
496 NS_IMETHODIMP
nsPrintSettings::SetHeaderStrCenter(const nsAString
& aTitle
) {
497 mHeaderStrs
[1] = aTitle
;
501 NS_IMETHODIMP
nsPrintSettings::GetHeaderStrRight(nsAString
& aTitle
) {
502 aTitle
= mHeaderStrs
[2];
505 NS_IMETHODIMP
nsPrintSettings::SetHeaderStrRight(const nsAString
& aTitle
) {
506 mHeaderStrs
[2] = aTitle
;
510 NS_IMETHODIMP
nsPrintSettings::GetFooterStrLeft(nsAString
& aTitle
) {
511 aTitle
= mFooterStrs
[0];
514 NS_IMETHODIMP
nsPrintSettings::SetFooterStrLeft(const nsAString
& aTitle
) {
515 mFooterStrs
[0] = aTitle
;
519 NS_IMETHODIMP
nsPrintSettings::GetFooterStrCenter(nsAString
& aTitle
) {
520 aTitle
= mFooterStrs
[1];
523 NS_IMETHODIMP
nsPrintSettings::SetFooterStrCenter(const nsAString
& aTitle
) {
524 mFooterStrs
[1] = aTitle
;
528 NS_IMETHODIMP
nsPrintSettings::GetFooterStrRight(nsAString
& aTitle
) {
529 aTitle
= mFooterStrs
[2];
532 NS_IMETHODIMP
nsPrintSettings::SetFooterStrRight(const nsAString
& aTitle
) {
533 mFooterStrs
[2] = aTitle
;
537 NS_IMETHODIMP
nsPrintSettings::GetPrintSilent(bool* aPrintSilent
) {
538 NS_ENSURE_ARG_POINTER(aPrintSilent
);
539 *aPrintSilent
= mPrintSilent
;
542 NS_IMETHODIMP
nsPrintSettings::SetPrintSilent(bool aPrintSilent
) {
543 mPrintSilent
= aPrintSilent
;
547 NS_IMETHODIMP
nsPrintSettings::GetShrinkToFit(bool* aShrinkToFit
) {
548 NS_ENSURE_ARG_POINTER(aShrinkToFit
);
549 *aShrinkToFit
= mShrinkToFit
;
552 NS_IMETHODIMP
nsPrintSettings::SetShrinkToFit(bool aShrinkToFit
) {
553 mShrinkToFit
= aShrinkToFit
;
557 NS_IMETHODIMP
nsPrintSettings::GetShowPrintProgress(bool* aShowPrintProgress
) {
558 NS_ENSURE_ARG_POINTER(aShowPrintProgress
);
559 *aShowPrintProgress
= mShowPrintProgress
;
562 NS_IMETHODIMP
nsPrintSettings::SetShowPrintProgress(bool aShowPrintProgress
) {
563 mShowPrintProgress
= aShowPrintProgress
;
567 NS_IMETHODIMP
nsPrintSettings::GetPaperName(nsAString
& aPaperName
) {
568 aPaperName
= mPaperName
;
571 NS_IMETHODIMP
nsPrintSettings::SetPaperName(const nsAString
& aPaperName
) {
572 mPaperName
= aPaperName
;
576 NS_IMETHODIMP
nsPrintSettings::GetIsCancelled(bool* aIsCancelled
) {
577 NS_ENSURE_ARG_POINTER(aIsCancelled
);
578 *aIsCancelled
= mIsCancelled
;
581 NS_IMETHODIMP
nsPrintSettings::SetIsCancelled(bool aIsCancelled
) {
582 mIsCancelled
= aIsCancelled
;
586 NS_IMETHODIMP
nsPrintSettings::GetSaveOnCancel(bool* aSaveOnCancel
) {
587 *aSaveOnCancel
= mSaveOnCancel
;
591 NS_IMETHODIMP
nsPrintSettings::GetPaperWidth(double* aPaperWidth
) {
592 NS_ENSURE_ARG_POINTER(aPaperWidth
);
593 *aPaperWidth
= mPaperWidth
;
596 NS_IMETHODIMP
nsPrintSettings::SetPaperWidth(double aPaperWidth
) {
597 mPaperWidth
= aPaperWidth
;
601 NS_IMETHODIMP
nsPrintSettings::GetPaperHeight(double* aPaperHeight
) {
602 NS_ENSURE_ARG_POINTER(aPaperHeight
);
603 *aPaperHeight
= mPaperHeight
;
606 NS_IMETHODIMP
nsPrintSettings::SetPaperHeight(double aPaperHeight
) {
607 mPaperHeight
= aPaperHeight
;
611 NS_IMETHODIMP
nsPrintSettings::GetPaperSizeUnit(int16_t* aPaperSizeUnit
) {
612 NS_ENSURE_ARG_POINTER(aPaperSizeUnit
);
613 *aPaperSizeUnit
= mPaperSizeUnit
;
616 NS_IMETHODIMP
nsPrintSettings::SetPaperSizeUnit(int16_t aPaperSizeUnit
) {
617 mPaperSizeUnit
= aPaperSizeUnit
;
621 NS_IMETHODIMP
nsPrintSettings::GetPaperData(int16_t* aPaperData
) {
622 NS_ENSURE_ARG_POINTER(aPaperData
);
623 *aPaperData
= mPaperData
;
626 NS_IMETHODIMP
nsPrintSettings::SetPaperData(int16_t aPaperData
) {
627 mPaperData
= aPaperData
;
631 /** ---------------------------------------------------
632 * See documentation in nsPrintSettingsService.h
633 * @update 6/21/00 dwc
634 * @update 1/12/01 rods
637 nsPrintSettings::SetMarginInTwips(nsIntMargin
& aMargin
) {
643 nsPrintSettings::SetEdgeInTwips(nsIntMargin
& aEdge
) {
648 // NOTE: Any subclass implementation of this function should make sure
649 // to check for negative margin values in aUnwriteableMargin (which
650 // would indicate that we should use the system default unwriteable margin.)
652 nsPrintSettings::SetUnwriteableMarginInTwips(nsIntMargin
& aUnwriteableMargin
) {
653 if (aUnwriteableMargin
.top
>= 0) {
654 mUnwriteableMargin
.top
= aUnwriteableMargin
.top
;
656 if (aUnwriteableMargin
.left
>= 0) {
657 mUnwriteableMargin
.left
= aUnwriteableMargin
.left
;
659 if (aUnwriteableMargin
.bottom
>= 0) {
660 mUnwriteableMargin
.bottom
= aUnwriteableMargin
.bottom
;
662 if (aUnwriteableMargin
.right
>= 0) {
663 mUnwriteableMargin
.right
= aUnwriteableMargin
.right
;
668 /** ---------------------------------------------------
669 * See documentation in nsPrintSettingsService.h
670 * @update 6/21/00 dwc
673 nsPrintSettings::GetMarginInTwips(nsIntMargin
& aMargin
) {
679 nsPrintSettings::GetEdgeInTwips(nsIntMargin
& aEdge
) {
685 nsPrintSettings::GetUnwriteableMarginInTwips(nsIntMargin
& aUnwriteableMargin
) {
686 aUnwriteableMargin
= mUnwriteableMargin
;
690 /** ---------------------------------------------------
691 * Stub - platform-specific implementations can use this function.
694 nsPrintSettings::SetupSilentPrinting() { return NS_OK
; }
696 /** ---------------------------------------------------
697 * See documentation in nsPrintSettingsService.h
700 nsPrintSettings::GetEffectivePageSize(double* aWidth
, double* aHeight
) {
701 if (mPaperSizeUnit
== kPaperSizeInches
) {
702 *aWidth
= NS_INCHES_TO_TWIPS(float(mPaperWidth
));
703 *aHeight
= NS_INCHES_TO_TWIPS(float(mPaperHeight
));
705 *aWidth
= NS_MILLIMETERS_TO_TWIPS(float(mPaperWidth
));
706 *aHeight
= NS_MILLIMETERS_TO_TWIPS(float(mPaperHeight
));
708 if (kLandscapeOrientation
== mOrientation
) {
709 double temp
= *aWidth
;
717 nsPrintSettings::GetPageRanges(nsTArray
<int32_t>& aPages
) {
722 nsresult
nsPrintSettings::_Clone(nsIPrintSettings
** _retval
) {
723 RefPtr
<nsPrintSettings
> printSettings
= new nsPrintSettings(*this);
724 printSettings
.forget(_retval
);
729 nsPrintSettings::Clone(nsIPrintSettings
** _retval
) {
730 NS_ENSURE_ARG_POINTER(_retval
);
731 return _Clone(_retval
);
734 nsresult
nsPrintSettings::_Assign(nsIPrintSettings
* aPS
) {
735 nsPrintSettings
* ps
= static_cast<nsPrintSettings
*>(aPS
);
741 nsPrintSettings::Assign(nsIPrintSettings
* aPS
) {
746 //-------------------------------------------
747 nsPrintSettings
& nsPrintSettings::operator=(const nsPrintSettings
& rhs
) {
752 mStartPageNum
= rhs
.mStartPageNum
;
753 mEndPageNum
= rhs
.mEndPageNum
;
754 mMargin
= rhs
.mMargin
;
756 mUnwriteableMargin
= rhs
.mUnwriteableMargin
;
757 mScaling
= rhs
.mScaling
;
758 mPrintBGColors
= rhs
.mPrintBGColors
;
759 mPrintBGImages
= rhs
.mPrintBGImages
;
760 mPrintRange
= rhs
.mPrintRange
;
763 mIsCancelled
= rhs
.mIsCancelled
;
764 mPrintSilent
= rhs
.mPrintSilent
;
765 mShrinkToFit
= rhs
.mShrinkToFit
;
766 mShowPrintProgress
= rhs
.mShowPrintProgress
;
767 mPaperName
= rhs
.mPaperName
;
768 mPaperData
= rhs
.mPaperData
;
769 mPaperWidth
= rhs
.mPaperWidth
;
770 mPaperHeight
= rhs
.mPaperHeight
;
771 mPaperSizeUnit
= rhs
.mPaperSizeUnit
;
772 mPrintReversed
= rhs
.mPrintReversed
;
773 mPrintInColor
= rhs
.mPrintInColor
;
774 mOrientation
= rhs
.mOrientation
;
775 mNumCopies
= rhs
.mNumCopies
;
776 mPrinter
= rhs
.mPrinter
;
777 mPrintToFile
= rhs
.mPrintToFile
;
778 mToFileName
= rhs
.mToFileName
;
779 mOutputFormat
= rhs
.mOutputFormat
;
780 mPrintPageDelay
= rhs
.mPrintPageDelay
;
782 for (int32_t i
= 0; i
< NUM_HEAD_FOOT
; i
++) {
783 mHeaderStrs
[i
] = rhs
.mHeaderStrs
[i
];
784 mFooterStrs
[i
] = rhs
.mFooterStrs
[i
];