1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
"nsISupports.idl"
17 [ref] native nsNativeIntMarginRef
(nsIntMargin
);
18 [ref] native IntegerArray
(nsTArray
<int32_t
>);
20 interface nsIPrintSession
;
23 * Simplified graphics interface for JS rendering.
25 [scriptable
, uuid(ecc5cbad
-57fc
-4731-b0bd
-09e865bd62ad
)]
27 interface nsIPrintSettings
: nsISupports
30 * PrintSettings to be Saved Navigation Constants
32 const unsigned long kInitSaveOddEvenPages
= 0x00000001;
33 const unsigned long kInitSaveHeaderLeft
= 0x00000002;
34 const unsigned long kInitSaveHeaderCenter
= 0x00000004;
35 const unsigned long kInitSaveHeaderRight
= 0x00000008;
36 const unsigned long kInitSaveFooterLeft
= 0x00000010;
37 const unsigned long kInitSaveFooterCenter
= 0x00000020;
38 const unsigned long kInitSaveFooterRight
= 0x00000040;
39 const unsigned long kInitSaveBGColors
= 0x00000080;
40 const unsigned long kInitSaveBGImages
= 0x00000100;
41 const unsigned long kInitSavePaperSize
= 0x00000200;
42 const unsigned long kInitSaveResolution
= 0x00000400;
43 const unsigned long kInitSaveDuplex
= 0x00000800;
44 /* Flag 0x00001000 is unused */
45 const unsigned long kInitSavePaperData
= 0x00002000;
46 const unsigned long kInitSaveUnwriteableMargins
= 0x00004000;
47 const unsigned long kInitSaveEdges
= 0x00008000;
49 const unsigned long kInitSaveReversed
= 0x00010000;
50 const unsigned long kInitSaveInColor
= 0x00020000;
51 const unsigned long kInitSaveOrientation
= 0x00040000;
53 const unsigned long kInitSavePrinterName
= 0x00100000;
54 const unsigned long kInitSavePrintToFile
= 0x00200000;
55 const unsigned long kInitSaveToFileName
= 0x00400000;
56 const unsigned long kInitSavePageDelay
= 0x00800000;
57 const unsigned long kInitSaveMargins
= 0x01000000;
58 const unsigned long kInitSaveNativeData
= 0x02000000;
60 const unsigned long kInitSaveShrinkToFit
= 0x08000000;
61 const unsigned long kInitSaveScaling
= 0x10000000;
63 const unsigned long kInitSaveAll
= 0xFFFFFFFF;
65 /* Print Option Flags for Bit Field*/
66 const long kPrintOddPages
= 0x00000001;
67 const long kPrintEvenPages
= 0x00000002;
68 const long kEnableSelectionRB
= 0x00000004;
70 /* Print Range Enums */
71 const long kRangeAllPages
= 0;
72 const long kRangeSpecifiedPageRange
= 1;
73 const long kRangeSelection
= 2;
74 const long kRangeFocusFrame
= 3;
76 /* Justification Enums */
77 const long kJustLeft
= 0;
78 const long kJustCenter
= 1;
79 const long kJustRight
= 2;
82 * FrameSet Default Type Constants
84 const short kUseInternalDefault
= 0;
85 const short kUseSettingWhenPossible
= 1;
88 * Page Size Type Constants
90 const short kPaperSizeNativeData
= 0;
91 const short kPaperSizeDefined
= 1;
94 * Page Size Unit Constants
96 const short kPaperSizeInches
= 0;
97 const short kPaperSizeMillimeters
= 1;
100 * Orientation Constants
102 const short kPortraitOrientation
= 0;
103 const short kLandscapeOrientation
= 1;
106 * Print Frame Constants
108 const short kNoFrames
= 0;
109 const short kFramesAsIs
= 1;
110 const short kSelectedFrame
= 2;
111 const short kEachFrameSep
= 3;
114 * How to Enable Frame Set Printing Constants
116 const short kFrameEnableNone
= 0;
117 const short kFrameEnableAll
= 1;
118 const short kFrameEnableAsIsAndEach
= 2;
123 const short kOutputFormatNative
= 0;
124 const short kOutputFormatPS
= 1;
125 const short kOutputFormatPDF
= 2;
130 void SetPrintOptions
(in int32_t aType
, in boolean aTurnOnOff
);
135 boolean GetPrintOptions
(in int32_t aType
);
138 * Get PrintOptions Bit field
140 int32_t GetPrintOptionsBits
();
143 * Set PrintOptions Bit field
145 void SetPrintOptionsBits
(in int32_t bits
);
148 * Get the page size in twips, considering the
149 * orientation (portrait or landscape).
151 void GetEffectivePageSize
(out double aWidth
, out double aHeight
);
156 nsIPrintSettings clone
();
159 * Assigns the internal values from the "in" arg to the current object
161 void assign
(in nsIPrintSettings aPS
);
166 [noscript
] attribute nsIPrintSession printSession
; /* We hold a weak reference */
168 attribute
long startPageRange
;
169 attribute
long endPageRange
;
172 * The edge measurements define the positioning of the headers
173 * and footers on the page. They're measured as an offset from
174 * the "unwriteable margin" (described below).
176 attribute
double edgeTop
; /* these are in inches */
177 attribute
double edgeLeft
;
178 attribute
double edgeBottom
;
179 attribute
double edgeRight
;
182 * The margins define the positioning of the content on the page.
183 * They're treated as an offset from the "unwriteable margin"
186 attribute
double marginTop
; /* these are in inches */
187 attribute
double marginLeft
;
188 attribute
double marginBottom
;
189 attribute
double marginRight
;
191 * The unwriteable margin defines the printable region of the paper, creating
192 * an invisible border from which the edge and margin attributes are measured.
194 attribute
double unwriteableMarginTop
; /* these are in inches */
195 attribute
double unwriteableMarginLeft
;
196 attribute
double unwriteableMarginBottom
;
197 attribute
double unwriteableMarginRight
;
199 attribute
double scaling
; /* values 0.0 - 1.0 */
200 attribute
boolean printBGColors
; /* Print Background Colors */
201 attribute
boolean printBGImages
; /* Print Background Images */
203 attribute
short printRange
;
205 attribute AString title
;
206 attribute AString docURL
;
208 attribute AString headerStrLeft
;
209 attribute AString headerStrCenter
;
210 attribute AString headerStrRight
;
212 attribute AString footerStrLeft
;
213 attribute AString footerStrCenter
;
214 attribute AString footerStrRight
;
216 attribute
short howToEnableFrameUI
; /* indicates how to enable the frameset UI */
217 attribute
boolean isCancelled
; /* indicates whether the print job has been cancelled */
218 attribute
short printFrameTypeUsage
; /* indicates whether to use the interal value or not */
219 attribute
short printFrameType
;
220 attribute
boolean printSilent
; /* print without putting up the dialog */
221 attribute
boolean shrinkToFit
; /* shrinks content to fit on page */
222 attribute
boolean showPrintProgress
; /* indicates whether the progress dialog should be shown */
224 /* Additional XP Related */
225 attribute AString paperName
; /* name of paper */
226 attribute
short paperData
; /* native data value */
227 attribute
double paperWidth
; /* width of the paper in inches or mm */
228 attribute
double paperHeight
; /* height of the paper in inches or mm */
229 attribute
short paperSizeUnit
; /* paper is in inches or mm */
231 attribute
boolean printReversed
;
232 attribute
boolean printInColor
; /* a false means grayscale */
233 attribute
long orientation
; /* see orientation consts */
234 attribute
long numCopies
;
236 attribute AString printerName
; /* name of destination printer */
238 attribute
boolean printToFile
;
239 attribute AString toFileName
;
240 attribute
short outputFormat
;
242 attribute
long printPageDelay
; /* in milliseconds */
244 attribute
long resolution
; /* print resolution (dpi) */
246 attribute
long duplex
; /* duplex mode */
248 /* initialize helpers */
250 * This attribute tracks whether the PS has been initialized
251 * from a printer specified by the "printerName" attr.
252 * If a different name is set into the "printerName"
253 * attribute than the one it was initialized with the PS
254 * will then get intialized from that printer.
256 attribute
boolean isInitializedFromPrinter
;
259 * This attribute tracks whether the PS has been initialized
260 * from prefs. If a different name is set into the "printerName"
261 * attribute than the one it was initialized with the PS
262 * will then get intialized from prefs again.
264 attribute
boolean isInitializedFromPrefs
;
266 /* C++ Helper Functions */
267 [noscript
] void SetMarginInTwips
(in nsNativeIntMarginRef aMargin
);
268 [noscript
] void SetEdgeInTwips
(in nsNativeIntMarginRef aEdge
);
269 /* Purposely made this an "in" arg */
270 [noscript
] void GetMarginInTwips
(in nsNativeIntMarginRef aMargin
);
271 [noscript
] void GetEdgeInTwips
(in nsNativeIntMarginRef aEdge
);
274 * We call this function so that anything that requires a run of the event loop
275 * can do so safely. The print dialog runs the event loop but in silent printing
276 * that doesn't happen.
278 * Either this or ShowPrintDialog (but not both) MUST be called by the print engine
279 * before printing, otherwise printing can fail on some platforms.
281 [noscript
] void SetupSilentPrinting
();
284 * Sets/Gets the "unwriteable margin" for the page format. This defines
285 * the boundary from which we'll measure the EdgeInTwips and MarginInTwips
286 * attributes, to place the headers and content, respectively.
288 * Note: Implementations of SetUnwriteableMarginInTwips should handle
289 * negative margin values by falling back on the system default for
292 [noscript
] void SetUnwriteableMarginInTwips
(in nsNativeIntMarginRef aEdge
);
293 [noscript
] void GetUnwriteableMarginInTwips
(in nsNativeIntMarginRef aEdge
);
296 * Get more accurate print ranges from the superior interval
297 * (startPageRange, endPageRange). The aPages array is populated with a
298 * list of pairs (start, end), where the endpoints are included. The print
299 * ranges (start, end), must not overlap and must be in the
300 * (startPageRange, endPageRange) scope.
302 * If there are no print ranges the aPages array is cleared.
304 [noscript
] void GetPageRanges
(in IntegerArray aPages
);