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
Родитель d03176fafc
Коммит 1b99ebfbae
8 изменённых файлов: 53 добавлений и 18 удалений

Просмотреть файл

@ -3069,7 +3069,8 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
mCachedPrintWebProgressListner = aWebProgressListener;
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;
@ -3120,8 +3121,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
}
return rv;
#else
return NS_ERROR_FAILURE;
#endif
PR_PL(("NS_PRINTING not defined - printing not implemented in this build!"));
return NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED;
#endif /* NS_PRINTING */
}
/** ---------------------------------------------------

Просмотреть файл

@ -2219,18 +2219,22 @@ void
nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting)
{
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);
nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(kCStringBundleServiceCID);
if (!stringBundleService) {
NS_WARNING("ERROR: Failed to get StringBundle Service instance.\n");
PR_PL(("ShowPrintErrorDialog: Failed to get StringBundle Service instance.\n"));
return;
}
nsCOMPtr<nsIStringBundle> 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;
}
nsXPIDLString msg,
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_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_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:
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));
}
if (!msg)
if (!msg) {
PR_PL(("ShowPrintErrorDialog(): msg==nsnull\n"));
return;
}
nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
if (NS_FAILED(rv))

Просмотреть файл

@ -150,7 +150,16 @@ typedef void * nsNativeDeviceContext;
/* requested plex mode not supported by printer */
#define NS_ERROR_GFX_PRINTER_PLEX_NOT_SUPPORTED \
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
*/

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -3069,7 +3069,8 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
mCachedPrintWebProgressListner = aWebProgressListener;
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;
@ -3120,8 +3121,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
}
return rv;
#else
return NS_ERROR_FAILURE;
#endif
PR_PL(("NS_PRINTING not defined - printing not implemented in this build!"));
return NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED;
#endif /* NS_PRINTING */
}
/** ---------------------------------------------------

Просмотреть файл

@ -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_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_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_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
noprinter=No printers available.
PrintToFile=Print To File

Просмотреть файл

@ -2219,18 +2219,22 @@ void
nsPrintEngine::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrinting)
{
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);
nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(kCStringBundleServiceCID);
if (!stringBundleService) {
NS_WARNING("ERROR: Failed to get StringBundle Service instance.\n");
PR_PL(("ShowPrintErrorDialog: Failed to get StringBundle Service instance.\n"));
return;
}
nsCOMPtr<nsIStringBundle> 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;
}
nsXPIDLString msg,
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_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_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:
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));
}
if (!msg)
if (!msg) {
PR_PL(("ShowPrintErrorDialog(): msg==nsnull\n"));
return;
}
nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
if (NS_FAILED(rv))