Bug 1842773 - Part 34: Enable test262 tests. r=sfink
[gecko.git] / widget / nsPrintSettingsImpl.h
blobf090cc584109d606a5da89ff349b98fa81c56c82
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"
12 #include "nsMargin.h"
13 #include "nsPaper.h"
14 #include "nsProxyRelease.h"
15 #include "nsString.h"
17 #define NUM_HEAD_FOOT 3
19 //*****************************************************************************
20 //*** nsPrintSettings
21 //*****************************************************************************
23 class nsPrintSettings;
25 namespace mozilla {
27 /**
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 {
32 nsString mPrinter;
33 PaperInfo mPaperInfo;
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;
39 int mResolution = 0;
40 int mSheetOrientation = nsIPrintSettings::kPortraitOrientation;
41 int mNumCopies = 1;
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;
49 #ifdef XP_WIN
50 CopyableTArray<uint8_t> mDevmodeWStorage;
51 #endif
54 } // namespace mozilla
56 class nsPrintSettings : public nsIPrintSettings {
57 public:
58 NS_DECL_ISUPPORTS
59 NS_DECL_NSIPRINTSETTINGS
60 using PrintSettingsInitializer = mozilla::PrintSettingsInitializer;
62 nsPrintSettings();
63 nsPrintSettings(const nsPrintSettings& aPS);
65 /**
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 nsPrintSettings& operator=(const nsPrintSettings& rhs);
74 // Sets a default file name for the print settings.
75 void SetDefaultFileName();
77 protected:
78 virtual ~nsPrintSettings();
80 // May be implemented by the platform-specific derived class
81 virtual nsresult _Clone(nsIPrintSettings** _retval);
82 virtual nsresult _Assign(nsIPrintSettings* aPS);
84 // Members
85 nsWeakPtr mSession; // Should never be touched by Clone or Assign
87 // mMargin, mEdge, and mUnwriteableMargin are stored in twips
88 nsIntMargin mMargin;
89 nsIntMargin mEdge;
90 nsIntMargin mUnwriteableMargin;
92 nsTArray<int32_t> mPageRanges;
94 double mScaling = 1.0;
95 bool mPrintBGColors = false;
96 bool mPrintBGImages = false;
98 bool mPrintSilent = false;
99 bool mShrinkToFit = true;
100 bool mShowMarginGuides = false;
101 bool mHonorPageRuleMargins = true;
102 bool mUsePageRuleSizeAsPaperSize = false;
103 bool mIgnoreUnwriteableMargins = false;
104 bool mPrintSelectionOnly = false;
106 int32_t mPrintPageDelay = 50; // XXX Do we really want this?
108 nsString mTitle;
109 nsString mURL;
110 nsString mHeaderStrs[NUM_HEAD_FOOT];
111 nsString mFooterStrs[NUM_HEAD_FOOT];
113 nsString mPaperId;
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;
127 nsString mPrinter;
128 nsString mToFileName;
129 nsCOMPtr<nsIOutputStream> mOutputStream;
130 bool mIsInitedFromPrinter = false;
131 bool mIsInitedFromPrefs = false;
134 #endif /* nsPrintSettings_h__ */