diff --git a/mozilla/gfx/idl/nsIPrintOptions.idl b/mozilla/gfx/idl/nsIPrintOptions.idl index 8d86cb0aa93..c8da52181d0 100644 --- a/mozilla/gfx/idl/nsIPrintOptions.idl +++ b/mozilla/gfx/idl/nsIPrintOptions.idl @@ -74,6 +74,12 @@ interface nsIPrintOptions : nsISupports const short kA4PaperSize = 3; const short kA3PaperSize = 4; + /** + * Orientation Constants + */ + const short kPortraitOrientation = 0; + const short kLandscapeOrientation = 1; + /** * Print Frame Constants */ @@ -143,6 +149,7 @@ interface nsIPrintOptions : nsISupports 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; diff --git a/mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp b/mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp index a003344583e..0e6c12051a1 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp +++ b/mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp @@ -113,6 +113,7 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS :: Init(PRBool aQuiet) PRBool reversed = PR_FALSE, color = PR_FALSE, landscape = PR_FALSE; PRBool tofile = PR_FALSE; PRInt32 paper_size = NS_LETTER_SIZE; + PRInt32 orientation = NS_PORTRAIT; int ileft = 500, iright = 0, itop = 500, ibottom = 0; char *command; char *printfile = nsnull; @@ -155,6 +156,7 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS :: Init(PRBool aQuiet) (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->GetIntPref("print.print_orientation", &orientation); (void) pPrefs->CopyCharPref("print.print_command", (char **) &command); (void) pPrefs->GetIntPref("print.print_margin_top", &itop); (void) pPrefs->GetIntPref("print.print_margin_left", &ileft); @@ -181,6 +183,7 @@ sprintf( mPrData.command, "lpr" ); mPrData.fpf = !reversed; mPrData.grayscale = !color; mPrData.size = paper_size; + mPrData.orientation = orientation; mPrData.toPrinter = !tofile; // PWD, HOME, or fail @@ -246,9 +249,23 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetPageDimensions ( float &aWidth, floa aWidth = 11.69; aHeight = 16.53; } + + if (mPrData.orientation == NS_LANDSCAPE) { + float temp; + temp = aWidth; + aWidth = aHeight; + aHeight = temp; + } + return NS_OK; } +NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetLandscape ( PRBool &landscape ) +{ + landscape = (mPrData.orientation == NS_LANDSCAPE); + return NS_OK; +} + NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetTopMargin ( float &value ) { value = mPrData.top; diff --git a/mozilla/gfx/src/beos/nsDeviceContextSpecB.h b/mozilla/gfx/src/beos/nsDeviceContextSpecB.h index eaa81ddde2b..88bc491ac40 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextSpecB.h +++ b/mozilla/gfx/src/beos/nsDeviceContextSpecB.h @@ -83,6 +83,8 @@ public: NS_IMETHOD GetPageDimensions (float &aWidth, float &aHeight ); + NS_IMETHOD GetLandscape (PRBool &aLandscape); + NS_IMETHOD GetUserCancelled( PRBool &aCancel ); protected: diff --git a/mozilla/gfx/src/beos/nsPrintdBeOS.h b/mozilla/gfx/src/beos/nsPrintdBeOS.h index c7186942db6..6cd6c38915b 100644 --- a/mozilla/gfx/src/beos/nsPrintdBeOS.h +++ b/mozilla/gfx/src/beos/nsPrintdBeOS.h @@ -38,6 +38,9 @@ PR_BEGIN_EXTERN_C #define NS_EXECUTIVE_SIZE 2 #define NS_A4_SIZE 3 #define NS_A3_SIZE 4 + +#define NS_PORTRAIT 0 +#define NS_LANDSCAPE 1 #endif #ifndef PATH_MAX diff --git a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp index 19980a74aa4..b7f2e4cb8d9 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp +++ b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp @@ -159,6 +159,7 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet) PRBool tofile = PR_FALSE; PRInt16 printRange = nsIPrintOptions::kRangeAllPages; PRInt32 paper_size = NS_LETTER_SIZE; + PRInt32 orientation = NS_PORTRAIT; PRInt32 fromPage = 1; PRInt32 toPage = 1; PRUnichar *command = nsnull; @@ -212,6 +213,7 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet) printService->GetPrintReversed(&reversed); printService->GetPrintInColor(&color); printService->GetPaperSize(&paper_size); + printService->GetOrientation(&orientation); printService->GetPrintCommand(&command); printService->GetPrintRange(&printRange); printService->GetToFileName(&printfile); @@ -251,6 +253,7 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet) mPrData.fpf = !reversed; mPrData.grayscale = !color; mPrData.size = paper_size; + mPrData.orientation = orientation; mPrData.toPrinter = !tofile; // PWD, HOME, or fail @@ -321,9 +324,23 @@ NS_IMETHODIMP nsDeviceContextSpecGTK :: GetPageDimensions ( float &aWidth, float // 297mm X 420mm == 11.69in X 16.53in aWidth = 11.69; aHeight = 16.53; } + + if (mPrData.orientation == NS_LANDSCAPE) { + float temp; + temp = aWidth; + aWidth = aHeight; + aHeight = temp; + } + return NS_OK; } +NS_IMETHODIMP nsDeviceContextSpecGTK :: GetLandscape ( PRBool &landscape ) +{ + landscape = (mPrData.orientation == NS_LANDSCAPE); + return NS_OK; +} + NS_IMETHODIMP nsDeviceContextSpecGTK :: GetTopMargin ( float &value ) { value = mPrData.top; diff --git a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.h b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.h index 37ef234f728..15d0340d406 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.h +++ b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.h @@ -104,6 +104,8 @@ public: NS_IMETHOD GetPageDimensions (float &aWidth, float &aHeight ); + NS_IMETHOD GetLandscape (PRBool &aLandscape); + NS_IMETHOD GetUserCancelled( PRBool &aCancel ); NS_IMETHOD GetPrintMethod(PrintMethod &aMethod ); diff --git a/mozilla/gfx/src/gtk/nsPrintdGTK.h b/mozilla/gfx/src/gtk/nsPrintdGTK.h index 65f6b3c5542..1ac7adb825f 100644 --- a/mozilla/gfx/src/gtk/nsPrintdGTK.h +++ b/mozilla/gfx/src/gtk/nsPrintdGTK.h @@ -38,6 +38,9 @@ PR_BEGIN_EXTERN_C #define NS_EXECUTIVE_SIZE 2 #define NS_A4_SIZE 3 #define NS_A3_SIZE 4 + +#define NS_PORTRAIT 0 +#define NS_LANDSCAPE 1 #endif #ifndef PATH_MAX @@ -53,6 +56,7 @@ typedef struct unixprdata { PRBool fpf; /* If PR_TRUE, first page first */ PRBool grayscale; /* If PR_TRUE, print grayscale */ int size; /* Paper size e.g., SizeLetter */ + int orientation; /* Orientation e.g. Portrait */ char command[ PATH_MAX ]; /* Print command e.g., lpr */ char path[ PATH_MAX ]; /* If toPrinter = PR_FALSE, dest file */ PRBool cancel; /* If PR_TRUE, user cancelled */ diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.cpp b/mozilla/gfx/src/nsPrintOptionsImpl.cpp index 45f6f444cf4..7345f53a592 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.cpp +++ b/mozilla/gfx/src/nsPrintOptionsImpl.cpp @@ -72,6 +72,7 @@ const char * kPrintDate = "print.print_date"; const char * kPrintReversed = "print.print_reversed"; const char * kPrintColor = "print.print_color"; const char * kPrintPaperSize = "print.print_paper_size"; +const char * kPrintOrientation= "print.print_orientation"; const char * kPrintCommand = "print.print_command"; const char * kPrintFile = "print.print_file"; const char * kPrintToFile = "print.print_tofile"; @@ -102,6 +103,7 @@ nsPrintOptions::nsPrintOptions() : mPrintReversed(PR_FALSE), mPrintInColor(PR_TRUE), mPaperSize(kLetterPaperSize), + mOrientation(kPortraitOrientation), mPrintToFile(PR_FALSE), mPrintFrameType(kFramesAsIs), mHowToEnableFrameUI(kFrameEnableNone), @@ -282,6 +284,7 @@ nsPrintOptions::ReadPrefs() prefs->GetBoolPref(kPrintReversed, &mPrintReversed); prefs->GetBoolPref(kPrintColor, &mPrintInColor); prefs->GetIntPref(kPrintPaperSize, &mPaperSize); + prefs->GetIntPref(kPrintOrientation, &mOrientation); ReadPrefString(prefs, kPrintCommand, mPrintCommand); prefs->GetBoolPref(kPrintFile, &mPrintToFile); ReadPrefString(prefs, kPrintToFile, mToFileName); @@ -320,6 +323,7 @@ nsPrintOptions::WritePrefs() prefs->SetBoolPref(kPrintReversed, mPrintReversed); prefs->SetBoolPref(kPrintColor, mPrintInColor); prefs->SetIntPref(kPrintPaperSize, mPaperSize); + prefs->SetIntPref(kPrintOrientation, mOrientation); WritePrefString(prefs, kPrintCommand, mPrintCommand); prefs->SetBoolPref(kPrintFile, mPrintToFile); WritePrefString(prefs, kPrintToFile, mToFileName); @@ -395,6 +399,19 @@ NS_IMETHODIMP nsPrintOptions::SetPaperSize(PRInt32 aPaperSize) return NS_OK; } +/* attribute short orientation; */ +NS_IMETHODIMP nsPrintOptions::GetOrientation(PRInt32 *aOrientation) +{ + //NS_ENSURE_ARG_POINTER(aOrientation); + *aOrientation = mOrientation; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetOrientation(PRInt32 aOrientation) +{ + mOrientation = aOrientation; + return NS_OK; +} + /* attribute wstring printCommand; */ NS_IMETHODIMP nsPrintOptions::GetPrintCommand(PRUnichar * *aPrintCommand) { diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.h b/mozilla/gfx/src/nsPrintOptionsImpl.h index d0d6ca6f76b..4bbed4a04d9 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.h +++ b/mozilla/gfx/src/nsPrintOptionsImpl.h @@ -73,6 +73,7 @@ protected: PRBool mPrintReversed; PRBool mPrintInColor; // a false means grayscale PRInt32 mPaperSize; // see page size consts + PRInt32 mOrientation; // see orientation consts nsString mPrintCommand; PRBool mPrintToFile; nsString mToFileName; diff --git a/mozilla/gfx/src/ps/nsIDeviceContextSpecPS.h b/mozilla/gfx/src/ps/nsIDeviceContextSpecPS.h index f95613421d1..3e88c53fbea 100644 --- a/mozilla/gfx/src/ps/nsIDeviceContextSpecPS.h +++ b/mozilla/gfx/src/ps/nsIDeviceContextSpecPS.h @@ -111,6 +111,14 @@ public: **/ NS_IMETHOD GetPageDimensions ( float &aWidth, float &aHeight ) = 0; + /* + * If PR_TRUE, user chose Landscape + * @update + * @param aLandscape + * @return + **/ + NS_IMETHOD GetLandscape ( PRBool &aLandscape ) = 0; + /* * If toPrinter = PR_FALSE, dest file * @update diff --git a/mozilla/gfx/src/ps/nsPostScriptObj.cpp b/mozilla/gfx/src/ps/nsPostScriptObj.cpp index 024dc34ac7f..81ef689179e 100644 --- a/mozilla/gfx/src/ps/nsPostScriptObj.cpp +++ b/mozilla/gfx/src/ps/nsPostScriptObj.cpp @@ -242,6 +242,7 @@ nsPostScriptObj::Init( nsIDeviceContextSpecPS *aSpec, PRUnichar * aTitle ) { PRBool isGray, isAPrinter, isFirstPageFirst; int printSize; + int landscape; float fwidth, fheight; char *buf; @@ -313,7 +314,11 @@ nsPostScriptObj::Init( nsIDeviceContextSpecPS *aSpec, PRUnichar * aTitle ) mPrintSetup->header = "header"; mPrintSetup->footer = "footer"; mPrintSetup->sizes = NULL; - mPrintSetup->landscape = PR_FALSE; // Rotated output + + aSpec->GetLandscape( landscape ); + mPrintSetup->landscape = (landscape) ? PR_TRUE : PR_FALSE; // Rotated output + //mPrintSetup->landscape = PR_FALSE; + mPrintSetup->underline = PR_TRUE; // underline links mPrintSetup->scale_images = PR_TRUE; // Scale unsized images which are too big mPrintSetup->scale_pre = PR_FALSE; // do the pre-scaling thing @@ -411,11 +416,15 @@ nsPostScriptObj::initialize_translation(PrintSetup* pi) dup->left = POINT_TO_PAGE(dup->left); dup->bottom = POINT_TO_PAGE(dup->bottom); dup->right = POINT_TO_PAGE(dup->right); +/* if (pi->landscape){ dup->height = POINT_TO_PAGE(pi->width); dup->width = POINT_TO_PAGE(pi->height); //XXX Should I swap the margins too ??? + //XXX kaie: I don't think so... The user still sees the options + // named left margin etc. } +*/ } /** --------------------------------------------------- diff --git a/mozilla/gfx/src/ps/nsPostScriptObj.h b/mozilla/gfx/src/ps/nsPostScriptObj.h index 2f8f55fe6f6..ee1f21f96a7 100644 --- a/mozilla/gfx/src/ps/nsPostScriptObj.h +++ b/mozilla/gfx/src/ps/nsPostScriptObj.h @@ -49,6 +49,9 @@ class nsIImage; #define NS_A4_SIZE 3 #define NS_A3_SIZE 4 +#define NS_PORTRAIT 0 +#define NS_LANDSCAPE 1 + #define N_FONTS 8 #define INCH_TO_PAGE(f) ((int) (.5 + (f)*720)) #define PAGE_TO_POINT_I(f) ((int) ((f) / 10.0)) @@ -140,7 +143,7 @@ struct PrintSetup_ { int width; /* Paper size, # of cols for text xlate */ int height; - + char* header; char* footer; diff --git a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp index 4be4f638c71..778cfcd77b9 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp +++ b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp @@ -140,6 +140,7 @@ NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet) PRBool tofile = PR_FALSE; PRInt16 printRange = nsIPrintOptions::kRangeAllPages; PRInt32 paper_size = NS_LETTER_SIZE; + PRInt32 orientation = NS_PORTRAIT; PRInt32 fromPage = 1; PRInt32 toPage = 1; PRUnichar *command = nsnull; @@ -185,6 +186,7 @@ NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet) printService->GetPrintReversed(&reversed); printService->GetPrintInColor(&color); printService->GetPaperSize(&paper_size); + printService->GetOrientation(&orientation); printService->GetPrintCommand(&command); printService->GetPrintRange(&printRange); printService->GetToFileName(&printfile); @@ -227,6 +229,7 @@ NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet) mPrData.fpf = !reversed; mPrData.grayscale = !color; mPrData.size = paper_size; + mPrData.orientation = orientation; mPrData.toPrinter = !tofile; // PWD, HOME, or fail @@ -301,6 +304,19 @@ NS_IMETHODIMP nsDeviceContextSpecQT::GetPageDimensions(float &aWidth, aHeight = 16.53; } + if (mPrData.orientation == NS_LANDSCAPE) { + float temp; + temp = aWidth; + aWidth = aHeight; + aHeight = temp; + } + + return NS_OK; +} + +NS_IMETHODIMP nsDeviceContextSpecQT::GetLandscape(PRBool &landscape) +{ + landscape = (mPrData.orientation == NS_LANDSCAPE); return NS_OK; } diff --git a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.h b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.h index 2b2f6dc544e..d9ebb32f9c1 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.h +++ b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.h @@ -85,6 +85,8 @@ public: NS_IMETHOD GetPageDimensions(float &aWidth, float &aHeight); + NS_IMETHOD GetLandscape(PRBool &aLandscape); + NS_IMETHOD GetUserCancelled(PRBool &aCancel); protected: diff --git a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp index deaa5c91e4e..dcbc028c558 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp +++ b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp @@ -146,6 +146,7 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet) PRBool tofile = PR_FALSE; PRInt16 printRange = nsIPrintOptions::kRangeAllPages; PRInt32 paper_size = NS_LETTER_SIZE; + PRInt32 orientation = NS_PORTRAIT; PRInt32 fromPage = 1; PRInt32 toPage = 1; PRUnichar *command = nsnull; @@ -199,6 +200,7 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet) printService->GetPrintReversed(&reversed); printService->GetPrintInColor(&color); printService->GetPaperSize(&paper_size); + printService->GetOrientation(&orientation); printService->GetPrintCommand(&command); printService->GetPrintRange(&printRange); printService->GetToFileName(&printfile); @@ -238,6 +240,7 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet) mPrData.fpf = !reversed; mPrData.grayscale = !color; mPrData.size = paper_size; + mPrData.orientation = orientation; mPrData.toPrinter = !tofile; // PWD, HOME, or fail @@ -309,10 +312,23 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::GetPageDimensions(float &aWidth, float &a aWidth = 11.69; aHeight = 16.53; } + + if (mPrData.orientation == NS_LANDSCAPE) { + float temp; + temp = aWidth; + aWidth = aHeight; + aHeight = temp; + } return NS_OK; } +NS_IMETHODIMP nsDeviceContextSpecXlib::GetLandscape(PRBool &landscape) +{ + landscape = (mPrData.orientation == NS_LANDSCAPE); + return NS_OK; +} + NS_IMETHODIMP nsDeviceContextSpecXlib::GetTopMargin(float &value) { value = mPrData.top; diff --git a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.h b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.h index 3f4e9a298b3..37207363efb 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.h +++ b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.h @@ -71,6 +71,7 @@ public: NS_IMETHOD GetCommand(char **aCommand); NS_IMETHOD GetPath (char **aPath); NS_IMETHOD GetPageDimensions(float &aWidth, float &aHeight); + NS_IMETHOD GetLandscape (PRBool &aLandscape); NS_IMETHOD GetUserCancelled(PRBool &aCancel); NS_IMETHOD GetPrintMethod(PrintMethod &aMethod); virtual ~nsDeviceContextSpecXlib(); diff --git a/mozilla/gfx/src/xlib/nsPrintdXlib.h b/mozilla/gfx/src/xlib/nsPrintdXlib.h index eaaec3f0c4b..3fb9d14afa7 100644 --- a/mozilla/gfx/src/xlib/nsPrintdXlib.h +++ b/mozilla/gfx/src/xlib/nsPrintdXlib.h @@ -34,6 +34,9 @@ PR_BEGIN_EXTERN_C #define NS_EXECUTIVE_SIZE 2 #define NS_A4_SIZE 3 #define NS_A3_SIZE 4 + +#define NS_PORTRAIT 0 +#define NS_LANDSCAPE 1 #endif #ifndef PATH_MAX @@ -49,6 +52,7 @@ typedef struct unixprdata { PRBool fpf; /* If PR_TRUE, first page first */ PRBool grayscale; /* If PR_TRUE, print grayscale */ int size; /* Paper size e.g., SizeLetter */ + int orientation; /* Orientation e.g. Portrait */ char command[PATH_MAX]; /* Print command e.g., lpr */ char path[PATH_MAX]; /* If toPrinter = PR_FALSE, dest file */ PRBool cancel; /* If PR_TRUE, user cancelled */ diff --git a/mozilla/gfx/src/xprint/nsIDeviceContextSpecXPrint.h b/mozilla/gfx/src/xprint/nsIDeviceContextSpecXPrint.h index 41e8e17dde1..83166cfe728 100644 --- a/mozilla/gfx/src/xprint/nsIDeviceContextSpecXPrint.h +++ b/mozilla/gfx/src/xprint/nsIDeviceContextSpecXPrint.h @@ -115,6 +115,14 @@ public: **/ NS_IMETHOD GetPageDimensions ( float &aWidth, float &aHeight ) = 0; + /* + * If PR_TRUE, user chose Landscape + * @update + * @param aLandscape + * @return + **/ + NS_IMETHOD GetLandscape ( PRBool &aLandscape ) = 0; + /* * If toPrinter = PR_FALSE, dest file * @update diff --git a/mozilla/gfx/src/xprint/nsXPrintContext.cpp b/mozilla/gfx/src/xprint/nsXPrintContext.cpp index 632e8dbc411..bccdd4d8994 100644 --- a/mozilla/gfx/src/xprint/nsXPrintContext.cpp +++ b/mozilla/gfx/src/xprint/nsXPrintContext.cpp @@ -217,6 +217,7 @@ nsXPrintContext::SetupPrintContext(nsIDeviceContextSpecXp *aSpec) int printSize; float top, bottom, left, right; + int landscape; char *buf; // Get the Attributes @@ -227,7 +228,8 @@ nsXPrintContext::SetupPrintContext(nsIDeviceContextSpecXp *aSpec) aSpec->GetBottomMargin(bottom); aSpec->GetLeftMargin(left); aSpec->GetRightMargin(right); - + aSpec->GetLandscape(landscape); + PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::SetupPrintContext: borders top=%f, bottom=%f, left=%f, right=%f\n", top, bottom, left, right)); @@ -269,11 +271,28 @@ nsXPrintContext::SetupPrintContext(nsIDeviceContextSpecXp *aSpec) dumpXpAttributes(mPDisplay, mPContext); #endif /* DEBUG */ - // Set the Document Attributes - // XpSetAttributes(mPDisplay,mPContext, XPDocAttr,(char *)"*content-orientation: landscape",XPAttrMerge); - // or - // XpuSetContentOrientation(mPDisplay,mPContext, XPDocAttr, "landscape"); - + /* which orientation ? */ + switch (landscape) + { + case 1 /* NS_LANDSCAPE */: + if (XpuSetContentOrientation(mPDisplay,mPContext, XPDocAttr, "landscape") != 1) + { + NS_WARNING("orientation 'landscape' not supported on this printer"); + return NS_ERROR_FAILURE; + } + break; + case 0 /* NS_PORTRAIT */: + if (XpuSetContentOrientation(mPDisplay,mPContext, XPDocAttr, "portrait") != 1) + { + NS_WARNING("orientation 'portrait' not supported on this printer"); + return NS_ERROR_FAILURE; + } + break; + default: + NS_WARNING("unsupported orientation"); + return NS_ERROR_FAILURE; + } + /* set printer context * WARNING: after this point it is no longer allows to change job attributes * only after the XpSetContext() call the alllication is allowed to make diff --git a/mozilla/layout/base/src/nsPrintPreviewContext.cpp b/mozilla/layout/base/src/nsPrintPreviewContext.cpp index 58b1f089201..3889ccf56ee 100644 --- a/mozilla/layout/base/src/nsPrintPreviewContext.cpp +++ b/mozilla/layout/base/src/nsPrintPreviewContext.cpp @@ -132,6 +132,15 @@ PrintPreviewContext::GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) break; } // switch + PRInt32 orientation = nsIPrintOptions::kPortraitOrientation; + printService->GetOrientation(&orientation); + if (orientation == nsIPrintOptions::kLandscapeOrientation) { + // swap + nscoord temp; + temp = aActualRect->width; + aActualRect->width = aActualRect->height; + aActualRect->height = temp; + } } #ifdef NS_DEBUG diff --git a/mozilla/xpfe/global/resources/content/unix/printdialog.js b/mozilla/xpfe/global/resources/content/unix/printdialog.js index 423b0c3a273..8b0a60c60bb 100644 --- a/mozilla/xpfe/global/resources/content/unix/printdialog.js +++ b/mozilla/xpfe/global/resources/content/unix/printdialog.js @@ -57,6 +57,9 @@ function initDialog() dialog.letterRadio = document.getElementById("letterRadio"); dialog.legalRadio = document.getElementById("legalRadio"); dialog.exectiveRadio = document.getElementById("exectiveRadio"); + + dialog.portraitRadio = document.getElementById("portraitRadio"); + dialog.landscapeRadio = document.getElementById("landscapeRadio"); dialog.allpagesRadio = document.getElementById("allpagesRadio"); dialog.rangeRadio = document.getElementById("rangeRadio"); @@ -157,6 +160,7 @@ function loadDialog() var print_reversed = false; var print_color = true; var print_paper_size = 0; + var print_orientation = 0; var print_margin_top = 0.5; var print_margin_left = 0.5; var print_margin_bottom = 0.5; @@ -181,6 +185,7 @@ function loadDialog() print_reversed = printService.printReversed; print_color = printService.printInColor; print_paper_size = printService.paperSize; + print_orientation = printService.orientation; print_margin_top = printService.marginTop; print_margin_left = printService.marginLeft; @@ -199,6 +204,7 @@ function loadDialog() dump("printReversed "+print_reversed+"\n"); dump("printInColor "+print_color+"\n"); dump("paperSize "+print_paper_size+"\n"); + dump("orientation "+print_orientation+"\n"); dump("printCommand "+print_command+"\n"); dump("toFileName "+print_file+"\n"); dump("printToFile "+print_tofile+"\n"); @@ -254,6 +260,12 @@ function loadDialog() dialog.a3Radio.checked = true; } + if ( print_orientation == gPrintOptInterface.kPortraitOrientation ) { + dialog.portraitRadio.checked = true; + } else if ( print_orientation == gPrintOptInterface.kLandscapeOrientation ) { + dialog.landscapeRadio.checked = true; + } + dialog.allpagesRadio.checked = true; if ( print_selection_radio_enabled) { dialog.selectionRadio.removeAttribute("disabled"); @@ -359,6 +371,13 @@ function onOK() print_paper_size = gPrintOptInterface.kA3PaperSize; } printService.paperSize = print_paper_size; + + if (dialog.portraitRadio.checked) { + print_orientation = gPrintOptInterface.kPortraitOrientation; + } else if (dialog.landscapeRadio.checked) { + print_orientation = gPrintOptInterface.kLandscapeOrientation; + } + printService.orientation = print_orientation; // save these out so they can be picked up by the device spec printService.marginTop = dialog.topInput.value; diff --git a/mozilla/xpfe/global/resources/content/unix/printdialog.xul b/mozilla/xpfe/global/resources/content/unix/printdialog.xul index 77ca9c57fb0..1903a50ebed 100644 --- a/mozilla/xpfe/global/resources/content/unix/printdialog.xul +++ b/mozilla/xpfe/global/resources/content/unix/printdialog.xul @@ -88,6 +88,13 @@ 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 d2fabe64264..991772a76f6 100644 --- a/mozilla/xpfe/global/resources/locale/en-US/unix/printdialog.dtd +++ b/mozilla/xpfe/global/resources/locale/en-US/unix/printdialog.dtd @@ -29,6 +29,10 @@ + + + +