From 5b130d03e0a68b2d58701f7910ef482b8d68e3c7 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Fri, 2 Feb 2001 08:42:53 +0000 Subject: [PATCH] Added UI for printing selectd frame Bug 66783 r=kmcclusk,ben,dcone sr=buster git-svn-id: svn://10.0.0.236/trunk@86059 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDocumentViewer.cpp | 17 +- mozilla/gfx/idl/nsIPrintOptions.idl | 178 +++--- mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp | 131 ++-- mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp | 4 +- mozilla/gfx/src/nsPrintOptionsImpl.cpp | 570 ++++++++++++------ mozilla/gfx/src/nsPrintOptionsImpl.h | 32 +- .../windows/nsDeviceContextSpecFactoryW.cpp | 117 +++- mozilla/layout/base/nsDocumentViewer.cpp | 17 +- mozilla/layout/base/src/nsDocumentViewer.cpp | 17 +- mozilla/layout/generic/nsPageFrame.cpp | 32 +- .../layout/generic/nsSimplePageSequence.cpp | 37 +- mozilla/layout/html/base/src/nsPageFrame.cpp | 32 +- .../html/base/src/nsSimplePageSequence.cpp | 37 +- mozilla/widget/src/build/widget.rc | 51 ++ .../resources/content/unix/printdialog.js | 253 +++++--- .../resources/content/unix/printdialog.xul | 8 + .../locale/en-US/unix/printdialog.dtd | 5 + 17 files changed, 940 insertions(+), 598 deletions(-) diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index d6df2625c06..ad94ec7343c 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -1500,12 +1500,10 @@ if (!doesContainFrameSet) { DumpLayoutData(cx, aDContext, rootFrame, aParent); #endif - nsPrintRange printRangeType = ePrintRange_AllPages; NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv); if (NS_SUCCEEDED(rv) && printService) { - PRInt32 printType; - printService->GetPrintRange(&printType); - printRangeType = (nsPrintRange)printType; + PRInt16 printRangeType = nsIPrintOptions::kRangeAllPages; + printService->GetPrintRange(&printRangeType); // get the document title const nsString* docTitle = mDocument->GetDocumentTitle(); @@ -1522,11 +1520,11 @@ if (!doesContainFrameSet) { nsAutoString urlStr; urlStr.AssignWithConversion(urlCStr); PRUnichar * urlUStr = urlStr.ToNewUnicode(); - printService->SetURL(urlUStr); + printService->SetDocURL(urlUStr); nsMemory::Free(urlUStr); nsMemory::Free(urlCStr); - if (ePrintRange_Selection == printRangeType) { + if (nsIPrintOptions::kRangeSelection == printRangeType) { cx->SetIsRenderingOnlySelection(PR_TRUE); // temporarily creating rendering context @@ -1546,7 +1544,8 @@ if (!doesContainFrameSet) { &startFrame, startPageNum, startRect, &endFrame, endPageNum, endRect); if (NS_SUCCEEDED(rv)) { - printService->SetPageRange(startPageNum, endPageNum); + printService->SetStartPageRange(startPageNum); + printService->SetEndPageRange(endPageNum); if (startPageNum == endPageNum) { nsIFrame * seqFrame; if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) { @@ -2285,7 +2284,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi nsresult rv = NS_ERROR_FAILURE; NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv); if (NS_SUCCEEDED(rv) && printService) { - printService->SetPrintOptions(NS_PRINT_OPTIONS_ENABLE_SELECTION_RADIO, IsThereASelection()); + printService->SetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectionRB, IsThereASelection()); } nsComponentManager::CreateInstance(kDeviceContextSpecFactoryCID, @@ -2304,7 +2303,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi mPrintDC = nsnull; mFilePointer = aFile; - factory->CreateDeviceContextSpec(nsnull, devspec, aSilent); + factory->CreateDeviceContextSpec(mWindow, devspec, aSilent); if (nsnull != devspec) { mPresContext->GetDeviceContext(getter_AddRefs(dx)); rv = dx->GetDeviceContextFor(devspec, mPrintDC); diff --git a/mozilla/gfx/idl/nsIPrintOptions.idl b/mozilla/gfx/idl/nsIPrintOptions.idl index cc1bab88ce8..a9ea07105ac 100644 --- a/mozilla/gfx/idl/nsIPrintOptions.idl +++ b/mozilla/gfx/idl/nsIPrintOptions.idl @@ -26,98 +26,63 @@ %{ C++ #include "nsMargin.h" #include "nsFont.h" - - enum nsPrintRange { - ePrintRange_AllPages, // print all pages - ePrintRange_SpecifiedPageRange, // only print pages in the specified range - ePrintRange_Selection, // only print the selection - ePrintRange_FocusFrame // only print the frame with the current focus - }; - - /** - * Print Option Printing state bits. - */ - typedef PRUint32 nsPrintOptionsType; - -#define NS_PRINT_OPTIONS_PRINT_ODD_PAGES 0x00000001 -#define NS_PRINT_OPTIONS_PRINT_EVEN_PAGES 0x00000002 -#define NS_PRINT_OPTIONS_PRINT_DOC_TITLE 0x00000004 -#define NS_PRINT_OPTIONS_PRINT_DOC_LOCATION 0x00000008 -#define NS_PRINT_OPTIONS_PRINT_PAGE_NUMS 0x00000010 -#define NS_PRINT_OPTIONS_PRINT_PAGE_TOTAL 0x00000020 -#define NS_PRINT_OPTIONS_PRINT_DATE_PRINTED 0x00000040 -#define NS_PRINT_OPTIONS_ENABLE_SELECTION_RADIO 0x00000080 - -// There are currently NOT supported -#define NS_PRINT_OPTIONS_PRINT_BEVEL_LINES 0x00000100 -#define NS_PRINT_OPTIONS_PRINT_BLACK_TEXT 0x00000200 -#define NS_PRINT_OPTIONS_PRINT_BLACK_LINES 0x00000400 -#define NS_PRINT_OPTIONS_PRINT_LAST_PAGE_FIRST 0x00000800 -#define NS_PRINT_OPTIONS_PRINT_BACKGROUNDS 0x00001000 - -// Justification Flags -#define NS_PRINT_JUSTIFY_LEFT 0x00000001 -#define NS_PRINT_JUSTIFY_CENTER 0x00000002 -#define NS_PRINT_JUSTIFY_RIGHT 0x00000004 - %} +/** + * Native types + */ + [ref] native nsNativeMarginRef(nsMargin); + [ref] native nsNativeFontRef(nsFont); + [ref] native nsNativeStringRef(nsString); + /** * Simplified graphics interface for JS rendering. */ [scriptable, uuid(CAE87E20-479E-11d4-A856-00105A183419)] - interface nsIPrintOptions : nsISupports { -%{C++ - // Set Default Font of Header and footer - NS_IMETHOD SetDefaultFont(const nsFont &aFont) = 0; - NS_IMETHOD SetFontNamePointSize(const nsString& aFontName, nscoord aPointSize) = 0; + /* 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; - NS_IMETHOD GetDefaultFont(nsFont &aFont) = 0; + /* Print Range Enums */ + const long kRangeAllPages = 0; + const long kRangeSpecifiedPageRange = 1; + const long kRangeSelection = 2; + const long kRangeFocusFrame = 3; - - // non-scriptable helper method - NS_IMETHOD GetMargin(nsMargin& aMargin) = 0; -%} + /* Justification Enums */ + const long kJustLeft = 0; + const long kJustCenter = 1; + const long kJustRight = 2; /** - * Set PageMargins + * Page Size Constants */ - void SetMargins(in PRInt32 aTop, in PRInt32 aLeft, in PRInt32 aRight, in PRInt32 aBottom); + const short kLetterPaperSize = 0; + const short kLegalPaperSize = 1; + const short kExecutivePaperSize = 2; + const short kA4PaperSize = 3; /** - * Get PageMargins + * Print Frame Constants */ - void GetMargins(out PRInt32 aTop, out PRInt32 aLeft, out PRInt32 aRight, out PRInt32 aBottom); - + const short kFramesAsIs = 0; + const short kSelectedFrame = 1; + const short kEachFrameSep = 2; /** * Show Native Print Options dialog, this may not be supported on all platforms */ void ShowNativeDialog(); - /** - * Set Print Range - */ - void SetPrintRange(in PRInt32 aPrintRange); - - /** - * Get Print Range - */ - void GetPrintRange(out PRInt32 aPrintRange); - - /** - * Set Page Range - */ - void SetPageRange(in PRInt32 aStartPage, in PRInt32 aEndPage); - - /** - * Get Page Range - */ - void GetPageRange(out PRInt32 aStartPage, out PRInt32 aEndPage); - /** * Set PrintOptions */ @@ -126,42 +91,12 @@ interface nsIPrintOptions : nsISupports /** * Get PrintOptions */ - void GetPrintOptions(in PRInt32 aType, out PRBool aTurnOnOff); + PRBool GetPrintOptions(in PRInt32 aType); /** * Set PrintOptions Bit field */ - void GetPrintOptionsBits(out PRInt32 aBits); - - /** - * Set Title field for Header - */ - void SetTitle(in wstring aTitle); - - /** - * Get Title field for Header - */ - void GetTitle(out wstring aTitle); - - /** - * Set URL field for Header - */ - void SetURL(in wstring aURL); - - /** - * Get URL field for Header - */ - void GetURL(out wstring aURL); - - /** - * Set Page Number Print Justification - */ - void SetPageNumJust(in PRInt32 aJust); - - /** - * Set Page Number Print Justification - */ - void GetPageNumJust(out PRInt32 aJust); + PRInt32 GetPrintOptionsBits(); /** * Read Prefs @@ -173,4 +108,45 @@ interface nsIPrintOptions : nsISupports */ void WritePrefs(); + + /** + * Data Members + */ + attribute long startPageRange; + attribute long endPageRange; + + attribute double marginTop; /* these are in inches */ + attribute double marginLeft; + attribute double marginBottom; + attribute double marginRight; + + attribute short printRange; + attribute short pageNumJust; + attribute wstring title; + attribute wstring docURL; + + attribute boolean isPrintFrame; + attribute short printFrameType; + + /* Additional XP Related */ + 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; + + /* 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); + + }; diff --git a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp index bceb667e2fe..c27856e9dbd 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp +++ b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp @@ -133,7 +133,7 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet) // if there is a current selection then enable the "Selection" radio button if (NS_SUCCEEDED(rv) && printService) { PRBool isOn; - printService->GetPrintOptions(NS_PRINT_OPTIONS_ENABLE_SELECTION_RADIO, &isOn); + printService->GetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectionRB, &isOn); nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); if (NS_SUCCEEDED(rv) && pPrefs) { (void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn); @@ -141,14 +141,19 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet) } char *path; - - PRBool reversed = PR_FALSE, color = PR_FALSE, landscape = PR_FALSE; - PRBool tofile = PR_FALSE, allpagesRange = PR_TRUE, pageRange = PR_FALSE, selectionRange = PR_FALSE; - PRInt32 paper_size = NS_LETTER_SIZE; - PRInt32 fromPage = 1, toPage = 1; - int ileft = 500, iright = 500, itop = 500, ibottom = 500; - char *command; - char *printfile = nsnull; + PRBool reversed = PR_FALSE; + PRBool color = PR_FALSE; + PRBool tofile = PR_FALSE; + PRInt16 printRange = nsIPrintOptions::kRangeAllPages; + PRInt32 paper_size = NS_LETTER_SIZE; + PRInt32 fromPage = 1; + PRInt32 toPage = 1; + PRUnichar *command = nsnull; + PRUnichar *printfile = nsnull; + double dleft = 0.5; + double dright = 0.5; + double dtop = 0.5; + double dbottom = 0.5; rv = NS_OK; nsCOMPtr ioParamBlock; @@ -189,65 +194,42 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet) PRInt32 buttonPressed = 0; ioParamBlock->GetInt(0, &buttonPressed); if (buttonPressed == 0) { - nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv) && pPrefs) { - (void) pPrefs->GetBoolPref("print.print_reversed", &reversed); - (void) pPrefs->GetBoolPref("print.print_color", &color); - (void) pPrefs->GetBoolPref("print.print_landscape", &landscape); - (void) pPrefs->GetIntPref("print.print_paper_size", &paper_size); - (void) pPrefs->CopyCharPref("print.print_command", (char **) &command); - // the _js extention means these were set via script with the xp - // dialog as integers, int * 1000, meaning a 0.5 inches is 500 - // the "real" values are set into the prefs as strings - // the PrintOption object will save out these values as twips - // in the prefs with these names without the _js extention - (void) pPrefs->GetIntPref("print.print_margin_top_js", &itop); - (void) pPrefs->GetIntPref("print.print_margin_left_js", &ileft); - (void) pPrefs->GetIntPref("print.print_margin_bottom_js", &ibottom); - (void) pPrefs->GetIntPref("print.print_margin_right_js", &iright); + if (printService) { + printService->GetPrintReversed(&reversed); + printService->GetPrintInColor(&color); + printService->GetPaperSize(&paper_size); + printService->GetPrintCommand(&command); + printService->GetPrintRange(&printRange); + printService->GetToFileName(&printfile); + printService->GetPrintToFile(&tofile); + printService->GetStartPageRange(&fromPage); + printService->GetEndPageRange(&toPage); + printService->GetMarginTop(&dtop); + printService->GetMarginLeft(&dleft); + printService->GetMarginBottom(&dbottom); + printService->GetMarginRight(&dright); - (void) pPrefs->CopyCharPref("print.print_file", (char **) &printfile); - (void) pPrefs->GetBoolPref("print.print_tofile", &tofile); + if (command != nsnull && printfile != nsnull) { + // convert Unicode strings to cstrings + nsAutoString cmdStr; + nsAutoString printFileStr; + cmdStr = command; + printFileStr = printfile; + char * pCmdStr = cmdStr.ToNewCString(); + char * pPrintFileStr = printFileStr.ToNewCString(); + sprintf( mPrData.command, pCmdStr ); + sprintf( mPrData.path, pPrintFileStr); + nsMemory::Free(pCmdStr); + nsMemory::Free(pPrintFileStr); + } - (void) pPrefs->GetBoolPref("print.print_allpagesrange", &allpagesRange); - (void) pPrefs->GetBoolPref("print.print_pagerange", &pageRange); - (void) pPrefs->GetBoolPref("print.print_selectionrange", &selectionRange); - (void) pPrefs->GetIntPref("print.print_frompage", &fromPage); - (void) pPrefs->GetIntPref("print.print_topage", &toPage); - sprintf( mPrData.command, command ); - sprintf( mPrData.path, printfile ); - - // fill the print options with the info from the dialog - if(printService) { - // convert the script values to twips - nsMargin margin; - margin.SizeTo(NS_INCHES_TO_TWIPS(float(ileft)/1000.0), - NS_INCHES_TO_TWIPS(float(itop)/1000.0), - NS_INCHES_TO_TWIPS(float(iright)/1000.0), - NS_INCHES_TO_TWIPS(float(ibottom)/1000.0)); - printService->SetMargins(margin.top, margin.left, margin.right, margin.bottom); #ifdef DEBUG_rods - printf("margins: %d,%d,%d,%d\n", itop, ileft, ibottom, iright); - printf("margins: %d,%d,%d,%d (twips)\n", margin.top, margin.left, margin.bottom, margin.right); - printf("allpagesRange %d\n", allpagesRange); - printf("pageRange %d\n", pageRange); - printf("selectionRange %d\n", selectionRange); + printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright); + printf("printRange %d\n", printRange); printf("fromPage %d\n", fromPage); printf("toPage %d\n", toPage); #endif - if (selectionRange) { - printService->SetPrintRange(ePrintRange_Selection); - - } else if (pageRange) { - printService->SetPrintRange(ePrintRange_SpecifiedPageRange); - printService->SetPageRange(fromPage, toPage); - - } else { // (allpagesRange) - printService->SetPrintRange(ePrintRange_AllPages); - } - } - } else { #ifndef VMS sprintf( mPrData.command, "lpr" ); @@ -258,25 +240,31 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet) #endif } - mPrData.top = itop / 1000.0; - mPrData.bottom = ibottom / 1000.0; - mPrData.left = ileft / 1000.0; - mPrData.right = iright / 1000.0; - mPrData.fpf = !reversed; + mPrData.top = dtop; + mPrData.bottom = dbottom; + mPrData.left = dleft; + mPrData.right = dright; + mPrData.fpf = !reversed; mPrData.grayscale = !color; - mPrData.size = paper_size; + mPrData.size = paper_size; mPrData.toPrinter = !tofile; // PWD, HOME, or fail if (!printfile) { if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) NULL ) - if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) NULL ) - strcpy( mPrData.path, "mozilla.ps" ); + if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) NULL ) + strcpy( mPrData.path, "mozilla.ps" ); if ( path != (char *) NULL ) - sprintf( mPrData.path, "%s/mozilla.ps", path ); + sprintf( mPrData.path, "%s/mozilla.ps", path ); else - return NS_ERROR_FAILURE; + return NS_ERROR_FAILURE; + } + if (command != nsnull) { + nsMemory::Free(command); + } + if (printfile != nsnull) { + nsMemory::Free(printfile); } return NS_OK; @@ -288,7 +276,6 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet) } return NS_ERROR_FAILURE; - } NS_IMETHODIMP nsDeviceContextSpecGTK :: GetToPrinter( PRBool &aToPrinter ) diff --git a/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp b/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp index 616164dfd0e..d059dc75989 100644 --- a/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp +++ b/mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp @@ -165,8 +165,8 @@ static nsModuleComponentInfo components[] = nsImageManagerConstructor }, { "Print Options", NS_PRINTOPTIONS_CID, - // "@mozilla.org/gfx/print_options;1", - "@mozilla.org/gfx/print_options;1", + // "@mozilla.org/gfx/printoptions;1", + "@mozilla.org/gfx/printoptions;1", nsPrintOptionsGTKConstructor }, { "GTK Font Enumerator", NS_FONT_ENUMERATOR_CID, diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.cpp b/mozilla/gfx/src/nsPrintOptionsImpl.cpp index ed6f1d16d6b..142e50249e7 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.cpp +++ b/mozilla/gfx/src/nsPrintOptionsImpl.cpp @@ -28,7 +28,29 @@ #include "nsIPref.h" #include "nsIServiceManager.h" -NS_IMPL_ISUPPORTS1(nsPrintOptions, nsIPrintOptions) +//NS_IMPL_ISUPPORTS1(nsPrintOptions, nsIPrintOptions) + NS_IMPL_ADDREF(nsPrintOptions) + NS_IMPL_RELEASE(nsPrintOptions) +NS_IMETHODIMP nsPrintOptions::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + + *aInstancePtr = NULL; + + if (aIID.Equals(NS_GET_IID(nsIPrintOptions))) { + *aInstancePtr = (void*) (nsIPrintOptions*)this; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(NS_GET_IID(nsISupports))) { + *aInstancePtr = (void*) ((nsISupports*)this); + NS_ADDREF_THIS(); + return NS_OK; + } + return NS_NOINTERFACE; +} // Pref Constants const char * kMarginTop = "print.print_margin_top"; @@ -36,7 +58,7 @@ const char * kMarginLeft = "print.print_margin_left"; const char * kMarginBottom = "print.print_margin_bottom"; const char * kMarginRight = "print.print_margin_right"; -// Prefs for Print Option +// Prefs for Print Options const char * kPrintEvenPages = "print.print_evenpages"; const char * kPrintOddPages = "print.print_oddpages"; const char * kPrintDocTitle = "print.print_doctitle"; @@ -46,6 +68,14 @@ const char * kPageNumsJust = "print.print_pagenumjust"; const char * kPrintPageTotals = "print.print_pagetotals"; const char * kPrintDate = "print.print_date"; +// Additional Prefs +const char * kPrintReversed = "print.print_reversed"; +const char * kPrintColor = "print.print_color"; +const char * kPrintPaperSize = "print.print_paper_size"; +const char * kPrintCommand = "print.print_command"; +const char * kPrintFile = "print.print_file"; +const char * kPrintToFile = "print.print_tofile"; + // There are currently NOT supported //const char * kPrintBevelLines = "print.print_bevellines"; //const char * kPrintBlackText = "print.print_blacktext"; @@ -64,24 +94,31 @@ const char * kRightJust = "right"; * @update 6/21/00 dwc */ nsPrintOptions::nsPrintOptions() : - mPrintRange(ePrintRange_AllPages), - mStartPageNum(0), - mEndPageNum(0), - mPrintOptions(0L) + mPrintRange(kRangeAllPages), + mStartPageNum(1), + mEndPageNum(1), + mPrintOptions(0L), + mPrintReversed(PR_FALSE), + mPrintInColor(PR_TRUE), + mPaperSize(kLetterPaperSize), + mPrintToFile(PR_FALSE), + mPrintFrameType(kSelectedFrame), + mIsPrintFrame(PR_FALSE), + mPageNumJust(kJustLeft) { NS_INIT_ISUPPORTS(); /* member initializers and constructor code */ nscoord halfInch = NS_INCHES_TO_TWIPS(0.5); - SetMargins(halfInch, halfInch, halfInch, halfInch); + mMargin.SizeTo(halfInch, halfInch, halfInch, halfInch); - mPrintOptions = NS_PRINT_OPTIONS_PRINT_EVEN_PAGES | - NS_PRINT_OPTIONS_PRINT_ODD_PAGES | - NS_PRINT_OPTIONS_PRINT_DOC_LOCATION | - NS_PRINT_OPTIONS_PRINT_DOC_TITLE | - NS_PRINT_OPTIONS_PRINT_PAGE_NUMS | - NS_PRINT_OPTIONS_PRINT_PAGE_TOTAL | - NS_PRINT_OPTIONS_PRINT_DATE_PRINTED; + mPrintOptions = kOptPrintOddPages | + kOptPrintEvenPages | + kOptPrintDocTitle | + kOptPrintDocLoc | + kOptPrintPageNums | + kOptPrintPageTotal | + kOptPrintDatePrinted; mDefaultFont = new nsFont("Times", NS_FONT_STYLE_NORMAL,NS_FONT_VARIANT_NORMAL, NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(10)); @@ -105,12 +142,12 @@ nsPrintOptions::~nsPrintOptions() * @update 1/12/01 rods */ NS_IMETHODIMP -nsPrintOptions::SetDefaultFont(const nsFont &aFont) +nsPrintOptions::SetFontNamePointSize(nsString& aFontName, PRInt32 aPointSize) { - if (mDefaultFont != nsnull) { - delete mDefaultFont; + if (mDefaultFont != nsnull && aFontName.Length() > 0 && aPointSize > 0) { + mDefaultFont->name = aFontName; + mDefaultFont->size = NSIntPointsToTwips(aPointSize); } - mDefaultFont = new nsFont(aFont); return NS_OK; } @@ -119,12 +156,12 @@ nsPrintOptions::SetDefaultFont(const nsFont &aFont) * @update 1/12/01 rods */ NS_IMETHODIMP -nsPrintOptions::SetFontNamePointSize(const nsString& aFontName, nscoord aPointSize) +nsPrintOptions::SetDefaultFont(nsFont &aFont) { - if (mDefaultFont != nsnull && aFontName.Length() > 0 && aPointSize > 0) { - mDefaultFont->name = aFontName; - mDefaultFont->size = NSIntPointsToTwips(aPointSize); + if (mDefaultFont != nsnull) { + delete mDefaultFont; } + mDefaultFont = new nsFont(aFont); return NS_OK; } @@ -145,30 +182,9 @@ nsPrintOptions::GetDefaultFont(nsFont &aFont) * @update 1/12/01 rods */ NS_IMETHODIMP -nsPrintOptions::SetMargins(PRInt32 aTop, PRInt32 aLeft, PRInt32 aRight, PRInt32 aBottom) +nsPrintOptions::SetMarginInTwips(nsMargin& aMargin) { - mMargin.SizeTo(aLeft, aTop, aRight, aBottom); - return NS_OK; -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 6/21/00 dwc - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::GetMargins(PRInt32 *aTop, PRInt32 *aLeft, PRInt32 *aRight, PRInt32 *aBottom) -{ - NS_ENSURE_ARG_POINTER(aTop); - NS_ENSURE_ARG_POINTER(aLeft); - NS_ENSURE_ARG_POINTER(aRight); - NS_ENSURE_ARG_POINTER(aBottom); - - *aTop = mMargin.top; - *aLeft = mMargin.left; - *aRight = mMargin.right; - *aBottom = mMargin.bottom; - + mMargin = aMargin; return NS_OK; } @@ -177,10 +193,9 @@ nsPrintOptions::GetMargins(PRInt32 *aTop, PRInt32 *aLeft, PRInt32 *aRight, PRInt * @update 6/21/00 dwc */ NS_IMETHODIMP -nsPrintOptions::GetMargin(nsMargin& aMargin) +nsPrintOptions::GetMarginInTwips(nsMargin& aMargin) { aMargin = mMargin; - //aMargin.SizeTo(mLeftMargin, mTopMargin, mRightMargin, mBottomMargin); return NS_OK; } @@ -195,56 +210,6 @@ nsPrintOptions::ShowNativeDialog() return NS_OK; } -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::SetPrintRange(PRInt32 aPrintRange) -{ - mPrintRange = (nsPrintRange)aPrintRange; - return NS_OK; -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::GetPrintRange(PRInt32 *aPrintRange) -{ - NS_ENSURE_ARG_POINTER(aPrintRange); - - *aPrintRange = (PRInt32)mPrintRange; - return NS_OK; -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::SetPageRange(PRInt32 aStartPage, PRInt32 aEndPage) -{ - mStartPageNum = aStartPage; - mEndPageNum = aEndPage; - return NS_OK; -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::GetPageRange(PRInt32 *aStartPage, PRInt32 *aEndPage) -{ - NS_ENSURE_ARG_POINTER(aStartPage); - NS_ENSURE_ARG_POINTER(aEndPage); - *aStartPage = mStartPageNum; - *aEndPage = mEndPageNum; - return NS_OK; -} - /** --------------------------------------------------- * See documentation in nsPrintOptionsImpl.h * @update 1/12/01 rods @@ -284,77 +249,6 @@ nsPrintOptions::GetPrintOptionsBits(PRInt32 *aBits) return NS_OK; } -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::SetTitle(const PRUnichar *aTitle) -{ - NS_ENSURE_ARG_POINTER(aTitle); - mTitle = aTitle; - return NS_OK; -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::GetTitle(PRUnichar **aTitle) -{ - NS_ENSURE_ARG_POINTER(aTitle); - *aTitle = mTitle.ToNewUnicode(); - return NS_OK; -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::SetURL(const PRUnichar *aURL) -{ - NS_ENSURE_ARG_POINTER(aURL); - mURL = aURL; - return NS_OK; -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::GetURL(PRUnichar **aURL) -{ - NS_ENSURE_ARG_POINTER(aURL); - *aURL = mURL.ToNewUnicode(); - return NS_OK; -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::SetPageNumJust(PRInt32 aJust) -{ - mPageNumJust = aJust; - return NS_OK; -} - -/** --------------------------------------------------- - * See documentation in nsPrintOptionsImpl.h - * @update 1/12/01 rods - */ -NS_IMETHODIMP -nsPrintOptions::GetPageNumJust(PRInt32 *aJust) -{ - NS_ENSURE_ARG_POINTER(aJust); - - *aJust = (PRInt32)mPageNumJust; - return NS_OK; -} /** --------------------------------------------------- * See documentation in nsPrintOptionsImpl.h @@ -370,15 +264,23 @@ nsPrintOptions::ReadPrefs() ReadInchesToTwipsPref(prefs, kMarginBottom, mMargin.bottom); ReadInchesToTwipsPref(prefs, kMarginRight, mMargin.right); - ReadBitFieldPref(prefs, kPrintEvenPages, NS_PRINT_OPTIONS_PRINT_EVEN_PAGES); - ReadBitFieldPref(prefs, kPrintOddPages, NS_PRINT_OPTIONS_PRINT_ODD_PAGES); - ReadBitFieldPref(prefs, kPrintDocTitle, NS_PRINT_OPTIONS_PRINT_DOC_TITLE); - ReadBitFieldPref(prefs, kPrintDocLoc, NS_PRINT_OPTIONS_PRINT_DOC_LOCATION); - ReadBitFieldPref(prefs, kPageNums, NS_PRINT_OPTIONS_PRINT_PAGE_NUMS); - ReadBitFieldPref(prefs, kPrintPageTotals, NS_PRINT_OPTIONS_PRINT_PAGE_TOTAL); - ReadBitFieldPref(prefs, kPrintDate, NS_PRINT_OPTIONS_PRINT_DATE_PRINTED); + ReadBitFieldPref(prefs, kPrintEvenPages, kOptPrintEvenPages); + ReadBitFieldPref(prefs, kPrintOddPages, kOptPrintOddPages); + ReadBitFieldPref(prefs, kPrintDocTitle, kOptPrintDocTitle); + ReadBitFieldPref(prefs, kPrintDocLoc, kOptPrintDocLoc); + ReadBitFieldPref(prefs, kPageNums, kOptPrintPageNums); + ReadBitFieldPref(prefs, kPrintPageTotals, kOptPrintPageTotal); + ReadBitFieldPref(prefs, kPrintDate, kOptPrintDatePrinted); - ReadJustification(prefs, kPageNumsJust, mPageNumJust, NS_PRINT_JUSTIFY_LEFT); + ReadJustification(prefs, kPageNumsJust, mPageNumJust, kJustLeft); + + // Read Additional XP Prefs + prefs->GetBoolPref(kPrintReversed, &mPrintReversed); + prefs->GetBoolPref(kPrintColor, &mPrintInColor); + prefs->GetIntPref(kPrintPaperSize, &mPaperSize); + ReadPrefString(prefs, kPrintCommand, mPrintCommand); + prefs->GetBoolPref(kPrintFile, &mPrintToFile); + ReadPrefString(prefs, kPrintToFile, mToFileName); return NS_OK; } @@ -399,24 +301,296 @@ nsPrintOptions::WritePrefs() WriteInchesFromTwipsPref(prefs, kMarginBottom, mMargin.bottom); WriteInchesFromTwipsPref(prefs, kMarginRight, mMargin.right); - WriteBitFieldPref(prefs, kPrintEvenPages, NS_PRINT_OPTIONS_PRINT_EVEN_PAGES); - WriteBitFieldPref(prefs, kPrintOddPages, NS_PRINT_OPTIONS_PRINT_ODD_PAGES); - WriteBitFieldPref(prefs, kPrintDocTitle, NS_PRINT_OPTIONS_PRINT_DOC_TITLE); - WriteBitFieldPref(prefs, kPrintDocLoc, NS_PRINT_OPTIONS_PRINT_DOC_LOCATION); - WriteBitFieldPref(prefs, kPageNums, NS_PRINT_OPTIONS_PRINT_PAGE_NUMS); - WriteBitFieldPref(prefs, kPrintPageTotals, NS_PRINT_OPTIONS_PRINT_PAGE_TOTAL); - WriteBitFieldPref(prefs, kPrintDate, NS_PRINT_OPTIONS_PRINT_DATE_PRINTED); + WriteBitFieldPref(prefs, kPrintEvenPages, kOptPrintEvenPages); + WriteBitFieldPref(prefs, kPrintOddPages, kOptPrintOddPages); + WriteBitFieldPref(prefs, kPrintDocTitle, kOptPrintDocTitle); + WriteBitFieldPref(prefs, kPrintDocLoc, kOptPrintDocLoc); + WriteBitFieldPref(prefs, kPageNums, kOptPrintPageNums); + WriteBitFieldPref(prefs, kPrintPageTotals, kOptPrintPageTotal); + WriteBitFieldPref(prefs, kPrintDate, kOptPrintDatePrinted); WriteJustification(prefs, kPageNumsJust, mPageNumJust); + // Write Additional XP Prefs + prefs->SetBoolPref(kPrintReversed, mPrintReversed); + prefs->SetBoolPref(kPrintColor, mPrintInColor); + prefs->SetIntPref(kPrintPaperSize, mPaperSize); + WritePrefString(prefs, kPrintCommand, mPrintCommand); + prefs->SetBoolPref(kPrintFile, mPrintToFile); + WritePrefString(prefs, kPrintToFile, mToFileName); + return NS_OK; } return NS_ERROR_FAILURE; } +/* attribute long startPageRange; */ +NS_IMETHODIMP nsPrintOptions::GetStartPageRange(PRInt32 *aStartPageRange) +{ + //NS_ENSURE_ARG_POINTER(aStartPageRange); + *aStartPageRange = mStartPageNum; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetStartPageRange(PRInt32 aStartPageRange) +{ + mStartPageNum = aStartPageRange; + return NS_OK; +} + +/* attribute long endPageRange; */ +NS_IMETHODIMP nsPrintOptions::GetEndPageRange(PRInt32 *aEndPageRange) +{ + //NS_ENSURE_ARG_POINTER(aEndPageRange); + *aEndPageRange = mEndPageNum; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetEndPageRange(PRInt32 aEndPageRange) +{ + mEndPageNum = aEndPageRange; + return NS_OK; +} + +/* attribute boolean printReversed; */ +NS_IMETHODIMP nsPrintOptions::GetPrintReversed(PRBool *aPrintReversed) +{ + //NS_ENSURE_ARG_POINTER(aPrintReversed); + *aPrintReversed = mPrintReversed; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetPrintReversed(PRBool aPrintReversed) +{ + mPrintReversed = aPrintReversed; + return NS_OK; +} + +/* attribute boolean printInColor; */ +NS_IMETHODIMP nsPrintOptions::GetPrintInColor(PRBool *aPrintInColor) +{ + //NS_ENSURE_ARG_POINTER(aPrintInColor); + *aPrintInColor = mPrintInColor; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetPrintInColor(PRBool aPrintInColor) +{ + mPrintInColor = aPrintInColor; + return NS_OK; +} + +/* attribute short paperSize; */ +NS_IMETHODIMP nsPrintOptions::GetPaperSize(PRInt32 *aPaperSize) +{ + //NS_ENSURE_ARG_POINTER(aPaperSize); + *aPaperSize = mPaperSize; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetPaperSize(PRInt32 aPaperSize) +{ + mPaperSize = aPaperSize; + return NS_OK; +} + +/* attribute wstring printCommand; */ +NS_IMETHODIMP nsPrintOptions::GetPrintCommand(PRUnichar * *aPrintCommand) +{ + //NS_ENSURE_ARG_POINTER(aPrintCommand); + *aPrintCommand = mPrintCommand.ToNewUnicode(); + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetPrintCommand(const PRUnichar * aPrintCommand) +{ + mPrintCommand = aPrintCommand; + return NS_OK; +} + +/* attribute boolean printToFile; */ +NS_IMETHODIMP nsPrintOptions::GetPrintToFile(PRBool *aPrintToFile) +{ + //NS_ENSURE_ARG_POINTER(aPrintToFile); + *aPrintToFile = mPrintToFile; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetPrintToFile(PRBool aPrintToFile) +{ + mPrintToFile = aPrintToFile; + return NS_OK; +} + +/* attribute wstring toFileName; */ +NS_IMETHODIMP nsPrintOptions::GetToFileName(PRUnichar * *aToFileName) +{ + //NS_ENSURE_ARG_POINTER(aToFileName); + *aToFileName = mToFileName.ToNewUnicode(); + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetToFileName(const PRUnichar * aToFileName) +{ + mToFileName = aToFileName; + return NS_OK; +} + +/* attribute double marginTop; */ +NS_IMETHODIMP nsPrintOptions::GetMarginTop(double *aMarginTop) +{ + NS_ENSURE_ARG_POINTER(aMarginTop); + *aMarginTop = NS_TWIPS_TO_INCHES(mMargin.top); + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetMarginTop(double aMarginTop) +{ + mMargin.top = NS_INCHES_TO_TWIPS(float(aMarginTop)); + return NS_OK; +} + +/* attribute double marginLeft; */ +NS_IMETHODIMP nsPrintOptions::GetMarginLeft(double *aMarginLeft) +{ + NS_ENSURE_ARG_POINTER(aMarginLeft); + *aMarginLeft = NS_TWIPS_TO_INCHES(mMargin.left); + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetMarginLeft(double aMarginLeft) +{ + mMargin.left = NS_INCHES_TO_TWIPS(float(aMarginLeft)); + return NS_OK; +} + +/* attribute double marginBottom; */ +NS_IMETHODIMP nsPrintOptions::GetMarginBottom(double *aMarginBottom) +{ + NS_ENSURE_ARG_POINTER(aMarginBottom); + *aMarginBottom = NS_TWIPS_TO_INCHES(mMargin.bottom); + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetMarginBottom(double aMarginBottom) +{ + mMargin.bottom = NS_INCHES_TO_TWIPS(float(aMarginBottom)); + return NS_OK; +} + +/* attribute double marginRight; */ +NS_IMETHODIMP nsPrintOptions::GetMarginRight(double *aMarginRight) +{ + NS_ENSURE_ARG_POINTER(aMarginRight); + *aMarginRight = NS_TWIPS_TO_INCHES(mMargin.right); + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetMarginRight(double aMarginRight) +{ + mMargin.right = NS_INCHES_TO_TWIPS(float(aMarginRight)); + return NS_OK; +} + +/* attribute long printRange; */ +NS_IMETHODIMP nsPrintOptions::GetPrintRange(PRInt16 *aPrintRange) +{ + NS_ENSURE_ARG_POINTER(aPrintRange); + *aPrintRange = mPrintRange; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetPrintRange(PRInt16 aPrintRange) +{ + mPrintRange = aPrintRange; + return NS_OK; +} + +/* attribute long pageNumJust; */ +NS_IMETHODIMP nsPrintOptions::GetPageNumJust(PRInt16 *aPageNumJust) +{ + NS_ENSURE_ARG_POINTER(aPageNumJust); + *aPageNumJust = mPageNumJust; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetPageNumJust(PRInt16 aPageNumJust) +{ + mPageNumJust = aPageNumJust; + return NS_OK; +} + +/* attribute wstring docTitle; */ +NS_IMETHODIMP nsPrintOptions::GetTitle(PRUnichar * *aTitle) +{ + NS_ENSURE_ARG_POINTER(aTitle); + *aTitle = mTitle.ToNewUnicode(); + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetTitle(const PRUnichar * aTitle) +{ + NS_ENSURE_ARG_POINTER(aTitle); + mTitle = aTitle; + return NS_OK; +} + +/* attribute wstring docURL; */ +NS_IMETHODIMP nsPrintOptions::GetDocURL(PRUnichar * *aDocURL) +{ + NS_ENSURE_ARG_POINTER(aDocURL); + *aDocURL = mURL.ToNewUnicode(); + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetDocURL(const PRUnichar * aDocURL) +{ + NS_ENSURE_ARG_POINTER(aDocURL); + mURL = aDocURL; + return NS_OK; +} + +/* attribute boolean isPrintFrame; */ +NS_IMETHODIMP nsPrintOptions::GetIsPrintFrame(PRBool *aIsPrintFrame) +{ + NS_ENSURE_ARG_POINTER(aIsPrintFrame); + *aIsPrintFrame = (PRInt32)mIsPrintFrame; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetIsPrintFrame(PRBool aIsPrintFrame) +{ + mIsPrintFrame = aIsPrintFrame; + return NS_OK; +} + +/* attribute long printFrame; */ +NS_IMETHODIMP nsPrintOptions::GetPrintFrameType(PRInt16 *aPrintFrameType) +{ + NS_ENSURE_ARG_POINTER(aPrintFrameType); + *aPrintFrameType = (PRInt32)mPrintFrameType; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetPrintFrameType(PRInt16 aPrintFrameType) +{ + mPrintFrameType = aPrintFrameType; + return NS_OK; +} + //----------------------------------------------------- //-- Protected Methods //----------------------------------------------------- +//--------------------------------------------------- +nsresult nsPrintOptions::ReadPrefString(nsIPref * aPref, + const char * aPrefId, + nsString& aString) +{ + char * str = nsnull; + nsresult rv = aPref->CopyCharPref(aPrefId, &str); + if (NS_SUCCEEDED(rv) && str) { + aString.AssignWithConversion(str); + nsMemory::Free(str); + } + return rv; +} + +nsresult nsPrintOptions::WritePrefString(nsIPref * aPref, + const char * aPrefId, + nsString& aString) +{ + NS_ENSURE_ARG_POINTER(aPref); + NS_ENSURE_ARG_POINTER(aPrefId); + + PRUnichar * str = aString.ToNewUnicode(); + nsresult rv = aPref->SetUnicharPref(aPrefId, str); + nsMemory::Free(str); + + return rv; +} + void nsPrintOptions::ReadBitFieldPref(nsIPref * aPref, const char * aPrefId, PRInt32 anOption) @@ -474,49 +648,45 @@ void nsPrintOptions::WriteInchesFromTwipsPref(nsIPref * aPref, } } -//--------------------------------------------------- void nsPrintOptions::ReadJustification(nsIPref * aPref, const char * aPrefId, - PRInt32& aJust, - PRInt32 aInitValue) + PRInt16& aJust, + PRInt16 aInitValue) { aJust = aInitValue; - char * str = nsnull; - nsresult rv = aPref->CopyCharPref(aPrefId, &str); - if (NS_SUCCEEDED(rv) && str) { - nsAutoString justStr; - justStr.AssignWithConversion(str); - + nsAutoString justStr; + if (NS_SUCCEEDED(ReadPrefString(aPref, aPrefId, justStr))) { if (justStr.EqualsWithConversion(kRightJust)) { - aJust = NS_PRINT_JUSTIFY_RIGHT; + aJust = kJustRight; } else if (justStr.EqualsWithConversion(kCenterJust)) { - aJust = NS_PRINT_JUSTIFY_CENTER; + aJust = kJustCenter; } else { - aJust = NS_PRINT_JUSTIFY_LEFT; + aJust = kJustLeft; } - nsMemory::Free(str); } } //--------------------------------------------------- void nsPrintOptions::WriteJustification(nsIPref * aPref, const char * aPrefId, - PRInt32 aJust) + PRInt16 aJust) { switch (aJust) { - case NS_PRINT_JUSTIFY_LEFT: + case kJustLeft: aPref->SetCharPref(aPrefId, kLeftJust); break; - case NS_PRINT_JUSTIFY_CENTER: + case kJustCenter: aPref->SetCharPref(aPrefId, kCenterJust); break; - case NS_PRINT_JUSTIFY_RIGHT: + case kJustRight: aPref->SetCharPref(aPrefId, kRightJust); break; } //switch } + + diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.h b/mozilla/gfx/src/nsPrintOptionsImpl.h index 7a9af306e86..b8ea754111b 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.h +++ b/mozilla/gfx/src/nsPrintOptionsImpl.h @@ -36,40 +36,44 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIPRINTOPTIONS - // C++ methods - NS_IMETHOD SetDefaultFont(const nsFont &aFont); - NS_IMETHOD SetFontNamePointSize(const nsString& aFontName, nscoord aPointSize); - - NS_IMETHOD GetDefaultFont(nsFont &aFont); - - // non-scriptable C++ helper method - NS_IMETHOD GetMargin(nsMargin& aMargin); - nsPrintOptions(); virtual ~nsPrintOptions(); protected: void ReadBitFieldPref(nsIPref * aPref, const char * aPrefId, PRInt32 anOption); void WriteBitFieldPref(nsIPref * aPref, const char * aPrefId, PRInt32 anOption); - void ReadJustification(nsIPref * aPref, const char * aPrefId, PRInt32& aJust, PRInt32 aInitValue); - void WriteJustification(nsIPref * aPref, const char * aPrefId, PRInt32 aJust); + void ReadJustification(nsIPref * aPref, const char * aPrefId, PRInt16& aJust, PRInt16 aInitValue); + void WriteJustification(nsIPref * aPref, const char * aPrefId, PRInt16 aJust); void ReadInchesToTwipsPref(nsIPref * aPref, const char * aPrefId, nscoord& aTwips); void WriteInchesFromTwipsPref(nsIPref * aPref, const char * aPrefId, nscoord aTwips); + nsresult ReadPrefString(nsIPref * aPref, const char * aPrefId, nsString& aString); + nsresult WritePrefString(nsIPref * aPref, const char * aPrefId, nsString& aString); + // Members nsMargin mMargin; + PRInt32 mPrintOptions; - nsPrintRange mPrintRange; + // scriptable data members + PRInt16 mPrintRange; PRInt32 mStartPageNum; // only used for ePrintRange_SpecifiedRange PRInt32 mEndPageNum; - PRInt32 mPageNumJust; + PRInt16 mPageNumJust; - PRInt32 mPrintOptions; + PRInt16 mPrintFrameType; + PRBool mIsPrintFrame; nsFont* mDefaultFont; nsString mTitle; nsString mURL; + PRBool mPrintReversed; + PRBool mPrintInColor; // a false means grayscale + PRInt32 mPaperSize; // see page size consts + nsString mPrintCommand; + PRBool mPrintToFile; + nsString mToFileName; + }; diff --git a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp index d8b76d1fac5..cf011441278 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp @@ -30,6 +30,9 @@ #include "nsIPrintOptions.h" +// This is for extending the dialog +#include + nsDeviceContextSpecFactoryWin :: nsDeviceContextSpecFactoryWin() { NS_INIT_REFCNT(); @@ -50,45 +53,104 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: Init(void) return NS_OK; } +//-------------------------------------------------------- +static void SetRadio(HWND aParent, + UINT aId, + PRBool aIsSet, + PRBool isEnabled = PR_TRUE) +{ + HWND wnd = GetDlgItem (aParent, aId); + if (!wnd) { + return; + } + if (!isEnabled) { + ::EnableWindow(wnd, FALSE); + return; + } + ::EnableWindow(wnd, TRUE); + ::SendMessage(wnd, BM_SETCHECK, (WPARAM)aIsSet, (LPARAM)0); +} + +//-------------------------------------------------------- +static UINT gFrameSelectedRadioBtn = NULL; + +//-------------------------------------------------------- +UINT CALLBACK PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + if (uiMsg == WM_COMMAND) { + gFrameSelectedRadioBtn = LOWORD(wParam); + + } else if (uiMsg == WM_INITDIALOG) { + PRINTDLG * printDlg = (PRINTDLG *)lParam; + PRBool doingFrames = (PRBool)printDlg->lCustData; + HWND collateChk = GetDlgItem (hdlg, chx2); + if (collateChk) { + ::ShowWindow(collateChk, SW_SHOW); + } + if (!doingFrames) { + // we are using this function to disabe the group box + SetRadio(hdlg, grp3, PR_FALSE, PR_FALSE); + // now disable radiobuttons + SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE); + SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE); + SetRadio(hdlg, rad6, PR_FALSE, PR_FALSE); + } else { + SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE); // XXX this is just temporary + SetRadio(hdlg, rad5, PR_TRUE); + SetRadio(hdlg, rad6, PR_FALSE); + } + } + return 0L; +} + //XXX this method needs to do what the API says... NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget *aWidget, nsIDeviceContextSpec *&aNewSpec, PRBool aQuiet) { + NS_ENSURE_ARG_POINTER(aWidget); + nsresult rv = NS_ERROR_FAILURE; NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv); PRINTDLG prntdlg; + HWND hWnd = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW); + HINSTANCE hInstance = (HINSTANCE)::GetWindowLong(hWnd, GWL_HINSTANCE); + prntdlg.lStructSize = sizeof(prntdlg); prntdlg.hwndOwner = NULL; //XXX need to find a window here. MMP prntdlg.hDevMode = NULL; prntdlg.hDevNames = NULL; prntdlg.hDC = NULL; - prntdlg.Flags = PD_ALLPAGES | PD_RETURNIC | PD_HIDEPRINTTOFILE; + prntdlg.Flags = PD_ALLPAGES | PD_RETURNIC | PD_HIDEPRINTTOFILE | + PD_ENABLEPRINTTEMPLATE | PD_ENABLEPRINTHOOK | PD_USEDEVMODECOPIESANDCOLLATE; // if there is a current selection then enable the "Selection" radio button + PRBool isPrintFrames = PR_FALSE; if (printService) { PRBool isOn; - printService->GetPrintOptions(NS_PRINT_OPTIONS_ENABLE_SELECTION_RADIO, &isOn); + printService->GetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectionRB, &isOn); if (!isOn) { prntdlg.Flags |= PD_NOSELECTION; } + printService->GetIsPrintFrame(&isPrintFrames); } - prntdlg.nFromPage = 1; - prntdlg.nToPage = 1; - prntdlg.nMinPage = 0; - prntdlg.nMaxPage = 1000; - prntdlg.nCopies = 1; - prntdlg.hInstance = NULL; - prntdlg.lCustData = 0; - prntdlg.lpfnPrintHook = NULL; - prntdlg.lpfnSetupHook = NULL; - prntdlg.lpPrintTemplateName = NULL; + + prntdlg.nFromPage = 1; + prntdlg.nToPage = 1; + prntdlg.nMinPage = 0; + prntdlg.nMaxPage = 1000; + prntdlg.nCopies = 1; + prntdlg.hInstance = hInstance; + prntdlg.lCustData = (DWORD)isPrintFrames; + prntdlg.lpfnPrintHook = PrintHookProc; + prntdlg.lpfnSetupHook = NULL; + prntdlg.lpPrintTemplateName = (LPCTSTR)"PRINTDLGNEW"; prntdlg.lpSetupTemplateName = NULL; - prntdlg.hPrintTemplate = NULL; - prntdlg.hSetupTemplate = NULL; + prntdlg.hPrintTemplate = NULL; + prntdlg.hSetupTemplate = NULL; if(PR_TRUE == aQuiet){ @@ -116,16 +178,33 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget if(printService) { if (prntdlg.Flags & PD_SELECTION) { - printService->SetPrintRange(ePrintRange_Selection); + printService->SetPrintRange(nsIPrintOptions::kRangeSelection); } else if (prntdlg.Flags & PD_PAGENUMS) { - printService->SetPrintRange(ePrintRange_SpecifiedPageRange); - printService->SetPageRange(prntdlg.nFromPage, prntdlg.nToPage); + printService->SetPrintRange(nsIPrintOptions::kRangeSpecifiedPageRange); + printService->SetStartPageRange(prntdlg.nFromPage); + printService->SetEndPageRange( prntdlg.nToPage); } else { // (prntdlg.Flags & PD_ALLPAGES) - printService->SetPrintRange(ePrintRange_AllPages); + printService->SetPrintRange(nsIPrintOptions::kRangeAllPages); } - } + + // check to see about the frame radio buttons + switch (gFrameSelectedRadioBtn) { + case rad4: + printService->SetPrintFrameType(nsIPrintOptions::kFramesAsIs); + break; + case rad5: + printService->SetPrintFrameType(nsIPrintOptions::kSelectedFrame); + break; + case rad6: + printService->SetPrintFrameType(nsIPrintOptions::kEachFrameSep); + break; + default: + printService->SetIsPrintFrame(PR_FALSE); + } // switch + } + #if defined(DEBUG_rods) || defined(DEBUG_dcone) PRBool printSelection = prntdlg.Flags & PD_SELECTION; diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index d6df2625c06..ad94ec7343c 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -1500,12 +1500,10 @@ if (!doesContainFrameSet) { DumpLayoutData(cx, aDContext, rootFrame, aParent); #endif - nsPrintRange printRangeType = ePrintRange_AllPages; NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv); if (NS_SUCCEEDED(rv) && printService) { - PRInt32 printType; - printService->GetPrintRange(&printType); - printRangeType = (nsPrintRange)printType; + PRInt16 printRangeType = nsIPrintOptions::kRangeAllPages; + printService->GetPrintRange(&printRangeType); // get the document title const nsString* docTitle = mDocument->GetDocumentTitle(); @@ -1522,11 +1520,11 @@ if (!doesContainFrameSet) { nsAutoString urlStr; urlStr.AssignWithConversion(urlCStr); PRUnichar * urlUStr = urlStr.ToNewUnicode(); - printService->SetURL(urlUStr); + printService->SetDocURL(urlUStr); nsMemory::Free(urlUStr); nsMemory::Free(urlCStr); - if (ePrintRange_Selection == printRangeType) { + if (nsIPrintOptions::kRangeSelection == printRangeType) { cx->SetIsRenderingOnlySelection(PR_TRUE); // temporarily creating rendering context @@ -1546,7 +1544,8 @@ if (!doesContainFrameSet) { &startFrame, startPageNum, startRect, &endFrame, endPageNum, endRect); if (NS_SUCCEEDED(rv)) { - printService->SetPageRange(startPageNum, endPageNum); + printService->SetStartPageRange(startPageNum); + printService->SetEndPageRange(endPageNum); if (startPageNum == endPageNum) { nsIFrame * seqFrame; if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) { @@ -2285,7 +2284,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi nsresult rv = NS_ERROR_FAILURE; NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv); if (NS_SUCCEEDED(rv) && printService) { - printService->SetPrintOptions(NS_PRINT_OPTIONS_ENABLE_SELECTION_RADIO, IsThereASelection()); + printService->SetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectionRB, IsThereASelection()); } nsComponentManager::CreateInstance(kDeviceContextSpecFactoryCID, @@ -2304,7 +2303,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi mPrintDC = nsnull; mFilePointer = aFile; - factory->CreateDeviceContextSpec(nsnull, devspec, aSilent); + factory->CreateDeviceContextSpec(mWindow, devspec, aSilent); if (nsnull != devspec) { mPresContext->GetDeviceContext(getter_AddRefs(dx)); rv = dx->GetDeviceContextFor(devspec, mPrintDC); diff --git a/mozilla/layout/base/src/nsDocumentViewer.cpp b/mozilla/layout/base/src/nsDocumentViewer.cpp index d6df2625c06..ad94ec7343c 100644 --- a/mozilla/layout/base/src/nsDocumentViewer.cpp +++ b/mozilla/layout/base/src/nsDocumentViewer.cpp @@ -1500,12 +1500,10 @@ if (!doesContainFrameSet) { DumpLayoutData(cx, aDContext, rootFrame, aParent); #endif - nsPrintRange printRangeType = ePrintRange_AllPages; NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv); if (NS_SUCCEEDED(rv) && printService) { - PRInt32 printType; - printService->GetPrintRange(&printType); - printRangeType = (nsPrintRange)printType; + PRInt16 printRangeType = nsIPrintOptions::kRangeAllPages; + printService->GetPrintRange(&printRangeType); // get the document title const nsString* docTitle = mDocument->GetDocumentTitle(); @@ -1522,11 +1520,11 @@ if (!doesContainFrameSet) { nsAutoString urlStr; urlStr.AssignWithConversion(urlCStr); PRUnichar * urlUStr = urlStr.ToNewUnicode(); - printService->SetURL(urlUStr); + printService->SetDocURL(urlUStr); nsMemory::Free(urlUStr); nsMemory::Free(urlCStr); - if (ePrintRange_Selection == printRangeType) { + if (nsIPrintOptions::kRangeSelection == printRangeType) { cx->SetIsRenderingOnlySelection(PR_TRUE); // temporarily creating rendering context @@ -1546,7 +1544,8 @@ if (!doesContainFrameSet) { &startFrame, startPageNum, startRect, &endFrame, endPageNum, endRect); if (NS_SUCCEEDED(rv)) { - printService->SetPageRange(startPageNum, endPageNum); + printService->SetStartPageRange(startPageNum); + printService->SetEndPageRange(endPageNum); if (startPageNum == endPageNum) { nsIFrame * seqFrame; if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) { @@ -2285,7 +2284,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi nsresult rv = NS_ERROR_FAILURE; NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv); if (NS_SUCCEEDED(rv) && printService) { - printService->SetPrintOptions(NS_PRINT_OPTIONS_ENABLE_SELECTION_RADIO, IsThereASelection()); + printService->SetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectionRB, IsThereASelection()); } nsComponentManager::CreateInstance(kDeviceContextSpecFactoryCID, @@ -2304,7 +2303,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi mPrintDC = nsnull; mFilePointer = aFile; - factory->CreateDeviceContextSpec(nsnull, devspec, aSilent); + factory->CreateDeviceContextSpec(mWindow, devspec, aSilent); if (nsnull != devspec) { mPresContext->GetDeviceContext(getter_AddRefs(dx)); rv = dx->GetDeviceContextFor(devspec, mPrintDC); diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 1bab5ea65c2..30bdd525bc2 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -218,15 +218,15 @@ nscoord nsPageFrame::GetXPosition(nsIRenderingContext& aRenderingContext, nscoord x = aRect.x; switch (aJust) { - case NS_PRINT_JUSTIFY_LEFT: + case nsIPrintOptions::kJustLeft: // do nothing, already set break; - case NS_PRINT_JUSTIFY_CENTER: + case nsIPrintOptions::kJustCenter: x += (aRect.width - width) / 2; break; - case NS_PRINT_JUSTIFY_RIGHT: + case nsIPrintOptions::kJustRight: x += aRect.width - width; break; } // switch @@ -314,7 +314,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { // get the current margin - mPrintOptions->GetMargin(mMargin); + mPrintOptions->GetMarginInTwips(mMargin); nsRect rect(0,0,mRect.width, mRect.height); @@ -353,13 +353,13 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, mPrintOptions->GetPrintOptionsBits(&printOptBits); // print page numbers - if (printOptBits & NS_PRINT_OPTIONS_PRINT_PAGE_NUMS && mPageNumFormat != nsnull) { - PRInt32 justify = NS_PRINT_JUSTIFY_LEFT; + if (printOptBits & nsIPrintOptions::kOptPrintPageNums && mPageNumFormat != nsnull) { + PRInt16 justify = nsIPrintOptions::kJustLeft; mPrintOptions->GetPageNumJust(&justify); PRUnichar * valStr; // print page number totals "x of x" - if (printOptBits & NS_PRINT_OPTIONS_PRINT_PAGE_TOTAL) { + if (printOptBits & nsIPrintOptions::kOptPrintPageTotal) { valStr = nsTextFormatter::smprintf(mPageNumFormat, mPageNum, mTotNumPages); } else { valStr = nsTextFormatter::smprintf(mPageNumFormat, mPageNum); @@ -370,7 +370,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, } // print localized date - if (printOptBits & NS_PRINT_OPTIONS_PRINT_DATE_PRINTED) { + if (printOptBits & nsIPrintOptions::kOptPrintDatePrinted) { // Get Locale for Formating DateTime nsCOMPtr locale; NS_WITH_SERVICE(nsILocaleService, localeSvc, kLocaleServiceCID, &rv); @@ -390,7 +390,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, time( <ime ); rv = dateTime->FormatTMTime(locale, kDateFormatShort, kTimeFormatNoSeconds, localtime( <ime ), dateString); if (NS_SUCCEEDED(rv)) { - DrawHeaderFooter(aRenderingContext, this, eFooter, NS_PRINT_JUSTIFY_RIGHT, dateString, rect, visibleHeight); + DrawHeaderFooter(aRenderingContext, this, eFooter, nsIPrintOptions::kJustRight, dateString, rect, visibleHeight); } } } @@ -398,21 +398,22 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, } - PRBool usingHalfThePage = (printOptBits & NS_PRINT_OPTIONS_PRINT_DOC_TITLE) && (printOptBits & NS_PRINT_OPTIONS_PRINT_DOC_LOCATION); + PRBool usingHalfThePage = (printOptBits & nsIPrintOptions::kOptPrintDocTitle) && + (printOptBits & nsIPrintOptions::kOptPrintDocLoc); // print document title PRUnichar * title; mPrintOptions->GetTitle(&title); // creates memory - if (title != nsnull && (printOptBits & NS_PRINT_OPTIONS_PRINT_DOC_TITLE)) { - DrawHeaderFooter(aRenderingContext, this, eHeader, NS_PRINT_JUSTIFY_LEFT, nsAutoString(title), rect, visibleHeight, usingHalfThePage); + if (title != nsnull && (printOptBits & nsIPrintOptions::kOptPrintDocTitle)) { + DrawHeaderFooter(aRenderingContext, this, eHeader, nsIPrintOptions::kJustLeft, nsAutoString(title), rect, visibleHeight, usingHalfThePage); nsMemory::Free(title); } // print document URL PRUnichar * url; - mPrintOptions->GetURL(&url); - if (title != url && (printOptBits & NS_PRINT_OPTIONS_PRINT_DOC_LOCATION)) { - DrawHeaderFooter(aRenderingContext, this, eHeader, NS_PRINT_JUSTIFY_RIGHT, nsAutoString(url), rect, visibleHeight, usingHalfThePage); + mPrintOptions->GetDocURL(&url); + if (title != url && (printOptBits & nsIPrintOptions::kOptPrintDocLoc)) { + DrawHeaderFooter(aRenderingContext, this, eHeader, nsIPrintOptions::kJustRight, nsAutoString(url), rect, visibleHeight, usingHalfThePage); nsMemory::Free(url); } @@ -455,4 +456,3 @@ nsPageFrame::SetPageNumberFormat(PRUnichar * aFormatStr) } mPageNumFormat = aFormatStr; } - diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index b7fc28298d3..351b6b4fbb4 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -79,9 +79,9 @@ nsSimplePageSequenceFrame::nsSimplePageSequenceFrame() : nsresult rv; NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv); if (NS_SUCCEEDED(rv) && printService) { - PRInt32 printType; + PRInt16 printType; printService->GetPrintRange(&printType); - mIsPrintingSelection = ePrintRange_Selection == nsPrintRange(printType); + mIsPrintingSelection = nsIPrintOptions::kRangeSelection == printType; } } @@ -372,24 +372,23 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, NS_ENSURE_ARG_POINTER(aPresContext); NS_ENSURE_ARG_POINTER(aPrintOptions); - nsPrintRange printRangeType; + PRInt32 printRangeType; PRInt32 fromPageNum; PRInt32 toPageNum; - PRInt32 marginL, marginR, marginT, marginB; PRBool printEvenPages, printOddPages; - PRInt32 printType; + PRInt16 printType; aPrintOptions->GetPrintRange(&printType); - printRangeType = (nsPrintRange)printType; - aPrintOptions->GetPageRange(&fromPageNum, &toPageNum); - aPrintOptions->GetMargins(&marginT, &marginL, &marginR, &marginB); - mMargin.SizeTo(nscoord(marginL), nscoord(marginT), nscoord(marginR), nscoord(marginB)); + printRangeType = printType; + aPrintOptions->GetStartPageRange(&fromPageNum); + aPrintOptions->GetEndPageRange(&toPageNum); + aPrintOptions->GetMarginInTwips(mMargin); - aPrintOptions->GetPrintOptions(NS_PRINT_OPTIONS_PRINT_EVEN_PAGES, &printEvenPages); - aPrintOptions->GetPrintOptions(NS_PRINT_OPTIONS_PRINT_ODD_PAGES, &printOddPages); + aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintEvenPages, &printEvenPages); + aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintOddPages, &printOddPages); - PRBool doingPageRange = ePrintRange_SpecifiedPageRange == printRangeType || - ePrintRange_Selection == printRangeType; + PRBool doingPageRange = nsIPrintOptions::kRangeSpecifiedPageRange == printRangeType || + nsIPrintOptions::kRangeSelection == printRangeType; // If printing a range of pages make sure at least the starting page // number is valid @@ -441,11 +440,11 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, pageNum++; } } - printf("***** Setting aPresContext %p is painting selection %d\n", aPresContext, ePrintRange_Selection == printRangeType); + printf("***** Setting aPresContext %p is painting selection %d\n", aPresContext, nsIPrintOptions::kRangeSelection == printRangeType); #endif // Determine if we are rendering only the selection - aPresContext->SetIsRenderingOnlySelection(ePrintRange_Selection == printRangeType); + aPresContext->SetIsRenderingOnlySelection(nsIPrintOptions::kRangeSelection == printRangeType); if (doingPageRange) { @@ -482,7 +481,7 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, } // adjust total number of pages - if (ePrintRange_Selection == printRangeType) { + if (nsIPrintOptions::kRangeSelection == printRangeType) { totalPages = toPageNum - fromPageNum + 1; } else { totalPages = pageNum - 1; @@ -517,7 +516,7 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, // Now go get the Localized Page Formating String PRBool doingPageTotals = PR_TRUE; - aPrintOptions->GetPrintOptions(NS_PRINT_OPTIONS_PRINT_PAGE_TOTAL, &doingPageTotals); + aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintPageTotal, &doingPageTotals); nsAutoString pageFormatStr; rv = nsFormControlHelper::GetLocalizedString(PRINTING_PROPERTIES, @@ -627,8 +626,8 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, } } - if (ePrintRange_Selection != printRangeType || - (ePrintRange_Selection == printRangeType && printThisPage)) { + if (nsIPrintOptions::kRangeSelection != printRangeType || + (nsIPrintOptions::kRangeSelection == printRangeType && printThisPage)) { printedPageNum++; } diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 1bab5ea65c2..30bdd525bc2 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -218,15 +218,15 @@ nscoord nsPageFrame::GetXPosition(nsIRenderingContext& aRenderingContext, nscoord x = aRect.x; switch (aJust) { - case NS_PRINT_JUSTIFY_LEFT: + case nsIPrintOptions::kJustLeft: // do nothing, already set break; - case NS_PRINT_JUSTIFY_CENTER: + case nsIPrintOptions::kJustCenter: x += (aRect.width - width) / 2; break; - case NS_PRINT_JUSTIFY_RIGHT: + case nsIPrintOptions::kJustRight: x += aRect.width - width; break; } // switch @@ -314,7 +314,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) { // get the current margin - mPrintOptions->GetMargin(mMargin); + mPrintOptions->GetMarginInTwips(mMargin); nsRect rect(0,0,mRect.width, mRect.height); @@ -353,13 +353,13 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, mPrintOptions->GetPrintOptionsBits(&printOptBits); // print page numbers - if (printOptBits & NS_PRINT_OPTIONS_PRINT_PAGE_NUMS && mPageNumFormat != nsnull) { - PRInt32 justify = NS_PRINT_JUSTIFY_LEFT; + if (printOptBits & nsIPrintOptions::kOptPrintPageNums && mPageNumFormat != nsnull) { + PRInt16 justify = nsIPrintOptions::kJustLeft; mPrintOptions->GetPageNumJust(&justify); PRUnichar * valStr; // print page number totals "x of x" - if (printOptBits & NS_PRINT_OPTIONS_PRINT_PAGE_TOTAL) { + if (printOptBits & nsIPrintOptions::kOptPrintPageTotal) { valStr = nsTextFormatter::smprintf(mPageNumFormat, mPageNum, mTotNumPages); } else { valStr = nsTextFormatter::smprintf(mPageNumFormat, mPageNum); @@ -370,7 +370,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, } // print localized date - if (printOptBits & NS_PRINT_OPTIONS_PRINT_DATE_PRINTED) { + if (printOptBits & nsIPrintOptions::kOptPrintDatePrinted) { // Get Locale for Formating DateTime nsCOMPtr locale; NS_WITH_SERVICE(nsILocaleService, localeSvc, kLocaleServiceCID, &rv); @@ -390,7 +390,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, time( <ime ); rv = dateTime->FormatTMTime(locale, kDateFormatShort, kTimeFormatNoSeconds, localtime( <ime ), dateString); if (NS_SUCCEEDED(rv)) { - DrawHeaderFooter(aRenderingContext, this, eFooter, NS_PRINT_JUSTIFY_RIGHT, dateString, rect, visibleHeight); + DrawHeaderFooter(aRenderingContext, this, eFooter, nsIPrintOptions::kJustRight, dateString, rect, visibleHeight); } } } @@ -398,21 +398,22 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, } - PRBool usingHalfThePage = (printOptBits & NS_PRINT_OPTIONS_PRINT_DOC_TITLE) && (printOptBits & NS_PRINT_OPTIONS_PRINT_DOC_LOCATION); + PRBool usingHalfThePage = (printOptBits & nsIPrintOptions::kOptPrintDocTitle) && + (printOptBits & nsIPrintOptions::kOptPrintDocLoc); // print document title PRUnichar * title; mPrintOptions->GetTitle(&title); // creates memory - if (title != nsnull && (printOptBits & NS_PRINT_OPTIONS_PRINT_DOC_TITLE)) { - DrawHeaderFooter(aRenderingContext, this, eHeader, NS_PRINT_JUSTIFY_LEFT, nsAutoString(title), rect, visibleHeight, usingHalfThePage); + if (title != nsnull && (printOptBits & nsIPrintOptions::kOptPrintDocTitle)) { + DrawHeaderFooter(aRenderingContext, this, eHeader, nsIPrintOptions::kJustLeft, nsAutoString(title), rect, visibleHeight, usingHalfThePage); nsMemory::Free(title); } // print document URL PRUnichar * url; - mPrintOptions->GetURL(&url); - if (title != url && (printOptBits & NS_PRINT_OPTIONS_PRINT_DOC_LOCATION)) { - DrawHeaderFooter(aRenderingContext, this, eHeader, NS_PRINT_JUSTIFY_RIGHT, nsAutoString(url), rect, visibleHeight, usingHalfThePage); + mPrintOptions->GetDocURL(&url); + if (title != url && (printOptBits & nsIPrintOptions::kOptPrintDocLoc)) { + DrawHeaderFooter(aRenderingContext, this, eHeader, nsIPrintOptions::kJustRight, nsAutoString(url), rect, visibleHeight, usingHalfThePage); nsMemory::Free(url); } @@ -455,4 +456,3 @@ nsPageFrame::SetPageNumberFormat(PRUnichar * aFormatStr) } mPageNumFormat = aFormatStr; } - diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp index b7fc28298d3..351b6b4fbb4 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp @@ -79,9 +79,9 @@ nsSimplePageSequenceFrame::nsSimplePageSequenceFrame() : nsresult rv; NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv); if (NS_SUCCEEDED(rv) && printService) { - PRInt32 printType; + PRInt16 printType; printService->GetPrintRange(&printType); - mIsPrintingSelection = ePrintRange_Selection == nsPrintRange(printType); + mIsPrintingSelection = nsIPrintOptions::kRangeSelection == printType; } } @@ -372,24 +372,23 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, NS_ENSURE_ARG_POINTER(aPresContext); NS_ENSURE_ARG_POINTER(aPrintOptions); - nsPrintRange printRangeType; + PRInt32 printRangeType; PRInt32 fromPageNum; PRInt32 toPageNum; - PRInt32 marginL, marginR, marginT, marginB; PRBool printEvenPages, printOddPages; - PRInt32 printType; + PRInt16 printType; aPrintOptions->GetPrintRange(&printType); - printRangeType = (nsPrintRange)printType; - aPrintOptions->GetPageRange(&fromPageNum, &toPageNum); - aPrintOptions->GetMargins(&marginT, &marginL, &marginR, &marginB); - mMargin.SizeTo(nscoord(marginL), nscoord(marginT), nscoord(marginR), nscoord(marginB)); + printRangeType = printType; + aPrintOptions->GetStartPageRange(&fromPageNum); + aPrintOptions->GetEndPageRange(&toPageNum); + aPrintOptions->GetMarginInTwips(mMargin); - aPrintOptions->GetPrintOptions(NS_PRINT_OPTIONS_PRINT_EVEN_PAGES, &printEvenPages); - aPrintOptions->GetPrintOptions(NS_PRINT_OPTIONS_PRINT_ODD_PAGES, &printOddPages); + aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintEvenPages, &printEvenPages); + aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintOddPages, &printOddPages); - PRBool doingPageRange = ePrintRange_SpecifiedPageRange == printRangeType || - ePrintRange_Selection == printRangeType; + PRBool doingPageRange = nsIPrintOptions::kRangeSpecifiedPageRange == printRangeType || + nsIPrintOptions::kRangeSelection == printRangeType; // If printing a range of pages make sure at least the starting page // number is valid @@ -441,11 +440,11 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, pageNum++; } } - printf("***** Setting aPresContext %p is painting selection %d\n", aPresContext, ePrintRange_Selection == printRangeType); + printf("***** Setting aPresContext %p is painting selection %d\n", aPresContext, nsIPrintOptions::kRangeSelection == printRangeType); #endif // Determine if we are rendering only the selection - aPresContext->SetIsRenderingOnlySelection(ePrintRange_Selection == printRangeType); + aPresContext->SetIsRenderingOnlySelection(nsIPrintOptions::kRangeSelection == printRangeType); if (doingPageRange) { @@ -482,7 +481,7 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, } // adjust total number of pages - if (ePrintRange_Selection == printRangeType) { + if (nsIPrintOptions::kRangeSelection == printRangeType) { totalPages = toPageNum - fromPageNum + 1; } else { totalPages = pageNum - 1; @@ -517,7 +516,7 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, // Now go get the Localized Page Formating String PRBool doingPageTotals = PR_TRUE; - aPrintOptions->GetPrintOptions(NS_PRINT_OPTIONS_PRINT_PAGE_TOTAL, &doingPageTotals); + aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintPageTotal, &doingPageTotals); nsAutoString pageFormatStr; rv = nsFormControlHelper::GetLocalizedString(PRINTING_PROPERTIES, @@ -627,8 +626,8 @@ nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext, } } - if (ePrintRange_Selection != printRangeType || - (ePrintRange_Selection == printRangeType && printThisPage)) { + if (nsIPrintOptions::kRangeSelection != printRangeType || + (nsIPrintOptions::kRangeSelection == printRangeType && printThisPage)) { printedPageNum++; } diff --git a/mozilla/widget/src/build/widget.rc b/mozilla/widget/src/build/widget.rc index 8d1268cb089..f19ff77fd50 100644 --- a/mozilla/widget/src/build/widget.rc +++ b/mozilla/widget/src/build/widget.rc @@ -20,6 +20,8 @@ * Contributor(s): */ #include "..\\windows\\resource.h" +#include +#include IDC_SELECTANCHOR CURSOR DISCARDABLE "res\\select.cur" IDC_ARROWSOUTH CURSOR DISCARDABLE "res\\arrow_south.cur" @@ -35,3 +37,52 @@ IDC_GRABBING CURSOR DISCARDABLE "res\\grabbing.cur" IDC_CELL CURSOR DISCARDABLE "res\\cell.cur" IDC_COPY CURSOR DISCARDABLE "res\\copy.cur" IDC_ALIAS CURSOR DISCARDABLE "res\\aliasb.cur" + +PRINTDLGNEW DIALOG DISCARDABLE 32, 32, 288, 226 +STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +CAPTION "Print" +FONT 8, "MS Sans Serif" +BEGIN + GROUPBOX "Printer",grp4,8,4,272,84,WS_GROUP + LTEXT "&Name:",stc6,16,20,36,8 + COMBOBOX cmb4,52,18,152,152,CBS_DROPDOWNLIST | CBS_SORT | + WS_VSCROLL | WS_GROUP | WS_TABSTOP + PUSHBUTTON "&Properties",psh2,212,17,60,14,WS_GROUP + LTEXT "Status:",stc8,16,36,36,10,SS_NOPREFIX + LTEXT "",stc12,52,36,224,10,SS_NOPREFIX | SS_LEFTNOWORDWRAP + LTEXT "Type:",stc7,16,48,36,10,SS_NOPREFIX + LTEXT "",stc11,52,48,224,10,SS_NOPREFIX | SS_LEFTNOWORDWRAP + LTEXT "Where:",stc10,16,60,36,10,SS_NOPREFIX + LTEXT "",stc14,52,60,224,10,SS_NOPREFIX | SS_LEFTNOWORDWRAP + LTEXT "Comment:",stc9,16,72,36,10,SS_NOPREFIX + LTEXT "",stc13,52,72,152,10,SS_NOPREFIX | SS_LEFTNOWORDWRAP + CONTROL "Print to fi&le",chx1,"Button",BS_AUTOCHECKBOX | + WS_GROUP | WS_TABSTOP,212,70,64,12 + GROUPBOX "Print range",grp1,8,92,144,64,WS_GROUP + CONTROL "&All",rad1,"Button",BS_AUTORADIOBUTTON | WS_GROUP | + WS_TABSTOP,16,106,64,12 + CONTROL "Pa&ges",rad3,"Button",BS_AUTORADIOBUTTON,16,122,36,12 + CONTROL "&Selection",rad2,"Button",BS_AUTORADIOBUTTON,16,138,64, + 12 + RTEXT "&from:",stc2,52,124,20,8 + EDITTEXT edt1,74,122,26,12,WS_GROUP | ES_NUMBER + RTEXT "&to:",stc3,100,124,16,8 + EDITTEXT edt2,118,122,26,12,WS_GROUP | ES_NUMBER + GROUPBOX "Copies",grp2,160,92,120,64,WS_GROUP + LTEXT "Number of &copies:",stc5,168,108,68,8 + EDITTEXT edt3,240,106,32,12,WS_GROUP | ES_NUMBER + ICON "",ico3,162,124,76,24,WS_GROUP | SS_CENTERIMAGE + CONTROL "C&ollate",chx2,"Button",BS_AUTOCHECKBOX | WS_GROUP | + WS_TABSTOP,240,130,36,12 + GROUPBOX "Print Frames",grp3,8,160,144,61,WS_GROUP + CONTROL "As &layed out on the screen",rad4,"Button", + BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,16,174,100,10 + CONTROL "The selected &frame",rad5,"Button", + BS_AUTORADIOBUTTON | WS_TABSTOP,16,189,77,10 + CONTROL "&Each frame separately",rad6,"Button", + BS_AUTORADIOBUTTON | WS_TABSTOP,16,204,86,10 + DEFPUSHBUTTON "OK",IDOK,180,207,48,14,WS_GROUP + PUSHBUTTON "Cancel",IDCANCEL,232,207,48,14 +END + diff --git a/mozilla/xpfe/global/resources/content/unix/printdialog.js b/mozilla/xpfe/global/resources/content/unix/printdialog.js index 79ccb4c5bbd..4f448c6d5bd 100644 --- a/mozilla/xpfe/global/resources/content/unix/printdialog.js +++ b/mozilla/xpfe/global/resources/content/unix/printdialog.js @@ -21,10 +21,11 @@ */ var dialog; -var prefs = null; +var printService = null; -var default_command = "lpr"; -var default_file = "mozilla.ps"; +var default_command = "lpr"; +var default_file = "mozilla.ps"; +var gPrintOptInterface = Components.interfaces.nsIPrintOptions; function initDialog() { @@ -62,6 +63,11 @@ function initDialog() dialog.topageInput = document.getElementById("topageInput"); dialog.topageLabel = document.getElementById("topageLabel"); + dialog.aslayedoutRadio = document.getElementById("aslayedoutRadio"); + dialog.selectedframeRadio = document.getElementById("selectedframeRadio"); + dialog.eachframesepRadio = document.getElementById("eachframesepRadio"); + dialog.printrangeGroupLabel = document.getElementById("printrangeGroupLabel"); + dialog.topInput = document.getElementById("topInput"); dialog.bottomInput = document.getElementById("bottomInput"); dialog.leftInput = document.getElementById("leftInput"); @@ -92,7 +98,7 @@ function checkValid(elementID) function doPrintToFile( value ) { - if (value == true ) { + if (value ) { dialog.fileLabel.removeAttribute("disabled"); dialog.cmdLabel.setAttribute("disabled","true" ); dialog.fileInput.removeAttribute("disabled"); @@ -109,7 +115,7 @@ function doPrintToFile( value ) function doPrintRange( value ) { - if ( value == true) { + if ( value) { dialog.frompageInput.removeAttribute("disabled"); dialog.frompageLabel.removeAttribute("disabled"); dialog.topageInput.removeAttribute("disabled"); @@ -122,51 +128,84 @@ function doPrintRange( value ) } } +function getDoubleStr( val, dec ) +{ + var str = val.toString(); + inx = str.indexOf("."); + return str.substring(0, inx+dec+1); +} + function loadDialog() { - var print_tofile = false; - var print_reversed = false; - var print_color = true; - var print_landscape = true; - var print_paper_size = 0; - var print_margin_top = 500; - var print_margin_left = 500; - var print_margin_bottom = 500; - var print_margin_right = 500; - var print_command = default_command; - var print_file = default_file; + var print_tofile = false; + var print_reversed = false; + var print_color = true; + var print_paper_size = 0; + var print_margin_top = 0.5; + var print_margin_left = 0.5; + var print_margin_bottom = 0.5; + var print_margin_right = 0.5; + var print_command = default_command; + var print_file = default_file; var print_selection_radio_enabled = false; + var print_isFrame = false; + var print_frametype = gPrintOptInterface.kSelectedFrame; try { - prefs = Components.classes["@mozilla.org/preferences;1"]; - if (prefs) { - prefs = prefs.getService(); - if (prefs) - prefs = prefs.QueryInterface(Components.interfaces.nsIPref); + printService = Components.classes["@mozilla.org/gfx/printoptions;1"]; + if (printService) { + printService = printService.getService(); + if (printService) { + printService = printService.QueryInterface(Components.interfaces.nsIPrintOptions); + } } - } catch(e) { } + } catch(e) {} - if (prefs) { - try { print_tofile = prefs.GetBoolPref("print.print_tofile"); } catch(e) { } - try { print_reversed = prefs.GetBoolPref("print.print_reversed"); } catch(e) { } - try { print_color = prefs.GetBoolPref("print.print_color"); } catch(e) { } - try { print_paper_size = prefs.GetIntPref("print.print_paper_size"); } catch(e) { } - // - // margins are set/get with the _js extention because we aren't converting them to twips - // the are multiplied by a 1000, i.e. 0.5 inches equals 500 - // - try { print_margin_top = prefs.GetIntPref("print.print_margin_top_js"); } catch(e) { } - try { print_margin_left = prefs.GetIntPref("print.print_margin_left_js"); } catch(e) { } - try { print_margin_bottom = prefs.GetIntPref("print.print_margin_bottom_js"); } catch(e) { } - try { print_margin_right = prefs.GetIntPref("print.print_margin_right_js"); } catch(e) { } + if (printService) { + print_reversed = printService.printReversed; + print_color = printService.printInColor; + print_paper_size = printService.paperSize; - try { print_command = prefs.CopyCharPref("print.print_command"); } catch(e) { } - try { print_file = prefs.CopyCharPref("print.print_file"); } catch(e) { } - try { print_tofile = prefs.GetBoolPref("print.print_tofile"); } catch(e) { } - try { print_selection_radio_enabled = prefs.GetBoolPref("print.selection_radio_enabled"); } catch(e) { } + print_margin_top = printService.marginTop; + print_margin_left = printService.marginLeft; + print_margin_right = printService.marginRight; + print_margin_bottom = printService.marginBottom; + + print_command = printService.printCommand; + print_file = printService.toFileName; + print_tofile = printService.printToFile; + print_frametype = printService.printFrameType; + print_isFrame = printService.isPrintFrame; + print_selection_radio_enabled = printService.GetPrintOptions(gPrintOptInterface.kPrintOptionsEnableSelectionRB); + } else { + dump("printService is null\n"); + } + dump("printReversed "+print_reversed+"\n"); + dump("printInColor "+print_color+"\n"); + dump("paperSize "+print_paper_size+"\n"); + dump("printCommand "+print_command+"\n"); + dump("toFileName "+print_file+"\n"); + dump("printToFile "+print_tofile+"\n"); + dump("printToFile "+print_tofile+"\n"); + dump("print_frame "+print_frametype+"\n"); + dump("print_isFrame "+print_isFrame+"\n"); + + dump("selection_radio_enabled "+print_selection_radio_enabled+"\n"); + + dump("print_margin_top "+print_margin_top+"\n"); + dump("print_margin_left "+print_margin_left+"\n"); + dump("print_margin_right "+print_margin_right+"\n"); + dump("print_margin_bottom "+print_margin_bottom+"\n"); + + if (print_file == "") { + print_file = default_file; } - if ( print_tofile == true) { + if (print_command == "") { + print_command = default_command; + } + + if ( print_tofile) { dialog.fileRadio.checked = true; doPrintToFile( true ); } else { @@ -174,30 +213,30 @@ function loadDialog() doPrintToFile( false ); } - if ( print_color == true) { + if ( print_color) { dialog.colorRadio.checked = true; } else { dialog.grayRadio.checked = true; } - if ( print_reversed == true) { + if ( print_reversed) { dialog.lastRadio.checked = true; } else { dialog.firstRadio.checked = true; } - if ( print_paper_size == 0 ) { + if ( print_paper_size == gPrintOptInterface.kLetterPaperSize ) { dialog.letterRadio.checked = true; - } else if ( print_paper_size == 1 ) { + } else if ( print_paper_size == gPrintOptInterface.kLegalPaperSize ) { dialog.legalRadio.checked = true; - } else if ( print_paper_size == 2 ) { + } else if ( print_paper_size == gPrintOptInterface.kExecutivePaperSize ) { dialog.exectiveRadio.checked = true; - } else if ( print_paper_size == 3 ) { + } else if ( print_paper_size == gPrintOptInterface.kA4PaperSize ) { dialog.a4Radio.checked = true; } dialog.allpagesRadio.checked = true; - if ( print_selection_radio_enabled == true) { + if ( print_selection_radio_enabled) { dialog.selectionRadio.removeAttribute("disabled"); } else { dialog.selectionRadio.setAttribute("disabled","true" ); @@ -206,17 +245,41 @@ function loadDialog() dialog.frompageInput.value = 1; dialog.topageInput.value = 1; - // convert back to inches - dialog.topInput.value = print_margin_top * 0.001; - dialog.bottomInput.value = print_margin_bottom * 0.001; - dialog.leftInput.value = print_margin_left * 0.001; - dialog.rightInput.value = print_margin_right * 0.001; + dialog.topInput.value = getDoubleStr(print_margin_top, 1); + dialog.bottomInput.value = getDoubleStr(print_margin_bottom, 1); + dialog.leftInput.value = getDoubleStr(print_margin_left, 1); + dialog.rightInput.value = getDoubleStr(print_margin_right, 1); - dialog.cmdInput.value = print_command; - dialog.fileInput.value = print_file; + dialog.cmdInput.value = print_command; + dialog.fileInput.value = print_file; dialog.print.setAttribute("value", - document.getElementById("printButton").getAttribute("value")); + document.getElementById("printButton").getAttribute("value")); + + // print frame + if ( print_isFrame ) { + dialog.aslayedoutRadio.removeAttribute("disabled"); + dialog.selectedframeRadio.removeAttribute("disabled"); + dialog.eachframesepRadio.removeAttribute("disabled"); + dialog.printrangeGroupLabel.removeAttribute("disabled"); + + if (print_frametype == gPrintOptInterface.kFramesAsIs) { + dialog.aslayedoutRadio.checked = true; + + } else if (print_frametype == gPrintOptInterface.kSelectedFrame) { + dialog.selectedframeRadio.checked = true; + + } else if (print_frametype == gPrintOptInterface.kEachFrameSep) { + dialog.eachframesepRadio.checked = true; + } + } else { + dialog.aslayedoutRadio.setAttribute("disabled","true" ); + dialog.selectedframeRadio.setAttribute("disabled","true" ); + dialog.eachframesepRadio.setAttribute("disabled","true" ); + dialog.printrangeGroupLabel.setAttribute("disabled","true" ); + + } + } var param; @@ -247,52 +310,56 @@ function onOK() { var print_paper_size = 0; - if (prefs) { + if (printService) { - if (dialog.fileRadio.checked == true) { - prefs.SetBoolPref("print.print_tofile", true); - } else { - prefs.SetBoolPref("print.print_tofile", false); - } + printService.printToFile = dialog.fileRadio.checked; + printService.printReversed = dialog.lastRadio.checked; + printService.printInColor = dialog.colorRadio.checked; - if (dialog.lastRadio.checked == true) { - prefs.SetBoolPref("print.print_reversed", true); - } else { - prefs.SetBoolPref("print.print_reversed", false); + if (dialog.letterRadio.checked) { + print_paper_size = gPrintOptInterface.kLetterPaperSize; + } else if (dialog.legalRadio.checked) { + print_paper_size = gPrintOptInterface.kLegalPaperSize; + } else if (dialog.exectiveRadio.checked) { + print_paper_size = gPrintOptInterface.kExecutivePaperSize; + } else if (dialog.a4Radio.checked) { + print_paper_size = gPrintOptInterface.kA4PaperSize; } - - if (dialog.colorRadio.checked == true) { - prefs.SetBoolPref("print.print_color", true); - } else { - prefs.SetBoolPref("print.print_color", false); - } - - if (dialog.letterRadio.checked == true) { - print_paper_size = 0; - } else if (dialog.legalRadio.checked == true) { - print_paper_size = 1; - } else if (dialog.exectiveRadio.checked == true) { - print_paper_size = 2; - } else if (dialog.a4Radio.checked == true) { - print_paper_size = 3; - } - prefs.SetIntPref("print.print_paper_size", print_paper_size); + printService.paperSize = print_paper_size; // save these out so they can be picked up by the device spec - prefs.SetIntPref("print.print_margin_top_js", dialog.topInput.value * 1000); - prefs.SetIntPref("print.print_margin_left_js", dialog.leftInput.value * 1000); - prefs.SetIntPref("print.print_margin_bottom_js", dialog.bottomInput.value *1000); - prefs.SetIntPref("print.print_margin_right_js", dialog.rightInput.value * 1000); + printService.marginTop = dialog.topInput.value; + printService.marginLeft = dialog.leftInput.value; + printService.marginBottom = dialog.bottomInput.value; + printService.marginRight = dialog.rightInput.value; - prefs.SetCharPref("print.print_command", dialog.cmdInput.value); - prefs.SetCharPref("print.print_file", dialog.fileInput.value); + printService.printCommand = dialog.cmdInput.value; + printService.toFileName = dialog.fileInput.value; - prefs.SetBoolPref("print.print_allpagesrange", dialog.allpagesRadio.checked); - prefs.SetBoolPref("print.print_pagerange", dialog.rangeRadio.checked); - prefs.SetBoolPref("print.print_selectionrange", dialog.selectionRadio.checked); - prefs.SetIntPref("print.print_frompage", dialog.frompageInput.value); - prefs.SetIntPref("print.print_topage", dialog.topageInput.value); + var printtype; + if (dialog.allpagesRadio.checked) { + printtype = gPrintOptInterface.kRangeAllPages; + } else if (dialog.rangeRadio.checked) { + printtype = gPrintOptInterface.kRangeSpecifiedPageRange; + } else if (dialog.selectionRadio.checked) { + printtype = gPrintOptInterface.kRangeSelection; + } + printService.startPageRange = dialog.frompageInput.value; + printService.endPageRange = dialog.topageInput.value; + var frametype; + if (dialog.aslayedoutRadio.checked) { + frametype = gPrintOptInterface.kFramesAsIs; + } else if (dialog.selectedframeRadio.checked) { + frametype = gPrintOptInterface.kSelectedFrame; + } else if (dialog.eachframesepRadio.checked) { + frametype = gPrintOptInterface.kEachFrameSep; + } else { + frametype = gPrintOptInterface.kSelectedFrame; + } + printService.printFrameType = frametype; + } else { + dump("************ printService: "+printService+"\n"); } if (param) { diff --git a/mozilla/xpfe/global/resources/content/unix/printdialog.xul b/mozilla/xpfe/global/resources/content/unix/printdialog.xul index a304ab8f7e2..3febb9de150 100644 --- a/mozilla/xpfe/global/resources/content/unix/printdialog.xul +++ b/mozilla/xpfe/global/resources/content/unix/printdialog.xul @@ -101,6 +101,14 @@ Contributor(s): Masaki Katakai + + + + + + + + diff --git a/mozilla/xpfe/global/resources/locale/en-US/unix/printdialog.dtd b/mozilla/xpfe/global/resources/locale/en-US/unix/printdialog.dtd index e17c2be781c..45293304243 100644 --- a/mozilla/xpfe/global/resources/locale/en-US/unix/printdialog.dtd +++ b/mozilla/xpfe/global/resources/locale/en-US/unix/printdialog.dtd @@ -35,6 +35,11 @@ + + + + +