зеркало из https://github.com/mozilla/pjs.git
Backing out Bug 417356, due to pagination reftest failures.
This commit is contained in:
Родитель
75971f75a6
Коммит
8dd5c85dec
|
@ -47,7 +47,7 @@
|
|||
|
||||
class THEBES_API gfxPDFSurface : public gfxASurface {
|
||||
public:
|
||||
gfxPDFSurface(nsIOutputStream *aStream, const gfxSize& aSizeInPoints);
|
||||
gfxPDFSurface(nsIOutputStream *aStream, const gfxSize& aSizeInPonits);
|
||||
virtual ~gfxPDFSurface();
|
||||
|
||||
virtual nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
class THEBES_API gfxPSSurface : public gfxASurface {
|
||||
public:
|
||||
gfxPSSurface(nsIOutputStream *aStream, const gfxSize& aSizeInPoints);
|
||||
gfxPSSurface(nsIOutputStream *aStream, const gfxSize& aSizeInPonits);
|
||||
virtual ~gfxPSSurface();
|
||||
|
||||
virtual nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
||||
|
|
|
@ -519,13 +519,6 @@ public:
|
|||
{ return NSToCoordRound(NS_TWIPS_TO_INCHES(aTwips) *
|
||||
mDeviceContext->AppUnitsPerInch()); }
|
||||
|
||||
// Margin-specific version, since they often need TwipsToAppUnits
|
||||
nsMargin TwipsToAppUnits(const nsMargin &marginInTwips) const
|
||||
{ return nsMargin(TwipsToAppUnits(marginInTwips.left),
|
||||
TwipsToAppUnits(marginInTwips.top),
|
||||
TwipsToAppUnits(marginInTwips.right),
|
||||
TwipsToAppUnits(marginInTwips.bottom)); }
|
||||
|
||||
PRInt32 AppUnitsToTwips(nscoord aTwips) const
|
||||
{ return NS_INCHES_TO_TWIPS((float)aTwips /
|
||||
mDeviceContext->AppUnitsPerInch()); }
|
||||
|
|
|
@ -198,16 +198,12 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
|||
|
||||
// now get out margins & edges
|
||||
if (mPageData->mPrintSettings) {
|
||||
nsMargin unwriteableTwips;
|
||||
mPageData->mPrintSettings->GetUnwriteableMarginInTwips(unwriteableTwips);
|
||||
NS_ASSERTION(unwriteableTwips.left >= 0 && unwriteableTwips.top >= 0 &&
|
||||
unwriteableTwips.right >= 0 && unwriteableTwips.bottom >= 0,
|
||||
"Unwriteable twips should be non-negative");
|
||||
|
||||
nsMargin marginTwips;
|
||||
mPageData->mPrintSettings->GetMarginInTwips(marginTwips);
|
||||
mMargin = aPresContext->TwipsToAppUnits(marginTwips + unwriteableTwips);
|
||||
|
||||
mMargin = nsMargin(aPresContext->TwipsToAppUnits(marginTwips.left),
|
||||
aPresContext->TwipsToAppUnits(marginTwips.top),
|
||||
aPresContext->TwipsToAppUnits(marginTwips.right),
|
||||
aPresContext->TwipsToAppUnits(marginTwips.bottom));
|
||||
PRInt16 printType;
|
||||
mPageData->mPrintSettings->GetPrintRange(&printType);
|
||||
mPrintRangeType = printType;
|
||||
|
@ -223,7 +219,10 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
|||
edgeTwips.right = PR_MIN(PR_MAX(edgeTwips.right, 0), inchInTwips);
|
||||
|
||||
mPageData->mEdgePaperMargin =
|
||||
aPresContext->TwipsToAppUnits(edgeTwips + unwriteableTwips);
|
||||
nsMargin(aPresContext->TwipsToAppUnits(edgeTwips.left),
|
||||
aPresContext->TwipsToAppUnits(edgeTwips.top),
|
||||
aPresContext->TwipsToAppUnits(edgeTwips.right),
|
||||
aPresContext->TwipsToAppUnits(edgeTwips.bottom));
|
||||
}
|
||||
|
||||
// *** Special Override ***
|
||||
|
|
|
@ -2194,7 +2194,10 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO)
|
|||
mPrt->mPrintSettings->SetEndPageRange(endPageNum);
|
||||
nsMargin marginTwips(0,0,0,0);
|
||||
mPrt->mPrintSettings->GetMarginInTwips(marginTwips);
|
||||
nsMargin margin = poPresContext->TwipsToAppUnits(marginTwips);
|
||||
nsMargin margin(poPresContext->TwipsToAppUnits(marginTwips.left),
|
||||
poPresContext->TwipsToAppUnits(marginTwips.top),
|
||||
poPresContext->TwipsToAppUnits(marginTwips.right),
|
||||
poPresContext->TwipsToAppUnits(marginTwips.bottom));
|
||||
|
||||
if (startPageNum == endPageNum) {
|
||||
{
|
||||
|
|
|
@ -245,26 +245,12 @@ pref("print.whileInPrintPreview", true);
|
|||
// Cache old Presentation when going into Print Preview
|
||||
pref("print.always_cache_old_pres", false);
|
||||
|
||||
// Enables you to specify the amount of the paper that is to be treated
|
||||
// as unwriteable. The print_edge_XXX and print_margin_XXX preferences
|
||||
// are treated as offsets that are added to this pref.
|
||||
// Default is "-1", which means "use the system default". (If there is
|
||||
// no system default, then the -1 is treated as if it were 0.)
|
||||
// This is used by both Printing and Print Preview.
|
||||
// Units are in 1/100ths of an inch.
|
||||
pref("print.print_unwriteable_margin_top", -1);
|
||||
pref("print.print_unwriteable_margin_left", -1);
|
||||
pref("print.print_unwriteable_margin_right", -1);
|
||||
pref("print.print_unwriteable_margin_bottom", -1);
|
||||
|
||||
// Enables you to specify the gap from the edge of the paper's
|
||||
// unwriteable area to the margin.
|
||||
// This is used by both Printing and Print Preview
|
||||
// Units are in 1/100ths of an inch.
|
||||
pref("print.print_edge_top", 0);
|
||||
pref("print.print_edge_left", 0);
|
||||
pref("print.print_edge_right", 0);
|
||||
pref("print.print_edge_bottom", 0);
|
||||
// Enables you to specify the gap from the edge of the paper to the margin
|
||||
// this is used by both Printing and Print Preview
|
||||
pref("print.print_edge_top", 0); // 1/100 of an inch
|
||||
pref("print.print_edge_left", 0); // 1/100 of an inch
|
||||
pref("print.print_edge_right", 0); // 1/100 of an inch
|
||||
pref("print.print_edge_bottom", 0); // 1/100 of an inch
|
||||
|
||||
// Pref used by the spellchecker extension to control the
|
||||
// maximum number of misspelled words that will be underlined
|
||||
|
@ -2127,6 +2113,13 @@ pref("print.print_color", true);
|
|||
pref("print.print_landscape", false);
|
||||
pref("print.print_paper_size", 0);
|
||||
|
||||
// Enables you to specify the gap from the edge of the paper to the margin
|
||||
// this is used by both Printing and Print Preview
|
||||
pref("print.print_edge_top", 4); // 1/100 of an inch
|
||||
pref("print.print_edge_left", 4); // 1/100 of an inch
|
||||
pref("print.print_edge_right", 4); // 1/100 of an inch
|
||||
pref("print.print_edge_bottom", 4); // 1/100 of an inch
|
||||
|
||||
// print_extra_margin enables platforms to specify an extra gap or margin
|
||||
// around the content of the page for Print Preview only
|
||||
pref("print.print_extra_margin", 0); // twips
|
||||
|
|
|
@ -58,7 +58,7 @@ interface nsIPrintSession;
|
|||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[scriptable, uuid(5af07661-6477-4235-8814-4a45215855b8)]
|
||||
[scriptable, uuid(3e097aba-c1d6-425d-9c52-b371d5da964a)]
|
||||
|
||||
interface nsIPrintSettings : nsISupports
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ interface nsIPrintSettings : nsISupports
|
|||
/* Flag 0x00000800 is unused */
|
||||
/* Flag 0x00001000 is unused */
|
||||
const unsigned long kInitSavePaperData = 0x00002000;
|
||||
const unsigned long kInitSaveUnwriteableMargins = 0x00004000;
|
||||
/* Flag 0x00004000 is unused */
|
||||
const unsigned long kInitSaveEdges = 0x00008000;
|
||||
|
||||
const unsigned long kInitSaveReversed = 0x00010000;
|
||||
|
@ -311,16 +311,4 @@ interface nsIPrintSettings : nsISupports
|
|||
* before printing, otherwise printing can fail on some platforms.
|
||||
*/
|
||||
[noscript] void SetupSilentPrinting();
|
||||
|
||||
/**
|
||||
* Sets/Gets the "unwriteable margin" for the page format. This defines
|
||||
* the boundary from which we'll measure the EdgeInTwips and MarginInTwips
|
||||
* attributes, to place the headers and content, respectively.
|
||||
*
|
||||
* Note: Implementations of SetUnwriteableMarginInTwips should handle
|
||||
* negative margin values by falling back on the system default for
|
||||
* that margin.
|
||||
*/
|
||||
[noscript] void SetUnwriteableMarginInTwips(in nsNativeMarginRef aEdge);
|
||||
[noscript] void GetUnwriteableMarginInTwips(in nsNativeMarginRef aEdge);
|
||||
};
|
||||
|
|
|
@ -72,7 +72,9 @@ public:
|
|||
*/
|
||||
NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
|
||||
void GetPaperRect(double* aTop, double* aLeft, double* aBottom, double* aRight);
|
||||
void GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight);
|
||||
void GetPageMargins(double *aTopMargin, double* aLeftMargin,
|
||||
double* aBottomMargin, double *aRightMargin);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
|
|
@ -185,15 +185,31 @@ NS_IMETHODIMP nsDeviceContextSpecX::EndPage()
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
void nsDeviceContextSpecX::GetPaperRect(double* aTop, double* aLeft, double* aBottom, double* aRight)
|
||||
void nsDeviceContextSpecX::GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
PMRect paperRect;
|
||||
::PMGetAdjustedPaperRect(mPageFormat, &paperRect);
|
||||
PMRect pageRect;
|
||||
::PMGetAdjustedPageRect(mPageFormat, &pageRect);
|
||||
*aTop = pageRect.top, *aLeft = pageRect.left;
|
||||
*aBottom = pageRect.bottom, *aRight = pageRect.right;
|
||||
|
||||
*aTop = paperRect.top, *aLeft = paperRect.left;
|
||||
*aBottom = paperRect.bottom, *aRight = paperRect.right;
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
void nsDeviceContextSpecX::GetPageMargins(double *aTopMargin, double* aLeftMargin,
|
||||
double* aBottomMargin, double *aRightMargin)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
PMPaper paper;
|
||||
PMPaperMargins margins;
|
||||
::PMGetPageFormatPaper(mPageFormat, &paper);
|
||||
::PMPaperGetMargins(paper, &margins);
|
||||
*aTopMargin = margins.top;
|
||||
*aLeftMargin = margins.left;
|
||||
*aBottomMargin = margins.bottom;
|
||||
*aRightMargin = margins.right;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
@ -203,7 +219,10 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetSurfaceForPrinter(gfxASurface **surface)
|
|||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
double top, left, bottom, right;
|
||||
GetPaperRect(&top, &left, &bottom, &right);
|
||||
double topMargin, leftMargin, bottomMargin, rightMargin;
|
||||
GetPageRect(&top, &left, &bottom, &right);
|
||||
GetPageMargins(&topMargin, &leftMargin, &bottomMargin, &rightMargin);
|
||||
|
||||
const double width = right - left;
|
||||
const double height = bottom - top;
|
||||
|
||||
|
@ -214,8 +233,8 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetSurfaceForPrinter(gfxASurface **surface)
|
|||
|
||||
if (context) {
|
||||
// Initially, origin is at bottom-left corner of the paper.
|
||||
// Here, we translate it to top-left corner of the paper.
|
||||
CGContextTranslateCTM(context, 0, height);
|
||||
// Here, we translate it to top-left corner of the printable area.
|
||||
CGContextTranslateCTM(context, leftMargin, bottomMargin + height);
|
||||
CGContextScaleCTM(context, 1.0, -1.0);
|
||||
newSurface = new gfxQuartzSurface(context, gfxSize(width, height), PR_TRUE);
|
||||
} else {
|
||||
|
|
|
@ -58,9 +58,6 @@ public:
|
|||
|
||||
nsresult Init();
|
||||
|
||||
// Page format's unwriteable margin
|
||||
nsresult GetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin);
|
||||
|
||||
protected:
|
||||
nsPrintSettingsX(const nsPrintSettingsX& src);
|
||||
nsPrintSettingsX& operator=(const nsPrintSettingsX& rhs);
|
||||
|
|
|
@ -259,23 +259,6 @@ nsresult nsPrintSettingsX::Init()
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::GetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
PMPaper paper;
|
||||
PMPaperMargins margins;
|
||||
::PMGetPageFormatPaper(mPageFormat, &paper);
|
||||
::PMPaperGetMargins(paper, &margins);
|
||||
aUnwriteableMargin.top = NS_POINTS_TO_TWIPS(margins.top);
|
||||
aUnwriteableMargin.left = NS_POINTS_TO_TWIPS(margins.left);
|
||||
aUnwriteableMargin.bottom = NS_POINTS_TO_TWIPS(margins.bottom);
|
||||
aUnwriteableMargin.right = NS_POINTS_TO_TWIPS(margins.right);
|
||||
return NS_OK;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
NS_IMETHODIMP nsPrintSettingsX::GetNativePrintSession(PMPrintSession *aNativePrintSession)
|
||||
|
@ -510,8 +493,8 @@ OSStatus nsPrintSettingsX::CreateDefaultPageFormat(PMPrintSession aSession, PMPa
|
|||
|
||||
outFormat = kPMNoPageFormat;
|
||||
status = ::PMCreatePageFormat(&pageFormat);
|
||||
if (status == noErr && pageFormat != kPMNoPageFormat) {
|
||||
status = ::PMSessionDefaultPageFormat(aSession, pageFormat);
|
||||
if (status == noErr && pageFormat != kPMNoPageFormat) {
|
||||
status = ::PMSessionDefaultPageFormat(aSession, pageFormat);
|
||||
if (status == noErr) {
|
||||
outFormat = pageFormat;
|
||||
return NS_OK;
|
||||
|
|
|
@ -418,8 +418,8 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::GetSurfaceForPrinter(gfxASurface **aSurfac
|
|||
double width, height;
|
||||
mPrintSettings->GetEffectivePageSize(&width, &height);
|
||||
// convert twips to points
|
||||
width /= TWIPS_PER_POINT_FLOAT;
|
||||
height /= TWIPS_PER_POINT_FLOAT;
|
||||
width /= 20;
|
||||
height /= 20;
|
||||
|
||||
DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", path, width, height));
|
||||
nsresult rv;
|
||||
|
|
|
@ -506,6 +506,66 @@ nsPrintSettingsGTK::SetNumCopies(PRInt32 aNumCopies)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute double edgeTop; */
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetEdgeTop(double *aEdgeTop)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEdgeTop);
|
||||
*aEdgeTop = gtk_page_setup_get_top_margin(mPageSetup, GTK_UNIT_INCH);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::SetEdgeTop(double aEdgeTop)
|
||||
{
|
||||
gtk_page_setup_set_top_margin(mPageSetup, aEdgeTop, GTK_UNIT_INCH);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute double edgeLeft; */
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetEdgeLeft(double *aEdgeLeft)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEdgeLeft);
|
||||
*aEdgeLeft = gtk_page_setup_get_left_margin(mPageSetup, GTK_UNIT_INCH);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::SetEdgeLeft(double aEdgeLeft)
|
||||
{
|
||||
gtk_page_setup_set_left_margin(mPageSetup, aEdgeLeft, GTK_UNIT_INCH);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute double edgeBottom; */
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetEdgeBottom(double *aEdgeBottom)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEdgeBottom);
|
||||
*aEdgeBottom = gtk_page_setup_get_bottom_margin(mPageSetup, GTK_UNIT_INCH);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::SetEdgeBottom(double aEdgeBottom)
|
||||
{
|
||||
gtk_page_setup_set_bottom_margin(mPageSetup, aEdgeBottom, GTK_UNIT_INCH);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute double edgeRight; */
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetEdgeRight(double *aEdgeRight)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEdgeRight);
|
||||
*aEdgeRight = gtk_page_setup_get_right_margin(mPageSetup, GTK_UNIT_INCH);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::SetEdgeRight(double aEdgeRight)
|
||||
{
|
||||
gtk_page_setup_set_right_margin(mPageSetup, aEdgeRight, GTK_UNIT_INCH);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute double scaling; */
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetScaling(double *aScaling)
|
||||
|
@ -573,43 +633,6 @@ nsPrintSettingsGTK::SaveNewPageSize()
|
|||
gtk_page_setup_set_paper_size(mPageSetup, mPaperSize);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin)
|
||||
{
|
||||
aUnwriteableMargin.SizeTo(
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_left_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_top_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_right_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_bottom_margin(mPageSetup, GTK_UNIT_INCH))
|
||||
);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Note that margin values less than 0 are treated as "use system default"
|
||||
// (i.e. we'll keep whatever's in mPageSetup)
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin)
|
||||
{
|
||||
if (aUnwriteableMargin.left >= 0) {
|
||||
gtk_page_setup_set_left_margin(mPageSetup,
|
||||
NS_TWIPS_TO_INCHES(aUnwriteableMargin.left), GTK_UNIT_INCH);
|
||||
}
|
||||
if (aUnwriteableMargin.top >= 0) {
|
||||
gtk_page_setup_set_top_margin(mPageSetup,
|
||||
NS_TWIPS_TO_INCHES(aUnwriteableMargin.top), GTK_UNIT_INCH);
|
||||
}
|
||||
if (aUnwriteableMargin.right >= 0) {
|
||||
gtk_page_setup_set_right_margin(mPageSetup,
|
||||
NS_TWIPS_TO_INCHES(aUnwriteableMargin.right), GTK_UNIT_INCH);
|
||||
}
|
||||
if (aUnwriteableMargin.bottom >= 0) {
|
||||
gtk_page_setup_set_bottom_margin(mPageSetup,
|
||||
NS_TWIPS_TO_INCHES(aUnwriteableMargin.bottom), GTK_UNIT_INCH);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute double paperWidth; */
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetPaperWidth(double *aPaperWidth)
|
||||
|
@ -663,6 +686,27 @@ nsPrintSettingsGTK::SetPaperSizeUnit(PRInt16 aPaperSizeUnit)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get/Set our margins as an nsMargin
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::SetEdgeInTwips(nsMargin& aEdge)
|
||||
{
|
||||
gtk_page_setup_set_top_margin(mPageSetup, NS_TWIPS_TO_INCHES(aEdge.top), GTK_UNIT_INCH);
|
||||
gtk_page_setup_set_left_margin(mPageSetup, NS_TWIPS_TO_INCHES(aEdge.left), GTK_UNIT_INCH);
|
||||
gtk_page_setup_set_bottom_margin(mPageSetup, NS_TWIPS_TO_INCHES(aEdge.bottom), GTK_UNIT_INCH);
|
||||
gtk_page_setup_set_right_margin(mPageSetup, NS_TWIPS_TO_INCHES(aEdge.right), GTK_UNIT_INCH);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetEdgeInTwips(nsMargin& aEdge)
|
||||
{
|
||||
aEdge.SizeTo(NS_INCHES_TO_TWIPS(gtk_page_setup_get_left_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_top_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_right_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_bottom_margin(mPageSetup, GTK_UNIT_INCH)));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetEffectivePageSize(double *aWidth, double *aHeight)
|
||||
{
|
||||
|
|
|
@ -114,9 +114,17 @@ public:
|
|||
NS_IMETHOD GetNumCopies(PRInt32 *aNumCopies);
|
||||
NS_IMETHOD SetNumCopies(PRInt32 aNumCopies);
|
||||
|
||||
// Page format's unwriteable margin
|
||||
NS_IMETHOD GetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin);
|
||||
NS_IMETHOD SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin);
|
||||
NS_IMETHOD GetEdgeTop(double *aEdgeTop);
|
||||
NS_IMETHOD SetEdgeTop(double aEdgeTop);
|
||||
|
||||
NS_IMETHOD GetEdgeLeft(double *aEdgeLeft);
|
||||
NS_IMETHOD SetEdgeLeft(double aEdgeLeft);
|
||||
|
||||
NS_IMETHOD GetEdgeBottom(double *aEdgeBottom);
|
||||
NS_IMETHOD SetEdgeBottom(double aEdgeBottom);
|
||||
|
||||
NS_IMETHOD GetEdgeRight(double *aEdgeRight);
|
||||
NS_IMETHOD SetEdgeRight(double aEdgeRight);
|
||||
|
||||
NS_IMETHOD GetScaling(double *aScaling);
|
||||
NS_IMETHOD SetScaling(double aScaling);
|
||||
|
@ -133,6 +141,9 @@ public:
|
|||
|
||||
NS_IMETHOD SetPaperSizeUnit(PRInt16 aPaperSizeUnit);
|
||||
|
||||
NS_IMETHOD SetEdgeInTwips(nsMargin& aEdge);
|
||||
NS_IMETHOD GetEdgeInTwips(nsMargin& aEdge);
|
||||
|
||||
NS_IMETHOD GetEffectivePageSize(double *aWidth, double *aHeight);
|
||||
|
||||
NS_IMETHOD SetupSilentPrinting();
|
||||
|
|
|
@ -367,8 +367,8 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::GetSurfaceForPrinter(gfxASurface **surface
|
|||
double width, height;
|
||||
mPrintSettings->GetEffectivePageSize(&width, &height);
|
||||
// convert twips to points
|
||||
width /= TWIPS_PER_POINT_FLOAT;
|
||||
height /= TWIPS_PER_POINT_FLOAT;
|
||||
width /= 20;
|
||||
height /= 20;
|
||||
|
||||
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
|
||||
rv = file->InitWithPath(filename);
|
||||
|
|
|
@ -528,8 +528,8 @@ NS_IMETHODIMP nsDeviceContextSpecWin::GetSurfaceForPrinter(gfxASurface **surface
|
|||
double width, height;
|
||||
mPrintSettings->GetEffectivePageSize(&width, &height);
|
||||
// convert twips to points
|
||||
width /= TWIPS_PER_POINT_FLOAT;
|
||||
height /= TWIPS_PER_POINT_FLOAT;
|
||||
width /= 20;
|
||||
height /= 20;
|
||||
|
||||
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
|
||||
nsresult rv = file->InitWithPath(filename);
|
||||
|
|
|
@ -74,10 +74,6 @@ static const char kEdgeTop[] = "print_edge_top";
|
|||
static const char kEdgeLeft[] = "print_edge_left";
|
||||
static const char kEdgeBottom[] = "print_edge_bottom";
|
||||
static const char kEdgeRight[] = "print_edge_right";
|
||||
static const char kUnwriteableMarginTop[] = "print_unwriteable_margin_top";
|
||||
static const char kUnwriteableMarginLeft[] = "print_unwriteable_margin_left";
|
||||
static const char kUnwriteableMarginBottom[] = "print_unwriteable_margin_bottom";
|
||||
static const char kUnwriteableMarginRight[] = "print_unwriteable_margin_right";
|
||||
|
||||
// Prefs for Print Options
|
||||
static const char kPrintEvenPages[] = "print_evenpages";
|
||||
|
@ -288,24 +284,6 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
|
|||
aPS->SetEdgeInTwips(margin);
|
||||
}
|
||||
|
||||
if (aFlags & nsIPrintSettings::kInitSaveUnwriteableMargins) {
|
||||
nsMargin margin;
|
||||
margin.SizeTo(0,0,0,0);
|
||||
ReadInchesIntToTwipsPref(GetPrefName(kUnwriteableMarginTop, aPrinterName), margin.top,
|
||||
kUnwriteableMarginTop);
|
||||
DUMP_INT(kReadStr, kUnwriteableMarginTop, margin.top);
|
||||
ReadInchesIntToTwipsPref(GetPrefName(kUnwriteableMarginLeft, aPrinterName), margin.left,
|
||||
kUnwriteableMarginLeft);
|
||||
DUMP_INT(kReadStr, kUnwriteableMarginLeft, margin.left);
|
||||
ReadInchesIntToTwipsPref(GetPrefName(kUnwriteableMarginBottom, aPrinterName),
|
||||
margin.bottom, kUnwriteableMarginBottom);
|
||||
DUMP_INT(kReadStr, kUnwriteableMarginBottom, margin.bottom);
|
||||
ReadInchesIntToTwipsPref(GetPrefName(kUnwriteableMarginRight, aPrinterName), margin.right,
|
||||
kUnwriteableMarginRight);
|
||||
DUMP_INT(kReadStr, kUnwriteableMarginRight, margin.right);
|
||||
aPS->SetUnwriteableMarginInTwips(margin);
|
||||
}
|
||||
|
||||
PRBool b;
|
||||
nsAutoString str;
|
||||
PRInt32 iVal;
|
||||
|
@ -594,24 +572,6 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName,
|
|||
}
|
||||
}
|
||||
|
||||
nsMargin unwriteableMargin;
|
||||
if (aFlags & nsIPrintSettings::kInitSaveUnwriteableMargins) {
|
||||
if (NS_SUCCEEDED(aPS->GetUnwriteableMarginInTwips(unwriteableMargin))) {
|
||||
WriteInchesIntFromTwipsPref(GetPrefName(kUnwriteableMarginTop, aPrinterName),
|
||||
unwriteableMargin.top);
|
||||
DUMP_INT(kWriteStr, kUnwriteableMarginTop, unwriteableMargin.top);
|
||||
WriteInchesIntFromTwipsPref(GetPrefName(kUnwriteableMarginLeft, aPrinterName),
|
||||
unwriteableMargin.left);
|
||||
DUMP_INT(kWriteStr, kUnwriteableMarginLeft, unwriteableMargin.top);
|
||||
WriteInchesIntFromTwipsPref(GetPrefName(kUnwriteableMarginBottom, aPrinterName),
|
||||
unwriteableMargin.bottom);
|
||||
DUMP_INT(kWriteStr, kUnwriteableMarginBottom, unwriteableMargin.top);
|
||||
WriteInchesIntFromTwipsPref(GetPrefName(kUnwriteableMarginRight, aPrinterName),
|
||||
unwriteableMargin.right);
|
||||
DUMP_INT(kWriteStr, kUnwriteableMarginRight, unwriteableMargin.top);
|
||||
}
|
||||
}
|
||||
|
||||
// Paper size prefs are saved as a group
|
||||
if (aFlags & nsIPrintSettings::kInitSavePaperSize) {
|
||||
PRInt16 sizeUnit, sizeType;
|
||||
|
|
|
@ -954,16 +954,6 @@ nsPrintSettings::SetEdgeInTwips(nsMargin& aEdge)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// NOTE: Any subclass implementation of this function should make sure
|
||||
// to check for negative margin values in aUnwriteableMargin (which
|
||||
// would indicate that we should use the system default unwriteable margin.)
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettings::SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin)
|
||||
{
|
||||
// Default implementation does nothing
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPrintOptionsImpl.h
|
||||
* @update 6/21/00 dwc
|
||||
|
@ -982,14 +972,6 @@ nsPrintSettings::GetEdgeInTwips(nsMargin& aEdge)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettings::GetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin)
|
||||
{
|
||||
// Default implementation just returns 0
|
||||
aUnwriteableMargin.SizeTo(0,0,0,0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Stub - platform-specific implementations can use this function.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче