nsPrintProgress* prtProgress = new nsPrintProgress(); nsresult rv = prtProgress->QueryInterface(NS_GET_IID(nsIPrintProgress), (void**)getter_AddRefs(mPrt->mPrintProgress)); if (NS_FAILED(rv)) return;   rv = prtProgress->QueryInterface(NS_GET_IID(nsIWebProgressListener), (void**)getter_AddRefs(mPrt->mPrintProgressListener)); if (NS_FAILED(rv)) return;  mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener); nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get()); NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!"); NS_ADDREF(wpl);
mPrt->mShowProgressDialog = PR_FALSE;
DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting){  nsPrintProgress* prtProgress = new nsPrintProgress();  nsresult rv = prtProgress->QueryInterface(NS_GET_IID(nsIPrintProgress), (void**)getter_AddRefs(mPrt->mPrintProgress));  if (NS_FAILED(rv)) return;  rv = prtProgress->QueryInterface(NS_GET_IID(nsIWebProgressListener), (void**)getter_AddRefs(mPrt->mPrintProgressListener));  if (NS_FAILED(rv)) return;  // add to listener list  mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener);  nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get());  NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!");  NS_ADDREF(wpl);  nsCOMPtr<nsIPref> prefs (do_GetService(NS_PREF_CONTRACTID));  if (prefs) {    prefs->GetBoolPref("print.show_print_progress", &mPrt->mShowProgressDialog);  }  // Turning off the showing of Print Progress in Prefs overrides  // whether the calling PS desire to have it on or off, so only check PS if   // prefs says it's ok to be on.  if (mPrt->mShowProgressDialog) {    mPrt->mPrintSettings->GetShowPrintProgress(&mPrt->mShowProgressDialog);  }  if (mPrt->mShowProgressDialog) {    nsPrintProgressParams* prtProgressParams = new nsPrintProgressParams();    nsCOMPtr<nsIPrintProgressParams> params;    rv = prtProgressParams->QueryInterface(NS_GET_IID(nsIPrintProgressParams), (void**)getter_AddRefs(mPrt->mPrintProgressParams));    if (NS_SUCCEEDED(rv) && mPrt->mPrintProgressParams) {      SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams);      nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));      if (wwatch) {        nsCOMPtr<nsIDOMWindow> active;        wwatch->GetActiveWindow(getter_AddRefs(active));        nsCOMPtr<nsIDOMWindowInternal> parent(do_QueryInterface(active));        mPrt->mPrintProgress->OpenProgressDialog(parent, "chrome://global/content/printProgress.xul", mPrt->mPrintProgressParams);      }    }  }}