mailnews/base/src/nsMsgPrintEngine.cpp,1.42 | . | Disk File |
Skipping to line 40 | . | |
#include "nsIInterfaceRequestorUtils.h" |
. |
#include "nsIInterfaceRequestorUtils.h" |
#include "nsIMarkupDocumentViewer.h" |
. |
#include "nsIMarkupDocumentViewer.h" |
#include "nsIMsgMailSession.h" |
. |
#include "nsIMsgMailSession.h" |
#include "nsMsgPrintEngine.h" |
. |
#include "nsMsgPrintEngine.h" |
#include "nsMsgBaseCID.h" |
. |
#include "nsMsgBaseCID.h" |
  |
. |
#include "nsIDocumentLoader.h" |
|
. |
|
// Interfaces Needed |
. |
// Interfaces Needed |
#include "nsIBaseWindow.h" |
. |
#include "nsIBaseWindow.h" |
#include "nsIDocShellTreeItem.h" |
. |
#include "nsIDocShellTreeItem.h" |
#include "nsIDocShellTreeNode.h" |
. |
#include "nsIDocShellTreeNode.h" |
Skipping to line 67 | . | |
nsMsgPrintEngine::~nsMsgPrintEngine() |
. |
nsMsgPrintEngine::~nsMsgPrintEngine() |
{ |
. |
{ |
} |
. |
} |
|
. |
|
// Implement AddRef and Release |
. |
// Implement AddRef and Release |
NS_IMPL_ISUPPORTS4(nsMsgPrintEngine, |
. |
NS_IMPL_ISUPPORTS3(nsMsgPrintEngine, |
nsIMsgPrintEngine, |
. |
nsIMsgPrintEngine, |
nsIWebProgressListener, |
. |
nsIWebProgressListener, |
nsISupportsWeakReference, |
. |
nsISupportsWeakReference); |
nsIPrintListener); |
. |
  |
|
. |
|
// nsIWebProgressListener implementation |
. |
// nsIWebProgressListener implementation |
NS_IMETHODIMP |
. |
NS_IMETHODIMP |
nsMsgPrintEngine::OnStateChange(nsIWebProgress* aWebProgress, |
. |
nsMsgPrintEngine::OnStateChange(nsIWebProgress* aWebProgress, |
nsIRequest *aRequest, |
. |
nsIRequest *aRequest, |
Skipping to line 91 | . | |
SetStatusMessage( msg ); |
. |
SetStatusMessage( msg ); |
if (msg) nsCRT::free(msg); |
. |
if (msg) nsCRT::free(msg); |
} |
. |
} |
|
. |
|
if (progressStateFlags & nsIWebProgressListener::STATE_STOP) { |
. |
if (progressStateFlags & nsIWebProgressListener::STATE_STOP) { |
// Now, fire off the print operation! |
. |
// if aWebProgress is a documentloader than the notification from |
rv = NS_ERROR_FAILURE; |
. |
// loading the documents. If it is NULL (or not a DocLoader) then it |
  |
. |
// it coming from Printing |
  |
. |
nsCOMPtr<nsIDocumentLoader> docLoader(do_QueryInterface(aWebProgress)); |
  |
. |
if (docLoader) { |
  |
. |
// Now, fire off the print operation! |
  |
. |
rv = NS_ERROR_FAILURE; |
  |
. |
|
  |
. |
// Tell the user the message is loaded... |
  |
. |
PRUnichar *msg = GetString(NS_LITERAL_STRING("MessageLoaded").get()); |
  |
. |
SetStatusMessage( msg ); |
  |
. |
if (msg) nsCRT::free(msg); |
|
. |
|
// Tell the user the message is loaded... |
. |
NS_ASSERTION(mDocShell,"can't print, there is no docshell"); |
PRUnichar *msg = GetString(NS_LITERAL_STRING("MessageLoaded").get()); |
. |
if ( (!mDocShell) || (!aRequest) ) |
SetStatusMessage( msg ); |
. |
{ |
if (msg) nsCRT::free(msg); |
. |
return StartNextPrintOperation(); |
|
. |
} |
NS_ASSERTION(mDocShell,"can't print, there is no docshell"); |
. |
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(aRequest); |
if ( (!mDocShell) || (!aRequest) ) |
. |
if (!aChannel) return NS_ERROR_FAILURE; |
{ |
. |
  |
return StartNextPrintOperation(); |
. |
  |
} |
. |
  |
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(aRequest); |
. |
  |
if (!aChannel) return NS_ERROR_FAILURE; |
. |
  |
|
. |
|
// Make sure this isn't just "about:blank" finishing.... |
. |
// Make sure this isn't just "about:blank" finishing.... |
nsCOMPtr<nsIURI> originalURI = nsnull; |
. |
nsCOMPtr<nsIURI> originalURI = nsnull; |
if (NS_SUCCEEDED(aChannel->GetOriginalURI(getter_AddRefs(originalURI)))
&& originalURI) |
. |
if (NS_SUCCEEDED(aChannel->GetOriginalURI(getter_AddRefs(originalURI))
) && originalURI) |
{ |
. |
{ |
nsXPIDLCString spec; |
. |
nsXPIDLCString spec; |
|
. |
|
if (NS_SUCCEEDED(originalURI->GetSpec(getter_Copies(spec))) && spec)
|
. |
if (NS_SUCCEEDED(originalURI->GetSpec(getter_Copies(spec))) && spec) |
{ |
. |
{ |
if (!nsCRT::strcasecmp(spec, "about:blank")) |
. |
if (!nsCRT::strcasecmp(spec, "about:blank")) |
{ |
. |
{ |
return StartNextPrintOperation(); |
. |
return StartNextPrintOperation(); |
  |
. |
} |
} |
. |
} |
} |
. |
} |
} |
. |
  |
|
. |
|
mDocShell->GetContentViewer(getter_AddRefs(mContentViewer)); |
. |
mDocShell->GetContentViewer(getter_AddRefs(mContentViewer)); |
if (mContentViewer) |
. |
if (mContentViewer) |
{ |
. |
  |
mViewerFile = do_QueryInterface(mContentViewer); |
. |
  |
if (mViewerFile) |
. |
  |
{ |
. |
{ |
if (mCurrentlyPrintingURI == 0) |
. |
mViewerFile = do_QueryInterface(mContentViewer); |
rv = mViewerFile->Print(PR_FALSE, nsnull, (nsIPrintListener *)this
); |
. |
if (mViewerFile)
|
else |
. |
  |
rv = mViewerFile->Print(PR_TRUE, nsnull, (nsIPrintListener *)this)
; |
. |
 
|
|
. |
  |
if (NS_FAILED(rv)) |
. |
  |
{ |
. |
  |
mViewerFile = nsnull; |
. |
  |
mContentViewer = nsnull; |
. |
  |
OnEndPrinting(rv); |
. |
  |
} |
. |
  |
else |
. |
  |
{ |
. |
{ |
// Tell the user we started printing... |
. |
if (mCurrentlyPrintingURI == 0) |
msg = GetString(NS_LITERAL_STRING("PrintingMessage").get());
|
. |
rv = mViewerFile->Print(PR_FALSE, nsnull, (nsIWebProgressListene
r *)this); |
SetStatusMessage( msg ); |
. |
else |
if (msg) nsCRT::free(msg);
|
. |
rv = mViewerFile->Print(PR_TRUE, nsnull, (nsIWebProgressListener
*)this); |
  |
. |
|
  |
. |
if (NS_FAILED(rv)) |
  |
. |
{ |
  |
. |
mViewerFile = nsnull; |
  |
. |
mContentViewer = nsnull; |
  |
. |
StartNextPrintOperation(); |
  |
. |
} |
  |
. |
else |
  |
. |
{ |
  |
. |
// Tell the user we started printing... |
  |
. |
msg = GetString(NS_LITERAL_STRING("PrintingMessage").get()); |
  |
. |
SetStatusMessage( msg ); |
  |
. |
if (msg) nsCRT::free(msg); |
  |
. |
} |
} |
. |
} |
} |
. |
} |
  |
. |
} else { |
  |
. |
StartNextPrintOperation(); |
  |
. |
rv = NS_OK; |
} |
. |
} |
} |
. |
} |
} |
. |
} |
|
. |
|
return rv; |
. |
return rv; |
Skipping to line 368 | . | |
nsCOMPtr<nsIWebProgress> progress(do_GetInterface(mDocShell)); |
. |
nsCOMPtr<nsIWebProgress> progress(do_GetInterface(mDocShell)); |
NS_ASSERTION(progress, "we were expecting a nsIWebProgress"); |
. |
NS_ASSERTION(progress, "we were expecting a nsIWebProgress"); |
if (progress) { |
. |
if (progress) { |
(void) progress->AddProgressListener((nsIWebProgressListener *)this); |
. |
(void) progress->AddProgressListener((nsIWebProgressListener *)this); |
} |
. |
} |
} |
. |
} |
} |
. |
  |
|
. |
  |
NS_IMETHODIMP |
. |
  |
nsMsgPrintEngine::OnStartPrinting(void) |
. |
  |
{ |
. |
  |
return NS_OK; |
. |
  |
} |
. |
  |
|
. |
  |
NS_IMETHODIMP |
. |
  |
nsMsgPrintEngine::OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgressMax
) |
. |
 
|
{ |
. |
  |
return NS_OK; |
. |
  |
} |
. |
  |
|
. |
  |
NS_IMETHODIMP |
. |
  |
nsMsgPrintEngine::OnEndPrinting(PRUint32 aStatus) |
. |
  |
{ |
. |
  |
StartNextPrintOperation(); |
. |
  |
return NS_OK; |
. |
  |
} |
. |
} |
|
. |
|
nsresult |
. |
nsresult |
nsMsgPrintEngine::SetStatusMessage(PRUnichar *aMsgString) |
. |
nsMsgPrintEngine::SetStatusMessage(PRUnichar *aMsgString) |
{ |
. |
{ |