diff --git a/xpfe/browser/resources/content/browser.js b/xpfe/browser/resources/content/browser.js
index af20b2ef94c..5ed3117802c 100644
--- a/xpfe/browser/resources/content/browser.js
+++ b/xpfe/browser/resources/content/browser.js
@@ -41,7 +41,6 @@
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
var gPrintSettingsAreGlobal = true;
var gSavePrintSettings = true;
-var gPrintSettings = null;
var gChromeState = null; // chrome state before we went into print preview
var gOldCloseHandler = null; // close handler before we went into print preview
var gInPrintPreviewMode = false;
@@ -175,37 +174,6 @@ function BrowserExitPrintPreview()
mainWin.setAttribute("onclose", gOldCloseHandler);
}
-function GetPrintSettings()
-{
- var prevPS = gPrintSettings;
-
- try {
- if (gPrintSettings == null) {
- var pref = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
- if (pref) {
- gPrintSettingsAreGlobal = pref.getBoolPref("print.use_global_printsettings", false);
- gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false);
- }
-
- var psService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
- .getService(Components.interfaces.nsIPrintSettingsService);
- if (gPrintSettingsAreGlobal) {
- gPrintSettings = psService.globalPrintSettings;
- if (gSavePrintSettings) {
- psService.initPrintSettingsFromPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData);
- }
- } else {
- gPrintSettings = psService.newPrintSettings;
- }
- }
- } catch (e) {
- dump("GetPrintSettings "+e);
- }
-
- return gPrintSettings;
-}
-
// This observer is called once the progress dialog has been "opened"
var gPrintPreviewObs = {
observe: function(aSubject, aTopic, aData)
@@ -311,50 +279,6 @@ function FinishPrintPreview()
}
-function BrowserPrintSetup()
-{
- var didOK = false;
- try {
- var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
- var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
- if (webBrowserPrint) {
- gPrintSettings = GetPrintSettings();
- }
-
- didOK = goPageSetup(window, gPrintSettings); // from utilityOverlay.js
- if (didOK) { // from utilityOverlay.js
-
- if (webBrowserPrint) {
- if (gPrintSettingsAreGlobal && gSavePrintSettings) {
- var psService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
- .getService(Components.interfaces.nsIPrintSettingsService);
- psService.savePrintSettingsToPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData);
- }
- }
- }
- } catch (e) {
- dump("BrowserPrintSetup "+e);
- }
- return didOK;
-}
-
-function BrowserPrint()
-{
- try {
- var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
- var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
- if (webBrowserPrint) {
- gPrintSettings = GetPrintSettings();
- webBrowserPrint.print(gPrintSettings, null);
- }
- } catch (e) {
- // Pressing cancel is expressed as an NS_ERROR_ABORT return value,
- // causing an exception to be thrown which we catch here.
- // Unfortunately this will also consume helpful failures, so add a
- // dump(e); // if you need to debug
- }
-}
-
function BrowserSetDefaultCharacterSet(aCharset)
{
// no longer needed; set when setting Force; see bug 79608
diff --git a/xpfe/browser/resources/content/navigator.xul b/xpfe/browser/resources/content/navigator.xul
index e98939c6d53..ab4934cf2e2 100644
--- a/xpfe/browser/resources/content/navigator.xul
+++ b/xpfe/browser/resources/content/navigator.xul
@@ -71,6 +71,7 @@ Contributor(s):
+
@@ -210,11 +211,11 @@ Contributor(s):
diff --git a/xpfe/browser/resources/content/navigatorOverlay.xul b/xpfe/browser/resources/content/navigatorOverlay.xul
index fa6f52a0e7a..cee804eccde 100644
--- a/xpfe/browser/resources/content/navigatorOverlay.xul
+++ b/xpfe/browser/resources/content/navigatorOverlay.xul
@@ -118,8 +118,8 @@
-
-
+
+
diff --git a/xpfe/browser/resources/content/viewSourceOverlay.xul b/xpfe/browser/resources/content/viewSourceOverlay.xul
index 8ef28d5193f..754483ff980 100644
--- a/xpfe/browser/resources/content/viewSourceOverlay.xul
+++ b/xpfe/browser/resources/content/viewSourceOverlay.xul
@@ -55,6 +55,7 @@
+
@@ -138,9 +139,8 @@
-
-
+
+
diff --git a/xpfe/communicator/jar.mn b/xpfe/communicator/jar.mn
index e1c074d2c9f..3fffeb18c29 100644
--- a/xpfe/communicator/jar.mn
+++ b/xpfe/communicator/jar.mn
@@ -29,6 +29,7 @@ comm.jar:
content/communicator/printPageSetup.js (resources/content/printPageSetup.js)
content/communicator/printPageSetup.xul (resources/content/printPageSetup.xul)
content/communicator/printPreviewBindings.xml (resources/content/printPreviewBindings.xml)
+ content/communicator/printing.js (resources/content/printing.js)
content/communicator/plugins.html (resources/content/plugins.html)
en-US.jar:
diff --git a/xpfe/communicator/resources/content/printPreviewBindings.xml b/xpfe/communicator/resources/content/printPreviewBindings.xml
index e49061cbfec..adeb1db6615 100644
--- a/xpfe/communicator/resources/content/printPreviewBindings.xml
+++ b/xpfe/communicator/resources/content/printPreviewBindings.xml
@@ -51,7 +51,7 @@
+ oncommand="NSPrint();"/>
@@ -164,9 +164,11 @@
this._debug("constructor");
var print = _getWebBrowserPrint();
- this.mTotalPages.value = print.printPreviewNumPages;
+ try {
+ this.mTotalPages.value = print.printPreviewNumPages;
+ _getValuesFromPS();
+ } catch(e) {}
- _getValuesFromPS();
// XXX TEMPORARY
// XXX Until bug 119491 ("Cleanup global vars in PostScript and Xprint
@@ -202,7 +204,7 @@
+ * Peter Annema
+ * Samir Gehani
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the NPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the NPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+var gPrintSettings = null;
+
+function GetPrintSettings()
+{
+ var prevPS = gPrintSettings;
+ try {
+ if (gPrintSettings == null) {
+ var pref = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+ if (pref) {
+ gPrintSettingsAreGlobal = pref.getBoolPref("print.use_global_printsettings", false);
+ gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false);
+ }
+
+ var psService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
+ .getService(Components.interfaces.nsIPrintSettingsService);
+ if (gPrintSettingsAreGlobal) {
+ gPrintSettings = psService.globalPrintSettings;
+ if (gSavePrintSettings) {
+ psService.initPrintSettingsFromPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData);
+ }
+ } else {
+ gPrintSettings = psService.newPrintSettings;
+ }
+ }
+ } catch (e) {
+ dump("GetPrintSettings "+e);
+ }
+
+ return gPrintSettings;
+}
+
+function goPageSetup(domwin, printSettings)
+{
+ try {
+ if (printSettings == null) {
+ dump("***************** PrintSettings arg is null!");
+ return false;
+ }
+
+ // This code calls the printoptions service to bring up the printoptions
+ // dialog. This will be an xp dialog if the platform did not override
+ // the ShowPrintSetupDialog method.
+ var printingPromptService = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"]
+ .getService(Components.interfaces.nsIPrintingPromptService);
+ printingPromptService.showPageSetup(domwin, printSettings, null);
+ return true;
+ } catch(e) {
+ return false;
+ }
+ return true;
+}
+
+function NSPrintSetup()
+{
+ var didOK = false;
+ try {
+ gPrintSettings = GetPrintSettings();
+
+ var webBrowserPrint = null;
+ if (_content) {
+ var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
+ webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
+ }
+
+ didOK = goPageSetup(window, gPrintSettings); // from printing.js
+ if (didOK) {
+
+ if (webBrowserPrint) {
+ if (gPrintSettingsAreGlobal && gSavePrintSettings) {
+ var psService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
+ .getService(Components.interfaces.nsIPrintSettingsService);
+ psService.savePrintSettingsToPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData);
+ }
+ }
+ }
+ } catch (e) {
+ dump("BrowserPrintSetup "+e);
+ }
+ return didOK;
+}
+
+function NSPrint()
+{
+ try {
+ var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
+ var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
+ if (webBrowserPrint) {
+ gPrintSettings = GetPrintSettings();
+ webBrowserPrint.print(gPrintSettings, null);
+ }
+ } catch (e) {
+ // Pressing cancel is expressed as an NS_ERROR_ABORT return value,
+ // causing an exception to be thrown which we catch here.
+ // Unfortunately this will also consume helpful failures, so add a
+ // dump(e); // if you need to debug
+ }
+}
diff --git a/xpfe/communicator/resources/content/utilityOverlay.js b/xpfe/communicator/resources/content/utilityOverlay.js
index 547866d7ef3..dab7e73ee1c 100644
--- a/xpfe/communicator/resources/content/utilityOverlay.js
+++ b/xpfe/communicator/resources/content/utilityOverlay.js
@@ -128,26 +128,6 @@ function getBrowserURL() {
return "chrome://navigator/content/navigator.xul";
}
-function goPageSetup(domwin, printSettings)
-{
- try {
- if (printSettings == null) {
- alert("PrintSettings arg is null!");
- }
-
- // This code calls the printoptions service to bring up the printoptions
- // dialog. This will be an xp dialog if the platform did not override
- // the ShowPrintSetupDialog method.
- var printingPromptService = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"]
- .getService(Components.interfaces.nsIPrintingPromptService);
- printingPromptService.showPageSetup(domwin, printSettings, null);
- return true;
- } catch(e) {
- return false;
- }
- return true;
-}
-
function goPreferences(containerID, paneURL, itemID)
{
var resizable;
diff --git a/xpfe/global/resources/content/printProgress.js b/xpfe/global/resources/content/printProgress.js
index 8c8656a648d..ca991f9597c 100644
--- a/xpfe/global/resources/content/printProgress.js
+++ b/xpfe/global/resources/content/printProgress.js
@@ -37,6 +37,7 @@ var targetFile;
var docTitle = "";
var docURL = "";
var progressParams = null;
+var switchUI = true;
function elipseString(aStr, doFront)
{
@@ -83,13 +84,25 @@ var progressListener = {
var percentPrint = getString( "progressText" );
percentPrint = replaceInsert( percentPrint, 1, 100 );
dialog.progressText.setAttribute("value", percentPrint);
-
window.close();
}
},
onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
{
+ if (switchUI)
+ {
+ dialog.tempLabel.setAttribute("hidden", "true");
+ dialog.progress.setAttribute("hidden", "false");
+ dialog.cancel.setAttribute("disabled", "false");
+
+ var progressLabel = getString("progress");
+ if (progressLabel == "") {
+ progressLabel = "Progress:"; // better than nothing
+ }
+ switchUI = false;
+ }
+
if (progressParams)
{
var docTitleStr = elipseString(progressParams.docTitle, false);
@@ -243,7 +256,6 @@ function onLoad() {
// set our web progress listener on the helper app launcher
printProgress.registerListener(progressListener);
moveToAlertPosition();
-
//We need to delay the set title else dom will overwrite it
window.setTimeout(doneIniting, 500);
}
@@ -278,15 +290,5 @@ function onCancel ()
function doneIniting()
{
- dialog.tempLabel.setAttribute("hidden", "true");
- dialog.progress.setAttribute("hidden", "false");
- dialog.cancel.setAttribute("disabled", "false");
-
- var progressLabel = getString("progress");
- if (progressLabel == "") {
- progressLabel = "Progress:"; // better than nothing
- }
- //dialog.progressLabel.value = progressLabel;
-
printProgress.doneIniting();
}