зеркало из https://github.com/mozilla/pjs.git
This now enables print listeners, print progress and the cancelling of printing
Bug 70946 & Bug 70949 r=dcone,chak sr=attinasi
This commit is contained in:
Родитель
4421ccbfc6
Коммит
ac1cbced14
|
@ -28,3 +28,4 @@ nsIEmbeddingSiteWindow.idl
|
|||
nsIWebBrowserPersist.idl
|
||||
nsIWebBrowserFocus.idl
|
||||
nsIWebBrowserFind.idl
|
||||
nsIWebBrowserPrint.idl
|
||||
|
|
|
@ -42,6 +42,7 @@ XPIDLSRCS = \
|
|||
nsIWebBrowserPersist.idl \
|
||||
nsIWebBrowserFocus.idl \
|
||||
nsIWebBrowserFind.idl \
|
||||
nsIWebBrowserPrint.idl \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -34,6 +34,7 @@ XPIDLSRCS= \
|
|||
.\nsIEmbeddingSiteWindow.idl \
|
||||
.\nsIWebBrowserFocus.idl \
|
||||
.\nsIWebBrowserFind.idl \
|
||||
.\nsIWebBrowserPrint.idl \
|
||||
$(NULL)
|
||||
|
||||
LIBRARY_NAME=nsWebBrowser_s
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
interface nsIDOMWindow;
|
||||
interface nsIPrintSettings;
|
||||
|
||||
|
||||
interface nsIPrintOptions;
|
||||
interface nsIPrintListener;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,11 @@ interface nsIWebBrowserPrint : nsISupports
|
|||
* aDOMWindow - The DOM window to print
|
||||
* aThePrintOptions - Printer Settings for the print job
|
||||
*/
|
||||
void Print(in nsIDOMWindow aDOMWindow,in nsIPrintOptions aThePrintOptions);
|
||||
void Print(in nsIDOMWindow aDOMWindow,
|
||||
in nsIPrintOptions aThePrintOptions,
|
||||
in nsIPrintListener aPrintListsner);
|
||||
|
||||
void Cancel();
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -45,6 +45,15 @@
|
|||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIWebBrowserFocus.h"
|
||||
|
||||
// Printing Includes
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIContentViewerFile.h"
|
||||
// Print Options
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsIServiceManager.h"
|
||||
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
|
||||
|
||||
static NS_DEFINE_CID(kWebShellCID, NS_WEB_SHELL_CID);
|
||||
static NS_DEFINE_IID(kChildCID, NS_CHILD_CID);
|
||||
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
|
@ -131,6 +140,7 @@ NS_INTERFACE_MAP_BEGIN(nsWebBrowser)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserPersist)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserFocus)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserFind)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserPrint)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
///*****************************************************************************
|
||||
|
@ -1587,3 +1597,38 @@ NS_IMETHODIMP nsWebBrowser::SetFocusedElement(nsIDOMElement * aFocusedElement)
|
|||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
/* void Print (in nsIDOMWindow aDOMWindow, in nsIPrintOptions aThePrintOptions); */
|
||||
NS_IMETHODIMP nsWebBrowser::Print(nsIDOMWindow *aDOMWindow,
|
||||
nsIPrintOptions *aThePrintOptions,
|
||||
nsIPrintListener *aPrintListener)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMWindow> thisDOMWin;
|
||||
// XXX this next line may need to be changed
|
||||
// it is unclear what the correct way is to get the document.
|
||||
GetContentDOMWindow(getter_AddRefs(thisDOMWin));
|
||||
if (aDOMWindow == thisDOMWin.get()) {
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
|
||||
if (contentViewer) {
|
||||
nsCOMPtr<nsIContentViewerFile> contentViewerFile(do_QueryInterface(contentViewer));
|
||||
if (contentViewerFile) {
|
||||
rv = contentViewerFile->Print(PR_FALSE, nsnull, aPrintListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void Cancel (); */
|
||||
NS_IMETHODIMP nsWebBrowser::Cancel(void)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && printService) {
|
||||
return printService->SetIsCancelled(PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsIWebBrowserPersist.h"
|
||||
#include "nsIWebBrowserFocus.h"
|
||||
#include "nsIWebBrowserFind.h"
|
||||
#include "nsIWebBrowserPrint.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
|
@ -89,7 +90,8 @@ class nsWebBrowser : public nsIWebBrowser,
|
|||
public nsIInterfaceRequestor,
|
||||
public nsIWebBrowserPersist,
|
||||
public nsIWebBrowserFocus,
|
||||
public nsIWebBrowserFind
|
||||
public nsIWebBrowserFind,
|
||||
public nsIWebBrowserPrint
|
||||
{
|
||||
friend class nsDocShellTreeOwner;
|
||||
friend class nsWBURIContentListener;
|
||||
|
@ -109,7 +111,8 @@ public:
|
|||
NS_DECL_NSIWEBBROWSERPERSIST
|
||||
NS_DECL_NSIWEBBROWSERFOCUS
|
||||
NS_DECL_NSIWEBBROWSERFIND
|
||||
|
||||
NS_DECL_NSIWEBBROWSERPRINT
|
||||
|
||||
protected:
|
||||
virtual ~nsWebBrowser();
|
||||
NS_IMETHOD InternalDestroy();
|
||||
|
|
|
@ -52,6 +52,10 @@
|
|||
#include "BrowserFrm.h"
|
||||
#include "Dialogs.h"
|
||||
|
||||
// Print Includes
|
||||
#include "PrintProgressDialog.h"
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
|
@ -96,6 +100,8 @@ BEGIN_MESSAGE_MAP(CBrowserView, CWnd)
|
|||
ON_COMMAND(ID_SAVE_LINK_AS, OnSaveLinkAs)
|
||||
ON_COMMAND(ID_SAVE_IMAGE_AS, OnSaveImageAs)
|
||||
ON_COMMAND(ID_EDIT_FIND, OnShowFindDlg)
|
||||
ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
|
||||
ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint)
|
||||
ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg)
|
||||
|
||||
// Menu/Toolbar UI update handlers
|
||||
|
@ -122,8 +128,10 @@ CBrowserView::CBrowserView()
|
|||
mbDocumentLoading = PR_FALSE;
|
||||
|
||||
m_pFindDlg = NULL;
|
||||
m_pPrintProgressDlg = NULL;
|
||||
|
||||
m_bUrlBarClipOp = FALSE;
|
||||
m_bUrlBarClipOp = FALSE;
|
||||
m_bCurrentlyPrinting = FALSE;
|
||||
}
|
||||
|
||||
CBrowserView::~CBrowserView()
|
||||
|
@ -901,6 +909,39 @@ LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CBrowserView::OnFilePrint()
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
if(domWindow) {
|
||||
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser));
|
||||
if(print)
|
||||
{
|
||||
CPrintProgressDialog dlg(mWebBrowser, domWindow);
|
||||
|
||||
nsCOMPtr<nsIURI> currentURI;
|
||||
nsresult rv = mWebNav->GetCurrentURI(getter_AddRefs(currentURI));
|
||||
if(NS_SUCCEEDED(rv) || currentURI)
|
||||
{
|
||||
nsXPIDLCString path;
|
||||
currentURI->GetPath(getter_Copies(path));
|
||||
dlg.SetURI(path.get());
|
||||
}
|
||||
m_bCurrentlyPrinting = TRUE;
|
||||
dlg.DoModal();
|
||||
m_bCurrentlyPrinting = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void CBrowserView::OnUpdateFilePrint(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable(!m_bCurrentlyPrinting);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Called from the busy state related methods in the
|
||||
// BrowserFrameGlue object
|
||||
//
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
class CBrowserFrame;
|
||||
class CBrowserImpl;
|
||||
class CFindDialog;
|
||||
class CPrintProgressDialog;
|
||||
|
||||
class CBrowserView : public CWnd
|
||||
{
|
||||
|
@ -94,7 +95,7 @@ public:
|
|||
|
||||
inline void ClearFindDialog() { m_pFindDlg = NULL; }
|
||||
CFindDialog* m_pFindDlg;
|
||||
|
||||
CPrintProgressDialog* m_pPrintProgressDlg;
|
||||
// When set to TRUE...
|
||||
// indicates that the clipboard operation needs to be
|
||||
// performed on the UrlBar rather than on
|
||||
|
@ -102,6 +103,9 @@ public:
|
|||
//
|
||||
BOOL m_bUrlBarClipOp;
|
||||
|
||||
// indicates whether we are currently printing
|
||||
BOOL m_bCurrentlyPrinting;
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CBrowserView)
|
||||
|
@ -144,6 +148,8 @@ protected:
|
|||
afx_msg void OnSaveLinkAs();
|
||||
afx_msg void OnSaveImageAs();
|
||||
afx_msg void OnShowFindDlg();
|
||||
afx_msg void OnFilePrint();
|
||||
afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI);
|
||||
afx_msg LRESULT OnFindMsg(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
// Handlers to keep the toolbar/menu items up to date
|
||||
|
|
|
@ -108,6 +108,8 @@ BEGIN
|
|||
MENUITEM "&Open File...\tCtrl+O", ID_FILE_OPEN
|
||||
MENUITEM "&Save Page As...\tCtrl+S", ID_FILE_SAVE_AS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Print...\tCtrl-P", ID_FILE_PRINT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
|
@ -232,7 +234,7 @@ BEGIN
|
|||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT
|
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_ESCAPE, ID_NAV_STOP, VIRTKEY
|
||||
VK_ESCAPE, ID_NAV_STOP, VIRTKEY
|
||||
END
|
||||
|
||||
|
||||
|
@ -356,6 +358,17 @@ BEGIN
|
|||
PUSHBUTTON "Cancel",IDCANCEL,182,23,50,14
|
||||
END
|
||||
|
||||
IDD_PRINT_PROGRESS_DIALOG DIALOG DISCARDABLE 0, 0, 294, 55
|
||||
STYLE DS_SYSMODAL | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE |
|
||||
WS_CAPTION
|
||||
CAPTION "Printing..."
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
PUSHBUTTON "Cancel",IDCANCEL,122,34,50,14
|
||||
LTEXT "Document:",IDC_PPD_DOC_TITLE_STATIC,7,7,36,8
|
||||
LTEXT "",IDC_PPD_DOC_TXT,43,7,244,8
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -439,6 +452,14 @@ BEGIN
|
|||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 69
|
||||
END
|
||||
|
||||
IDD_PRINT_PROGRESS_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 287
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 48
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
|
|
@ -0,0 +1,246 @@
|
|||
// PrintProgressDialog.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "mfcembed.h"
|
||||
#include "PrintProgressDialog.h"
|
||||
#include "BrowserView.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsIWebBrowserPrint.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPrintProgressDialog dialog
|
||||
|
||||
class CDlgPrintListener : public nsIPrintListener
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CDlgPrintListener(CPrintProgressDialog* aDlg);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPRINTLISTENER
|
||||
|
||||
void ClearDlg() { m_PrintDlg = NULL; } // weak reference
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
CPrintProgressDialog* m_PrintDlg;
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(CDlgPrintListener)
|
||||
NS_IMPL_RELEASE(CDlgPrintListener)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(CDlgPrintListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrintListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIPrintListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
CDlgPrintListener::CDlgPrintListener(CPrintProgressDialog* aDlg) :
|
||||
m_PrintDlg(aDlg)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
//NS_ADDREF_THIS();
|
||||
}
|
||||
|
||||
/* void OnStartPrinting (); */
|
||||
NS_IMETHODIMP
|
||||
CDlgPrintListener::OnStartPrinting()
|
||||
{
|
||||
if (m_PrintDlg) {
|
||||
return m_PrintDlg->OnStartPrinting();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void OnProgressPrinting (in PRUint32 aProgress, in PRUint32 aProgressMax); */
|
||||
NS_IMETHODIMP
|
||||
CDlgPrintListener::OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgressMax)
|
||||
{
|
||||
if (m_PrintDlg) {
|
||||
return m_PrintDlg->OnProgressPrinting(aProgress, aProgressMax);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void OnEndPrinting (in PRUint32 aStatus); */
|
||||
NS_IMETHODIMP
|
||||
CDlgPrintListener::OnEndPrinting(PRUint32 aStatus)
|
||||
{
|
||||
if (m_PrintDlg) {
|
||||
return m_PrintDlg->OnEndPrinting(aStatus);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPrintProgressDialog dialog
|
||||
|
||||
|
||||
CPrintProgressDialog::CPrintProgressDialog(nsIWebBrowser* aWebBrowser,
|
||||
nsIDOMWindow* aDOMWin,
|
||||
CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CPrintProgressDialog::IDD, pParent),
|
||||
m_WebBrowser(aWebBrowser),
|
||||
m_DOMWin(aDOMWin),
|
||||
m_PrintListener(nsnull),
|
||||
m_InModalMode(PR_FALSE)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CPrintProgressDialog)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
CPrintProgressDialog::~CPrintProgressDialog()
|
||||
{
|
||||
CDlgPrintListener * pl = (CDlgPrintListener*)m_PrintListener.get();
|
||||
if (pl) {
|
||||
pl->ClearDlg();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPrintProgressDialog::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CPrintProgressDialog)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CPrintProgressDialog, CDialog)
|
||||
//{{AFX_MSG_MAP(CPrintProgressDialog)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPrintProgressDialog message handlers
|
||||
static void GetLocalRect(CWnd * aWnd, CRect& aRect, CWnd * aParent)
|
||||
{
|
||||
CRect wr;
|
||||
aParent->GetWindowRect(wr);
|
||||
|
||||
CRect cr;
|
||||
aParent->GetClientRect(cr);
|
||||
|
||||
aWnd->GetWindowRect(aRect);
|
||||
|
||||
int borderH = wr.Height() - cr.Height();
|
||||
int borderW = (wr.Width() - cr.Width())/2;
|
||||
aRect.top -= wr.top+borderH-borderW;
|
||||
aRect.left -= wr.left+borderW;
|
||||
aRect.right -= wr.left+borderW;
|
||||
aRect.bottom -= wr.top+borderH-borderW;
|
||||
|
||||
}
|
||||
|
||||
BOOL CPrintProgressDialog::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
CRect clientRect;
|
||||
GetClientRect(&clientRect);
|
||||
|
||||
CRect titleRect;
|
||||
GetLocalRect(GetDlgItem(IDC_PPD_DOC_TITLE_STATIC), titleRect, this);
|
||||
|
||||
CRect itemRect;
|
||||
GetLocalRect(GetDlgItem(IDC_PPD_DOC_TXT), itemRect, this);
|
||||
|
||||
CRect progRect;
|
||||
progRect.left = titleRect.left;
|
||||
progRect.top = itemRect.top+itemRect.Height()+5;
|
||||
progRect.right = clientRect.Width()-(2*titleRect.left);
|
||||
progRect.bottom = progRect.top+titleRect.Height();
|
||||
|
||||
|
||||
m_wndProgress.Create (WS_CHILD | WS_VISIBLE, progRect, this, -1);
|
||||
m_wndProgress.SetPos (0);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
int CPrintProgressDialog::DoModal( )
|
||||
{
|
||||
PRBool doModal = PR_FALSE;
|
||||
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(m_WebBrowser));
|
||||
if(print)
|
||||
{
|
||||
m_PrintListener = new CDlgPrintListener(this); // constructor addrefs
|
||||
if (m_PrintListener) {
|
||||
// doModal will be set to false if the print job was cancelled
|
||||
doModal = NS_SUCCEEDED(print->Print(m_DOMWin, nsnull, m_PrintListener)) == PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (doModal) {
|
||||
m_InModalMode = PR_TRUE;
|
||||
return CDialog::DoModal();
|
||||
}
|
||||
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 aProgressMax)
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(m_WebBrowser));
|
||||
if (print) {
|
||||
print->Cancel();
|
||||
}
|
||||
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
void CPrintProgressDialog::SetURI(const char* aTitle)
|
||||
{
|
||||
m_URL = _T(aTitle);
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
#if !defined(AFX_PRINTPROGRESSDIALOG_H__1BAF9B13_1875_11D5_9773_000064657374__INCLUDED_)
|
||||
#define AFX_PRINTPROGRESSDIALOG_H__1BAF9B13_1875_11D5_9773_000064657374__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// PrintProgressDialog.h : header file
|
||||
//
|
||||
|
||||
#include "nsIPrintListener.h"
|
||||
class nsIWebBrowser;
|
||||
class nsIDOMWindow;
|
||||
class nsIPrintListener;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPrintProgressDialog dialog
|
||||
|
||||
class CPrintProgressDialog : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CPrintProgressDialog(nsIWebBrowser* aWebBrowser,
|
||||
nsIDOMWindow* aDOMWin,
|
||||
CWnd* pParent = NULL);
|
||||
virtual ~CPrintProgressDialog();
|
||||
virtual int DoModal( );
|
||||
|
||||
// Helper
|
||||
void SetURI(const char* aTitle);
|
||||
|
||||
// same as nsIPrintListener
|
||||
NS_IMETHOD OnStartPrinting(void);
|
||||
NS_IMETHOD OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD OnEndPrinting(PRUint32 aStatus);
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPrintProgressDialog)
|
||||
enum { IDD = IDD_PRINT_PROGRESS_DIALOG };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPrintProgressDialog)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
CProgressCtrl m_wndProgress;
|
||||
CString m_URL;
|
||||
nsIWebBrowser* m_WebBrowser;
|
||||
nsIDOMWindow* m_DOMWin;
|
||||
nsCOMPtr<nsIPrintListener> m_PrintListener;
|
||||
BOOL m_InModalMode;
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CPrintProgressDialog)
|
||||
virtual BOOL OnInitDialog();
|
||||
virtual void OnCancel();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_PRINTPROGRESSDIALOG_H__1BAF9B13_1875_11D5_9773_000064657374__INCLUDED_)
|
|
@ -83,6 +83,11 @@
|
|||
#include "nsIEmbeddingSiteWindow.h"
|
||||
#include "nsIWebBrowserFind.h"
|
||||
|
||||
// Printer Includes
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsIWebBrowserPrint.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ OBJS = \
|
|||
.\$(OBJDIR)\ProfilesDlg.obj \
|
||||
.\$(OBJDIR)\winEmbedFileLocProvider.obj \
|
||||
.\$(OBJDIR)\MostRecentUrls.obj \
|
||||
.\$(OBJDIR)\PrintProgressDialog.obj \
|
||||
.\$(OBJDIR)\StdAfx.obj \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -130,6 +130,10 @@ SOURCE=.\MostRecentUrls.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PrintProgressDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ProfileMgr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -178,6 +182,10 @@ SOURCE=.\MostRecentUrls.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PrintProgressDialog.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ProfileMgr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by MfcEmbed.rc
|
||||
// Used by mfcembed.rc
|
||||
//
|
||||
#define IDD_ABOUTBOX 100
|
||||
#define IDR_MAINFRAME 128
|
||||
|
@ -11,11 +11,12 @@
|
|||
#define IDR_CTXMENU_IMAGE 133
|
||||
#define IDD_PROMPT_DIALOG 134
|
||||
#define IDD_PROMPT_PASSWORD_DIALOG 135
|
||||
#define IDD_PROMPT_USERPASS_DIALOG 136
|
||||
#define IDD_PROFILES 137
|
||||
#define IDD_PROFILE_NEW 138
|
||||
#define IDD_PROFILE_RENAME 139
|
||||
#define IDD_FINDDLG 140
|
||||
#define IDD_PROMPT_USERPASS_DIALOG 136
|
||||
#define IDD_PROFILES 137
|
||||
#define IDD_PROFILE_NEW 138
|
||||
#define IDD_PROFILE_RENAME 139
|
||||
#define IDD_FINDDLG 140
|
||||
#define IDD_PRINT_PROGRESS_DIALOG 141
|
||||
#define ID_URL_BAR 1001
|
||||
#define ID_PROG_BAR 1002
|
||||
#define IDC_PROMPT_ANSWER 1003
|
||||
|
@ -26,23 +27,21 @@
|
|||
#define IDC_CHECK_SAVE_PASSWORD 1008
|
||||
#define IDC_USERNAME_LABEL 1009
|
||||
#define IDC_PASSWORD_LABEL 1010
|
||||
#define IDC_LIST1 1011
|
||||
#define IDC_PROF_RENAME 1012
|
||||
#define IDC_PROF_DELETE 1013
|
||||
#define IDC_PROF_NEW 1014
|
||||
#define IDC_CHECK_ASK_AT_START 1015
|
||||
#define IDC_NEW_PROF_NAME 1016
|
||||
#define IDC_LOCALE_COMBO 1017
|
||||
#define IDC_NEW_NAME 1018
|
||||
// BEGIN - Do not change these IDs
|
||||
// These IDs are needed for the MFC FindReplaceDialog
|
||||
// to work properly
|
||||
#define IDC_LIST1 1011
|
||||
#define IDC_PROF_RENAME 1012
|
||||
#define IDC_PROF_DELETE 1013
|
||||
#define IDC_PROF_NEW 1014
|
||||
#define IDC_CHECK_ASK_AT_START 1015
|
||||
#define IDC_NEW_PROF_NAME 1016
|
||||
#define IDC_LOCALE_COMBO 1017
|
||||
#define IDC_NEW_NAME 1018
|
||||
#define IDC_PPD_DOC_TXT 1020
|
||||
#define IDC_PPD_DOC_TITLE_STATIC 1021
|
||||
#define IDC_MATCH_WHOLE_WORD 1040
|
||||
#define IDC_MATCH_CASE 1041
|
||||
#define IDC_WRAP_AROUND 1042
|
||||
#define IDC_SEARCH_BACKWARDS 1043
|
||||
#define IDC_FIND_EDIT 1152
|
||||
// END - Do not change these IDs
|
||||
#define ID_NAV_BACK 32773
|
||||
#define ID_NAV_FORWARD 32774
|
||||
#define ID_NAV_HOME 32775
|
||||
|
@ -57,16 +56,16 @@
|
|||
#define ID_SAVE_LINK_AS 32784
|
||||
#define ID_SAVE_IMAGE_AS 32785
|
||||
#define ID_COPY_LINK_LOCATION 32786
|
||||
#define ID_MANAGE_PROFILES 32787
|
||||
#define ID_MANAGE_PROFILES 32787
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 141
|
||||
#define _APS_NEXT_COMMAND_VALUE 32788
|
||||
#define _APS_NEXT_CONTROL_VALUE 1019
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 142
|
||||
#define _APS_NEXT_COMMAND_VALUE 32789
|
||||
#define _APS_NEXT_CONTROL_VALUE 1022
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче