зеркало из https://github.com/mozilla/gecko-dev.git
Bug 389949, second patch: rotate landscape-mode printed output in Linux. (so we don't end up printing landscape-oriented content on top of portrait-oriented paper.) r+sr=vlad a=blocking1.9
This commit is contained in:
Родитель
177ed1bc66
Коммит
616bf5f49e
|
@ -38,6 +38,7 @@
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
#include "nsSimplePageSequence.h"
|
#include "nsSimplePageSequence.h"
|
||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
|
#include "gfxContext.h"
|
||||||
#include "nsIRenderingContext.h"
|
#include "nsIRenderingContext.h"
|
||||||
#include "nsGkAtoms.h"
|
#include "nsGkAtoms.h"
|
||||||
#include "nsIDeviceContext.h"
|
#include "nsIDeviceContext.h"
|
||||||
|
@ -619,6 +620,20 @@ nsSimplePageSequenceFrame::PrintNextPage()
|
||||||
PresContext()->PresShell()->
|
PresContext()->PresShell()->
|
||||||
CreateRenderingContext(mCurrentPageFrame,
|
CreateRenderingContext(mCurrentPageFrame,
|
||||||
getter_AddRefs(renderingContext));
|
getter_AddRefs(renderingContext));
|
||||||
|
|
||||||
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||||
|
// On linux, need to rotate landscape-mode output on printed surfaces
|
||||||
|
PRInt32 orientation;
|
||||||
|
mPageData->mPrintSettings->GetOrientation(&orientation);
|
||||||
|
if (nsIPrintSettings::kLandscapeOrientation == orientation) {
|
||||||
|
// Shift up by one landscape-page-height (in points) before we rotate.
|
||||||
|
float offset = POINTS_PER_INCH_FLOAT *
|
||||||
|
(mCurrentPageFrame->GetSize().height / float(dc->AppUnitsPerInch()));
|
||||||
|
renderingContext->ThebesContext()->Translate(gfxPoint(offset, 0));
|
||||||
|
renderingContext->ThebesContext()->Rotate(M_PI/2);
|
||||||
|
}
|
||||||
|
#endif // XP_UNIX && !XP_MACOSX
|
||||||
|
|
||||||
nsRect drawingRect(nsPoint(0, 0),
|
nsRect drawingRect(nsPoint(0, 0),
|
||||||
mCurrentPageFrame->GetSize());
|
mCurrentPageFrame->GetSize());
|
||||||
nsRegion drawingRegion(drawingRect);
|
nsRegion drawingRegion(drawingRect);
|
||||||
|
|
|
@ -1871,7 +1871,20 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
|
||||||
} else {
|
} else {
|
||||||
nscoord pageWidth, pageHeight;
|
nscoord pageWidth, pageHeight;
|
||||||
mPrt->mPrintDC->GetDeviceSurfaceDimensions(pageWidth, pageHeight);
|
mPrt->mPrintDC->GetDeviceSurfaceDimensions(pageWidth, pageHeight);
|
||||||
|
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||||
|
// If we're in landscape mode on Linux, the device surface will have
|
||||||
|
// been rotated, so for the purposes of reflowing content, we'll
|
||||||
|
// treat device's height as our width and its width as our height,
|
||||||
|
PRInt32 orientation;
|
||||||
|
mPrt->mPrintSettings->GetOrientation(&orientation);
|
||||||
|
if (nsIPrintSettings::kLandscapeOrientation == orientation) {
|
||||||
|
adjSize = nsSize(pageHeight, pageWidth);
|
||||||
|
} else {
|
||||||
|
adjSize = nsSize(pageWidth, pageHeight);
|
||||||
|
}
|
||||||
|
#else
|
||||||
adjSize = nsSize(pageWidth, pageHeight);
|
adjSize = nsSize(pageWidth, pageHeight);
|
||||||
|
#endif // XP_UNIX && !XP_MACOSX
|
||||||
documentIsTopLevel = PR_TRUE;
|
documentIsTopLevel = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -417,6 +417,17 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::GetSurfaceForPrinter(gfxASurface **aSurfac
|
||||||
|
|
||||||
double width, height;
|
double width, height;
|
||||||
mPrintSettings->GetEffectivePageSize(&width, &height);
|
mPrintSettings->GetEffectivePageSize(&width, &height);
|
||||||
|
|
||||||
|
// If we're in landscape mode, we'll be rotating the output --
|
||||||
|
// need to swap width & height.
|
||||||
|
PRInt32 orientation;
|
||||||
|
mPrintSettings->GetOrientation(&orientation);
|
||||||
|
if (nsIPrintSettings::kLandscapeOrientation == orientation) {
|
||||||
|
double tmp = width;
|
||||||
|
width = height;
|
||||||
|
height = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// convert twips to points
|
// convert twips to points
|
||||||
width /= TWIPS_PER_POINT_FLOAT;
|
width /= TWIPS_PER_POINT_FLOAT;
|
||||||
height /= TWIPS_PER_POINT_FLOAT;
|
height /= TWIPS_PER_POINT_FLOAT;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче