From 78a059bcddceff5ecfeeeeb394fd92138eea7412 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Sat, 3 Nov 2001 13:00:40 +0000 Subject: [PATCH] Fixed up nsIPrintSettings interface and add a Get/Set method to nsIPrintOptions (only the setter is implemented at this time) Bug 107399 r=kmcclusk sr=alexf/attinasi --- gfx/idl/MANIFEST_IDL | 1 + gfx/idl/Makefile.in | 1 + gfx/idl/makefile.win | 1 + gfx/idl/nsIPrintOptions.idl | 3 +- gfx/idl/nsIPrintSettings.idl | 77 ++++++++++++----------------- gfx/src/nsPrintOptionsImpl.cpp | 89 ++++++++++++++++++++++++++++++++++ gfx/src/nsPrintOptionsImpl.h | 1 + 7 files changed, 127 insertions(+), 46 deletions(-) diff --git a/gfx/idl/MANIFEST_IDL b/gfx/idl/MANIFEST_IDL index c92ec05a2d5c..a1c020de4618 100644 --- a/gfx/idl/MANIFEST_IDL +++ b/gfx/idl/MANIFEST_IDL @@ -8,3 +8,4 @@ nsIScriptableRegion.idl nsIScreen.idl nsIScreenManager.idl nsIPrintOptions.idl +nsIPrintSettings.idl diff --git a/gfx/idl/Makefile.in b/gfx/idl/Makefile.in index a011a88c0f01..a0f70a4d6443 100644 --- a/gfx/idl/Makefile.in +++ b/gfx/idl/Makefile.in @@ -37,6 +37,7 @@ XPIDLSRCS = \ nsIScreen.idl \ nsIScreenManager.idl \ nsIPrintOptions.idl \ + nsIPrintSettings.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/gfx/idl/makefile.win b/gfx/idl/makefile.win index d09b0251b890..9e8f44030d47 100644 --- a/gfx/idl/makefile.win +++ b/gfx/idl/makefile.win @@ -32,6 +32,7 @@ XPIDLSRCS = \ .\nsIScreen.idl \ .\nsIScreenManager.idl \ .\nsIPrintOptions.idl \ + .\nsIPrintSettings.idl \ $(NULL) EXPORTS= \ diff --git a/gfx/idl/nsIPrintOptions.idl b/gfx/idl/nsIPrintOptions.idl index 2e535143ad83..8d71e1672ae3 100644 --- a/gfx/idl/nsIPrintOptions.idl +++ b/gfx/idl/nsIPrintOptions.idl @@ -38,6 +38,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsISupports.idl" +#include "nsIPrintSettings.idl" %{ C++ #include "nsMargin.h" @@ -133,7 +134,6 @@ interface nsIPrintOptions : nsISupports */ void WritePrefs(); - /** * Data Members */ @@ -163,6 +163,7 @@ interface nsIPrintOptions : nsISupports attribute boolean isCancelled; attribute boolean PrintSilent; /* print without putting up the dialog */ + attribute nsIPrintSettings printSettings; /* Additional XP Related */ attribute boolean printReversed; diff --git a/gfx/idl/nsIPrintSettings.idl b/gfx/idl/nsIPrintSettings.idl index 769e0067c979..12957607af6e 100644 --- a/gfx/idl/nsIPrintSettings.idl +++ b/gfx/idl/nsIPrintSettings.idl @@ -39,18 +39,6 @@ #include "nsISupports.idl" -%{ C++ -#include "nsMargin.h" -#include "nsFont.h" -%} - -/** - * Native types - */ - [ref] native nsNativeMarginRef(nsMargin); - [ref] native nsNativeFontRef(nsFont); - [ref] native nsNativeStringRef(nsString); - /** * Simplified graphics interface for JS rendering. * @@ -63,14 +51,9 @@ interface nsIPrintSettings : nsISupports { /* Print Option Flags for Bit Field*/ - const long kOptPrintOddPages = 0x00000001; - const long kOptPrintEvenPages = 0x00000002; - const long kOptPrintDocTitle = 0x00000004; - const long kOptPrintDocLoc = 0x00000008; - const long kOptPrintPageNums = 0x00000010; - const long kOptPrintPageTotal = 0x00000020; - const long kOptPrintDatePrinted = 0x00000040; - const long kPrintOptionsEnableSelectionRB = 0x00000080; + const long kOptPrintOddPages = 0x00000001; + const long kOptPrintEvenPages = 0x00000002; + const long kPrintOptionsEnableSelectionRB = 0x00000004; /* Print Range Enums */ const long kRangeAllPages = 0; @@ -92,13 +75,19 @@ interface nsIPrintSettings : nsISupports const short kA4PaperSize = 3; const short kA3PaperSize = 4; + /** + * Orientation Constants + */ + const short kPortraitOrientation = 0; + const short kLandscapeOrientation = 1; + /** * Print Frame Constants */ - const short kFramesAsIs = 0; - const short kSelectedFrame = 1; - const short kEachFrameSep = 2; - + const short kNoFrames = 0; + const short kFramesAsIs = 1; + const short kSelectedFrame = 2; + const short kEachFrameSep = 3; /** * Set PrintOptions @@ -115,44 +104,42 @@ interface nsIPrintSettings : nsISupports */ PRInt32 GetPrintOptionsBits(); - /** * Data Members */ attribute long startPageRange; attribute long endPageRange; - attribute boolean printReversed; - attribute boolean printInColor; /* a false means grayscale */ - attribute long paperSize; /* see page size consts */ - attribute wstring printCommand; - attribute boolean printToFile; - attribute wstring toFileName; - attribute double marginTop; /* these are in inches */ attribute double marginLeft; attribute double marginBottom; attribute double marginRight; - attribute long printRange; - attribute long pageNumJust; + attribute short printRange; + attribute wstring title; attribute wstring docURL; - attribute boolean isPrintFrame; - attribute long printFrameType; + attribute wstring headerStrLeft; + attribute wstring headerStrCenter; + attribute wstring headerStrRight; - /* No Script Methods */ + attribute wstring footerStrLeft; + attribute wstring footerStrCenter; + attribute wstring footerStrRight; - [noscript] void SetFontNamePointSize(in nsNativeStringRef aName, in PRInt32 aPointSize); + attribute short printFrameType; + attribute boolean PrintSilent; /* print without putting up the dialog */ - [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); + /* Additional XP Related */ + attribute boolean printReversed; + attribute boolean printInColor; /* a false means grayscale */ + attribute long paperSize; /* see page size consts */ + attribute long orientation; /* see orientation consts */ + attribute wstring printCommand; + attribute boolean printToFile; + attribute wstring toFileName; + attribute long printPageDelay; /* in milliseconds */ }; diff --git a/gfx/src/nsPrintOptionsImpl.cpp b/gfx/src/nsPrintOptionsImpl.cpp index 107b119f0f9a..c0a085363713 100644 --- a/gfx/src/nsPrintOptionsImpl.cpp +++ b/gfx/src/nsPrintOptionsImpl.cpp @@ -723,6 +723,95 @@ NS_IMETHODIMP nsPrintOptions::GetNativeData(PRInt16 aDataType, void * *_retval) return NS_ERROR_NOT_IMPLEMENTED; } +/* attribute nsIPrintSettings printSettings; */ +NS_IMETHODIMP nsPrintOptions::GetPrintSettings(nsIPrintSettings * *aPrintSettings) +{ + NS_ENSURE_ARG_POINTER(aPrintSettings); + *aPrintSettings = nsnull; + + /* This may need to be implemented in the future */ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP nsPrintOptions::SetPrintSettings(nsIPrintSettings * aPrintSettings) +{ + + NS_ENSURE_ARG_POINTER(aPrintSettings); + + aPrintSettings->GetStartPageRange(&mStartPageNum); + aPrintSettings->GetEndPageRange(&mEndPageNum); + + double dblVal; + aPrintSettings->GetMarginTop(&dblVal); + SetMarginTop(dblVal); + + aPrintSettings->GetMarginLeft(&dblVal); + SetMarginLeft(dblVal); + + aPrintSettings->GetMarginBottom(&dblVal); + SetMarginBottom(dblVal); + + aPrintSettings->GetMarginRight(&dblVal); + SetMarginRight(dblVal); + + aPrintSettings->GetPrintRange(&mPrintRange); + + PRUnichar* uniChar; + aPrintSettings->GetTitle(&uniChar); + SetTitle(uniChar); + if (uniChar != nsnull) nsMemory::Free(uniChar); + + aPrintSettings->GetDocURL(&uniChar); + SetDocURL(uniChar); + if (uniChar != nsnull) nsMemory::Free(uniChar); + + aPrintSettings->GetHeaderStrLeft(&uniChar); + SetHeaderStrLeft(uniChar); + if (uniChar != nsnull) nsMemory::Free(uniChar); + + aPrintSettings->GetHeaderStrCenter(&uniChar); + SetHeaderStrCenter(uniChar); + if (uniChar != nsnull) nsMemory::Free(uniChar); + + aPrintSettings->GetHeaderStrRight(&uniChar); + SetHeaderStrRight(uniChar); + if (uniChar != nsnull) nsMemory::Free(uniChar); + + aPrintSettings->GetFooterStrLeft(&uniChar); + SetFooterStrLeft(uniChar); + if (uniChar != nsnull) nsMemory::Free(uniChar); + + aPrintSettings->GetFooterStrCenter(&uniChar); + SetFooterStrCenter(uniChar); + + aPrintSettings->GetFooterStrRight(&uniChar); + SetFooterStrRight(uniChar); + if (uniChar != nsnull) nsMemory::Free(uniChar); + + aPrintSettings->GetPrintFrameType(&mPrintFrameType); + aPrintSettings->GetPrintSilent(&mPrintSilent); + aPrintSettings->GetPrintReversed(&mPrintReversed); + aPrintSettings->GetPrintInColor(&mPrintInColor); + aPrintSettings->GetPaperSize(&mPaperSize); + aPrintSettings->GetOrientation(&mOrientation); + + aPrintSettings->GetPrintCommand(&uniChar); + SetPrintCommand(uniChar); + if (uniChar != nsnull) nsMemory::Free(uniChar); + + aPrintSettings->GetPrintToFile(&mPrintToFile); + + aPrintSettings->GetToFileName(&uniChar); + SetToFileName(uniChar); + if (uniChar != nsnull) nsMemory::Free(uniChar); + + aPrintSettings->GetPrintPageDelay(&mPrintPageDelay); + SetPrintPageDelay(mPrintPageDelay); + + return NS_OK; +} + + //----------------------------------------------------- //-- Protected Methods //----------------------------------------------------- diff --git a/gfx/src/nsPrintOptionsImpl.h b/gfx/src/nsPrintOptionsImpl.h index 77cf6293062b..96ba64486994 100644 --- a/gfx/src/nsPrintOptionsImpl.h +++ b/gfx/src/nsPrintOptionsImpl.h @@ -26,6 +26,7 @@ #include "nsIPrintOptions.h" class nsIPref; +class nsIPrintSettings; //***************************************************************************** //*** nsPrintOptions