From dc8e284e0420d13332e4ce739a79f75249851165 Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Sat, 11 Mar 2000 01:32:16 +0000 Subject: [PATCH] HandleUnknownContentType is no longer part of the nsIDocumentLoaderObserver interface. Use the docShell APIs where possible instead of the webShell ones. --- mailnews/base/src/nsMsgPrintEngine.cpp | 62 ++++++++++++++------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/mailnews/base/src/nsMsgPrintEngine.cpp b/mailnews/base/src/nsMsgPrintEngine.cpp index a12f6721f1c2..c185c94a6387 100644 --- a/mailnews/base/src/nsMsgPrintEngine.cpp +++ b/mailnews/base/src/nsMsgPrintEngine.cpp @@ -24,7 +24,6 @@ #include "nsIURI.h" #include "nsEscape.h" #include "nsIWebShell.h" -#include "nsIBaseWindow.h" #include "nsIDOMDocument.h" #include "nsIDocumentViewer.h" #include "nsIPresContext.h" @@ -40,6 +39,12 @@ #include "nsMsgPrintEngine.h" +// Interfaces Needed +#include "nsIBaseWindow.h" +#include "nsIDocShell.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDocShellTreeNode.h" + ///////////////////////////////////////////////////////////////////////// // nsMsgPrintEngine implementation ///////////////////////////////////////////////////////////////////////// @@ -81,8 +86,9 @@ nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIChannel *aChan nsresult rv = NS_ERROR_FAILURE; nsCOMPtr viewer; - NS_ASSERTION(mWebShell,"can't print, there is no webshell"); - if ( (!mWebShell) || (!aChannel) ) + nsCOMPtr docShell(do_QueryInterface(mWebShell)); + NS_ASSERTION(docShell,"can't print, there is no webshell"); + if ( (!docShell) || (!aChannel) ) { return StartNextPrintOperation(); } @@ -102,7 +108,7 @@ nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIChannel *aChan } } - mWebShell->GetContentViewer(getter_AddRefs(viewer)); + docShell->GetContentViewer(getter_AddRefs(viewer)); if (viewer) { nsCOMPtr viewerFile = do_QueryInterface(viewer); @@ -139,12 +145,6 @@ nsMsgPrintEngine::OnEndURLLoad(nsIDocumentLoader *aLoader, nsIChannel *aChannel, return NS_OK; } -NS_IMETHODIMP -nsMsgPrintEngine::HandleUnknownContentType(nsIDocumentLoader *aLoader, nsIChannel *aChannel, const char *aContentType, const char *aCommand) -{ - return NS_OK; -} - NS_IMETHODIMP nsMsgPrintEngine::SetWindow(nsIDOMWindow *aWin) { @@ -155,7 +155,6 @@ nsMsgPrintEngine::SetWindow(nsIDOMWindow *aWin) return NS_OK; } - nsAutoString webShellName("printengine"); NS_IF_RELEASE(mWindow); mWindow = aWin; NS_ADDREF(aWin); @@ -165,22 +164,25 @@ nsMsgPrintEngine::SetWindow(nsIDOMWindow *aWin) nsCOMPtr docShell; globalObj->GetDocShell(getter_AddRefs(docShell)); - nsCOMPtr webShell(do_QueryInterface(docShell)); - if (!webShell) - { - return NS_ERROR_FAILURE; - } - nsCOMPtr rootWebShell; - webShell->GetRootWebShell(*getter_AddRefs(rootWebShell)); - if (nsnull != rootWebShell) - { - nsresult rv = rootWebShell->FindChildWithName(webShellName.GetUnicode(), *getter_AddRefs(mWebShell)); - if (NS_SUCCEEDED(rv) && mWebShell) - { - SetupObserver(); - } - } + nsCOMPtr docShellAsItem(do_QueryInterface(docShell)); + NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE); + + nsCOMPtr rootAsItem; + docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootAsItem)); + + nsAutoString childName("printengine"); + nsCOMPtr rootAsNode(do_QueryInterface(rootAsItem)); + NS_ENSURE_TRUE(rootAsNode, NS_ERROR_FAILURE); + + nsCOMPtr childItem; + rootAsNode->FindChildWithName(childName.GetUnicode(), PR_TRUE, PR_FALSE, nsnull, + getter_AddRefs(childItem)); + + mWebShell = do_QueryInterface(childItem); + + if(mWebShell) + SetupObserver(); return NS_OK; } @@ -268,11 +270,12 @@ void nsMsgPrintEngine::InitializeDisplayCharset() { // libmime always converts to UTF-8 (both HTML and XML) - if (mWebShell) + nsCOMPtr docShell(do_QueryInterface(mWebShell)); + if (docShell) { nsAutoString aForceCharacterSet("UTF-8"); nsCOMPtr cv; - mWebShell->GetContentViewer(getter_AddRefs(cv)); + docShell->GetContentViewer(getter_AddRefs(cv)); if (cv) { nsCOMPtr muDV = do_QueryInterface(cv); @@ -293,7 +296,8 @@ nsMsgPrintEngine::SetupObserver() nsCOMPtr observer = do_QueryInterface(this); if (observer) { - mWebShell->SetDocLoaderObserver(observer); + nsCOMPtr docShell(do_QueryInterface(mWebShell)); + docShell->SetDocLoaderObserver(observer); } }