mDebugFile = aDebugFile;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mContainer)); NS_ASSERTION(docShell, "This has to be a docshell");  nsCOMPtr<nsIPresShell> presShell; docShell->GetPresShell(getter_AddRefs(presShell));  if (!presShell) {   return NS_OK; }  if (mIsDoingPrintPreview) { PRBool okToPrint = PR_FALSE; nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID)); if (prefs) { prefs->GetBoolPref("print.whileInPrintPreview", &okToPrint); } if (!okToPrint) { ShowPrintErrorDialog(NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW, PR_FALSE); return NS_OK; } }      if (mIsDoingPrinting) {  rv = NS_ERROR_NOT_AVAILABLE; ShowPrintErrorDialog(rv); return rv; }  mPrt = new PrintData(PrintData::eIsPrinting); if (!mPrt) { return NS_ERROR_OUT_OF_MEMORY; }
DocumentViewerImpl::Print(PRBool            aSilent,                          FILE *            aDebugFile,                          nsIPrintSettings* aPrintSettings){  nsCOMPtr<nsIPrintSettings> printSettings;#ifdef NS_DEBUG  nsresult rv = NS_ERROR_FAILURE;  mDebugFile = aDebugFile;  // if they don't pass in a PrintSettings, then make one  // it will have all the default values  printSettings = aPrintSettings;  nsCOMPtr<nsIPrintOptions> printOptions = do_GetService(kPrintOptionsCID, &rv);  if (NS_SUCCEEDED(rv)) {    // if they don't pass in a PrintSettings, then make one    if (printSettings == nsnull) {      printOptions->CreatePrintSettings(getter_AddRefs(printSettings));    }    NS_ASSERTION(printSettings, "You can't PrintPreview without a PrintSettings!");  }  if (printSettings) printSettings->SetPrintSilent(aSilent);#endif  return Print(printSettings, nsnull);}