Bug 414314 - "Since landing of bug 193001, I cannot print with HP-Toolbox 2.7.10 or earlier" [p=ventnor.bugzilla@yahoo.com.au (Michael Ventnor) r+sr=roc a=blocking1.9+]

This commit is contained in:
reed@reedloden.com 2008-02-13 03:03:43 -08:00
Родитель 4ac23ce8a2
Коммит e17e6dbbbd
1 изменённых файлов: 29 добавлений и 0 удалений

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

@ -391,6 +391,16 @@ nsDeviceContextSpecGTK::nsDeviceContextSpecGTK()
nsDeviceContextSpecGTK::~nsDeviceContextSpecGTK()
{
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::~nsDeviceContextSpecGTK()\n"));
if (mGtkPageSetup) {
g_object_unref(mGtkPageSetup);
mGtkPageSetup = NULL;
}
if (mGtkPrintSettings) {
g_object_unref(mGtkPrintSettings);
mGtkPrintSettings = NULL;
}
}
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK,
@ -510,6 +520,25 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIWidget *aWidget,
mGtkPrintSettings = printSettingsGTK->GetGtkPrintSettings();
mGtkPageSetup = printSettingsGTK->GetGtkPageSetup();
// This is a horrible workaround for some printer driver bugs that treat custom page sizes different
// to standard ones. If our paper object matches one of a standard one, use a standard paper size
// object instead.
GtkPaperSize* geckosHackishPaperSize = gtk_page_setup_get_paper_size(mGtkPageSetup);
GtkPaperSize* standardGtkPaperSize = gtk_paper_size_new(gtk_paper_size_get_name(geckosHackishPaperSize));
mGtkPageSetup = gtk_page_setup_copy(mGtkPageSetup);
mGtkPrintSettings = gtk_print_settings_copy(mGtkPrintSettings);
GtkPaperSize* properPaperSize;
if (gtk_paper_size_is_equal(geckosHackishPaperSize, standardGtkPaperSize)) {
properPaperSize = standardGtkPaperSize;
} else {
properPaperSize = geckosHackishPaperSize;
gtk_paper_size_free(standardGtkPaperSize);
}
gtk_print_settings_set_paper_size(mGtkPrintSettings, properPaperSize);
gtk_page_setup_set_paper_size_and_default_margins(mGtkPageSetup, properPaperSize);
return NS_OK;
}