michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: michael@0: %{ C++ michael@0: #include "nsMargin.h" michael@0: #include "nsTArray.h" michael@0: %} michael@0: michael@0: /** michael@0: * Native types michael@0: */ michael@0: [ref] native nsNativeIntMarginRef(nsIntMargin); michael@0: [ref] native IntegerArray(nsTArray); michael@0: michael@0: interface nsIPrintSession; michael@0: michael@0: /** michael@0: * Simplified graphics interface for JS rendering. michael@0: */ michael@0: [scriptable, uuid(1bcfc611-8941-4c39-9e06-7116e564a1ce)] michael@0: michael@0: interface nsIPrintSettings : nsISupports michael@0: { michael@0: /** michael@0: * PrintSettings to be Saved Navigation Constants michael@0: */ michael@0: const unsigned long kInitSaveOddEvenPages = 0x00000001; michael@0: const unsigned long kInitSaveHeaderLeft = 0x00000002; michael@0: const unsigned long kInitSaveHeaderCenter = 0x00000004; michael@0: const unsigned long kInitSaveHeaderRight = 0x00000008; michael@0: const unsigned long kInitSaveFooterLeft = 0x00000010; michael@0: const unsigned long kInitSaveFooterCenter = 0x00000020; michael@0: const unsigned long kInitSaveFooterRight = 0x00000040; michael@0: const unsigned long kInitSaveBGColors = 0x00000080; michael@0: const unsigned long kInitSaveBGImages = 0x00000100; michael@0: const unsigned long kInitSavePaperSize = 0x00000200; michael@0: const unsigned long kInitSaveResolution = 0x00000400; michael@0: const unsigned long kInitSaveDuplex = 0x00000800; michael@0: /* Flag 0x00001000 is unused */ michael@0: const unsigned long kInitSavePaperData = 0x00002000; michael@0: const unsigned long kInitSaveUnwriteableMargins = 0x00004000; michael@0: const unsigned long kInitSaveEdges = 0x00008000; michael@0: michael@0: const unsigned long kInitSaveReversed = 0x00010000; michael@0: const unsigned long kInitSaveInColor = 0x00020000; michael@0: const unsigned long kInitSaveOrientation = 0x00040000; michael@0: const unsigned long kInitSavePrintCommand = 0x00080000; michael@0: const unsigned long kInitSavePrinterName = 0x00100000; michael@0: const unsigned long kInitSavePrintToFile = 0x00200000; michael@0: const unsigned long kInitSaveToFileName = 0x00400000; michael@0: const unsigned long kInitSavePageDelay = 0x00800000; michael@0: const unsigned long kInitSaveMargins = 0x01000000; michael@0: const unsigned long kInitSaveNativeData = 0x02000000; michael@0: const unsigned long kInitSavePlexName = 0x04000000; michael@0: const unsigned long kInitSaveShrinkToFit = 0x08000000; michael@0: const unsigned long kInitSaveScaling = 0x10000000; michael@0: const unsigned long kInitSaveColorspace = 0x20000000; michael@0: const unsigned long kInitSaveResolutionName = 0x40000000; michael@0: const unsigned long kInitSaveDownloadFonts = 0x80000000; michael@0: const unsigned long kInitSaveAll = 0xFFFFFFFF; michael@0: michael@0: /* Print Option Flags for Bit Field*/ michael@0: const long kPrintOddPages = 0x00000001; michael@0: const long kPrintEvenPages = 0x00000002; michael@0: const long kEnableSelectionRB = 0x00000004; michael@0: michael@0: /* Print Range Enums */ michael@0: const long kRangeAllPages = 0; michael@0: const long kRangeSpecifiedPageRange = 1; michael@0: const long kRangeSelection = 2; michael@0: const long kRangeFocusFrame = 3; michael@0: michael@0: /* Justification Enums */ michael@0: const long kJustLeft = 0; michael@0: const long kJustCenter = 1; michael@0: const long kJustRight = 2; michael@0: michael@0: /** michael@0: * FrameSet Default Type Constants michael@0: */ michael@0: const short kUseInternalDefault = 0; michael@0: const short kUseSettingWhenPossible = 1; michael@0: michael@0: /** michael@0: * Page Size Type Constants michael@0: */ michael@0: const short kPaperSizeNativeData = 0; michael@0: const short kPaperSizeDefined = 1; michael@0: michael@0: /** michael@0: * Page Size Unit Constants michael@0: */ michael@0: const short kPaperSizeInches = 0; michael@0: const short kPaperSizeMillimeters = 1; michael@0: michael@0: /** michael@0: * Orientation Constants michael@0: */ michael@0: const short kPortraitOrientation = 0; michael@0: const short kLandscapeOrientation = 1; michael@0: michael@0: /** michael@0: * Print Frame Constants michael@0: */ michael@0: const short kNoFrames = 0; michael@0: const short kFramesAsIs = 1; michael@0: const short kSelectedFrame = 2; michael@0: const short kEachFrameSep = 3; michael@0: michael@0: /** michael@0: * How to Enable Frame Set Printing Constants michael@0: */ michael@0: const short kFrameEnableNone = 0; michael@0: const short kFrameEnableAll = 1; michael@0: const short kFrameEnableAsIsAndEach = 2; michael@0: michael@0: /** michael@0: * Output file format michael@0: */ michael@0: const short kOutputFormatNative = 0; michael@0: const short kOutputFormatPS = 1; michael@0: const short kOutputFormatPDF = 2; michael@0: michael@0: /** michael@0: * Set PrintOptions michael@0: */ michael@0: void SetPrintOptions(in int32_t aType, in boolean aTurnOnOff); michael@0: michael@0: /** michael@0: * Get PrintOptions michael@0: */ michael@0: boolean GetPrintOptions(in int32_t aType); michael@0: michael@0: /** michael@0: * Set PrintOptions Bit field michael@0: */ michael@0: int32_t GetPrintOptionsBits(); michael@0: michael@0: /** michael@0: * Get the page size in twips, considering the michael@0: * orientation (portrait or landscape). michael@0: */ michael@0: void GetEffectivePageSize(out double aWidth, out double aHeight); michael@0: michael@0: /** michael@0: * Makes a new copy michael@0: */ michael@0: nsIPrintSettings clone(); michael@0: michael@0: /** michael@0: * Assigns the internal values from the "in" arg to the current object michael@0: */ michael@0: void assign(in nsIPrintSettings aPS); michael@0: michael@0: /** michael@0: * Data Members michael@0: */ michael@0: [noscript] attribute nsIPrintSession printSession; /* We hold a weak reference */ michael@0: michael@0: attribute long startPageRange; michael@0: attribute long endPageRange; michael@0: michael@0: /** michael@0: * The edge measurements define the positioning of the headers michael@0: * and footers on the page. They're measured as an offset from michael@0: * the "unwriteable margin" (described below). michael@0: */ michael@0: attribute double edgeTop; /* these are in inches */ michael@0: attribute double edgeLeft; michael@0: attribute double edgeBottom; michael@0: attribute double edgeRight; michael@0: michael@0: /** michael@0: * The margins define the positioning of the content on the page. michael@0: * They're treated as an offset from the "unwriteable margin" michael@0: * (described below). michael@0: */ michael@0: attribute double marginTop; /* these are in inches */ michael@0: attribute double marginLeft; michael@0: attribute double marginBottom; michael@0: attribute double marginRight; michael@0: /** michael@0: * The unwriteable margin defines the printable region of the paper, creating michael@0: * an invisible border from which the edge and margin attributes are measured. michael@0: */ michael@0: attribute double unwriteableMarginTop; /* these are in inches */ michael@0: attribute double unwriteableMarginLeft; michael@0: attribute double unwriteableMarginBottom; michael@0: attribute double unwriteableMarginRight; michael@0: michael@0: attribute double scaling; /* values 0.0 - 1.0 */ michael@0: attribute boolean printBGColors; /* Print Background Colors */ michael@0: attribute boolean printBGImages; /* Print Background Images */ michael@0: michael@0: attribute short printRange; michael@0: michael@0: attribute wstring title; michael@0: attribute wstring docURL; michael@0: michael@0: attribute wstring headerStrLeft; michael@0: attribute wstring headerStrCenter; michael@0: attribute wstring headerStrRight; michael@0: michael@0: attribute wstring footerStrLeft; michael@0: attribute wstring footerStrCenter; michael@0: attribute wstring footerStrRight; michael@0: michael@0: attribute short howToEnableFrameUI; /* indicates how to enable the frameset UI */ michael@0: attribute boolean isCancelled; /* indicates whether the print job has been cancelled */ michael@0: attribute short printFrameTypeUsage; /* indicates whether to use the interal value or not */ michael@0: attribute short printFrameType; michael@0: attribute boolean printSilent; /* print without putting up the dialog */ michael@0: attribute boolean shrinkToFit; /* shrinks content to fit on page */ michael@0: attribute boolean showPrintProgress; /* indicates whether the progress dialog should be shown */ michael@0: michael@0: /* Additional XP Related */ michael@0: attribute wstring paperName; /* name of paper */ michael@0: attribute short paperSizeType; /* use native data or is defined here */ michael@0: attribute short paperData; /* native data value */ michael@0: attribute double paperWidth; /* width of the paper in inches or mm */ michael@0: attribute double paperHeight; /* height of the paper in inches or mm */ michael@0: attribute short paperSizeUnit; /* paper is in inches or mm */ michael@0: michael@0: attribute wstring plexName; /* name of plex mode (like "simplex", "duplex", michael@0: * "tumble" and various custom values) */ michael@0: michael@0: attribute wstring colorspace; /* device-specific name of colorspace, overrides |printInColor| */ michael@0: attribute wstring resolutionName;/* device-specific identifer of resolution or quality michael@0: * (like "600", "600x300", "600x300x12", "high-res", michael@0: * "med-res". "low-res", etc.) */ michael@0: attribute boolean downloadFonts; /* enable font download to printer? */ michael@0: michael@0: attribute boolean printReversed; michael@0: attribute boolean printInColor; /* a false means grayscale */ michael@0: attribute long orientation; /* see orientation consts */ michael@0: attribute wstring printCommand; michael@0: attribute long numCopies; michael@0: michael@0: attribute wstring printerName; /* name of destination printer */ michael@0: michael@0: attribute boolean printToFile; michael@0: attribute wstring toFileName; michael@0: attribute short outputFormat; michael@0: michael@0: attribute long printPageDelay; /* in milliseconds */ michael@0: michael@0: attribute long resolution; /* print resolution (dpi) */ michael@0: michael@0: attribute long duplex; /* duplex mode */ michael@0: michael@0: /* initialize helpers */ michael@0: /** michael@0: * This attribute tracks whether the PS has been initialized michael@0: * from a printer specified by the "printerName" attr. michael@0: * If a different name is set into the "printerName" michael@0: * attribute than the one it was initialized with the PS michael@0: * will then get intialized from that printer. michael@0: */ michael@0: attribute boolean isInitializedFromPrinter; michael@0: michael@0: /** michael@0: * This attribute tracks whether the PS has been initialized michael@0: * from prefs. If a different name is set into the "printerName" michael@0: * attribute than the one it was initialized with the PS michael@0: * will then get intialized from prefs again. michael@0: */ michael@0: attribute boolean isInitializedFromPrefs; michael@0: michael@0: /** michael@0: * This attribute tracks if the settings made on the margin box is michael@0: * stored in the prefs or not. michael@0: */ michael@0: attribute boolean persistMarginBoxSettings; michael@0: michael@0: /* C++ Helper Functions */ michael@0: [noscript] void SetMarginInTwips(in nsNativeIntMarginRef aMargin); michael@0: [noscript] void SetEdgeInTwips(in nsNativeIntMarginRef aEdge); michael@0: /* Purposely made this an "in" arg */ michael@0: [noscript] void GetMarginInTwips(in nsNativeIntMarginRef aMargin); michael@0: [noscript] void GetEdgeInTwips(in nsNativeIntMarginRef aEdge); michael@0: michael@0: /** michael@0: * We call this function so that anything that requires a run of the event loop michael@0: * can do so safely. The print dialog runs the event loop but in silent printing michael@0: * that doesn't happen. michael@0: * michael@0: * Either this or ShowPrintDialog (but not both) MUST be called by the print engine michael@0: * before printing, otherwise printing can fail on some platforms. michael@0: */ michael@0: [noscript] void SetupSilentPrinting(); michael@0: michael@0: /** michael@0: * Sets/Gets the "unwriteable margin" for the page format. This defines michael@0: * the boundary from which we'll measure the EdgeInTwips and MarginInTwips michael@0: * attributes, to place the headers and content, respectively. michael@0: * michael@0: * Note: Implementations of SetUnwriteableMarginInTwips should handle michael@0: * negative margin values by falling back on the system default for michael@0: * that margin. michael@0: */ michael@0: [noscript] void SetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge); michael@0: [noscript] void GetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge); michael@0: michael@0: /** michael@0: * Get more accurate print ranges from the superior interval michael@0: * (startPageRange, endPageRange). The aPages array is populated with a michael@0: * list of pairs (start, end), where the endpoints are included. The print michael@0: * ranges (start, end), must not overlap and must be in the michael@0: * (startPageRange, endPageRange) scope. michael@0: * michael@0: * If there are no print ranges the aPages array is cleared. michael@0: */ michael@0: [noscript] void GetPageRanges(in IntegerArray aPages); michael@0: };