nsIPrintSettings.idl 10 KB

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