1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/nsIPrintSettings.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,319 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 + 1.12 +%{ C++ 1.13 +#include "nsMargin.h" 1.14 +#include "nsTArray.h" 1.15 +%} 1.16 + 1.17 +/** 1.18 + * Native types 1.19 + */ 1.20 + [ref] native nsNativeIntMarginRef(nsIntMargin); 1.21 + [ref] native IntegerArray(nsTArray<int32_t>); 1.22 + 1.23 +interface nsIPrintSession; 1.24 + 1.25 +/** 1.26 + * Simplified graphics interface for JS rendering. 1.27 + */ 1.28 +[scriptable, uuid(1bcfc611-8941-4c39-9e06-7116e564a1ce)] 1.29 + 1.30 +interface nsIPrintSettings : nsISupports 1.31 +{ 1.32 + /** 1.33 + * PrintSettings to be Saved Navigation Constants 1.34 + */ 1.35 + const unsigned long kInitSaveOddEvenPages = 0x00000001; 1.36 + const unsigned long kInitSaveHeaderLeft = 0x00000002; 1.37 + const unsigned long kInitSaveHeaderCenter = 0x00000004; 1.38 + const unsigned long kInitSaveHeaderRight = 0x00000008; 1.39 + const unsigned long kInitSaveFooterLeft = 0x00000010; 1.40 + const unsigned long kInitSaveFooterCenter = 0x00000020; 1.41 + const unsigned long kInitSaveFooterRight = 0x00000040; 1.42 + const unsigned long kInitSaveBGColors = 0x00000080; 1.43 + const unsigned long kInitSaveBGImages = 0x00000100; 1.44 + const unsigned long kInitSavePaperSize = 0x00000200; 1.45 + const unsigned long kInitSaveResolution = 0x00000400; 1.46 + const unsigned long kInitSaveDuplex = 0x00000800; 1.47 + /* Flag 0x00001000 is unused */ 1.48 + const unsigned long kInitSavePaperData = 0x00002000; 1.49 + const unsigned long kInitSaveUnwriteableMargins = 0x00004000; 1.50 + const unsigned long kInitSaveEdges = 0x00008000; 1.51 + 1.52 + const unsigned long kInitSaveReversed = 0x00010000; 1.53 + const unsigned long kInitSaveInColor = 0x00020000; 1.54 + const unsigned long kInitSaveOrientation = 0x00040000; 1.55 + const unsigned long kInitSavePrintCommand = 0x00080000; 1.56 + const unsigned long kInitSavePrinterName = 0x00100000; 1.57 + const unsigned long kInitSavePrintToFile = 0x00200000; 1.58 + const unsigned long kInitSaveToFileName = 0x00400000; 1.59 + const unsigned long kInitSavePageDelay = 0x00800000; 1.60 + const unsigned long kInitSaveMargins = 0x01000000; 1.61 + const unsigned long kInitSaveNativeData = 0x02000000; 1.62 + const unsigned long kInitSavePlexName = 0x04000000; 1.63 + const unsigned long kInitSaveShrinkToFit = 0x08000000; 1.64 + const unsigned long kInitSaveScaling = 0x10000000; 1.65 + const unsigned long kInitSaveColorspace = 0x20000000; 1.66 + const unsigned long kInitSaveResolutionName = 0x40000000; 1.67 + const unsigned long kInitSaveDownloadFonts = 0x80000000; 1.68 + const unsigned long kInitSaveAll = 0xFFFFFFFF; 1.69 + 1.70 + /* Print Option Flags for Bit Field*/ 1.71 + const long kPrintOddPages = 0x00000001; 1.72 + const long kPrintEvenPages = 0x00000002; 1.73 + const long kEnableSelectionRB = 0x00000004; 1.74 + 1.75 + /* Print Range Enums */ 1.76 + const long kRangeAllPages = 0; 1.77 + const long kRangeSpecifiedPageRange = 1; 1.78 + const long kRangeSelection = 2; 1.79 + const long kRangeFocusFrame = 3; 1.80 + 1.81 + /* Justification Enums */ 1.82 + const long kJustLeft = 0; 1.83 + const long kJustCenter = 1; 1.84 + const long kJustRight = 2; 1.85 + 1.86 + /** 1.87 + * FrameSet Default Type Constants 1.88 + */ 1.89 + const short kUseInternalDefault = 0; 1.90 + const short kUseSettingWhenPossible = 1; 1.91 + 1.92 + /** 1.93 + * Page Size Type Constants 1.94 + */ 1.95 + const short kPaperSizeNativeData = 0; 1.96 + const short kPaperSizeDefined = 1; 1.97 + 1.98 + /** 1.99 + * Page Size Unit Constants 1.100 + */ 1.101 + const short kPaperSizeInches = 0; 1.102 + const short kPaperSizeMillimeters = 1; 1.103 + 1.104 + /** 1.105 + * Orientation Constants 1.106 + */ 1.107 + const short kPortraitOrientation = 0; 1.108 + const short kLandscapeOrientation = 1; 1.109 + 1.110 + /** 1.111 + * Print Frame Constants 1.112 + */ 1.113 + const short kNoFrames = 0; 1.114 + const short kFramesAsIs = 1; 1.115 + const short kSelectedFrame = 2; 1.116 + const short kEachFrameSep = 3; 1.117 + 1.118 + /** 1.119 + * How to Enable Frame Set Printing Constants 1.120 + */ 1.121 + const short kFrameEnableNone = 0; 1.122 + const short kFrameEnableAll = 1; 1.123 + const short kFrameEnableAsIsAndEach = 2; 1.124 + 1.125 + /** 1.126 + * Output file format 1.127 + */ 1.128 + const short kOutputFormatNative = 0; 1.129 + const short kOutputFormatPS = 1; 1.130 + const short kOutputFormatPDF = 2; 1.131 + 1.132 + /** 1.133 + * Set PrintOptions 1.134 + */ 1.135 + void SetPrintOptions(in int32_t aType, in boolean aTurnOnOff); 1.136 + 1.137 + /** 1.138 + * Get PrintOptions 1.139 + */ 1.140 + boolean GetPrintOptions(in int32_t aType); 1.141 + 1.142 + /** 1.143 + * Set PrintOptions Bit field 1.144 + */ 1.145 + int32_t GetPrintOptionsBits(); 1.146 + 1.147 + /** 1.148 + * Get the page size in twips, considering the 1.149 + * orientation (portrait or landscape). 1.150 + */ 1.151 + void GetEffectivePageSize(out double aWidth, out double aHeight); 1.152 + 1.153 + /** 1.154 + * Makes a new copy 1.155 + */ 1.156 + nsIPrintSettings clone(); 1.157 + 1.158 + /** 1.159 + * Assigns the internal values from the "in" arg to the current object 1.160 + */ 1.161 + void assign(in nsIPrintSettings aPS); 1.162 + 1.163 + /** 1.164 + * Data Members 1.165 + */ 1.166 + [noscript] attribute nsIPrintSession printSession; /* We hold a weak reference */ 1.167 + 1.168 + attribute long startPageRange; 1.169 + attribute long endPageRange; 1.170 + 1.171 + /** 1.172 + * The edge measurements define the positioning of the headers 1.173 + * and footers on the page. They're measured as an offset from 1.174 + * the "unwriteable margin" (described below). 1.175 + */ 1.176 + attribute double edgeTop; /* these are in inches */ 1.177 + attribute double edgeLeft; 1.178 + attribute double edgeBottom; 1.179 + attribute double edgeRight; 1.180 + 1.181 + /** 1.182 + * The margins define the positioning of the content on the page. 1.183 + * They're treated as an offset from the "unwriteable margin" 1.184 + * (described below). 1.185 + */ 1.186 + attribute double marginTop; /* these are in inches */ 1.187 + attribute double marginLeft; 1.188 + attribute double marginBottom; 1.189 + attribute double marginRight; 1.190 + /** 1.191 + * The unwriteable margin defines the printable region of the paper, creating 1.192 + * an invisible border from which the edge and margin attributes are measured. 1.193 + */ 1.194 + attribute double unwriteableMarginTop; /* these are in inches */ 1.195 + attribute double unwriteableMarginLeft; 1.196 + attribute double unwriteableMarginBottom; 1.197 + attribute double unwriteableMarginRight; 1.198 + 1.199 + attribute double scaling; /* values 0.0 - 1.0 */ 1.200 + attribute boolean printBGColors; /* Print Background Colors */ 1.201 + attribute boolean printBGImages; /* Print Background Images */ 1.202 + 1.203 + attribute short printRange; 1.204 + 1.205 + attribute wstring title; 1.206 + attribute wstring docURL; 1.207 + 1.208 + attribute wstring headerStrLeft; 1.209 + attribute wstring headerStrCenter; 1.210 + attribute wstring headerStrRight; 1.211 + 1.212 + attribute wstring footerStrLeft; 1.213 + attribute wstring footerStrCenter; 1.214 + attribute wstring footerStrRight; 1.215 + 1.216 + attribute short howToEnableFrameUI; /* indicates how to enable the frameset UI */ 1.217 + attribute boolean isCancelled; /* indicates whether the print job has been cancelled */ 1.218 + attribute short printFrameTypeUsage; /* indicates whether to use the interal value or not */ 1.219 + attribute short printFrameType; 1.220 + attribute boolean printSilent; /* print without putting up the dialog */ 1.221 + attribute boolean shrinkToFit; /* shrinks content to fit on page */ 1.222 + attribute boolean showPrintProgress; /* indicates whether the progress dialog should be shown */ 1.223 + 1.224 + /* Additional XP Related */ 1.225 + attribute wstring paperName; /* name of paper */ 1.226 + attribute short paperSizeType; /* use native data or is defined here */ 1.227 + attribute short paperData; /* native data value */ 1.228 + attribute double paperWidth; /* width of the paper in inches or mm */ 1.229 + attribute double paperHeight; /* height of the paper in inches or mm */ 1.230 + attribute short paperSizeUnit; /* paper is in inches or mm */ 1.231 + 1.232 + attribute wstring plexName; /* name of plex mode (like "simplex", "duplex", 1.233 + * "tumble" and various custom values) */ 1.234 + 1.235 + attribute wstring colorspace; /* device-specific name of colorspace, overrides |printInColor| */ 1.236 + attribute wstring resolutionName;/* device-specific identifer of resolution or quality 1.237 + * (like "600", "600x300", "600x300x12", "high-res", 1.238 + * "med-res". "low-res", etc.) */ 1.239 + attribute boolean downloadFonts; /* enable font download to printer? */ 1.240 + 1.241 + attribute boolean printReversed; 1.242 + attribute boolean printInColor; /* a false means grayscale */ 1.243 + attribute long orientation; /* see orientation consts */ 1.244 + attribute wstring printCommand; 1.245 + attribute long numCopies; 1.246 + 1.247 + attribute wstring printerName; /* name of destination printer */ 1.248 + 1.249 + attribute boolean printToFile; 1.250 + attribute wstring toFileName; 1.251 + attribute short outputFormat; 1.252 + 1.253 + attribute long printPageDelay; /* in milliseconds */ 1.254 + 1.255 + attribute long resolution; /* print resolution (dpi) */ 1.256 + 1.257 + attribute long duplex; /* duplex mode */ 1.258 + 1.259 + /* initialize helpers */ 1.260 + /** 1.261 + * This attribute tracks whether the PS has been initialized 1.262 + * from a printer specified by the "printerName" attr. 1.263 + * If a different name is set into the "printerName" 1.264 + * attribute than the one it was initialized with the PS 1.265 + * will then get intialized from that printer. 1.266 + */ 1.267 + attribute boolean isInitializedFromPrinter; 1.268 + 1.269 + /** 1.270 + * This attribute tracks whether the PS has been initialized 1.271 + * from prefs. If a different name is set into the "printerName" 1.272 + * attribute than the one it was initialized with the PS 1.273 + * will then get intialized from prefs again. 1.274 + */ 1.275 + attribute boolean isInitializedFromPrefs; 1.276 + 1.277 + /** 1.278 + * This attribute tracks if the settings made on the margin box is 1.279 + * stored in the prefs or not. 1.280 + */ 1.281 + attribute boolean persistMarginBoxSettings; 1.282 + 1.283 + /* C++ Helper Functions */ 1.284 + [noscript] void SetMarginInTwips(in nsNativeIntMarginRef aMargin); 1.285 + [noscript] void SetEdgeInTwips(in nsNativeIntMarginRef aEdge); 1.286 + /* Purposely made this an "in" arg */ 1.287 + [noscript] void GetMarginInTwips(in nsNativeIntMarginRef aMargin); 1.288 + [noscript] void GetEdgeInTwips(in nsNativeIntMarginRef aEdge); 1.289 + 1.290 + /** 1.291 + * We call this function so that anything that requires a run of the event loop 1.292 + * can do so safely. The print dialog runs the event loop but in silent printing 1.293 + * that doesn't happen. 1.294 + * 1.295 + * Either this or ShowPrintDialog (but not both) MUST be called by the print engine 1.296 + * before printing, otherwise printing can fail on some platforms. 1.297 + */ 1.298 + [noscript] void SetupSilentPrinting(); 1.299 + 1.300 + /** 1.301 + * Sets/Gets the "unwriteable margin" for the page format. This defines 1.302 + * the boundary from which we'll measure the EdgeInTwips and MarginInTwips 1.303 + * attributes, to place the headers and content, respectively. 1.304 + * 1.305 + * Note: Implementations of SetUnwriteableMarginInTwips should handle 1.306 + * negative margin values by falling back on the system default for 1.307 + * that margin. 1.308 + */ 1.309 + [noscript] void SetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge); 1.310 + [noscript] void GetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge); 1.311 + 1.312 + /** 1.313 + * Get more accurate print ranges from the superior interval 1.314 + * (startPageRange, endPageRange). The aPages array is populated with a 1.315 + * list of pairs (start, end), where the endpoints are included. The print 1.316 + * ranges (start, end), must not overlap and must be in the 1.317 + * (startPageRange, endPageRange) scope. 1.318 + * 1.319 + * If there are no print ranges the aPages array is cleared. 1.320 + */ 1.321 + [noscript] void GetPageRanges(in IntegerArray aPages); 1.322 +};