This checkin re-enables printing. Thanks to Kyle Yuan from Sun Microsystems.

Next step is to take a step back and see what's best to do next!

M classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java

- call through to print related methods

M src_moz/CurrentPageImpl.cpp

- Copy from CurrentPageActionEvents.cpp

M test/automated/src/classes/org/mozilla/webclient/CurrentPageTest.java

- add test stub for print preview.


git-svn-id: svn://10.0.0.236/trunk@169174 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2005-02-14 02:37:51 +00:00
parent a5d1754eb2
commit 392d6a201f
3 changed files with 193 additions and 23 deletions

View File

@@ -39,6 +39,8 @@
#include "nsIWebBrowser.h"
#include "nsIWebBrowserFind.h"
#include "nsIWebBrowserPrint.h"
#include "nsIPrintSettings.h"
#include "nsIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsIDOMRange.h"
@@ -528,8 +530,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
}
}
#if 0 // convenience
/*
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
* Method: nativePrint
@@ -539,10 +539,33 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
(JNIEnv * env, jobject obj, jint nativeBCPtr)
{
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
if (nativeBrowserControl->initComplete) {
wsPrintEvent * actionEvent = new wsPrintEvent(nativeBrowserControl);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostEvent(nativeBrowserControl, event);
nsresult rv;
nsCOMPtr<nsIWebBrowser> webBrowser;
nsCOMPtr<nsIPrintSettings> printSettings;
// get the web browser
rv = nativeBrowserControl->mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
if (NS_FAILED(rv) || !webBrowser) {
::util_ThrowExceptionToJava(env, "Exception: nativePrint: Can't get WebBrowser");
}
// get the print interface
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(webBrowser));
if (!print) {
::util_ThrowExceptionToJava(env, "Exception: nativePrint: Can't get nsIWebBrowserPrint");
}
rv = print->GetGlobalPrintSettings(getter_AddRefs(printSettings));
if (NS_FAILED(rv) || !printSettings) {
::util_ThrowExceptionToJava(env, "Exception: nativePrint: Can't get printSettings");
}
// XXX kyle: we have to disable the Print Progress dialog until we are able to show the java native dialog.
printSettings->SetShowPrintProgress(PR_FALSE);
rv = print->Print(printSettings, nsnull);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativePrint: Can't print");
}
}
@@ -555,11 +578,40 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
(JNIEnv * env, jobject obj, jint nativeBCPtr, jboolean preview)
{
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
if (nativeBrowserControl->initComplete) {
wsPrintPreviewEvent * actionEvent = new wsPrintPreviewEvent(nativeBrowserControl, preview);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostEvent(nativeBrowserControl, event);
nsresult rv;
nsCOMPtr<nsIWebBrowser> webBrowser;
nsCOMPtr<nsIPrintSettings> printSettings;
// get the web browser
rv = nativeBrowserControl->mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
if (NS_FAILED(rv) || !webBrowser) {
::util_ThrowExceptionToJava(env, "Exception: nativePrint: Can't get WebBrowser");
}
// get the print interface
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(webBrowser));
if (!print) {
::util_ThrowExceptionToJava(env, "Exception: nativePrint: Can't get nsIWebBrowserPrint");
}
rv = print->GetGlobalPrintSettings(getter_AddRefs(printSettings));
if (NS_FAILED(rv) || !printSettings) {
::util_ThrowExceptionToJava(env, "Exception: nativePrint: Can't get printSettings");
}
// XXX kyle: we have to disable the Print Progress dialog by now because we are unable to show the java native dialog yet.
printSettings->SetShowPrintProgress(PR_FALSE);
printSettings->SetShowPrintProgress(PR_FALSE);
if (preview) {
rv = print->PrintPreview(printSettings, nsnull, nsnull);
}
else {
rv = print->ExitPrintPreview();
}
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: nativePrint: Can't print");
}
}
# endif // if 0