Impl print preview for mail and addrbook

This also makes it so printing parents the printing content window is is modal
Bug 158110 r=bienvenu sr=sspitzer
This commit is contained in:
rods%netscape.com 2002-10-03 11:13:55 +00:00
Родитель ae47f51ffb
Коммит b7964688f6
7 изменённых файлов: 73 добавлений и 11 удалений

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

@ -302,7 +302,7 @@ function GetPrintSettings()
return gPrintSettings;
}
function AbPrintCard()
function AbPrintCardInternal(doPrintPreview, msgType)
{
var selectedItems = GetSelectedAbCards();
var numSelected = selectedItems.length;
@ -340,18 +340,29 @@ function AbPrintCard()
printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
"",
"chrome,dialog=no,all",
totalCard, selectionArray, statusFeedback, gPrintSettings);
totalCard, selectionArray, statusFeedback,
gPrintSettings, doPrintPreview, msgType);
return;
}
function AbPrintCard()
{
AbPrintCardInternal(false, Components.interfaces.nsIMsgPrintEngine.MNAB_PRINT_AB_CARD);
}
function AbPrintPreviewCard()
{
AbPrintCardInternal(true, Components.interfaces.nsIMsgPrintEngine.MNAB_PRINTPREVIEW_AB_CARD);
}
function CreatePrintCardUrl(card)
{
var url = "data:text/xml;base64," + card.convertToBase64EncodedXML();
return url;
}
function AbPrintAddressBook()
function AbPrintAddressBookInternal(doPrintPreview, msgType)
{
var addressbook = Components.classes["@mozilla.org/addressbook;1"].createInstance(Components.interfaces.nsIAddressBook);
var uri = GetAbViewURI();
@ -377,11 +388,21 @@ function AbPrintAddressBook()
printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
"",
"chrome,dialog=no,all",
1, [printUrl], statusFeedback, gPrintSettings);
1, [printUrl], statusFeedback, gPrintSettings, doPrintPreview, msgType);
return;
}
function AbPrintAddressBook()
{
AbPrintAddressBookInternal(false, Components.interfaces.nsIMsgPrintEngine.MNAB_PRINT_ADDRBOOK);
}
function AbPrintPreviewAddressBook()
{
AbPrintAddressBookInternal(true, Components.interfaces.nsIMsgPrintEngine.MNAB_PRINTPREVIEW_ADDRBOOK);
}
function AbExport()
{
try {

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

@ -57,6 +57,7 @@ Contributor(s):
<stringbundleset id="stringbundleset">
<stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
<stringbundle id="bundle_brand" src="chrome://global/locale/brand.properties"/>
</stringbundleset>
<script type="application/x-javascript" src="chrome://messenger/content/accountUtils.js"/>
@ -64,6 +65,7 @@ Contributor(s):
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/addressbook.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abCommon.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaClick.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/printing.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/msgPrintEngine.js"/>
<commandset id="addressBook">
@ -76,9 +78,11 @@ Contributor(s):
<commandset id="globalEditMenuItems"/>
<command id="cmd_newNavigator"/>
<command id="cmd_newEditor"/>
<command id="cmd_printSetup" oncommand="goPageSetup()"/>
<command id="cmd_printSetup" oncommand="NSPrintSetup()"/>
<command id="cmd_printCard" oncommand="AbPrintCard()"/>
<command id="cmd_printPreviewCard" oncommand="AbPrintPreviewCard()"/>
<command id="cmd_printAddressBook" oncommand="AbPrintAddressBook()"/>
<command id="cmd_printPreviewAddressBook" oncommand="AbPrintPreviewAddressBook()"/>
<command id="cmd_quit"/>
<command id="cmd_close" oncommand="AbClose()"/>
<command id="cmd_properties" oncommand="goDoCommand('button_edit');"/>
@ -147,9 +151,12 @@ Contributor(s):
<menuitem id="menu_close"/>
<menuseparator/>
<!--Page setup gets overlaid here from platformGlobalOverlay.xul / -->
<menuitem id="printSetupMenuItem" label="&printSetupCmd.label;" accesskey="&printSetupCmd.accesskey;" command="cmd_printSetup"/>
<menuitem id="printMenuItem" label="&printCardViewCmd.label;" accesskey="&printCardViewCmd.accesskey;" key="key_printCard" command="cmd_printCard"/>
<menuitem id="printAddressBook" label="&printAddressBook.label;" accesskey="&printAddressBook.accesskey;"
command="cmd_printAddressBook"/>
<menuitem id="printAddressBook" label="&printAddressBook.label;" accesskey="&printAddressBook.accesskey;" command="cmd_printAddressBook"/>
<menuseparator/>
<menuitem id="printPreviewMenuItem" label="&printPreviewCardViewCmd.label;" command="cmd_printPreviewCard"/>
<menuitem id="printPreviewAddressBook" label="&printPreviewAddressBook.label;" command="cmd_printPreviewAddressBook"/>
</menupopup>
</menu>

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

@ -41,13 +41,16 @@ Rights Reserved.
<!ENTITY importCmd.accesskey "I">
<!ENTITY exportCmd.label "Export...">
<!ENTITY exportCmd.accesskey "E">
<!ENTITY printPreviewCmd.label ".Print Preview">
<!ENTITY printCardViewCmd.label "Print Card...">
<!ENTITY printCardViewCmd.accesskey "p">
<!ENTITY printPreviewCardViewCmd.label "Print Preview Card">
<!-- LOCALIZATION NOTE (printCardViewCmd.key) : DONT_TRANSLATE -->
<!ENTITY printCardViewCmd.key "P">
<!ENTITY printAddressBook.label "Print Address Book...">
<!ENTITY printAddressBook.accesskey "A">
<!ENTITY printPreviewAddressBook.label "Print Preview Address Book">
<!ENTITY printSetupCmd.label "Page Setup...">
<!ENTITY printSetupCmd.accesskey "u">
<!-- Edit Menu -->
<!ENTITY deleteAbCmd.label "Delete Address Book">

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

@ -39,9 +39,16 @@
#include "nsIWebProgressListener.h"
#include "nsWeakReference.h"
#include "nsIPrintSettings.h"
#include "nsIObserver.h"
// Progress Dialog
#include "nsIPrintProgress.h"
#include "nsIPrintProgressParams.h"
#include "nsIPrintingPromptService.h"
class nsMsgPrintEngine : public nsIMsgPrintEngine,
public nsIWebProgressListener,
public nsIObserver,
public nsSupportsWeakReference {
public:
@ -57,17 +64,27 @@ public:
// For nsIWebProgressListener
NS_DECL_NSIWEBPROGRESSLISTENER
// For nsIObserver
NS_DECL_NSIOBSERVER
void PrintMsgWindow();
NS_IMETHOD StartNextPrintOperation();
protected:
PRBool FirePrintEvent();
PRBool FireStartNextEvent();
NS_IMETHOD FireThatLoadOperationStartup(nsString *uri);
NS_IMETHOD FireThatLoadOperation(nsString *uri);
NS_IMETHOD StartNextPrintOperation();
void InitializeDisplayCharset();
void SetupObserver();
nsresult SetStatusMessage(PRUnichar *aMsgString);
PRUnichar *GetString(const PRUnichar *aStringName);
nsresult ShowProgressDialog(PRBool aIsForPrinting, PRBool& aDoNotify);
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIDOMWindowInternal> mWindow;
nsCOMPtr<nsIDOMWindowInternal> mParentWindow;
PRInt32 mURICount;
nsStringArray mURIArray;
PRInt32 mCurrentlyPrintingURI;
@ -78,4 +95,15 @@ protected:
nsCOMPtr<nsIWebBrowserPrint> mWebBrowserPrint;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
nsCOMPtr<nsIDOMWindow> mMsgDOMWin;
PRBool mIsDoingPrintPreview;
nsCOMPtr<nsIObserver> mStartupPPObs;
PRInt32 mMsgInx;
// Progress Dialog
nsCOMPtr<nsIPrintingPromptService> mPrintPromptService;
nsCOMPtr<nsIWebProgressListener> mPrintProgressListener;
nsCOMPtr<nsIPrintProgress> mPrintProgress;
nsCOMPtr<nsIPrintProgressParams> mPrintProgressParams;
nsAutoString mLoadURI;
};

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

@ -616,7 +616,7 @@ var defaultController =
case "cmd_sendNow" : if (defaultController.isCommandEnabled(command)) SendMessage(); break;
case "cmd_sendWithCheck" : if (defaultController.isCommandEnabled(command)) SendMessageWithCheck(); break;
case "cmd_sendLater" : if (defaultController.isCommandEnabled(command)) SendMessageLater(); break;
case "cmd_printSetup" : goPageSetup(); break;
case "cmd_printSetup" : NSPrintSetup(); break;
case "cmd_print" : DoCommandPrint(); break;
//Edit Menu

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

@ -67,6 +67,7 @@
<stringbundle id="bundle_offlinePrompts" src="chrome://messenger/locale/offline.properties"/>
</stringbundleset>
<script type="application/x-javascript" src="chrome://communicator/content/printing.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/accountUtils.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/widgetglue.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/mail-offline.js"/>
@ -230,7 +231,7 @@
<menuitem label="&sendNowCmd.label;" accesskey="&sendNowCmd.accesskey;" key="key_send" command="cmd_sendNow" id="menu-item-send-now"/>
<menuitem label="&sendLaterCmd.label;" accesskey="&sendLaterCmd.accesskey;" key="key_sendLater" command="cmd_sendLater"/>
<menuseparator/>
<!--Page setup gets overlaid here from platformGlobalOverlay.xul / -->
<menuitem id="printSetupMenuItem" label="&printSetupCmd.label;" accesskey="&printSetupCmd.accesskey;" command="Browser:PrintSetup"/>
<menuitem id="printMenuItem" label="&printCmd.label;" accesskey="&printCmd.accesskey;" key="key_print" command="cmd_print"/>
</menupopup>
</menu>

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

@ -40,6 +40,8 @@
<!ENTITY printCmd.label "Print...">
<!ENTITY printCmd.key "P">
<!ENTITY printCmd.accesskey "P">
<!ENTITY printSetupCmd.label "Page Setup...">
<!ENTITY printSetupCmd.accesskey "u">
<!ENTITY closeCmd.label "Close">
<!-- Edit menu items -->