1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsPrintSettingsImpl_h__
8 #define nsPrintSettingsImpl_h__
10 #include "nsIPrintSettings.h"
11 #include "nsIWeakReferenceUtils.h"
14 #include "nsProxyRelease.h"
17 #define NUM_HEAD_FOOT 3
19 //*****************************************************************************
21 //*****************************************************************************
23 class nsPrintSettings
;
28 * A struct that can be used off the main thread to collect printer-specific
29 * info that can be used to initialized a default nsIPrintSettings object.
31 struct PrintSettingsInitializer
{
34 int16_t mPaperSizeUnit
= nsIPrintSettings::kPaperSizeInches
;
35 // If we fail to obtain printer capabilities, being given the option to print
36 // in color to your monochrome printer is a lot less annoying than not being
37 // given the option to print in color to your color printer.
38 bool mPrintInColor
= true;
40 int mSheetOrientation
= nsIPrintSettings::kPortraitOrientation
;
42 int mDuplex
= nsIPrintSettings::kDuplexNone
;
44 // This is to hold a reference to a newly cloned settings object that will
45 // then be initialized by the other values in the initializer that may have
46 // been changed on a background thread.
47 nsMainThreadPtrHandle
<nsPrintSettings
> mPrintSettings
;
50 CopyableTArray
<uint8_t> mDevmodeWStorage
;
54 } // namespace mozilla
56 class nsPrintSettings
: public nsIPrintSettings
{
59 NS_DECL_NSIPRINTSETTINGS
60 using PrintSettingsInitializer
= mozilla::PrintSettingsInitializer
;
63 nsPrintSettings(const nsPrintSettings
& aPS
);
66 * Initialize relevant members from the PrintSettingsInitializer.
67 * This is specifically not a constructor so that we can ensure that the
68 * relevant setters are dynamically dispatched to derived classes.
70 virtual void InitWithInitializer(const PrintSettingsInitializer
& aSettings
);
72 PrintSettingsInitializer
GetSettingsInitializer() final
;
74 nsPrintSettings
& operator=(const nsPrintSettings
& rhs
);
76 // Sets a default file name for the print settings.
77 void SetDefaultFileName();
80 virtual ~nsPrintSettings();
82 // May be implemented by the platform-specific derived class
83 virtual nsresult
_Clone(nsIPrintSettings
** _retval
);
84 virtual nsresult
_Assign(nsIPrintSettings
* aPS
);
87 nsWeakPtr mSession
; // Should never be touched by Clone or Assign
89 // mMargin, mEdge, and mUnwriteableMargin are stored in twips
92 nsIntMargin mUnwriteableMargin
;
94 nsTArray
<int32_t> mPageRanges
;
96 double mScaling
= 1.0;
97 bool mPrintBGColors
= false;
98 bool mPrintBGImages
= false;
100 bool mPrintSilent
= false;
101 bool mShrinkToFit
= true;
102 bool mShowMarginGuides
= false;
103 bool mHonorPageRuleMargins
= true;
104 bool mPrintSelectionOnly
= false;
106 int32_t mPrintPageDelay
= 50; // XXX Do we really want this?
110 nsString mHeaderStrs
[NUM_HEAD_FOOT
];
111 nsString mFooterStrs
[NUM_HEAD_FOOT
];
114 double mPaperWidth
= 8.5;
115 double mPaperHeight
= 11.0;
116 int16_t mPaperSizeUnit
= kPaperSizeInches
;
118 bool mPrintReversed
= false;
119 bool mPrintInColor
= true;
120 int32_t mOrientation
= kPortraitOrientation
;
121 int32_t mResolution
= 0;
122 int32_t mDuplex
= kDuplexNone
;
123 int32_t mNumCopies
= 1;
124 int32_t mNumPagesPerSheet
= 1;
125 int16_t mOutputFormat
= kOutputFormatNative
;
126 OutputDestinationType mOutputDestination
= kOutputDestinationPrinter
;
128 nsString mToFileName
;
129 nsCOMPtr
<nsIOutputStream
> mOutputStream
;
130 bool mIsInitedFromPrinter
= false;
131 bool mIsInitedFromPrefs
= false;
134 #endif /* nsPrintSettings_h__ */