- if (!printout)
- return FALSE;
-
- printout->SetIsPreview(FALSE);
- printout->OnPreparePrinting();
-
- // Get some parameters from the printout, if defined
- int fromPage, toPage;
- int minPage, maxPage;
- printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
-
- if (maxPage == 0)
- return FALSE;
-
- printData.SetMinPage(minPage);
- printData.SetMaxPage(maxPage);
- if (fromPage != 0)
- printData.SetFromPage(fromPage);
- if (toPage != 0)
- printData.SetToPage(toPage);
-
- if (minPage != 0)
- {
- printData.EnablePageNumbers(TRUE);
- if (printData.GetFromPage() < printData.GetMinPage())
- printData.SetFromPage(printData.GetMinPage());
- else if (printData.GetFromPage() > printData.GetMaxPage())
- printData.SetFromPage(printData.GetMaxPage());
- if (printData.GetToPage() > printData.GetMaxPage())
- printData.SetToPage(printData.GetMaxPage());
- else if (printData.GetToPage() < printData.GetMinPage())
- printData.SetToPage(printData.GetMinPage());
- }
- else
- printData.EnablePageNumbers(FALSE);
-
- // Create a suitable device context
- wxDC *dc = (wxDC *) NULL;
- if (prompt)
- {
- wxGenericPrintDialog dialog(parent, & printData);
- if (dialog.ShowModal() == wxID_OK)
- {
- dc = dialog.GetPrintDC();
- printData = dialog.GetPrintData();
- }
- }
- else
- {
- dc = new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) NULL);
- }
-
- // May have pressed cancel.
- if (!dc || !dc->Ok())
- {
- if (dc) delete dc;
- return FALSE;
- }
-
- int logPPIScreenX = 0;
- int logPPIScreenY = 0;
- int logPPIPrinterX = 0;
- int logPPIPrinterY = 0;
-
- // Correct values for X/PostScript?
- logPPIScreenX = 100;
- logPPIScreenY = 100;
- logPPIPrinterX = 100;
- logPPIPrinterY = 100;
-
- printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
- printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
-
- // Set printout parameters
- printout->SetDC(dc);
-
- int w, h;
- long ww, hh;
- dc->GetSize(&w, &h);
- printout->SetPageSizePixels((int)w, (int)h);
- dc->GetSizeMM(&ww, &hh);
- printout->SetPageSizeMM((int)ww, (int)hh);
-
- // Create an abort window
- wxBeginBusyCursor();
-
- printout->OnBeginPrinting();
-
- bool keepGoing = TRUE;
-
- int copyCount;
- for (copyCount = 1; copyCount <= printData.GetNoCopies(); copyCount ++)
- {
- if (!printout->OnBeginDocument(printData.GetFromPage(), printData.GetToPage()))
+ if (!printout)
+ {
+ sm_lastError = wxPRINTER_ERROR;
+ return FALSE;
+ }
+
+ printout->SetIsPreview(FALSE);
+
+#if 0
+ // 4/9/99, JACS: this is a silly place to allow preparation, considering
+ // the DC and no parameters have been set in the printout object.
+ // Moved further down.
+
+ // printout->OnPreparePrinting();
+
+ // Get some parameters from the printout, if defined
+ int fromPage, toPage;
+ int minPage, maxPage;
+ printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
+
+ if (maxPage == 0)