Bug11366 [FEATURE] Print Address Book Card, r=rhp+hangas

This commit is contained in:
chuang%netscape.com 2000-04-18 20:27:28 +00:00
Родитель a99c584a7f
Коммит 5fee9025e8
4 изменённых файлов: 50 добавлений и 11 удалений

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

@ -166,12 +166,40 @@ function AbCreateNewAddressBook(name)
function AbPrintCard()
{
dump("print card\n");
try {
addressbook.printCard();
var selectedItems = resultsTree.selectedItems;
var numSelected = selectedItems.length;
if (numSelected == 0)
{
dump("AbPrintCard(): No card selected.\n");
return false;
}
catch (ex) {
dump("failed to print card\n");
var statusFeedback;
statusFeedback = Components.classes["component://netscape/messenger/statusfeedback"].createInstance();
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
var selectionArray = new Array(numSelected);
var totalCard = 0;
for(var i = 0; i < numSelected; i++)
{
var uri = selectedItems[i].getAttribute("id");
var cardResource = top.rdf.GetResource(uri);
var card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
if (card.printCardUrl.length)
{
selectionArray[totalCard++] = card.printCardUrl;
dump("printCardUrl = " + card.printCardUrl + "\n");
}
}
printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
"",
"chrome,dialog=no,all",
totalCard, selectionArray, statusFeedback);
return true;
}
function AbPrintAddressBook()

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

@ -46,6 +46,7 @@ Rights Reserved.
<html:script language="JavaScript" src="chrome://messenger/content/widgetglue.js"/>
<html:script language="JavaScript" src="chrome://addressbook/content/addressbook.js"/>
<html:script language="JavaScript" src="chrome://addressbook/content/abCommon.js"/>
<html:script language="JavaScript" src="chrome://messenger/content/msgPrintEngine.js"/>
<!--html:script language="JavaScript" src="resource:/res/samples/DumpDOM.js"/-->
<commands id="commands">
@ -62,7 +63,7 @@ Rights Reserved.
<broadcaster id="cmd_newNavigator"/>
<broadcaster id="cmd_newEditor"/>
<broadcaster id="cmd_newMessage"/>
<broadcaster id="cmd_PrintCard" oncommand="AbPrintCard()" disabled="true"/>
<broadcaster id="cmd_PrintCard" oncommand="AbPrintCard()"/>
<broadcaster id="cmd_close" oncommand="AbClose()"/>
<broadcaster id="cmd_quit"/>
<!-- Edit Menu -->
@ -124,7 +125,7 @@ Rights Reserved.
<menuseparator/>
<menuitem id="menu_pageSetup"/>
<menuitem value="&printPreviewCmd.label;" disabled="true" oncommand="AbPrintPreview()"/>
<menuitem value="&printCardViewCmd.label;" key="key_PrintCard" disabled="true" observes="cmd_PrintCard"/>
<menuitem value="&printCardViewCmd.label;" key="key_PrintCard" observes="cmd_PrintCard"/>
<menuitem value="&printAddressBook.label;" disabled="true" oncommand="AbPrintAddressBook()"/>
<menuseparator/>
</menupopup>

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

@ -39,7 +39,7 @@ Rights Reserved.
<!ENTITY importCmd.label "Import...">
<!ENTITY exportCmd.label ".Export...">
<!ENTITY printPreviewCmd.label ".Print Preview">
<!ENTITY printCardViewCmd.label ".Print Card View...">
<!ENTITY printCardViewCmd.label "Print Card View...">
<!-- LOCALIZATION NOTE (printCardViewCmd.key) : DONT_TRANSLATE -->
<!ENTITY printCardViewCmd.key "P">
<!ENTITY printAddressBook.label ".Print Address Book...">

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

@ -1255,16 +1255,26 @@ nsAbCardProperty::GetPrintCardUrl(char * *aPrintCardUrl)
static const char *kAbPrintUrlFormat = "addbook:printone?email=%s&folder=%s";
if (!aPrintCardUrl)
return NS_ERROR_NULL_POINTER;
return NS_OK;
PRUnichar *email = nsnull;
GetPrimaryEmail(&email);
nsString emailStr(email);
if (emailStr.Length() == 0)
{
*aPrintCardUrl = PR_smprintf("");
return NS_OK;
}
PRUnichar *dirName = nsnull;
if (mCardDatabase)
mCardDatabase->GetDirectoryName(&dirName);
nsString dirNameStr(dirName);
if (dirNameStr.Length() == 0)
{
*aPrintCardUrl = PR_smprintf("");
return NS_OK;
}
dirNameStr.ReplaceSubstring(" ", "%20");
char *emailCharStr = emailStr.ToNewCString();