зеркало из https://github.com/mozilla/pjs.git
1) Removes most all the unneeded data from nsPrintOptions service. All data
should be in the PrintSettings. 2) Removed unneeded methods from PrintOptions 3) PrintOption can now read and write (most) all the data in a PrintSettings object. The items not saved are those used during the printing process and it wouldn't make any sense to save them. 4) Adds a prefs for turning on and off the automatic saving of PrintSettings. If this is turned on it is almost the same as using the global PS. 5) On Linux it turns on the saving of PS prefs and turns on the global PS. Meaning it will always use a single Global PS object. 6) The PrintSettings can be initialized from a generic non-printer specific set of prefs. Then if a printer name is available in the PS then it tries to initialize itself from the printer specific prefs. This enables to define "back stop" prefs for picking up first. Then the printer specific prefs can override those settings. For example, we may define in prefs that the default paper size 8.5x11, then if if the "save PS prefs" is turned on, for a given printer it might save 8.5x16 as the size. 7) A "flags" arg has been added so you can indicate which prefs you want read or written.
This commit is contained in:
Родитель
72a0a83f30
Коммит
237d6ca34c
|
@ -62,100 +62,11 @@ interface nsISimpleEnumerator;
|
|||
|
||||
interface nsIPrintOptions : nsISupports
|
||||
{
|
||||
/* Print Option Flags for Bit Field*/
|
||||
const long kOptPrintOddPages = 0x00000001;
|
||||
const long kOptPrintEvenPages = 0x00000002;
|
||||
const long kPrintOptionsEnableSelectionRB = 0x00000004;
|
||||
|
||||
/* Print Range Enums */
|
||||
const long kRangeAllPages = 0;
|
||||
const long kRangeSpecifiedPageRange = 1;
|
||||
const long kRangeSelection = 2;
|
||||
const long kRangeFocusFrame = 3;
|
||||
|
||||
/* Justification Enums */
|
||||
const long kJustLeft = 0;
|
||||
const long kJustCenter = 1;
|
||||
const long kJustRight = 2;
|
||||
|
||||
/**
|
||||
* Page Size Constants (NOTE: These have been deprecated!);
|
||||
*/
|
||||
const short kLetterPaperSize = 0;
|
||||
const short kLegalPaperSize = 1;
|
||||
const short kExecutivePaperSize = 2;
|
||||
const short kA4PaperSize = 3;
|
||||
const short kA3PaperSize = 4;
|
||||
|
||||
/**
|
||||
* FrameSet Default Type Constants
|
||||
*/
|
||||
const short kUseInternalDefault = 0;
|
||||
const short kUseSettingWhenPossible = 1;
|
||||
|
||||
/**
|
||||
* Page Size Type Constants
|
||||
*/
|
||||
const short kPaperSizeNativeData = 0;
|
||||
const short kPaperSizeDefined = 1;
|
||||
|
||||
/**
|
||||
* Page Size Unit Constants
|
||||
*/
|
||||
const short kPaperSizeInches = 0;
|
||||
const short kPaperSizeMillimeters = 1;
|
||||
|
||||
/**
|
||||
* Orientation Constants
|
||||
*/
|
||||
const short kPortraitOrientation = 0;
|
||||
const short kLandscapeOrientation = 1;
|
||||
|
||||
/**
|
||||
* Print Frame Constants
|
||||
*/
|
||||
const short kNoFrames = 0;
|
||||
const short kFramesAsIs = 1;
|
||||
const short kSelectedFrame = 2;
|
||||
const short kEachFrameSep = 3;
|
||||
|
||||
/**
|
||||
* How to Enable Frame Set Printing Constants
|
||||
*/
|
||||
const short kFrameEnableNone = 0;
|
||||
const short kFrameEnableAll = 1;
|
||||
const short kFrameEnableAsIsAndEach = 2;
|
||||
|
||||
/**
|
||||
* Show Native Print Options dialog, this may not be supported on all platforms
|
||||
*/
|
||||
void ShowPrintSetupDialog(in nsIPrintSettings aThePrintSettings);
|
||||
|
||||
/**
|
||||
* Set PrintOptions
|
||||
*/
|
||||
void SetPrintOptions(in PRInt32 aType, in PRBool aTurnOnOff);
|
||||
|
||||
/**
|
||||
* Get PrintOptions
|
||||
*/
|
||||
PRBool GetPrintOptions(in PRInt32 aType);
|
||||
|
||||
/**
|
||||
* Set PrintOptions Bit field
|
||||
*/
|
||||
PRInt32 GetPrintOptionsBits();
|
||||
|
||||
/**
|
||||
* Read Prefs
|
||||
*/
|
||||
void ReadPrefs();
|
||||
|
||||
/**
|
||||
* Write Prefs
|
||||
*/
|
||||
void WritePrefs();
|
||||
|
||||
/**
|
||||
* Creates a new PrintSettnigs Object
|
||||
* and initializes it from prefs
|
||||
|
@ -171,79 +82,20 @@ interface nsIPrintOptions : nsISupports
|
|||
|
||||
/**
|
||||
* Initialize the values in the PrintSettings from Prefs
|
||||
* aPS - PrintSettings to have its settings read
|
||||
* aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix
|
||||
*/
|
||||
void InitPrintSettingsFromPrefs(in nsIPrintSettings aPO);
|
||||
void initPrintSettingsFromPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags);
|
||||
|
||||
/**
|
||||
* Data Members
|
||||
* Save all the PrintSettings to Prefs.
|
||||
* This is on a printer by printer basis
|
||||
* Or saved generically if the printer name is null or empty
|
||||
*
|
||||
* aPS - PrintSettings to have its settings saved
|
||||
* aUsePrinterNamePrefix - indicates whether to use the printer name as a prefix
|
||||
*/
|
||||
attribute long startPageRange;
|
||||
attribute long endPageRange;
|
||||
|
||||
attribute double marginTop; /* these are in inches */
|
||||
attribute double marginLeft;
|
||||
attribute double marginBottom;
|
||||
attribute double marginRight;
|
||||
|
||||
attribute double scaling; /* values 0.0 - 1.0 */
|
||||
attribute boolean printBGColors; /* Print Background Colors */
|
||||
attribute boolean printBGImages; /* Print Background Images */
|
||||
|
||||
attribute short printRange;
|
||||
|
||||
attribute wstring title;
|
||||
attribute wstring docURL;
|
||||
|
||||
attribute wstring headerStrLeft;
|
||||
attribute wstring headerStrCenter;
|
||||
attribute wstring headerStrRight;
|
||||
|
||||
attribute wstring footerStrLeft;
|
||||
attribute wstring footerStrCenter;
|
||||
attribute wstring footerStrRight;
|
||||
|
||||
attribute short howToEnableFrameUI;
|
||||
attribute boolean isCancelled;
|
||||
attribute short printFrameTypeUsage; /* indicates whether to use the interal value or not*/
|
||||
attribute short printFrameType;
|
||||
attribute boolean printSilent; /* print without putting up the dialog */
|
||||
|
||||
attribute nsIPrintSettings printSettingsValues; /* used copy the values to/from the settings obj*/
|
||||
attribute nsIPrintSettings printSettings; /* used to set and get the current object */
|
||||
|
||||
/* Additional XP Related */
|
||||
attribute short paperSizeType; /* use native data or is defined here */
|
||||
attribute short paperData; /* native data value */
|
||||
attribute double paperWidth; /* width of the paper in inches or mm */
|
||||
attribute double paperHeight; /* height of the paper in inches or mm */
|
||||
attribute short paperSizeUnit; /* paper is in inches or mm */
|
||||
|
||||
attribute long paperSize; /* This has been deprecated */
|
||||
|
||||
attribute boolean printReversed;
|
||||
attribute boolean printInColor; /* a false means grayscale */
|
||||
attribute long orientation; /* see orientation consts */
|
||||
attribute wstring printCommand;
|
||||
attribute long numCopies;
|
||||
attribute wstring printerName;
|
||||
attribute boolean printToFile;
|
||||
attribute wstring toFileName;
|
||||
|
||||
attribute long printPageDelay; /* in milliseconds */
|
||||
|
||||
/* No Script Methods */
|
||||
|
||||
[noscript] void SetFontNamePointSize(in nsNativeStringRef aName, in PRInt32 aPointSize);
|
||||
|
||||
[noscript] void SetMarginInTwips(in nsNativeMarginRef aMargin);
|
||||
/* Purposely made this an "in" arg */
|
||||
[noscript] void GetMarginInTwips(in nsNativeMarginRef aMargin);
|
||||
|
||||
[noscript] void SetDefaultFont(in nsNativeFontRef aMargin);
|
||||
/* Purposely made this an "in" arg */
|
||||
[noscript] void GetDefaultFont(in nsNativeFontRef aMargin);
|
||||
|
||||
[noscript] void GetPageSizeInTwips(out long aWidth, out long aHeight);
|
||||
void savePrintSettingsToPrefs(in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags);
|
||||
|
||||
/**
|
||||
* available Printers
|
||||
|
@ -255,6 +107,22 @@ interface nsIPrintOptions : nsISupports
|
|||
*/
|
||||
void displayJobProperties (in wstring aPrinter, in nsIPrintSettings aPrintSettings, out boolean aDisplayed);
|
||||
|
||||
// Attributes
|
||||
attribute boolean isCancelled;
|
||||
|
||||
attribute wstring title;
|
||||
attribute wstring docURL;
|
||||
|
||||
attribute boolean printToFile;
|
||||
attribute wstring toFileName;
|
||||
|
||||
// no script methods
|
||||
[noscript] void SetFontNamePointSize(in nsNativeStringRef aName, in PRInt32 aPointSize);
|
||||
|
||||
[noscript] void SetDefaultFont(in nsNativeFontRef aFont);
|
||||
/* Purposely made this an "in" arg */
|
||||
[noscript] void GetDefaultFont(in nsNativeFontRef aFont);
|
||||
|
||||
/**
|
||||
* Native data constants
|
||||
*/
|
||||
|
|
|
@ -59,6 +59,36 @@
|
|||
|
||||
interface nsIPrintSettings : nsISupports
|
||||
{
|
||||
/**
|
||||
* PrintSettings to be Saved Navigation Constants
|
||||
*/
|
||||
const unsigned long kInitSaveOddEvenPages = 0x00000001;
|
||||
const unsigned long kInitSaveHeaderLeft = 0x00000002;
|
||||
const unsigned long kInitSaveHeaderCenter = 0x00000004;
|
||||
const unsigned long kInitSaveHeaderRight = 0x00000008;
|
||||
const unsigned long kInitSaveFooterLeft = 0x00000010;
|
||||
const unsigned long kInitSaveFooterCenter = 0x00000020;
|
||||
const unsigned long kInitSaveFooterRight = 0x00000040;
|
||||
const unsigned long kInitSaveBGColors = 0x00000080;
|
||||
const unsigned long kInitSaveBGImages = 0x00000100;
|
||||
const unsigned long kInitSavePaperSize = 0x00000200;
|
||||
const unsigned long kInitSavePaperName = 0x00000400;
|
||||
const unsigned long kInitSavePaperSizeUnit = 0x00000800;
|
||||
const unsigned long kInitSavePaperSizeType = 0x00001000;
|
||||
const unsigned long kInitSavePaperData = 0x00002000;
|
||||
const unsigned long kInitSavePaperWidth = 0x00004000;
|
||||
const unsigned long kInitSavePaperHeight = 0x00008000;
|
||||
|
||||
const unsigned long kInitSaveReversed = 0x00010000;
|
||||
const unsigned long kInitSaveInColor = 0x00020000;
|
||||
const unsigned long kInitSaveOrientation = 0x00040000;
|
||||
const unsigned long kInitSavePrintCommand = 0x00080000;
|
||||
const unsigned long kInitSavePrinterName = 0x00100000;
|
||||
const unsigned long kInitSavePrintToFile = 0x00200000;
|
||||
const unsigned long kInitSaveToFileName = 0x00400000;
|
||||
const unsigned long kInitSavePageDelay = 0x00800000;
|
||||
const unsigned long kInitSaveMargins = 0x01000000;
|
||||
const unsigned long kInitSaveAll = 0xFFFFFFFF;
|
||||
|
||||
/* Print Option Flags for Bit Field*/
|
||||
const long kPrintOddPages = 0x00000001;
|
||||
|
@ -171,6 +201,7 @@ interface nsIPrintSettings : nsISupports
|
|||
attribute boolean shrinkToFit; /* shrinks content to fit on page */
|
||||
|
||||
/* Additional XP Related */
|
||||
attribute wstring paperName; /* name of paper */
|
||||
attribute short paperSizeType; /* use native data or is defined here */
|
||||
attribute short paperData; /* native data value */
|
||||
attribute double paperWidth; /* width of the paper in inches or mm */
|
||||
|
|
|
@ -1528,7 +1528,8 @@ nsDeviceContextSpecWin::GetDataFromPrinter(const PRUnichar * aName, nsIPrintSett
|
|||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (!GlobalPrinters::GetInstance()->PrintersAreAllocated()) {
|
||||
return rv;
|
||||
rv = GlobalPrinters::GetInstance()->EnumeratePrinterList();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
HANDLE hPrinter = NULL;
|
||||
|
@ -1794,7 +1795,7 @@ nsPrinterEnumeratorWin::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult
|
|||
PRInt32 count = 0;
|
||||
PRInt32 printerInx = 0;
|
||||
while( count < numItems ) {
|
||||
LPTSTR name = GlobalPrinters::GetInstance()->GetItemFromList(printerInx);
|
||||
LPTSTR name = GlobalPrinters::GetInstance()->GetItemFromList(printerInx++);
|
||||
nsString newName;
|
||||
newName.AssignWithConversion(name);
|
||||
PRUnichar *str = ToNewUnicode(newName);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -50,62 +50,26 @@ protected:
|
|||
|
||||
nsresult ReadPrefString(nsIPref * aPref, const char * aPrefId, nsString& aString);
|
||||
nsresult WritePrefString(nsIPref * aPref, const char * aPrefId, nsString& aString);
|
||||
nsresult WritePrefString(nsIPref* aPref, PRUnichar*& aStr, const char* aPrefId);
|
||||
nsresult ReadPrefDouble(nsIPref * aPref, const char * aPrefId, double& aVal);
|
||||
nsresult WritePrefDouble(nsIPref * aPref, const char * aPrefId, double aVal);
|
||||
|
||||
typedef enum {
|
||||
eHeader,
|
||||
eFooter
|
||||
} nsHeaderFooterEnum;
|
||||
|
||||
nsresult GetMarginStrs(PRUnichar * *aTitle, nsHeaderFooterEnum aType, PRInt16 aJust);
|
||||
nsresult SetMarginStrs(const PRUnichar * aTitle, nsHeaderFooterEnum aType, PRInt16 aJust);
|
||||
nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
const char* GetPrefName(const char * aPrefName,
|
||||
const nsString& aPrinterName);
|
||||
|
||||
// Members
|
||||
nsMargin mMargin;
|
||||
PRInt32 mPrintOptions;
|
||||
|
||||
// scriptable data members
|
||||
PRInt16 mPrintRange;
|
||||
PRInt32 mStartPageNum; // only used for ePrintRange_SpecifiedRange
|
||||
PRInt32 mEndPageNum;
|
||||
double mScaling;
|
||||
PRBool mPrintBGColors; // print background colors
|
||||
PRBool mPrintBGImages; // print background images
|
||||
|
||||
PRInt16 mPrintFrameTypeUsage;
|
||||
PRInt16 mPrintFrameType;
|
||||
PRBool mHowToEnableFrameUI;
|
||||
PRBool mIsCancelled;
|
||||
PRBool mPrintSilent;
|
||||
PRInt32 mPrintPageDelay;
|
||||
|
||||
nsString mTitle;
|
||||
nsString mURL;
|
||||
nsString mPageNumberFormat;
|
||||
nsString mHeaderStrs[3];
|
||||
nsString mFooterStrs[3];
|
||||
|
||||
nsIPrintSettings* mPrintSettingsObj; //weak ref, hold address only
|
||||
|
||||
PRInt16 mPaperData;
|
||||
PRInt16 mPaperSizeType;
|
||||
double mPaperWidth;
|
||||
double mPaperHeight;
|
||||
PRInt16 mPaperSizeUnit;
|
||||
|
||||
PRInt32 mPaperSize; // this has been deprecated
|
||||
PRBool mPrintReversed;
|
||||
PRBool mPrintInColor; // a false means grayscale
|
||||
PRInt32 mOrientation; // see orientation consts
|
||||
nsString mPrintCommand;
|
||||
PRInt32 mNumCopies;
|
||||
nsString mPrinter;
|
||||
PRBool mPrintToFile;
|
||||
nsString mToFileName;
|
||||
|
||||
nsCOMPtr<nsIPrintSettings> mGlobalPrintSettings;
|
||||
|
||||
nsCString mPrefName;
|
||||
|
||||
static nsFont* sDefaultFont;
|
||||
};
|
||||
|
||||
|
|
|
@ -48,30 +48,30 @@ NS_IMPL_ISUPPORTS1(nsPrintSettings, nsIPrintSettings)
|
|||
* @update 6/21/00 dwc
|
||||
*/
|
||||
nsPrintSettings::nsPrintSettings() :
|
||||
mPrintOptions(0L),
|
||||
mPrintRange(kRangeAllPages),
|
||||
mStartPageNum(1),
|
||||
mEndPageNum(1),
|
||||
mScaling(1.0),
|
||||
mNumCopies(1),
|
||||
mPrintBGColors(PR_FALSE),
|
||||
mPrintBGImages(PR_FALSE),
|
||||
mPrintOptions(0L),
|
||||
mPrintReversed(PR_FALSE),
|
||||
mPrintInColor(PR_TRUE),
|
||||
mOrientation(kPortraitOrientation),
|
||||
mPrintToFile(PR_FALSE),
|
||||
mPrintFrameTypeUsage(kUseInternalDefault),
|
||||
mPrintFrameType(kFramesAsIs),
|
||||
mHowToEnableFrameUI(kFrameEnableNone),
|
||||
mIsCancelled(PR_FALSE),
|
||||
mPrintSilent(PR_FALSE),
|
||||
mShrinkToFit(PR_FALSE),
|
||||
mPrintPageDelay(500),
|
||||
mPaperSizeType(kPaperSizeDefined),
|
||||
mPaperData(0),
|
||||
mPaperSizeType(kPaperSizeDefined),
|
||||
mPaperWidth(8.5),
|
||||
mPaperHeight(11.0),
|
||||
mPaperSizeUnit(kPaperSizeInches),
|
||||
mPrintSilent(PR_FALSE),
|
||||
mShrinkToFit(PR_FALSE),
|
||||
mHowToEnableFrameUI(kFrameEnableNone),
|
||||
mIsCancelled(PR_FALSE)
|
||||
mPrintReversed(PR_FALSE),
|
||||
mPrintInColor(PR_TRUE),
|
||||
mOrientation(kPortraitOrientation),
|
||||
mNumCopies(1),
|
||||
mPrintToFile(PR_FALSE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
|
@ -591,6 +591,24 @@ NS_IMETHODIMP nsPrintSettings::SetShrinkToFit(PRBool aShrinkToFit)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute wstring paperName; */
|
||||
NS_IMETHODIMP nsPrintSettings::GetPaperName(PRUnichar * *aPaperName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPaperName);
|
||||
if (mPaperName.Length()) {
|
||||
*aPaperName = ToNewUnicode(mPaperName);
|
||||
} else {
|
||||
*aPaperName = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetPaperName(const PRUnichar * aPaperName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPaperName);
|
||||
mPaperName = aPaperName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute boolean howToEnableFrameUI; */
|
||||
NS_IMETHODIMP nsPrintSettings::GetHowToEnableFrameUI(PRInt16 *aHowToEnableFrameUI)
|
||||
{
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "nsMargin.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIPrintSettings;
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsPrintSettings
|
||||
//*****************************************************************************
|
||||
|
@ -76,6 +74,7 @@ protected:
|
|||
nsString mHeaderStrs[3];
|
||||
nsString mFooterStrs[3];
|
||||
|
||||
nsString mPaperName;
|
||||
PRInt16 mPaperData;
|
||||
PRInt16 mPaperSizeType;
|
||||
double mPaperWidth;
|
||||
|
|
Загрузка…
Ссылка в новой задаче