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"
16 #define NUM_HEAD_FOOT 3
18 //*****************************************************************************
20 //*****************************************************************************
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
{
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;
37 CopyableTArray
<uint8_t> mDevmodeWStorage
;
41 } // namespace mozilla
43 class nsPrintSettings
: public nsIPrintSettings
{
46 NS_DECL_NSIPRINTSETTINGS
47 using PrintSettingsInitializer
= mozilla::PrintSettingsInitializer
;
50 nsPrintSettings(const nsPrintSettings
& aPS
);
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();
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
;
74 nsWeakPtr mSession
; // Should never be touched by Clone or Assign
76 // mMargin, mEdge, and mUnwriteableMargin are stored in twips
79 nsIntMargin mUnwriteableMargin
;
81 nsTArray
<int32_t> mPageRanges
;
84 bool mPrintBGColors
; // print background colors
85 bool mPrintBGImages
; // print background images
91 bool mShowPrintProgress
;
92 bool mShowMarginGuides
;
93 bool mHonorPageRuleMargins
;
94 bool mIsPrintSelectionRBEnabled
;
95 bool mPrintSelectionOnly
;
96 int32_t mPrintPageDelay
;
100 nsString mHeaderStrs
[NUM_HEAD_FOOT
];
101 nsString mFooterStrs
[NUM_HEAD_FOOT
];
106 int16_t mPaperSizeUnit
;
109 bool mPrintInColor
; // a false means grayscale
110 int32_t mOrientation
; // see orientation consts
114 int32_t mNumPagesPerSheet
;
117 nsString mToFileName
;
118 int16_t mOutputFormat
;
119 bool mIsInitedFromPrinter
;
120 bool mIsInitedFromPrefs
;
123 #endif /* nsPrintSettings_h__ */