Bug 325068: Improve printing UI (and interfaces). r=jminta

This commit is contained in:
mvl%exedo.nl 2006-03-18 13:10:58 +00:00
Родитель b3fcaad307
Коммит 9011b0796c
10 изменённых файлов: 287 добавлений и 183 удалений

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

@ -70,6 +70,7 @@ XPIDLSRCS = calIAlarmService.idl \
calITodo.idl \
calIDateTimeFormatter.idl \
calIWeekTitleService.idl \
calIPrintFormatter.idl \
$(NULL)
EXPORTS = calBaseCID.h

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

@ -0,0 +1,68 @@
/* -*- Mode: IDL; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Calendar Code.
*
* The Initial Developer of the Original Code is
* Michiel van Leeuwen <mvl@exedo.nl>.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* 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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface calIItemBase;
interface calIDateTime;
interface nsIOutputStream;
[scriptable, uuid(014dea21-90cd-4563-b1bd-13b842a465e0)]
interface calIPrintFormatter : nsISupports
{
/**
* The name of this layout. Implementers should make sure this string
* is localizable, ie uses nsIStringBundle
*/
readonly attribute AString name;
/**
* Format the items into the stream, as html code.
* May assume that all the items are inside the given daterange.
* The user requested to show all the days in the daterange, so unless
* there is a special reason, all the days should be shown.
* aStart and aEnd may be null, in which case the implementation can
* show the minimal days needed to show all the events. It can skip
* months without events, for example.
*/
void formatToHtml(in nsIOutputStream aStream,
in calIDateTime aStart,
in calIDateTime aEnd,
in unsigned long aCount,
[array, size_is(aCount)] in calIItemBase aItems);
};

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

@ -46,6 +46,7 @@ EXTRA_COMPONENTS = \
calOutlookCSVImportExport.js \
calHtmlExport.js \
calIcsImportExport.js \
calListFormatter.js \
calImportExportModule.js \
$(NULL)

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

@ -54,11 +54,19 @@ const componentData =
service: false},
{cid: Components.ID("{72d9ab35-9b1b-442a-8cd0-ae49f00b159b}"),
contractid: "@mozilla.org/calendar/export;1?type=html",
contractid: "@mozilla.org/calendar/export;1?type=htmllist",
script: "calHtmlExport.js",
constructor: "calHtmlExporter",
category: "cal-exporters",
categoryEntry: "cal-html-exporter",
categoryEntry: "cal-html-list-exporter",
service: false},
{cid: Components.ID("{9ae04413-fee3-45b9-8bbb-1eb39a4cbd1b}"),
contractid: "@mozilla.org/calendar/printformatter;1?type=list",
script: "calListFormatter.js",
constructor: "calListFormatter",
category: "cal-print-formatters",
categoryEntry: "cal-list-printformatter",
service: false},
{cid: Components.ID("{64a5d17a-0497-48c5-b54f-72b15c9e9a14}"),

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

@ -0,0 +1,71 @@
/* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Calendar code.
*
* The Initial Developer of the Original Code is
* Michiel van Leeuwen <mvl@exedo.nl>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* 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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* A thin wrapper that is a print formatter, and just calls the html (list)
* exporter
*/
function calListFormatter() {
this.wrappedJSObject = this;
}
calListFormatter.prototype.QueryInterface =
function QueryInterface(aIID) {
if (!aIID.equals(Components.interfaces.nsISupports) &&
!aIID.equals(Components.interfaces.calIPrintFormatter)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
};
calListFormatter.prototype.getName =
function list_getName() {
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var props = sbs.createBundle("chrome://calendar/locale/calendar.properties");
return props.GetStringFromName("formatListName");
};
calListFormatter.prototype.__defineGetter__("name", calListFormatter.prototype.getName);
calListFormatter.prototype.formatToHtml =
function list_formatToHtml(aStream, aStart, aEnd, aCount, aItems) {
var htmlexporter = Components.classes["@mozilla.org/calendar/export;1?type=htmllist"]
.createInstance(Components.interfaces.calIExporter);
htmlexporter.exportToStream(aStream, aCount, aItems);
};

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

@ -179,7 +179,9 @@ function OnLoadPrintEngine(){
var windowTitle = props.formatStringFromName("PrintPreviewWindowTitle", [args.title], 1);
document.title = windowTitle;
var htmlexporter = Components.classes["@mozilla.org/calendar/export;1?type=html"].createInstance(Components.interfaces.calIExporter);
var printformatter =
Components.classes[args.layoutContractid]
.createInstance(Components.interfaces.calIPrintFormatter);
// Fail-safe check to not init twice, to prevent leaking files
if (!gTempFile) {
@ -200,7 +202,8 @@ function OnLoadPrintEngine(){
.createInstance(Components.interfaces.nsIFileOutputStream);
try {
stream.init(gTempFile, 0x2A, 0600, 0);
htmlexporter.exportToStream(stream, args.eventList.length, args.eventList);
printformatter.formatToHtml(stream, args.start, args.end,
args.eventList.length, args.eventList);
stream.close();
}
catch(ex) {

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

@ -25,6 +25,7 @@
* ArentJan Banck <ajbanck@planet.nl>
* Chris Allen
* Eric Belhaire <belhaire@ief.u-psud.fr>
* Michiel van Leeuwen <mvl@exedo.nl>
*
* 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
@ -45,8 +46,6 @@
/***** calendar/printDialog.js
* PRIMARY AUTHOR
* Chris Allen
* REQUIRED INCLUDES
* <script type="application/x-javascript" src="chrome://calendar/content/dateUtils.js"/>
*
* NOTES
* Code for the calendar's print dialog.
@ -68,30 +67,52 @@ var gCalendarWindow = window.opener.gCalendarWindow;
function loadCalendarPrintDialog()
{
// set the date to the currently selected date
document.getElementById( "start-date-picker" ).value = gCalendarWindow.currentView.selectedDate;
document.getElementById( "end-date-picker" ).value = gCalendarWindow.currentView.selectedDate;
// set the date to the currently selected date
document.getElementById("start-date-picker").value =
window.opener.document.getElementById("view-deck").selectedPanel.startDay.jsDate;
document.getElementById("end-date-picker").value =
window.opener.document.getElementById("view-deck").selectedPanel.endDay.jsDate;
// start focus on title
var firstFocus = document.getElementById( "title-field" ).focus();
// start focus on title
var firstFocus = document.getElementById( "title-field" ).focus();
if (gCalendarWindow.EventSelection.selectedEvents.length == 0)
document.getElementById("list").setAttribute("disabled", true);
// Get a list of formatters
var contractids = new Array();
var catman = Components.classes["@mozilla.org/categorymanager;1"]
.getService(Components.interfaces.nsICategoryManager);
var catenum = catman.enumerateCategory('cal-print-formatters');
opener.setCursor( "auto" );
self.focus();
// Walk the list, adding item to the layout menupopup
var layoutList = document.getElementById("layout-field");
while (catenum.hasMoreElements()) {
var entry = catenum.getNext();
entry = entry.QueryInterface(Components.interfaces.nsISupportsCString);
var contractid = catman.getCategoryEntry('cal-print-formatters', entry);
var formatter = Components.classes[contractid]
.getService(Components.interfaces.calIPrintFormatter);
// Use the contractid as value
layoutList.appendItem(formatter.name, contractid);
}
layoutList.selectedIndex = 0;
opener.setCursor( "auto" );
self.focus();
}
function printCalendar() {
var ccalendar = getDisplayComposite();
var start;
var end;
var eventList;
var listener = {
mEventArray: new Array(),
onOperationComplete: function (aCalendar, aStatus, aOperationType, aId, aDateTime) {
printInitWindow(listener.mEventArray);
printInitWindow(listener.mEventArray, start, end);
},
onGetResult: function (aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
@ -104,44 +125,47 @@ function printCalendar() {
var filter = ccalendar.ITEM_FILTER_TYPE_EVENT |
ccalendar.ITEM_FILTER_CLASS_OCCURRENCES;
switch( document.getElementById("view-field").value )
{
case 'currentview':
case '': //just in case
var displayStart = gCalendarWindow.currentView.displayStartDate;
var displayEnd = gCalendarWindow.currentView.displayEndDate;
//multiweek and month views call their display range something else
if(!displayStart) {
displayStart = gCalendarWindow.currentView.firstDateOfView;
displayEnd = gCalendarWindow.currentView.endExDateOfView;
}
ccalendar.getItems(filter, 0, jsDateToDateTime(displayStart), jsDateToDateTime(displayEnd), listener);
break;
case 'list' :
printInitWindow(gCalendarWindow.EventSelection.selectedEvents);
break;
case 'custom' :
var start = document.getElementById("start-date-picker").value;
var end = document.getElementById("end-date-picker").value;
ccalendar.getItems(filter, 0, jsDateToDateTime(start), jsDateToDateTime(end), listener);
break ;
default :
dump("Error : no case in printDialog.js::printCalendar()");
}
var start;
var end;
switch (document.getElementById("view-field").selectedItem.value) {
case 'currentview':
case '': //just in case
start = window.opener.document.getElementById("view-deck").selectedPanel.startDay;
end = window.opener.document.getElementById("view-deck").selectedPanel.endDay;
break;
case 'selected' :
eventList = gCalendarWindow.EventSelection.selectedEvents;
break;
case 'custom' :
start = jsDateToDateTime(document.getElementById("start-date-picker").value);
end = jsDateToDateTime(document.getElementById("end-date-picker").value);
break ;
default :
dump("Error : no case in printDialog.js::printCalendar()");
}
if (!eventList) {
// end isn't exclusive, so we need to add one day
end = end.clone();
end.day = end.day + 1;
end.normalize();
ccalendar.getItems(filter, 0, start, end, listener);
} else {
printInitWindow(eventList, null, null);
}
}
function printInitWindow(eventList)
{
var args = new Object();
args.title = document.getElementById("title-field").value;
args.showprivate = document.getElementById("private-checkbox");
args.eventList = eventList;
function printInitWindow(aEventList, aStart, aEnd) {
var args = new Object();
args.title = document.getElementById("title-field").value;
args.layoutContractid = document.getElementById("layout-field").value;
args.eventList = aEventList;
args.start = aStart;
args.end = aEnd;
window.openDialog("chrome://calendar/content/calPrintEngine.xul",
"CalendarPrintWindow",
"chrome,dialog=no,all,centerscreen",
args);
window.openDialog("chrome://calendar/content/calPrintEngine.xul",
"CalendarPrintWindow",
"chrome,dialog=no,all,centerscreen",
args);
}
/*-----------------------------------------------------------------

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

@ -68,133 +68,57 @@
persist="screenX screenY"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:nc="http://home.netscape.com/NC-rdf#">
<!-- Javascript DTD To Variable -->
<script type="application/x-javascript">
var calendarxxxxxx = "&calendar.print.window.title;";
</script>
<script type="application/x-javascript" src="chrome://calendar/content/printDialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/printDialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<!-- required for datepicker (probably until bug 58757 fixed) -->
<script type="application/x-javascript"
src="chrome://global/content/strres.js" />
<script type="application/x-javascript"
src="chrome://calendar/content/dateUtils.js"/>
<vbox id="standard-dialog-content" flex="1">
<grid>
<columns>
<column />
<column flex="1"/>
</columns>
<rows>
<!-- Title -->
<row align="center">
<hbox class="field-label-box-class">
<label for="title-field" value="&calendar.print.title.label;"/>
</hbox>
<textbox id="title-field"/>
</row>
<!-- Data used in JS from dtd -->
<!-- Layout -->
<row align="center">
<hbox class="field-label-box-class">
<label for="title-field" value="&calendar.print.layout.label;"/>
</hbox>
<menulist id="layout-field">
<!-- menupopup will be filled in printDialog.js -->
<menupopup id="layout-menulist-menupopup"/>
</menulist>
</row>
</rows>
</grid>
<dataset>
<data id="data-event-title-edit" value="&event.title.edit;" />
</dataset>
<vbox id="standard-dialog-content" flex="1">
<grid>
<columns>
<column />
<column flex="1"/>
</columns>
<rows>
<!-- announce -->
<row align="center">
<spacer />
<hbox class="field-label-box-class" pack="end">
<label value="&calendar.print.selectoptions.label;" />
</hbox>
</row>
<!-- Title -->
<row align="center">
<hbox class="field-label-box-class" pack="end">
<label for="title-field" value="&newevent.title.label;"/>
</hbox>
<textbox id="title-field"/>
</row>
<row align="center">
<spacer />
<radiogroup id="view-field" >
<caption label="&calendar.print.selectviews.label;" />
<radio label="&calendar.print.currentview.label;"
value="currentview"
selected="true" />
<radio id="list" label="&calendar.print.listselected.label;"
value="list"/>
<radio id="custom-range" label="&calendar.print.custom.label;" value="custom"/>
</radiogroup>
</row>
<!-- Start Date -->
<row align="center">
<spacer />
<hbox class="field-label-box-class" pack="end">
<label value="&newevent.startdate.label;"/>
<datepicker id="start-date-picker" onchange="onDatePick();"/>
<label value="&newevent.enddate.label;"/>
<datepicker id="end-date-picker" onchange="onDatePick();"/>
</hbox>
</row>
<!-- Private -->
<row align="center" collapsed="true">
<spacer />
<checkbox id="private-checkbox"
checked="true"
label="&newevent.private.label;"/>
</row>
<!-- Calendar Status -->
<row align="center" collapsed="true">
<spacer />
<checkbox id="status-checkbox"
checked="false"
label="&calendar.print.onlyitemsstatus.label;"/>
</row>
<row align="center" collapsed="true">
<spacer />
<menulist id="status-field" label="&newevent.status.label;">
<menupopup id="status-menulist-menupopup">
<menuitem label="&newevent.status.tentative.label;"
value="ICAL_STATUS_TENTATIVE"/>
<menuitem label="&newevent.status.confirmed.label;"
value="ICAL_STATUS_CONFIRMED"/>
<menuitem label="&newevent.status.cancelled.label;"
value="ICAL_STATUS_CANCELLED"/>
</menupopup>
</menulist>
</row>
<!-- Categories -->
<row align="center" collapsed="true">
<spacer />
<checkbox id="category-checkbox"
checked="false"
label="&calendar.print.onlyitemscategory.label;"/>
</row>
<row align="center" collapsed="true">
<spacer />
<menulist id="categories-field"
label="&newevent.category.label;">
<menupopup id="categories-menulist-menupopup">
<menuitem label="&priority.level.none;"
value="0"/>
</menupopup>
</menulist>
</row>
</rows>
</grid>
</vbox> <!-- standard-dialog-content -->
<groupbox>
<caption label="&calendar.print.range.label;"/>
<radiogroup id="view-field" >
<radio label="&calendar.print.currentview.label;"
value="currentview"
selected="true" />
<radio id="selected" label="&calendar.print.selected.label;"
value="selected"/>
<radio id="custom-range" label="&calendar.print.custom.label;"
value="custom"/>
<hbox align="center">
<label value="&calendar.print.from.label;"/>
<datepicker id="start-date-picker" onchange="onDatePick();"/>
<label value="&calendar.print.from.label;"/>
<datepicker id="end-date-picker" onchange="onDatePick();"/>
</hbox>
</radiogroup>
</groupbox>
</vbox>
</dialog>

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

@ -570,13 +570,14 @@
<!-- Calendar Printing -->
<!ENTITY calendar.print.window.title "Print A Calendar">
<!ENTITY calendar.print.selectoptions.label "Select your options below, and use OK to print">
<!ENTITY calendar.print.selectviews.label "Select View to Print">
<!ENTITY calendar.print.currentview.label "List all events in current view">
<!ENTITY calendar.print.listselected.label "List Selected Events">
<!ENTITY calendar.print.custom.label "List events between:">
<!ENTITY calendar.print.onlyitemsstatus.label "Print only items with this status:">
<!ENTITY calendar.print.onlyitemscategory.label "Print only items with this category:">
<!ENTITY calendar.print.title.label "Title">
<!ENTITY calendar.print.layout.label "Layout">
<!ENTITY calendar.print.range.label "Range to print">
<!ENTITY calendar.print.currentview.label "Events in current view">
<!ENTITY calendar.print.selected.label "Selected events">
<!ENTITY calendar.print.custom.label "Custom:">
<!ENTITY calendar.print.from.label "From:">
<!ENTITY calendar.print.to.label "To:">
<!-- Error reporting -->
<!ENTITY calendar.error.detail "Details...">

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

@ -237,3 +237,6 @@ stillReadOnlyError=There has been an error reading data for calendar: %1$S.
# mozilla/calendar/base/src/tzdata.c. If you don't understand that file or
# these instructions, simply put the Olson-timezone name in English, ie "America/New_York"
likelyTimezone=America/New_York
# Print Layout
formatListName = List