Bug 381631 - Cannot print pages in Landscape mode. r=pavlov, sr=roc.

This commit is contained in:
kherron@fmailbox.com 2007-06-24 04:20:34 -07:00
parent 771982213b
commit 0a5c57beee
8 changed files with 24 additions and 34 deletions

View File

@ -845,9 +845,9 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
// (this won't break anyone, since page layout mode was never really
// usable)
#endif
PRInt32 pageWidth = 0, pageHeight = 0;
mPresContext->GetPrintSettings()->GetPageSizeInTwips(&pageWidth,
&pageHeight);
double pageWidth = 0, pageHeight = 0;
mPresContext->GetPrintSettings()->GetEffectivePageSize(&pageWidth,
&pageHeight);
mPresContext->SetPageSize(
nsSize(mPresContext->TwipsToAppUnits(pageWidth),
mPresContext->TwipsToAppUnits(pageHeight)));

View File

@ -58,7 +58,7 @@ interface nsIPrintSession;
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(f1094df6-ce0e-42c9-9847-2f663172c38d)]
[scriptable, uuid(89c06ccb-6d41-4846-a8e2-63bfa7bd3157)]
interface nsIPrintSettings : nsISupports
{
@ -178,9 +178,10 @@ interface nsIPrintSettings : nsISupports
PRInt32 GetPrintOptionsBits();
/**
* Returns W/H in Twips from Paper Size H/W
* Get the page size in twips, considering the
* orientation (portrait or landscape).
*/
void GetPageSizeInTwips(out long aWidth, out long aHeight);
void GetEffectivePageSize(out double aWidth, out double aHeight);
/**
* Makes a new copy

View File

@ -402,11 +402,6 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS :: ClosePrintManager()
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecBeOS::GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight)
{
return mPrintSettings->GetPageSizeInTwips(aWidth, aHeight);
}
// Printer Enumerator
nsPrinterEnumeratorBeOS::nsPrinterEnumeratorBeOS()
{

View File

@ -85,8 +85,6 @@ public:
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight);
NS_IMETHOD GetToPrinter( PRBool &aToPrinter );
NS_IMETHOD GetPrinterName ( const char **aPrinter );

View File

@ -403,14 +403,13 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::GetSurfaceForPrinter(gfxASurface **aSurfac
const char *path;
GetPath(&path);
PRInt32 width, height;
GetPageSizeInTwips(&width, &height);
double w, h;
double width, height;
mPrintSettings->GetEffectivePageSize(&width, &height);
// convert twips to points
w = width/20;
h = height/20;
width /= 20;
height /= 20;
printf("\"%s\", %d, %d\n", path, width, height);
DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", path, width, height));
nsresult rv = nsPrintJobFactoryGTK::CreatePrintJob(this, mPrintJob);
if (NS_FAILED(rv))
@ -427,9 +426,9 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::GetSurfaceForPrinter(gfxASurface **aSurfac
return rv;
#ifdef USE_PDF
gfxPDFSurface *surface = new gfxPDFSurface(stream, gfxSize(w, h));
gfxPDFSurface *surface = new gfxPDFSurface(stream, gfxSize(width, height));
#else
gfxPSSurface *surface = new gfxPSSurface(stream, gfxSize(w, h));
gfxPSSurface *surface = new gfxPSSurface(stream, gfxSize(width, height));
#endif
// surface->SetDPI(600, 600);
@ -663,11 +662,6 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::GetDownloadFonts(PRBool &aDownloadFonts)
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK::GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight)
{
return mPrintSettings->GetPageSizeInTwips(aWidth, aHeight);
}
NS_IMETHODIMP nsDeviceContextSpecGTK::GetPrintMethod(PrintMethod &aMethod)
{
return GetPrintMethod(mPrinter, aMethod);

View File

@ -89,7 +89,6 @@ public:
NS_IMETHOD GetUserCancelled(PRBool &aCancel);
NS_IMETHOD GetPrintMethod(PrintMethod &aMethod);
static nsresult GetPrintMethod(const char *aPrinter, PrintMethod &aMethod);
NS_IMETHOD GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight);
NS_IMETHOD GetPaperName(const char **aPaperName);
NS_IMETHOD GetPlexName(const char **aPlexName);
NS_IMETHOD GetResolutionName(const char **aResolutionName);

View File

@ -530,11 +530,10 @@ NS_IMETHODIMP nsDeviceContextSpecWin::GetSurfaceForPrinter(gfxASurface **surface
mPrintSettings->GetToFileName(getter_Copies(filename));
PRInt32 width, height;
mPrintSettings->GetPageSizeInTwips(&width, &height);
double w, h;
mPrintSettings->GetEffectivePageSize(&width, &height);
// convert twips to points
w = width/20;
h = height/20;
width /= 20;
height /= 20;
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
nsresult rv = file->InitWithPath(filename);
@ -546,7 +545,7 @@ NS_IMETHODIMP nsDeviceContextSpecWin::GetSurfaceForPrinter(gfxASurface **surface
if (NS_FAILED(rv))
return rv;
newSurface = new gfxPDFSurface(stream, gfxSize(w, h));
newSurface = new gfxPDFSurface(stream, gfxSize(width, height));
} else {
if (mDevMode) {
HDC dc = ::CreateDC(mDriverName, mDeviceName, NULL, mDevMode);

View File

@ -920,10 +920,9 @@ nsPrintSettings::GetMarginInTwips(nsMargin& aMargin)
/** ---------------------------------------------------
* See documentation in nsPrintOptionsImpl.h
* @update 6/21/00 dwc
*/
NS_IMETHODIMP
nsPrintSettings::GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight)
nsPrintSettings::GetEffectivePageSize(double *aWidth, double *aHeight)
{
if (mPaperSizeUnit == kPaperSizeInches) {
*aWidth = NS_INCHES_TO_TWIPS(float(mPaperWidth));
@ -932,6 +931,11 @@ nsPrintSettings::GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight)
*aWidth = NS_MILLIMETERS_TO_TWIPS(float(mPaperWidth));
*aHeight = NS_MILLIMETERS_TO_TWIPS(float(mPaperHeight));
}
if (kLandscapeOrientation == mOrientation) {
double temp = *aWidth;
*aWidth = *aHeight;
*aHeight = temp;
}
return NS_OK;
}