embedding/qa/testembed/PrintProgressDialog.cpp - Revision 1.1

There were 15 changes made.
Legend
   Added lines
   Changed lines
   Removed lines

embedding/qa/testembed/PrintProgressDialog.cpp,1.1
.
Disk File
Skipping to line 5. 
#include "Testembed.h"
.
#include "Testembed.h"
#include "PrintProgressDialog.h"
.
#include "PrintProgressDialog.h"
#include "BrowserView.h"
.
#include "BrowserView.h"
#include "nsIWebBrowser.h"
.
#include "nsIWebBrowser.h"
#include "nsIWebBrowserPrint.h"
.
#include "nsIWebBrowserPrint.h"
 
.
#include "nsIWebProgressListener.h"
 
.
 
#ifdef _DEBUG
.
#ifdef _DEBUG
#define new DEBUG_NEW
.
#define new DEBUG_NEW
#undef THIS_FILE
.
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
.
static char THIS_FILE[] = __FILE__;
Skipping to line 17. 
 
.
 
/////////////////////////////////////////////////////////////////////////////
.
/////////////////////////////////////////////////////////////////////////////
// CPrintProgressDialog dialog
.
// CPrintProgressDialog dialog
 
.
 
class CDlgPrintListener : public nsIPrintListener
.
class CDlgPrintListener : public nsIWebProgressListener
{
.
{
// Construction
.
// Construction
public:
.
public:
	CDlgPrintListener(CPrintProgressDialog* aDlg); 
.
	CDlgPrintListener(CPrintProgressDialog* aDlg); 
 
.
 
Skipping to line 28. 
  NS_DECL_NSIPRINTLISTENER
.
  NS_DECL_NSIWEBPROGRESSLISTENER
 
.
 
 
.
 
  void ClearDlg() { m_PrintDlg = NULL; } // weak reference
.
  void ClearDlg() { m_PrintDlg = NULL; } // weak reference
 
.
 
// Implementation
.
// Implementation
protected:
.
protected:
Skipping to line 37. 
 
.
 
NS_IMPL_ADDREF(CDlgPrintListener)
.
NS_IMPL_ADDREF(CDlgPrintListener)
NS_IMPL_RELEASE(CDlgPrintListener)
.
NS_IMPL_RELEASE(CDlgPrintListener)
 
.
 
NS_INTERFACE_MAP_BEGIN(CDlgPrintListener)
.
NS_INTERFACE_MAP_BEGIN(CDlgPrintListener)
    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrintListener)
.
    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebProgressListener)
    NS_INTERFACE_MAP_ENTRY(nsIPrintListener)
.
    NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_END
.
NS_INTERFACE_MAP_END
 
.
 
 
.
 
CDlgPrintListener::CDlgPrintListener(CPrintProgressDialog* aDlg) :
.
CDlgPrintListener::CDlgPrintListener(CPrintProgressDialog* aDlg) :
  m_PrintDlg(aDlg)
.
  m_PrintDlg(aDlg)
Skipping to line 50. 
  NS_INIT_ISUPPORTS();
.
  NS_INIT_ISUPPORTS();
  //NS_ADDREF_THIS();
.
  //NS_ADDREF_THIS();
}
.
}
 
.
 
/* void OnStartPrinting (); */
 
.
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest,
 in long aStateFlags, in unsigned long aStatus); */
NS_IMETHODIMP 
.
NS_IMETHODIMP 
CDlgPrintListener::OnStartPrinting()
 
.
CDlgPrintListener::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRe
quest, PRInt32 aStateFlags, PRUint32 aStatus)
{
.
{
  if (m_PrintDlg) {
.
  if (m_PrintDlg) {
    return m_PrintDlg->OnStartPrinting();
.
    if (aStatus == nsIWebProgressListener::STATE_START) {
 
.
      return m_PrintDlg->OnStartPrinting();
 
.
 
 
.
    } else if (aStatus == nsIWebProgressListener::STATE_STOP) {
 
.
      return m_PrintDlg->OnEndPrinting(aStatus);
 
.
    }
  }
.
  }
  return NS_OK;
.
  return NS_OK;
}
.
}
 
.
 
/* void OnProgressPrinting (in PRUint32 aProgress, in PRUint32 aProgressMax); 
*/
 
.
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aReque
st, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgr
ess, in long aMaxTotalProgress); */
NS_IMETHODIMP 
.
NS_IMETHODIMP 
CDlgPrintListener::OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgressMa
x)
 
.
CDlgPrintListener::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *
aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTota
lProgress, PRInt32 aMaxTotalProgress)
{
.
{
  if (m_PrintDlg) {
.
  if (m_PrintDlg) {
    return m_PrintDlg->OnProgressPrinting(aProgress, aProgressMax);
 
.
    return m_PrintDlg->OnProgressPrinting(aCurSelfProgress, aMaxSelfProgress);
  }
.
  }
  return NS_OK;
.
  return NS_OK;
}
.
}
 
.
 
/* void OnEndPrinting (in PRUint32 aStatus); */
 
.
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aReque
st, in nsIURI location); */
NS_IMETHODIMP 
.
NS_IMETHODIMP 
CDlgPrintListener::OnEndPrinting(PRUint32 aStatus)
 
.
CDlgPrintListener::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *
aRequest, nsIURI *location)
{
.
{
  if (m_PrintDlg) {
.
    return NS_ERROR_NOT_IMPLEMENTED;
    return m_PrintDlg->OnEndPrinting(aStatus);
.
}
  }
.
 
  return NS_OK;
 
.
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest
, in nsresult aStatus, in wstring aMessage); */
 
.
NS_IMETHODIMP 
 
 
.
CDlgPrintListener::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aR
equest, nsresult aStatus, const PRUnichar *aMessage)
 
.
{
 
.
    return NS_ERROR_NOT_IMPLEMENTED;
 
.
}
 
.
 
 
 
.
/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aReque
st, in long state); */
 
.
NS_IMETHODIMP 
 
 
.
CDlgPrintListener::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *
aRequest, PRInt32 state)
 
.
{
 
.
    return NS_ERROR_NOT_IMPLEMENTED;
}
.
}
 
.
 
/////////////////////////////////////////////////////////////////////////////
.
/////////////////////////////////////////////////////////////////////////////
// CPrintProgressDialog dialog
.
// CPrintProgressDialog dialog
 
.
 
Skipping to line 194. 
  if(print) 
.
  if(print) 
  {
.
  {
    m_PrintListener = new CDlgPrintListener(this); // constructor addrefs
.
    m_PrintListener = new CDlgPrintListener(this); // constructor addrefs
    if (m_PrintListener) {
.
    if (m_PrintListener) {
      // doModal will be set to false if the print job was cancelled
.
      // doModal will be set to false if the print job was cancelled
      doModal = NS_SUCCEEDED(print->Print(m_DOMWin, nsnull, m_PrintListener)) 
== PR_TRUE;
.
      doModal = NS_SUCCEEDED(print->Print(m_DOMWin, nsnull, nsnull)) == PR_TRU
E;
    }
.
    }
  }
.
  }
 
.
 
  if (doModal) {
.
  if (doModal) {
    m_InModalMode = PR_TRUE;
.
    m_InModalMode = PR_TRUE;
Skipping to line 206. 
  }
.
  }
  return 0;
.
  return 0;
}
.
}
 
.
 
 
.
 
/* void OnStartPrinting (); */
.
 
NS_IMETHODIMP 
.
 
CPrintProgressDialog::OnStartPrinting()
.
 
{
.
 
  return NS_OK;
.
 
}
.
 
 
.
 
/* void OnProgressPrinting (in PRUint32 aProgress, in PRUint32 aProgressMax); 
*/
.
 
 
NS_IMETHODIMP 
.
 
CPrintProgressDialog::OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgres
sMax)
.
 
 
{
.
 
  // Initialize the progress meter we we get the "zero" progress
.
 
  // which also tells us the max progress
.
 
  if (aProgress == 0) {
.
 
	  CWnd *pWnd = GetDlgItem(IDC_PPD_DOC_TXT);
.
 
	  if(pWnd)
.
 
		  pWnd->SetWindowText(m_URL);
.
 
 
.
 
	  m_wndProgress.SetRange(0, aProgressMax);
.
 
    m_wndProgress.SetPos(0);
.
 
  }
.
 
	m_wndProgress.SetPos(aProgress);
.
 
  RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
.
 
 
.
 
  return NS_OK;
.
 
}
.
 
 
.
 
/* void OnEndPrinting (in PRUint32 aStatus); */
.
 
NS_IMETHODIMP 
.
 
CPrintProgressDialog::OnEndPrinting(PRUint32 aStatus)
.
 
{
.
 
  // Here we need to know whether we have gone "modal" 
.
 
  // because we could get notified here if the user cancels
.
 
  // before we ever get a chance to go into the modal loop
.
 
  if (m_InModalMode) {
.
 
    EndDialog(1);
.
 
  }
.
 
  return NS_OK;
.
 
}
.
 
 
.
 
void CPrintProgressDialog::OnCancel() 
.
void CPrintProgressDialog::OnCancel() 
{
.
{
  nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(m_WebBrowser));
.
  nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(m_WebBrowser));
  if (print) {
.
  if (print) {