Bug 234752 - Print code returns NS_OK in cases where it should return

an error.  Patch by roland.mainz@nrubsig.org, r+sr=roc.
This commit is contained in:
tor%cs.brown.edu 2004-02-19 21:58:40 +00:00
parent d03176fafc
commit 1b99ebfbae
8 changed files with 53 additions and 18 deletions

View File

@ -3069,7 +3069,8 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
mCachedPrintWebProgressListner = aWebProgressListener; mCachedPrintWebProgressListner = aWebProgressListener;
mPrintIsPending = PR_TRUE; mPrintIsPending = PR_TRUE;
} }
return NS_OK; PR_PL(("Printing Stopped - document is still busy!"));
return NS_ERROR_GFX_PRINTER_DOC_IS_BUSY;
} }
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
@ -3120,8 +3121,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
} }
return rv; return rv;
#else #else
return NS_ERROR_FAILURE; PR_PL(("NS_PRINTING not defined - printing not implemented in this build!"));
#endif return NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED;
#endif /* NS_PRINTING */
} }
/** --------------------------------------------------- /** ---------------------------------------------------

View File

@ -2219,18 +2219,22 @@ void
nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting) nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting)
{ {
nsresult rv; nsresult rv;
PR_PL(("nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError=%lx, PRBool aIsPrinting=%d)\n", (long)rv, (int)aIsPrinting));
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(kCStringBundleServiceCID); nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(kCStringBundleServiceCID);
if (!stringBundleService) { if (!stringBundleService) {
NS_WARNING("ERROR: Failed to get StringBundle Service instance.\n"); PR_PL(("ShowPrintErrorDialog: Failed to get StringBundle Service instance.\n"));
return; return;
} }
nsCOMPtr<nsIStringBundle> myStringBundle; nsCOMPtr<nsIStringBundle> myStringBundle;
rv = stringBundleService->CreateBundle(NS_ERROR_GFX_PRINTER_BUNDLE_URL, getter_AddRefs(myStringBundle)); rv = stringBundleService->CreateBundle(NS_ERROR_GFX_PRINTER_BUNDLE_URL, getter_AddRefs(myStringBundle));
if (NS_FAILED(rv)) if (NS_FAILED(rv)) {
PR_PL(("ShowPrintErrorDialog(): CreateBundle() failure for NS_ERROR_GFX_PRINTER_BUNDLE_URL, rv=%lx\n", (long)rv));
return; return;
}
nsXPIDLString msg, nsXPIDLString msg,
title; title;
@ -2273,6 +2277,9 @@ nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTROMPTSERVICE) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTROMPTSERVICE)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_XPRINT_NO_XPRINT_SERVERS_FOUND) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_XPRINT_NO_XPRINT_SERVERS_FOUND)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE)
default: default:
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_FAILURE) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_FAILURE)
@ -2290,8 +2297,10 @@ nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting)
myStringBundle->GetStringFromName(NS_LITERAL_STRING("printpreview_error_dialog_title").get(), getter_Copies(title)); myStringBundle->GetStringFromName(NS_LITERAL_STRING("printpreview_error_dialog_title").get(), getter_Copies(title));
} }
if (!msg) if (!msg) {
PR_PL(("ShowPrintErrorDialog(): msg==nsnull\n"));
return; return;
}
nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv); nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
if (NS_FAILED(rv)) if (NS_FAILED(rv))

View File

@ -150,7 +150,16 @@ typedef void * nsNativeDeviceContext;
/* requested plex mode not supported by printer */ /* requested plex mode not supported by printer */
#define NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED \ #define NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+31) NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+31)
/* The document is still being loaded */
#define NS_ERROR_GFX_PRINTER_DOC_IS_BUSY \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+32)
/* Printing is not implemented */
#define NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+33)
/* Cannot load the matching print module */
#define NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+34)
/** /**
* Conts need for Print Preview * Conts need for Print Preview
*/ */

View File

@ -536,7 +536,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDev
nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv)); nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context."); NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context.");
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE;
rv = dcxp->SetSpec(aDevice); rv = dcxp->SetSpec(aDevice);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
@ -562,7 +562,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDev
nsCOMPtr<nsIDeviceContextPS> dcps(do_CreateInstance(kCDeviceContextPS, &rv)); nsCOMPtr<nsIDeviceContextPS> dcps(do_CreateInstance(kCDeviceContextPS, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context."); NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context.");
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE;
rv = dcps->SetSpec(aDevice); rv = dcps->SetSpec(aDevice);
if (NS_FAILED(rv)) if (NS_FAILED(rv))

View File

@ -442,7 +442,7 @@ NS_IMETHODIMP nsDeviceContextXlib::GetDeviceContextFor(nsIDeviceContextSpec *aDe
nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv)); nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context."); NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context.");
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE;
rv = dcxp->SetSpec(aDevice); rv = dcxp->SetSpec(aDevice);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
@ -468,7 +468,7 @@ NS_IMETHODIMP nsDeviceContextXlib::GetDeviceContextFor(nsIDeviceContextSpec *aDe
nsCOMPtr<nsIDeviceContextPS> dcps(do_CreateInstance(kCDeviceContextPS, &rv)); nsCOMPtr<nsIDeviceContextPS> dcps(do_CreateInstance(kCDeviceContextPS, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context."); NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context.");
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE;
rv = dcps->SetSpec(aDevice); rv = dcps->SetSpec(aDevice);
if (NS_FAILED(rv)) if (NS_FAILED(rv))

View File

@ -3069,7 +3069,8 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
mCachedPrintWebProgressListner = aWebProgressListener; mCachedPrintWebProgressListner = aWebProgressListener;
mPrintIsPending = PR_TRUE; mPrintIsPending = PR_TRUE;
} }
return NS_OK; PR_PL(("Printing Stopped - document is still busy!"));
return NS_ERROR_GFX_PRINTER_DOC_IS_BUSY;
} }
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIPresShell> presShell;
@ -3120,8 +3121,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
} }
return rv; return rv;
#else #else
return NS_ERROR_FAILURE; PR_PL(("NS_PRINTING not defined - printing not implemented in this build!"));
#endif return NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED;
#endif /* NS_PRINTING */
} }
/** --------------------------------------------------- /** ---------------------------------------------------

View File

@ -85,8 +85,12 @@ NS_ERROR_GFX_PRINTER_DOC_IS_BUSY_PP=The browser cannot print preview right now.\
NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED=The page was replaced while you were trying to print.\nPlease try again. NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED=The page was replaced while you were trying to print.\nPlease try again.
NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT=Either pluggable dialogs were not properly installed\nOr this GFX Toolkit no longer supports native Print Dialogs NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT=Either pluggable dialogs were not properly installed\nOr this GFX Toolkit no longer supports native Print Dialogs
NS_ERROR_GFX_NO_PRINTROMPTSERVICE=The Printing Prompt Service is missing. NS_ERROR_GFX_NO_PRINTROMPTSERVICE=The Printing Prompt Service is missing.
NS_ERROR_GFX_PRINTER_XPRINT_NO_XPRINT_SERVERS_FOUND=There was a problem printing. No Xprint server(s) could be found.\nCheck whether the XPSERVERLIST environment variable contains any valid Xprint servers. NS_ERROR_GFX_PRINTER_XPRINT_NO_XPRINT_SERVERS_FOUND=There was a problem printing. No Xprint server(s) could be found.\nCheck whether the XPSERVERLIST environment variable contains any valid Xprint servers.\nFor further information see http://xprint.mozdev.org/ or http://www.mozilla.org/projects/xprint/
NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED=There was a problem printing because the plex mode you specified is not supported by your printer. NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED=There was a problem printing because the plex mode you specified is not supported by your printer.
NS_ERROR_GFX_PRINTER_DOC_IS_BUSY=The browser cannot print the document while it is being loaded.
NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED=Printing is not implemented.
NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE=The requested print module cannot be loaded.
# No printers available # No printers available
noprinter=No printers available. noprinter=No printers available.
PrintToFile=Print To File PrintToFile=Print To File

View File

@ -2219,18 +2219,22 @@ void
nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting) nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting)
{ {
nsresult rv; nsresult rv;
PR_PL(("nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError=%lx, PRBool aIsPrinting=%d)\n", (long)rv, (int)aIsPrinting));
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(kCStringBundleServiceCID); nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(kCStringBundleServiceCID);
if (!stringBundleService) { if (!stringBundleService) {
NS_WARNING("ERROR: Failed to get StringBundle Service instance.\n"); PR_PL(("ShowPrintErrorDialog: Failed to get StringBundle Service instance.\n"));
return; return;
} }
nsCOMPtr<nsIStringBundle> myStringBundle; nsCOMPtr<nsIStringBundle> myStringBundle;
rv = stringBundleService->CreateBundle(NS_ERROR_GFX_PRINTER_BUNDLE_URL, getter_AddRefs(myStringBundle)); rv = stringBundleService->CreateBundle(NS_ERROR_GFX_PRINTER_BUNDLE_URL, getter_AddRefs(myStringBundle));
if (NS_FAILED(rv)) if (NS_FAILED(rv)) {
PR_PL(("ShowPrintErrorDialog(): CreateBundle() failure for NS_ERROR_GFX_PRINTER_BUNDLE_URL, rv=%lx\n", (long)rv));
return; return;
}
nsXPIDLString msg, nsXPIDLString msg,
title; title;
@ -2273,6 +2277,9 @@ nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTROMPTSERVICE) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTROMPTSERVICE)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_XPRINT_NO_XPRINT_SERVERS_FOUND) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_XPRINT_NO_XPRINT_SERVERS_FOUND)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED)
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE)
default: default:
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_FAILURE) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_FAILURE)
@ -2290,8 +2297,10 @@ nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting)
myStringBundle->GetStringFromName(NS_LITERAL_STRING("printpreview_error_dialog_title").get(), getter_Copies(title)); myStringBundle->GetStringFromName(NS_LITERAL_STRING("printpreview_error_dialog_title").get(), getter_Copies(title));
} }
if (!msg) if (!msg) {
PR_PL(("ShowPrintErrorDialog(): msg==nsnull\n"));
return; return;
}
nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv); nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
if (NS_FAILED(rv)) if (NS_FAILED(rv))