- abortIt = FALSE;
- abortWindow = NULL;
-
- 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 = NULL;
- if (prompt)
- {
- wxPrintDialog dialog(parent, & printData);
- if (dialog.ShowModal() == wxID_OK)
- {
- dc = dialog.GetPrintDC();
- printData = dialog.GetPrintData();
- }
- }
- else
- {
- dc = new wxPrinterDC("", "", "", FALSE, printData.GetOrientation());
- }
-
- // 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;
-
- HDC hdc = ::GetDC(NULL);
- logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX);
- logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY);
- ::ReleaseDC(NULL, hdc);
-
- logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX);
- logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY);
- if (logPPIPrinterX == 0 || logPPIPrinterY == 0)
- {
- delete dc;
- return FALSE;
- }
+ sm_abortIt = false;
+ sm_abortWindow = NULL;
+
+ if (!printout)
+ {
+ sm_lastError = wxPRINTER_ERROR;
+ return false;
+ }
+
+ if (m_printDialogData.GetMinPage() < 1)
+ m_printDialogData.SetMinPage(1);
+ if (m_printDialogData.GetMaxPage() < 1)
+ m_printDialogData.SetMaxPage(9999);
+
+ // Create a suitable device context
+ wxPrinterDC *dc wxDUMMY_INITIALIZE(NULL);
+ if (prompt)
+ {
+ dc = wxDynamicCast(PrintDialog(parent), wxPrinterDC);
+ if (!dc)
+ return false;
+ }
+ else
+ {
+ dc = new wxPrinterDC(m_printDialogData.GetPrintData());
+ }