mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 06:52:25 +00:00
1) Removes the arg of nsIDOMWindow in the nsIWebBrowserPrint calls
2) Adds a couple of new methods and an attr to nsIWebBrowserPrint (navigate, is frameset, & exitPP) 3) Removes all but one method from nsIContentViewerFile.idl/h the remaining call is for print regression testing 4) Removes the "static" implementation of nsIContentViewerFile.h 5) Fixed up nsIContentViewerFile.idl and turned it back on so it is now generating the header file 6) Removed all uses of nsIContentViewerFile.h except for the WebCrawler (uses it for Printing Regression testing) 7) nsDocumentViewer.cpp now implements nsIWebBrowserPrint.idl this makes it easier to add new print functionality in one place 8) You can now ask an instance of the ContentViewer for a nsIWebBrowserPrint to do printing (it retruns the nsIWebBrowserPrint interface implemented by the nsDocumentViewer) 9) Anybody who was using nsIContentViewerFile to print will now use nsIWebBrowserPrint 10) You can now do a "GetInterface()" on a GlobalWindow for a nsIWebBrowserPrint 11) The browser UI now uses the GetInterface on the GlobalWindow to get a nsIWebBrowserPrint object to do printing and this can be used for all printing functionality Bug 120622 r=dcone sr=waterson
This commit is contained in:
parent
b3f69137a2
commit
9658379654
@ -39,7 +39,6 @@
|
||||
|
||||
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
|
||||
var gPrintSettings = null;
|
||||
var gUseGlobalPrintSettings = false;
|
||||
|
||||
function getWebNavigation()
|
||||
{
|
||||
@ -72,23 +71,46 @@ function BrowserReloadWithFlags(reloadFlags)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function GetPrintSettings(webBrowserPrint)
|
||||
{
|
||||
try {
|
||||
if (gPrintSettings == null) {
|
||||
var useGlobalPrintSettings = true;
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
if (pref) {
|
||||
useGlobalPrintSettings = pref.getBoolPref("print.use_global_printsettings", false);
|
||||
}
|
||||
|
||||
if (useGlobalPrintSettings) {
|
||||
gPrintSettings = webBrowserPrint.newPrintSettings;
|
||||
} else {
|
||||
gPrintSettings = webBrowserPrint.globalPrintSettings;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
alert("GetPrintSettings "+e);
|
||||
}
|
||||
return gPrintSettings;
|
||||
}
|
||||
|
||||
function BrowserPrintPreview()
|
||||
{
|
||||
var printOptionsService = Components.classes["@mozilla.org/gfx/printoptions;1"]
|
||||
.getService(Components.interfaces.nsIPrintOptions);
|
||||
if (gPrintSettings == null) {
|
||||
gPrintSettings = printOptionsService.CreatePrintSettings();
|
||||
}
|
||||
// using _content.printPreview() until printing becomes scriptable on docShell
|
||||
try {
|
||||
_content.printPreview(gPrintSettings);
|
||||
|
||||
var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
|
||||
var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
|
||||
if (webBrowserPrint) {
|
||||
gPrintSettings = GetPrintSettings(webBrowserPrint);
|
||||
webBrowserPrint.printPreview(gPrintSettings);
|
||||
}
|
||||
} catch (e) {
|
||||
// Pressing cancel is expressed as an NS_ERROR_FAILURE return value,
|
||||
// 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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -96,33 +118,20 @@ function BrowserPrintSetup()
|
||||
{
|
||||
|
||||
try {
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
if (pref) {
|
||||
gUseGlobalPrintSettings = pref.getBoolPref("print.use_global_printsettings", false);
|
||||
}
|
||||
|
||||
var printOptionsService = Components.classes["@mozilla.org/gfx/printoptions;1"]
|
||||
.getService(Components.interfaces.nsIPrintOptions);
|
||||
|
||||
// create our own local copy of the print settings
|
||||
if (gPrintSettings == null) {
|
||||
gPrintSettings = printOptionsService.CreatePrintSettings();
|
||||
}
|
||||
|
||||
// if we are using the global settings then get them
|
||||
// before calling page setup
|
||||
if (gUseGlobalPrintSettings) {
|
||||
gPrintSettings = printOptionsService.printSettingsValues;
|
||||
var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
|
||||
var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
|
||||
if (webBrowserPrint) {
|
||||
gPrintSettings = GetPrintSettings(webBrowserPrint);
|
||||
}
|
||||
|
||||
goPageSetup(gPrintSettings); // from utilityOverlay.js
|
||||
|
||||
// now set our setting into the global settings
|
||||
// after the changes were made
|
||||
if (gUseGlobalPrintSettings) {
|
||||
printOptionsService.printSettingsValues = gPrintSettings;
|
||||
if (webBrowserPrint) {
|
||||
if (webBrowserPrint.doingPrintPreview) {
|
||||
webBrowserPrint.printPreview(gPrintSettings);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
alert("BrowserPrintSetup "+e);
|
||||
}
|
||||
@ -131,32 +140,12 @@ function BrowserPrintSetup()
|
||||
function BrowserPrint()
|
||||
{
|
||||
try {
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
if (pref) {
|
||||
gUseGlobalPrintSettings = pref.getBoolPref("print.use_global_printsettings");
|
||||
var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
|
||||
var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
|
||||
if (webBrowserPrint) {
|
||||
gPrintSettings = GetPrintSettings(webBrowserPrint);
|
||||
webBrowserPrint.print(gPrintSettings, null);
|
||||
}
|
||||
var printOptionsService = Components.classes["@mozilla.org/gfx/printoptions;1"]
|
||||
.getService(Components.interfaces.nsIPrintOptions);
|
||||
if (gPrintSettings == null) {
|
||||
gPrintSettings = printOptionsService.CreatePrintSettings();
|
||||
}
|
||||
|
||||
// if we are using the global settings then get them
|
||||
// before calling print
|
||||
if (gUseGlobalPrintSettings) {
|
||||
gPrintSettings = printOptionsService.printSettingsValues;
|
||||
}
|
||||
|
||||
// using _content.print() until printing becomes scriptable on docShell
|
||||
_content.printWithSettings(gPrintSettings);
|
||||
|
||||
// now set our setting into the global settings
|
||||
// after the changes were made
|
||||
if (gUseGlobalPrintSettings) {
|
||||
printOptionsService.printSettingsValues = gPrintSettings;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
// Pressing cancel is expressed as an NS_ERROR_ABORT return value,
|
||||
// causing an exception to be thrown which we catch here.
|
||||
|
Loading…
x
Reference in New Issue
Block a user