Backing out Bug 417356, due to pagination reftest failures.
This commit is contained in:
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
class THEBES_API gfxPDFSurface : public gfxASurface {
|
class THEBES_API gfxPDFSurface : public gfxASurface {
|
||||||
public:
|
public:
|
||||||
gfxPDFSurface(nsIOutputStream *aStream, const gfxSize& aSizeInPoints);
|
gfxPDFSurface(nsIOutputStream *aStream, const gfxSize& aSizeInPonits);
|
||||||
virtual ~gfxPDFSurface();
|
virtual ~gfxPDFSurface();
|
||||||
|
|
||||||
virtual nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
virtual nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
class THEBES_API gfxPSSurface : public gfxASurface {
|
class THEBES_API gfxPSSurface : public gfxASurface {
|
||||||
public:
|
public:
|
||||||
gfxPSSurface(nsIOutputStream *aStream, const gfxSize& aSizeInPoints);
|
gfxPSSurface(nsIOutputStream *aStream, const gfxSize& aSizeInPonits);
|
||||||
virtual ~gfxPSSurface();
|
virtual ~gfxPSSurface();
|
||||||
|
|
||||||
virtual nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
virtual nsresult BeginPrinting(const nsAString& aTitle, const nsAString& aPrintToFileName);
|
||||||
|
|||||||
@@ -519,13 +519,6 @@ public:
|
|||||||
{ return NSToCoordRound(NS_TWIPS_TO_INCHES(aTwips) *
|
{ return NSToCoordRound(NS_TWIPS_TO_INCHES(aTwips) *
|
||||||
mDeviceContext->AppUnitsPerInch()); }
|
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
|
PRInt32 AppUnitsToTwips(nscoord aTwips) const
|
||||||
{ return NS_INCHES_TO_TWIPS((float)aTwips /
|
{ return NS_INCHES_TO_TWIPS((float)aTwips /
|
||||||
mDeviceContext->AppUnitsPerInch()); }
|
mDeviceContext->AppUnitsPerInch()); }
|
||||||
|
|||||||
@@ -198,16 +198,12 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
|||||||
|
|
||||||
// now get out margins & edges
|
// now get out margins & edges
|
||||||
if (mPageData->mPrintSettings) {
|
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;
|
nsMargin marginTwips;
|
||||||
mPageData->mPrintSettings->GetMarginInTwips(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;
|
PRInt16 printType;
|
||||||
mPageData->mPrintSettings->GetPrintRange(&printType);
|
mPageData->mPrintSettings->GetPrintRange(&printType);
|
||||||
mPrintRangeType = printType;
|
mPrintRangeType = printType;
|
||||||
@@ -223,7 +219,10 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
|||||||
edgeTwips.right = PR_MIN(PR_MAX(edgeTwips.right, 0), inchInTwips);
|
edgeTwips.right = PR_MIN(PR_MAX(edgeTwips.right, 0), inchInTwips);
|
||||||
|
|
||||||
mPageData->mEdgePaperMargin =
|
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 ***
|
// *** Special Override ***
|
||||||
|
|||||||
@@ -2194,7 +2194,10 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO)
|
|||||||
mPrt->mPrintSettings->SetEndPageRange(endPageNum);
|
mPrt->mPrintSettings->SetEndPageRange(endPageNum);
|
||||||
nsMargin marginTwips(0,0,0,0);
|
nsMargin marginTwips(0,0,0,0);
|
||||||
mPrt->mPrintSettings->GetMarginInTwips(marginTwips);
|
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) {
|
if (startPageNum == endPageNum) {
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -245,26 +245,12 @@ pref("print.whileInPrintPreview", true);
|
|||||||
// Cache old Presentation when going into Print Preview
|
// Cache old Presentation when going into Print Preview
|
||||||
pref("print.always_cache_old_pres", false);
|
pref("print.always_cache_old_pres", false);
|
||||||
|
|
||||||
// Enables you to specify the amount of the paper that is to be treated
|
// Enables you to specify the gap from the edge of the paper to the margin
|
||||||
// as unwriteable. The print_edge_XXX and print_margin_XXX preferences
|
// this is used by both Printing and Print Preview
|
||||||
// are treated as offsets that are added to this pref.
|
pref("print.print_edge_top", 0); // 1/100 of an inch
|
||||||
// Default is "-1", which means "use the system default". (If there is
|
pref("print.print_edge_left", 0); // 1/100 of an inch
|
||||||
// no system default, then the -1 is treated as if it were 0.)
|
pref("print.print_edge_right", 0); // 1/100 of an inch
|
||||||
// This is used by both Printing and Print Preview.
|
pref("print.print_edge_bottom", 0); // 1/100 of an inch
|
||||||
// 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);
|
|
||||||
|
|
||||||
// Pref used by the spellchecker extension to control the
|
// Pref used by the spellchecker extension to control the
|
||||||
// maximum number of misspelled words that will be underlined
|
// 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_landscape", false);
|
||||||
pref("print.print_paper_size", 0);
|
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
|
// print_extra_margin enables platforms to specify an extra gap or margin
|
||||||
// around the content of the page for Print Preview only
|
// around the content of the page for Print Preview only
|
||||||
pref("print.print_extra_margin", 0); // twips
|
pref("print.print_extra_margin", 0); // twips
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ interface nsIPrintSession;
|
|||||||
*
|
*
|
||||||
* @status UNDER_REVIEW
|
* @status UNDER_REVIEW
|
||||||
*/
|
*/
|
||||||
[scriptable, uuid(5af07661-6477-4235-8814-4a45215855b8)]
|
[scriptable, uuid(3e097aba-c1d6-425d-9c52-b371d5da964a)]
|
||||||
|
|
||||||
interface nsIPrintSettings : nsISupports
|
interface nsIPrintSettings : nsISupports
|
||||||
{
|
{
|
||||||
@@ -79,7 +79,7 @@ interface nsIPrintSettings : nsISupports
|
|||||||
/* Flag 0x00000800 is unused */
|
/* Flag 0x00000800 is unused */
|
||||||
/* Flag 0x00001000 is unused */
|
/* Flag 0x00001000 is unused */
|
||||||
const unsigned long kInitSavePaperData = 0x00002000;
|
const unsigned long kInitSavePaperData = 0x00002000;
|
||||||
const unsigned long kInitSaveUnwriteableMargins = 0x00004000;
|
/* Flag 0x00004000 is unused */
|
||||||
const unsigned long kInitSaveEdges = 0x00008000;
|
const unsigned long kInitSaveEdges = 0x00008000;
|
||||||
|
|
||||||
const unsigned long kInitSaveReversed = 0x00010000;
|
const unsigned long kInitSaveReversed = 0x00010000;
|
||||||
@@ -311,16 +311,4 @@ interface nsIPrintSettings : nsISupports
|
|||||||
* before printing, otherwise printing can fail on some platforms.
|
* before printing, otherwise printing can fail on some platforms.
|
||||||
*/
|
*/
|
||||||
[noscript] void SetupSilentPrinting();
|
[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);
|
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:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -185,15 +185,31 @@ NS_IMETHODIMP nsDeviceContextSpecX::EndPage()
|
|||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
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;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
PMRect paperRect;
|
PMRect pageRect;
|
||||||
::PMGetAdjustedPaperRect(mPageFormat, &paperRect);
|
::PMGetAdjustedPageRect(mPageFormat, &pageRect);
|
||||||
|
*aTop = pageRect.top, *aLeft = pageRect.left;
|
||||||
|
*aBottom = pageRect.bottom, *aRight = pageRect.right;
|
||||||
|
|
||||||
*aTop = paperRect.top, *aLeft = paperRect.left;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
*aBottom = paperRect.bottom, *aRight = paperRect.right;
|
}
|
||||||
|
|
||||||
|
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;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
}
|
}
|
||||||
@@ -203,7 +219,10 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetSurfaceForPrinter(gfxASurface **surface)
|
|||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
|
||||||
double top, left, bottom, right;
|
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 width = right - left;
|
||||||
const double height = bottom - top;
|
const double height = bottom - top;
|
||||||
|
|
||||||
@@ -214,8 +233,8 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetSurfaceForPrinter(gfxASurface **surface)
|
|||||||
|
|
||||||
if (context) {
|
if (context) {
|
||||||
// Initially, origin is at bottom-left corner of the paper.
|
// Initially, origin is at bottom-left corner of the paper.
|
||||||
// Here, we translate it to top-left corner of the paper.
|
// Here, we translate it to top-left corner of the printable area.
|
||||||
CGContextTranslateCTM(context, 0, height);
|
CGContextTranslateCTM(context, leftMargin, bottomMargin + height);
|
||||||
CGContextScaleCTM(context, 1.0, -1.0);
|
CGContextScaleCTM(context, 1.0, -1.0);
|
||||||
newSurface = new gfxQuartzSurface(context, gfxSize(width, height), PR_TRUE);
|
newSurface = new gfxQuartzSurface(context, gfxSize(width, height), PR_TRUE);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -58,9 +58,6 @@ public:
|
|||||||
|
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
|
|
||||||
// Page format's unwriteable margin
|
|
||||||
nsresult GetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsPrintSettingsX(const nsPrintSettingsX& src);
|
nsPrintSettingsX(const nsPrintSettingsX& src);
|
||||||
nsPrintSettingsX& operator=(const nsPrintSettingsX& rhs);
|
nsPrintSettingsX& operator=(const nsPrintSettingsX& rhs);
|
||||||
|
|||||||
@@ -259,23 +259,6 @@ nsresult nsPrintSettingsX::Init()
|
|||||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
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)
|
NS_IMETHODIMP nsPrintSettingsX::GetNativePrintSession(PMPrintSession *aNativePrintSession)
|
||||||
@@ -510,8 +493,8 @@ OSStatus nsPrintSettingsX::CreateDefaultPageFormat(PMPrintSession aSession, PMPa
|
|||||||
|
|
||||||
outFormat = kPMNoPageFormat;
|
outFormat = kPMNoPageFormat;
|
||||||
status = ::PMCreatePageFormat(&pageFormat);
|
status = ::PMCreatePageFormat(&pageFormat);
|
||||||
if (status == noErr && pageFormat != kPMNoPageFormat) {
|
if (status == noErr && pageFormat != kPMNoPageFormat) {
|
||||||
status = ::PMSessionDefaultPageFormat(aSession, pageFormat);
|
status = ::PMSessionDefaultPageFormat(aSession, pageFormat);
|
||||||
if (status == noErr) {
|
if (status == noErr) {
|
||||||
outFormat = pageFormat;
|
outFormat = pageFormat;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -418,8 +418,8 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::GetSurfaceForPrinter(gfxASurface **aSurfac
|
|||||||
double width, height;
|
double width, height;
|
||||||
mPrintSettings->GetEffectivePageSize(&width, &height);
|
mPrintSettings->GetEffectivePageSize(&width, &height);
|
||||||
// convert twips to points
|
// convert twips to points
|
||||||
width /= TWIPS_PER_POINT_FLOAT;
|
width /= 20;
|
||||||
height /= TWIPS_PER_POINT_FLOAT;
|
height /= 20;
|
||||||
|
|
||||||
DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", path, width, height));
|
DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", path, width, height));
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|||||||
@@ -506,6 +506,66 @@ nsPrintSettingsGTK::SetNumCopies(PRInt32 aNumCopies)
|
|||||||
return NS_OK;
|
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; */
|
/* attribute double scaling; */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPrintSettingsGTK::GetScaling(double *aScaling)
|
nsPrintSettingsGTK::GetScaling(double *aScaling)
|
||||||
@@ -573,43 +633,6 @@ nsPrintSettingsGTK::SaveNewPageSize()
|
|||||||
gtk_page_setup_set_paper_size(mPageSetup, mPaperSize);
|
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; */
|
/* attribute double paperWidth; */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPrintSettingsGTK::GetPaperWidth(double *aPaperWidth)
|
nsPrintSettingsGTK::GetPaperWidth(double *aPaperWidth)
|
||||||
@@ -663,6 +686,27 @@ nsPrintSettingsGTK::SetPaperSizeUnit(PRInt16 aPaperSizeUnit)
|
|||||||
return NS_OK;
|
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
|
NS_IMETHODIMP
|
||||||
nsPrintSettingsGTK::GetEffectivePageSize(double *aWidth, double *aHeight)
|
nsPrintSettingsGTK::GetEffectivePageSize(double *aWidth, double *aHeight)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,9 +114,17 @@ public:
|
|||||||
NS_IMETHOD GetNumCopies(PRInt32 *aNumCopies);
|
NS_IMETHOD GetNumCopies(PRInt32 *aNumCopies);
|
||||||
NS_IMETHOD SetNumCopies(PRInt32 aNumCopies);
|
NS_IMETHOD SetNumCopies(PRInt32 aNumCopies);
|
||||||
|
|
||||||
// Page format's unwriteable margin
|
NS_IMETHOD GetEdgeTop(double *aEdgeTop);
|
||||||
NS_IMETHOD GetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin);
|
NS_IMETHOD SetEdgeTop(double aEdgeTop);
|
||||||
NS_IMETHOD SetUnwriteableMarginInTwips(nsMargin& aUnwriteableMargin);
|
|
||||||
|
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 GetScaling(double *aScaling);
|
||||||
NS_IMETHOD SetScaling(double aScaling);
|
NS_IMETHOD SetScaling(double aScaling);
|
||||||
@@ -133,6 +141,9 @@ public:
|
|||||||
|
|
||||||
NS_IMETHOD SetPaperSizeUnit(PRInt16 aPaperSizeUnit);
|
NS_IMETHOD SetPaperSizeUnit(PRInt16 aPaperSizeUnit);
|
||||||
|
|
||||||
|
NS_IMETHOD SetEdgeInTwips(nsMargin& aEdge);
|
||||||
|
NS_IMETHOD GetEdgeInTwips(nsMargin& aEdge);
|
||||||
|
|
||||||
NS_IMETHOD GetEffectivePageSize(double *aWidth, double *aHeight);
|
NS_IMETHOD GetEffectivePageSize(double *aWidth, double *aHeight);
|
||||||
|
|
||||||
NS_IMETHOD SetupSilentPrinting();
|
NS_IMETHOD SetupSilentPrinting();
|
||||||
|
|||||||
@@ -367,8 +367,8 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::GetSurfaceForPrinter(gfxASurface **surface
|
|||||||
double width, height;
|
double width, height;
|
||||||
mPrintSettings->GetEffectivePageSize(&width, &height);
|
mPrintSettings->GetEffectivePageSize(&width, &height);
|
||||||
// convert twips to points
|
// convert twips to points
|
||||||
width /= TWIPS_PER_POINT_FLOAT;
|
width /= 20;
|
||||||
height /= TWIPS_PER_POINT_FLOAT;
|
height /= 20;
|
||||||
|
|
||||||
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
|
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
|
||||||
rv = file->InitWithPath(filename);
|
rv = file->InitWithPath(filename);
|
||||||
|
|||||||
@@ -528,8 +528,8 @@ NS_IMETHODIMP nsDeviceContextSpecWin::GetSurfaceForPrinter(gfxASurface **surface
|
|||||||
double width, height;
|
double width, height;
|
||||||
mPrintSettings->GetEffectivePageSize(&width, &height);
|
mPrintSettings->GetEffectivePageSize(&width, &height);
|
||||||
// convert twips to points
|
// convert twips to points
|
||||||
width /= TWIPS_PER_POINT_FLOAT;
|
width /= 20;
|
||||||
height /= TWIPS_PER_POINT_FLOAT;
|
height /= 20;
|
||||||
|
|
||||||
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
|
nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
|
||||||
nsresult rv = file->InitWithPath(filename);
|
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 kEdgeLeft[] = "print_edge_left";
|
||||||
static const char kEdgeBottom[] = "print_edge_bottom";
|
static const char kEdgeBottom[] = "print_edge_bottom";
|
||||||
static const char kEdgeRight[] = "print_edge_right";
|
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
|
// Prefs for Print Options
|
||||||
static const char kPrintEvenPages[] = "print_evenpages";
|
static const char kPrintEvenPages[] = "print_evenpages";
|
||||||
@@ -288,24 +284,6 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
|
|||||||
aPS->SetEdgeInTwips(margin);
|
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;
|
PRBool b;
|
||||||
nsAutoString str;
|
nsAutoString str;
|
||||||
PRInt32 iVal;
|
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
|
// Paper size prefs are saved as a group
|
||||||
if (aFlags & nsIPrintSettings::kInitSavePaperSize) {
|
if (aFlags & nsIPrintSettings::kInitSavePaperSize) {
|
||||||
PRInt16 sizeUnit, sizeType;
|
PRInt16 sizeUnit, sizeType;
|
||||||
|
|||||||
@@ -954,16 +954,6 @@ nsPrintSettings::SetEdgeInTwips(nsMargin& aEdge)
|
|||||||
return NS_OK;
|
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
|
* See documentation in nsPrintOptionsImpl.h
|
||||||
* @update 6/21/00 dwc
|
* @update 6/21/00 dwc
|
||||||
@@ -982,14 +972,6 @@ nsPrintSettings::GetEdgeInTwips(nsMargin& aEdge)
|
|||||||
return NS_OK;
|
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.
|
* Stub - platform-specific implementations can use this function.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user