Bug 1735252 [wpt PR 31197] - Regenerate WPT certificates, a=testonly
[gecko.git] / widget / nsPrintSettingsImpl.h
blobe391bab5bc8bf808566de1397f265ca7a3426a3b
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 "nsString.h"
16 #define NUM_HEAD_FOOT 3
18 //*****************************************************************************
19 //*** nsPrintSettings
20 //*****************************************************************************
22 namespace mozilla {
24 /**
25 * A struct that can be used off the main thread to collect printer-specific
26 * info that can be used to initialized a default nsIPrintSettings object.
28 struct PrintSettingsInitializer {
29 nsString mPrinter;
30 PaperInfo mPaperInfo;
31 // If we fail to obtain printer capabilities, being given the option to print
32 // in color to your monochrome printer is a lot less annoying than not being
33 // given the option to print in color to your color printer.
34 bool mPrintInColor = true;
35 int mResolution = 0;
36 #ifdef XP_WIN
37 CopyableTArray<uint8_t> mDevmodeWStorage;
38 #endif
41 } // namespace mozilla
43 class nsPrintSettings : public nsIPrintSettings {
44 public:
45 NS_DECL_ISUPPORTS
46 NS_DECL_NSIPRINTSETTINGS
47 using PrintSettingsInitializer = mozilla::PrintSettingsInitializer;
49 nsPrintSettings();
50 nsPrintSettings(const nsPrintSettings& aPS);
52 /**
53 * Initialize relevant members from the PrintSettingsInitializer.
54 * This is specifically not a constructor so that we can ensure that the
55 * relevant setters are dynamically dispatched to derived classes.
57 virtual void InitWithInitializer(const PrintSettingsInitializer& aSettings);
59 nsPrintSettings& operator=(const nsPrintSettings& rhs);
61 // Sets a default file name for the print settings.
62 void SetDefaultFileName();
64 protected:
65 virtual ~nsPrintSettings();
67 // May be implemented by the platform-specific derived class
68 virtual nsresult _Clone(nsIPrintSettings** _retval);
69 virtual nsresult _Assign(nsIPrintSettings* aPS);
71 typedef enum { eHeader, eFooter } nsHeaderFooterEnum;
73 // Members
74 nsWeakPtr mSession; // Should never be touched by Clone or Assign
76 // mMargin, mEdge, and mUnwriteableMargin are stored in twips
77 nsIntMargin mMargin;
78 nsIntMargin mEdge;
79 nsIntMargin mUnwriteableMargin;
81 nsTArray<int32_t> mPageRanges;
83 double mScaling;
84 bool mPrintBGColors; // print background colors
85 bool mPrintBGImages; // print background images
87 bool mIsCancelled;
88 bool mSaveOnCancel;
89 bool mPrintSilent;
90 bool mShrinkToFit;
91 bool mShowPrintProgress;
92 bool mShowMarginGuides;
93 bool mHonorPageRuleMargins;
94 bool mIsPrintSelectionRBEnabled;
95 bool mPrintSelectionOnly;
96 int32_t mPrintPageDelay;
98 nsString mTitle;
99 nsString mURL;
100 nsString mHeaderStrs[NUM_HEAD_FOOT];
101 nsString mFooterStrs[NUM_HEAD_FOOT];
103 nsString mPaperId;
104 double mPaperWidth;
105 double mPaperHeight;
106 int16_t mPaperSizeUnit;
108 bool mPrintReversed;
109 bool mPrintInColor; // a false means grayscale
110 int32_t mOrientation; // see orientation consts
111 int32_t mResolution;
112 int32_t mDuplex;
113 int32_t mNumCopies;
114 int32_t mNumPagesPerSheet;
115 nsString mPrinter;
116 bool mPrintToFile;
117 nsString mToFileName;
118 int16_t mOutputFormat;
119 bool mIsInitedFromPrinter;
120 bool mIsInitedFromPrefs;
123 #endif /* nsPrintSettings_h__ */