mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1315121
- OS X Remote printing (print_via_parent) scaled prints don't fill page; r=mconley
Send the size from PMGetAdjustedPaperRect to the child to use as the page size. Add an Mac implementation of GetEffectivePageSize that returns the adjusted dimensions. MozReview-Commit-ID: GgTFgBzkxTy --HG-- extra : rebase_source : 9b6e3200698a695d3ca03f3848060083b8fe4ae6
This commit is contained in:
parent
386540035e
commit
b98f841402
@ -118,6 +118,8 @@ struct PrintData {
|
||||
*/
|
||||
float widthScale;
|
||||
float heightScale;
|
||||
double adjustedPaperWidth;
|
||||
double adjustedPaperHeight;
|
||||
};
|
||||
|
||||
} // namespace embedding
|
||||
|
@ -145,7 +145,18 @@ nsPrintDialogServiceX::Show(nsPIDOMWindowOuter *aParent, nsIPrintSettings *aSett
|
||||
[dict setObject: [NSNumber numberWithFloat: 1]
|
||||
forKey: NSPrintScalingFactor];
|
||||
}
|
||||
// Set the scaling factor to 100% in the NSPrintInfo
|
||||
// object so that it will not affect the paper size
|
||||
// retrieved from the PMPageFormat routines.
|
||||
[copy setScalingFactor:1.0];
|
||||
} else {
|
||||
aSettings->SetScaling([copy scalingFactor]);
|
||||
}
|
||||
|
||||
// Set the adjusted paper size now that we've updated
|
||||
// the scaling factor.
|
||||
settingsX->InitAdjustedPaperSize();
|
||||
|
||||
[copy release];
|
||||
|
||||
int16_t pageRange;
|
||||
|
@ -71,6 +71,11 @@ nsPrintOptionsX::SerializeToPrintData(nsIPrintSettings* aSettings,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
double adjustedWidth, adjustedHeight;
|
||||
settingsX->GetAdjustedPaperSize(&adjustedWidth, &adjustedHeight);
|
||||
data->adjustedPaperWidth() = adjustedWidth;
|
||||
data->adjustedPaperHeight() = adjustedHeight;
|
||||
|
||||
NSDictionary* dict = [printInfo dictionary];
|
||||
if (NS_WARN_IF(!dict)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -285,6 +290,9 @@ nsPrintOptionsX::DeserializeToPrintSettings(const PrintData& data,
|
||||
settingsX->SetCocoaPrintInfo(newPrintInfo);
|
||||
[newPrintInfo release];
|
||||
|
||||
settingsX->SetAdjustedPaperSize(data.adjustedPaperWidth(),
|
||||
data.adjustedPaperHeight());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@ public:
|
||||
void SetCocoaPrintInfo(NSPrintInfo* aPrintInfo);
|
||||
virtual nsresult ReadPageFormatFromPrefs();
|
||||
virtual nsresult WritePageFormatToPrefs();
|
||||
virtual nsresult GetEffectivePageSize(double *aWidth,
|
||||
double *aHeight) override;
|
||||
|
||||
PMPrintSettings GetPMPrintSettings();
|
||||
PMPrintSession GetPMPrintSession();
|
||||
@ -35,9 +37,16 @@ public:
|
||||
// Should be called whenever mPageFormat is initialized or overwritten.
|
||||
nsresult InitUnwriteableMargin();
|
||||
|
||||
// Re-initialize mAdjustedPaper{Width,Height} with values from mPageFormat.
|
||||
// Should be called whenever mPageFormat is initialized or overwritten.
|
||||
nsresult InitAdjustedPaperSize();
|
||||
|
||||
void SetInchesScale(float aWidthScale, float aHeightScale);
|
||||
void GetInchesScale(float *aWidthScale, float *aHeightScale);
|
||||
|
||||
void SetAdjustedPaperSize(double aWidth, double aHeight);
|
||||
void GetAdjustedPaperSize(double *aWidth, double *aHeight);
|
||||
|
||||
protected:
|
||||
virtual ~nsPrintSettingsX();
|
||||
|
||||
@ -57,6 +66,8 @@ protected:
|
||||
// paper size units to inches
|
||||
float mWidthScale;
|
||||
float mHeightScale;
|
||||
double mAdjustedPaperWidth;
|
||||
double mAdjustedPaperHeight;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsX, NS_PRINTSETTINGSX_IID)
|
||||
|
@ -68,6 +68,7 @@ nsresult nsPrintSettingsX::Init()
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
InitUnwriteableMargin();
|
||||
InitAdjustedPaperSize();
|
||||
|
||||
return NS_OK;
|
||||
|
||||
@ -94,6 +95,23 @@ NS_IMETHODIMP nsPrintSettingsX::InitUnwriteableMargin()
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPrintSettingsX::InitAdjustedPaperSize()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
PMPageFormat pageFormat = GetPMPageFormat();
|
||||
|
||||
PMRect paperRect;
|
||||
::PMGetAdjustedPaperRect(pageFormat, &paperRect);
|
||||
|
||||
mAdjustedPaperWidth = paperRect.right - paperRect.left;
|
||||
mAdjustedPaperHeight = paperRect.bottom - paperRect.top;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
void
|
||||
nsPrintSettingsX::SetCocoaPrintInfo(NSPrintInfo* aPrintInfo)
|
||||
{
|
||||
@ -206,8 +224,10 @@ nsPrintSettingsX::SetPMPageFormat(PMPageFormat aPageFormat)
|
||||
void
|
||||
nsPrintSettingsX::SetInchesScale(float aWidthScale, float aHeightScale)
|
||||
{
|
||||
mWidthScale = aWidthScale;
|
||||
mHeightScale = aHeightScale;
|
||||
if (aWidthScale > 0 && aHeightScale > 0) {
|
||||
mWidthScale = aWidthScale;
|
||||
mHeightScale = aHeightScale;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -216,3 +236,24 @@ nsPrintSettingsX::GetInchesScale(float *aWidthScale, float *aHeightScale)
|
||||
*aWidthScale = mWidthScale;
|
||||
*aHeightScale = mHeightScale;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsX::GetEffectivePageSize(double *aWidth, double *aHeight)
|
||||
{
|
||||
*aWidth = NS_INCHES_TO_TWIPS(mAdjustedPaperWidth / mWidthScale);
|
||||
*aHeight = NS_INCHES_TO_TWIPS(mAdjustedPaperHeight / mHeightScale);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsPrintSettingsX::SetAdjustedPaperSize(double aWidth, double aHeight)
|
||||
{
|
||||
mAdjustedPaperWidth = aWidth;
|
||||
mAdjustedPaperHeight = aHeight;
|
||||
}
|
||||
|
||||
void nsPrintSettingsX::GetAdjustedPaperSize(double *aWidth, double *aHeight)
|
||||
{
|
||||
*aWidth = mAdjustedPaperWidth;
|
||||
*aHeight = mAdjustedPaperHeight;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user