widget/nsIPrintSettings.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsISupports.idl"
michael@0 7
michael@0 8
michael@0 9 %{ C++
michael@0 10 #include "nsMargin.h"
michael@0 11 #include "nsTArray.h"
michael@0 12 %}
michael@0 13
michael@0 14 /**
michael@0 15 * Native types
michael@0 16 */
michael@0 17 [ref] native nsNativeIntMarginRef(nsIntMargin);
michael@0 18 [ref] native IntegerArray(nsTArray<int32_t>);
michael@0 19
michael@0 20 interface nsIPrintSession;
michael@0 21
michael@0 22 /**
michael@0 23 * Simplified graphics interface for JS rendering.
michael@0 24 */
michael@0 25 [scriptable, uuid(1bcfc611-8941-4c39-9e06-7116e564a1ce)]
michael@0 26
michael@0 27 interface nsIPrintSettings : nsISupports
michael@0 28 {
michael@0 29 /**
michael@0 30 * PrintSettings to be Saved Navigation Constants
michael@0 31 */
michael@0 32 const unsigned long kInitSaveOddEvenPages = 0x00000001;
michael@0 33 const unsigned long kInitSaveHeaderLeft = 0x00000002;
michael@0 34 const unsigned long kInitSaveHeaderCenter = 0x00000004;
michael@0 35 const unsigned long kInitSaveHeaderRight = 0x00000008;
michael@0 36 const unsigned long kInitSaveFooterLeft = 0x00000010;
michael@0 37 const unsigned long kInitSaveFooterCenter = 0x00000020;
michael@0 38 const unsigned long kInitSaveFooterRight = 0x00000040;
michael@0 39 const unsigned long kInitSaveBGColors = 0x00000080;
michael@0 40 const unsigned long kInitSaveBGImages = 0x00000100;
michael@0 41 const unsigned long kInitSavePaperSize = 0x00000200;
michael@0 42 const unsigned long kInitSaveResolution = 0x00000400;
michael@0 43 const unsigned long kInitSaveDuplex = 0x00000800;
michael@0 44 /* Flag 0x00001000 is unused */
michael@0 45 const unsigned long kInitSavePaperData = 0x00002000;
michael@0 46 const unsigned long kInitSaveUnwriteableMargins = 0x00004000;
michael@0 47 const unsigned long kInitSaveEdges = 0x00008000;
michael@0 48
michael@0 49 const unsigned long kInitSaveReversed = 0x00010000;
michael@0 50 const unsigned long kInitSaveInColor = 0x00020000;
michael@0 51 const unsigned long kInitSaveOrientation = 0x00040000;
michael@0 52 const unsigned long kInitSavePrintCommand = 0x00080000;
michael@0 53 const unsigned long kInitSavePrinterName = 0x00100000;
michael@0 54 const unsigned long kInitSavePrintToFile = 0x00200000;
michael@0 55 const unsigned long kInitSaveToFileName = 0x00400000;
michael@0 56 const unsigned long kInitSavePageDelay = 0x00800000;
michael@0 57 const unsigned long kInitSaveMargins = 0x01000000;
michael@0 58 const unsigned long kInitSaveNativeData = 0x02000000;
michael@0 59 const unsigned long kInitSavePlexName = 0x04000000;
michael@0 60 const unsigned long kInitSaveShrinkToFit = 0x08000000;
michael@0 61 const unsigned long kInitSaveScaling = 0x10000000;
michael@0 62 const unsigned long kInitSaveColorspace = 0x20000000;
michael@0 63 const unsigned long kInitSaveResolutionName = 0x40000000;
michael@0 64 const unsigned long kInitSaveDownloadFonts = 0x80000000;
michael@0 65 const unsigned long kInitSaveAll = 0xFFFFFFFF;
michael@0 66
michael@0 67 /* Print Option Flags for Bit Field*/
michael@0 68 const long kPrintOddPages = 0x00000001;
michael@0 69 const long kPrintEvenPages = 0x00000002;
michael@0 70 const long kEnableSelectionRB = 0x00000004;
michael@0 71
michael@0 72 /* Print Range Enums */
michael@0 73 const long kRangeAllPages = 0;
michael@0 74 const long kRangeSpecifiedPageRange = 1;
michael@0 75 const long kRangeSelection = 2;
michael@0 76 const long kRangeFocusFrame = 3;
michael@0 77
michael@0 78 /* Justification Enums */
michael@0 79 const long kJustLeft = 0;
michael@0 80 const long kJustCenter = 1;
michael@0 81 const long kJustRight = 2;
michael@0 82
michael@0 83 /**
michael@0 84 * FrameSet Default Type Constants
michael@0 85 */
michael@0 86 const short kUseInternalDefault = 0;
michael@0 87 const short kUseSettingWhenPossible = 1;
michael@0 88
michael@0 89 /**
michael@0 90 * Page Size Type Constants
michael@0 91 */
michael@0 92 const short kPaperSizeNativeData = 0;
michael@0 93 const short kPaperSizeDefined = 1;
michael@0 94
michael@0 95 /**
michael@0 96 * Page Size Unit Constants
michael@0 97 */
michael@0 98 const short kPaperSizeInches = 0;
michael@0 99 const short kPaperSizeMillimeters = 1;
michael@0 100
michael@0 101 /**
michael@0 102 * Orientation Constants
michael@0 103 */
michael@0 104 const short kPortraitOrientation = 0;
michael@0 105 const short kLandscapeOrientation = 1;
michael@0 106
michael@0 107 /**
michael@0 108 * Print Frame Constants
michael@0 109 */
michael@0 110 const short kNoFrames = 0;
michael@0 111 const short kFramesAsIs = 1;
michael@0 112 const short kSelectedFrame = 2;
michael@0 113 const short kEachFrameSep = 3;
michael@0 114
michael@0 115 /**
michael@0 116 * How to Enable Frame Set Printing Constants
michael@0 117 */
michael@0 118 const short kFrameEnableNone = 0;
michael@0 119 const short kFrameEnableAll = 1;
michael@0 120 const short kFrameEnableAsIsAndEach = 2;
michael@0 121
michael@0 122 /**
michael@0 123 * Output file format
michael@0 124 */
michael@0 125 const short kOutputFormatNative = 0;
michael@0 126 const short kOutputFormatPS = 1;
michael@0 127 const short kOutputFormatPDF = 2;
michael@0 128
michael@0 129 /**
michael@0 130 * Set PrintOptions
michael@0 131 */
michael@0 132 void SetPrintOptions(in int32_t aType, in boolean aTurnOnOff);
michael@0 133
michael@0 134 /**
michael@0 135 * Get PrintOptions
michael@0 136 */
michael@0 137 boolean GetPrintOptions(in int32_t aType);
michael@0 138
michael@0 139 /**
michael@0 140 * Set PrintOptions Bit field
michael@0 141 */
michael@0 142 int32_t GetPrintOptionsBits();
michael@0 143
michael@0 144 /**
michael@0 145 * Get the page size in twips, considering the
michael@0 146 * orientation (portrait or landscape).
michael@0 147 */
michael@0 148 void GetEffectivePageSize(out double aWidth, out double aHeight);
michael@0 149
michael@0 150 /**
michael@0 151 * Makes a new copy
michael@0 152 */
michael@0 153 nsIPrintSettings clone();
michael@0 154
michael@0 155 /**
michael@0 156 * Assigns the internal values from the "in" arg to the current object
michael@0 157 */
michael@0 158 void assign(in nsIPrintSettings aPS);
michael@0 159
michael@0 160 /**
michael@0 161 * Data Members
michael@0 162 */
michael@0 163 [noscript] attribute nsIPrintSession printSession; /* We hold a weak reference */
michael@0 164
michael@0 165 attribute long startPageRange;
michael@0 166 attribute long endPageRange;
michael@0 167
michael@0 168 /**
michael@0 169 * The edge measurements define the positioning of the headers
michael@0 170 * and footers on the page. They're measured as an offset from
michael@0 171 * the "unwriteable margin" (described below).
michael@0 172 */
michael@0 173 attribute double edgeTop; /* these are in inches */
michael@0 174 attribute double edgeLeft;
michael@0 175 attribute double edgeBottom;
michael@0 176 attribute double edgeRight;
michael@0 177
michael@0 178 /**
michael@0 179 * The margins define the positioning of the content on the page.
michael@0 180 * They're treated as an offset from the "unwriteable margin"
michael@0 181 * (described below).
michael@0 182 */
michael@0 183 attribute double marginTop; /* these are in inches */
michael@0 184 attribute double marginLeft;
michael@0 185 attribute double marginBottom;
michael@0 186 attribute double marginRight;
michael@0 187 /**
michael@0 188 * The unwriteable margin defines the printable region of the paper, creating
michael@0 189 * an invisible border from which the edge and margin attributes are measured.
michael@0 190 */
michael@0 191 attribute double unwriteableMarginTop; /* these are in inches */
michael@0 192 attribute double unwriteableMarginLeft;
michael@0 193 attribute double unwriteableMarginBottom;
michael@0 194 attribute double unwriteableMarginRight;
michael@0 195
michael@0 196 attribute double scaling; /* values 0.0 - 1.0 */
michael@0 197 attribute boolean printBGColors; /* Print Background Colors */
michael@0 198 attribute boolean printBGImages; /* Print Background Images */
michael@0 199
michael@0 200 attribute short printRange;
michael@0 201
michael@0 202 attribute wstring title;
michael@0 203 attribute wstring docURL;
michael@0 204
michael@0 205 attribute wstring headerStrLeft;
michael@0 206 attribute wstring headerStrCenter;
michael@0 207 attribute wstring headerStrRight;
michael@0 208
michael@0 209 attribute wstring footerStrLeft;
michael@0 210 attribute wstring footerStrCenter;
michael@0 211 attribute wstring footerStrRight;
michael@0 212
michael@0 213 attribute short howToEnableFrameUI; /* indicates how to enable the frameset UI */
michael@0 214 attribute boolean isCancelled; /* indicates whether the print job has been cancelled */
michael@0 215 attribute short printFrameTypeUsage; /* indicates whether to use the interal value or not */
michael@0 216 attribute short printFrameType;
michael@0 217 attribute boolean printSilent; /* print without putting up the dialog */
michael@0 218 attribute boolean shrinkToFit; /* shrinks content to fit on page */
michael@0 219 attribute boolean showPrintProgress; /* indicates whether the progress dialog should be shown */
michael@0 220
michael@0 221 /* Additional XP Related */
michael@0 222 attribute wstring paperName; /* name of paper */
michael@0 223 attribute short paperSizeType; /* use native data or is defined here */
michael@0 224 attribute short paperData; /* native data value */
michael@0 225 attribute double paperWidth; /* width of the paper in inches or mm */
michael@0 226 attribute double paperHeight; /* height of the paper in inches or mm */
michael@0 227 attribute short paperSizeUnit; /* paper is in inches or mm */
michael@0 228
michael@0 229 attribute wstring plexName; /* name of plex mode (like "simplex", "duplex",
michael@0 230 * "tumble" and various custom values) */
michael@0 231
michael@0 232 attribute wstring colorspace; /* device-specific name of colorspace, overrides |printInColor| */
michael@0 233 attribute wstring resolutionName;/* device-specific identifer of resolution or quality
michael@0 234 * (like "600", "600x300", "600x300x12", "high-res",
michael@0 235 * "med-res". "low-res", etc.) */
michael@0 236 attribute boolean downloadFonts; /* enable font download to printer? */
michael@0 237
michael@0 238 attribute boolean printReversed;
michael@0 239 attribute boolean printInColor; /* a false means grayscale */
michael@0 240 attribute long orientation; /* see orientation consts */
michael@0 241 attribute wstring printCommand;
michael@0 242 attribute long numCopies;
michael@0 243
michael@0 244 attribute wstring printerName; /* name of destination printer */
michael@0 245
michael@0 246 attribute boolean printToFile;
michael@0 247 attribute wstring toFileName;
michael@0 248 attribute short outputFormat;
michael@0 249
michael@0 250 attribute long printPageDelay; /* in milliseconds */
michael@0 251
michael@0 252 attribute long resolution; /* print resolution (dpi) */
michael@0 253
michael@0 254 attribute long duplex; /* duplex mode */
michael@0 255
michael@0 256 /* initialize helpers */
michael@0 257 /**
michael@0 258 * This attribute tracks whether the PS has been initialized
michael@0 259 * from a printer specified by the "printerName" attr.
michael@0 260 * If a different name is set into the "printerName"
michael@0 261 * attribute than the one it was initialized with the PS
michael@0 262 * will then get intialized from that printer.
michael@0 263 */
michael@0 264 attribute boolean isInitializedFromPrinter;
michael@0 265
michael@0 266 /**
michael@0 267 * This attribute tracks whether the PS has been initialized
michael@0 268 * from prefs. If a different name is set into the "printerName"
michael@0 269 * attribute than the one it was initialized with the PS
michael@0 270 * will then get intialized from prefs again.
michael@0 271 */
michael@0 272 attribute boolean isInitializedFromPrefs;
michael@0 273
michael@0 274 /**
michael@0 275 * This attribute tracks if the settings made on the margin box is
michael@0 276 * stored in the prefs or not.
michael@0 277 */
michael@0 278 attribute boolean persistMarginBoxSettings;
michael@0 279
michael@0 280 /* C++ Helper Functions */
michael@0 281 [noscript] void SetMarginInTwips(in nsNativeIntMarginRef aMargin);
michael@0 282 [noscript] void SetEdgeInTwips(in nsNativeIntMarginRef aEdge);
michael@0 283 /* Purposely made this an "in" arg */
michael@0 284 [noscript] void GetMarginInTwips(in nsNativeIntMarginRef aMargin);
michael@0 285 [noscript] void GetEdgeInTwips(in nsNativeIntMarginRef aEdge);
michael@0 286
michael@0 287 /**
michael@0 288 * We call this function so that anything that requires a run of the event loop
michael@0 289 * can do so safely. The print dialog runs the event loop but in silent printing
michael@0 290 * that doesn't happen.
michael@0 291 *
michael@0 292 * Either this or ShowPrintDialog (but not both) MUST be called by the print engine
michael@0 293 * before printing, otherwise printing can fail on some platforms.
michael@0 294 */
michael@0 295 [noscript] void SetupSilentPrinting();
michael@0 296
michael@0 297 /**
michael@0 298 * Sets/Gets the "unwriteable margin" for the page format. This defines
michael@0 299 * the boundary from which we'll measure the EdgeInTwips and MarginInTwips
michael@0 300 * attributes, to place the headers and content, respectively.
michael@0 301 *
michael@0 302 * Note: Implementations of SetUnwriteableMarginInTwips should handle
michael@0 303 * negative margin values by falling back on the system default for
michael@0 304 * that margin.
michael@0 305 */
michael@0 306 [noscript] void SetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge);
michael@0 307 [noscript] void GetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge);
michael@0 308
michael@0 309 /**
michael@0 310 * Get more accurate print ranges from the superior interval
michael@0 311 * (startPageRange, endPageRange). The aPages array is populated with a
michael@0 312 * list of pairs (start, end), where the endpoints are included. The print
michael@0 313 * ranges (start, end), must not overlap and must be in the
michael@0 314 * (startPageRange, endPageRange) scope.
michael@0 315 *
michael@0 316 * If there are no print ranges the aPages array is cleared.
michael@0 317 */
michael@0 318 [noscript] void GetPageRanges(in IntegerArray aPages);
michael@0 319 };

mercurial