Bug 175879. Display ISO paper sizes in mm & remove extraneous 1/4-inch

margin from printouts. r=tor, sr=roc
This commit is contained in:
kjh-5727%comcast.net 2006-02-07 01:14:44 +00:00
Родитель 4fd253c039
Коммит d238a3e16a
1 изменённых файлов: 21 добавлений и 39 удалений

Просмотреть файл

@ -63,8 +63,7 @@
#endif /* USE_XPRINT */
#ifdef USE_POSTSCRIPT
/* Fetch |postscript_module_paper_sizes| */
#include "nsPostScriptObj.h"
#include "nsPaperPS.h" /* Paper size list */
#endif /* USE_POSTSCRIPT */
/* Ensure that the result is always equal to either PR_TRUE or PR_FALSE */
@ -948,13 +947,9 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::InitPrintSettingsFromPrinter(const PRUnich
}
#ifdef SET_PRINTER_FEATURES_VIA_PREFS
int i;
for( i = 0 ; postscript_module_orientations[i].orientation != nsnull ; i++ )
{
const PSOrientationRec *curr = &postscript_module_orientations[i];
printerFeatures.SetOrientationRecord(i, curr->orientation);
}
printerFeatures.SetNumOrientationRecords(i);
printerFeatures.SetOrientationRecord(0, "portrait");
printerFeatures.SetOrientationRecord(1, "landscape");
printerFeatures.SetNumOrientationRecords(2);
#endif /* SET_PRINTER_FEATURES_VIA_PREFS */
/* PostScript module does not support changing the plex mode... */
@ -973,44 +968,31 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::InitPrintSettingsFromPrinter(const PRUnich
#endif /* SET_PRINTER_FEATURES_VIA_PREFS */
nsXPIDLCString papername;
if (NS_SUCCEEDED(CopyPrinterCharPref(pPrefs, "postscript", printerName, "paper_size", getter_Copies(papername)))) {
int i;
const PSPaperSizeRec *default_paper = nsnull;
for( i = 0 ; postscript_module_paper_sizes[i].name != nsnull ; i++ )
{
const PSPaperSizeRec *curr = &postscript_module_paper_sizes[i];
nsPaperSizePS paper;
if (!PL_strcasecmp(papername, curr->name)) {
default_paper = curr;
break;
}
}
if (default_paper) {
DO_PR_DEBUG_LOG(("setting default paper size to '%s' (%g inch/%g inch)\n",
default_paper->name,
PSPaperSizeRec_FullPaperWidth(default_paper),
PSPaperSizeRec_FullPaperHeight(default_paper)));
aPrintSettings->SetPaperSizeType(nsIPrintSettings::kPaperSizeDefined);
aPrintSettings->SetPaperSizeUnit(nsIPrintSettings::kPaperSizeInches);
aPrintSettings->SetPaperWidth(PSPaperSizeRec_FullPaperWidth(default_paper));
aPrintSettings->SetPaperHeight(PSPaperSizeRec_FullPaperHeight(default_paper));
aPrintSettings->SetPaperName(NS_ConvertUTF8toUCS2(default_paper->name).get());
if (paper.Find(papername)) {
DO_PR_DEBUG_LOG(("setting default paper size to '%s' (%g mm/%g mm)\n",
paper.Name(), paper.Width_mm(), paper.Height_mm()));
aPrintSettings->SetPaperSizeUnit(paper.IsMetric() ?
(int)nsIPrintSettings::kPaperSizeMillimeters :
(int)nsIPrintSettings::kPaperSizeInches);
aPrintSettings->SetPaperWidth(paper.Width_mm());
aPrintSettings->SetPaperHeight(paper.Height_mm());
aPrintSettings->SetPaperName(NS_ConvertASCIItoUCS2(paper.Name()).get());
}
else {
DO_PR_DEBUG_LOG(("Unknown paper size '%s' given.\n", papername.get()));
}
#ifdef SET_PRINTER_FEATURES_VIA_PREFS
for( i = 0 ; postscript_module_paper_sizes[i].name != nsnull ; i++ )
paper.First();
int count = 0;
while (!paper.AtEnd())
{
const PSPaperSizeRec *curr = &postscript_module_paper_sizes[i];
#define CONVERT_INCH_TO_MILLIMETERS(inch) ((inch) * 25.4)
double total_width = CONVERT_INCH_TO_MILLIMETERS(PSPaperSizeRec_FullPaperWidth(curr)),
total_height = CONVERT_INCH_TO_MILLIMETERS(PSPaperSizeRec_FullPaperHeight(curr));
printerFeatures.SetPaperRecord(i, curr->name, PRInt32(total_width), PRInt32(total_height), PR_TRUE);
printerFeatures.SetPaperRecord(count++, paper.Name(),
(int)paper.Width_mm(), (int)paper.Height_mm(), !paper.IsMetric());
paper.Next();
}
printerFeatures.SetNumPaperSizeRecords(i);
printerFeatures.SetNumPaperSizeRecords(count);
#endif /* SET_PRINTER_FEATURES_VIA_PREFS */
}