The does the following:

1) Fixes a minor problem in with which kind of PrintSettings object we are getting in browser.js
2) AddressBook now creates its own copy of the PrintSettings and passes it into the nsMsgPrintEngine
3) Mail now creates its own copy of the PrintSettings and passes it into the nsMsgPrintEngine
4) Add a PS arg to the MsgPrintEngine IDL/XUL/JS
r=ducarroz sr=spitzer a=asa
This commit is contained in:
rods%netscape.com 2002-03-05 12:52:37 +00:00
parent 96d51bdd46
commit 9a206ffa69
5 changed files with 82 additions and 7 deletions

View File

@ -45,6 +45,7 @@ var gSearchTimer = null;
var gStatusText = null;
var gQueryURIFormat = null;
var gSearchInput;
var gPrintSettings = null;
// Constants that correspond to choices
// in Address Book->View -->Show Name as
@ -255,6 +256,36 @@ function AbCreateNewAddressBook(name)
top.addressbook.newAddressBook(properties);
}
function GetPrintSettings()
{
var prevPS = gPrintSettings;
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);
}
// I would rather be using nsIWebBrowserPrint API
// but I really don't have a document at this point
var printOptionsService = Components.classes["@mozilla.org/gfx/printoptions;1"]
.getService(Components.interfaces.nsIPrintOptions);
if (useGlobalPrintSettings) {
gPrintSettings = printOptionsService.globalPrintSettings;
} else {
gPrintSettings = printOptionsService.CreatePrintSettings();
}
}
} catch (e) {
dump("GetPrintSettings "+e);
}
return gPrintSettings;
}
function AbPrintCard()
{
var selectedItems = GetSelectedAbCards();
@ -286,10 +317,14 @@ function AbPrintCard()
}
}
if (gPrintSettings == null) {
gPrintSettings = GetPrintSettings();
}
printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
"",
"chrome,dialog=no,all",
totalCard, selectionArray, statusFeedback);
totalCard, selectionArray, statusFeedback, gPrintSettings);
return;
}

View File

@ -39,6 +39,7 @@
#include "nsIMsgStatusFeedback.idl"
interface nsIDOMWindowInternal;
interface nsIPrintSettings;
[scriptable, uuid(91FD6B10-E0BC-11d3-8F97-000064657374)]
@ -48,6 +49,6 @@ interface nsIMsgPrintEngine : nsISupports {
void SetStatusFeedback(in nsIMsgStatusFeedback feedback);
void SetPrintURICount(in PRInt32 aCount);
void AddPrintURI(in wstring aURI);
void StartPrintOperation();
void StartPrintOperation(in nsIPrintSettings aPS);
};

View File

@ -31,6 +31,7 @@ var nsPrefBranch = null;
var gOfflineManager;
var gWindowManagerInterface;
var gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var gPrintSettings = null;
var gTimelineService = null;
var gTimelineEnabled = ("@mozilla.org;timeline-service;1" in Components.classes);
@ -1157,6 +1158,36 @@ function MsgSendUnsentMsgs()
}
}
function GetPrintSettings()
{
var prevPS = gPrintSettings;
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);
}
// I would rather be using nsIWebBrowserPrint API
// but I really don't have a document at this point
var printOptionsService = Components.classes["@mozilla.org/gfx/printoptions;1"]
.getService(Components.interfaces.nsIPrintOptions);
if (useGlobalPrintSettings) {
gPrintSettings = printOptionsService.globalPrintSettings;
} else {
gPrintSettings = printOptionsService.CreatePrintSettings();
}
}
} catch (e) {
dump("GetPrintSettings "+e);
}
return gPrintSettings;
}
function PrintEnginePrint()
{
var messageList = GetSelectedMessages();
@ -1167,10 +1198,14 @@ function PrintEnginePrint()
return false;
}
if (gPrintSettings == null) {
gPrintSettings = GetPrintSettings();
}
printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
"",
"chrome,dialog=no,all",
numMessages, messageList, statusFeedback);
numMessages, messageList, statusFeedback, gPrintSettings);
return true;
}

View File

@ -24,13 +24,14 @@
var printEngineContractID = "@mozilla.org/messenger/msgPrintEngine;1";
var printEngineWindow;
var printEngine;
var printSettings;
/* Functions related to startup */
function OnLoadPrintEngine()
{
PrintEngineCreateGlobals();
InitPrintEngineWindow();
printEngine.StartPrintOperation();
printEngine.StartPrintOperation(printSettings);
}
function OnUnloadPrintEngine()
@ -57,9 +58,10 @@ function InitPrintEngineWindow()
{
var numSelected = window.arguments[0];
var uriArray = window.arguments[1];
var statusFeedback = window.arguments[2];
var statusFeedback = window.arguments[2];
printSettings = window.arguments[3].QueryInterface(Components.interfaces.nsIPrintSettings);
printEngine.SetStatusFeedback(statusFeedback);
printEngine.SetStatusFeedback(statusFeedback);
if (numSelected > 0)
{

View File

@ -278,8 +278,10 @@ nsMsgPrintEngine::SetPrintURICount(PRInt32 aCount)
}
NS_IMETHODIMP
nsMsgPrintEngine::StartPrintOperation()
nsMsgPrintEngine::StartPrintOperation(nsIPrintSettings* aPS)
{
mPrintSettings = aPS;
// Load the about:blank on the tail end...
nsresult rv = AddPrintURI(NS_LITERAL_STRING("about:blank").get());
if (NS_FAILED(rv)) return rv;