зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1411121) for failling browser-chrome browser/base/content/test/static/browser_all_files_referenced.js r=backout on a CLOSED TREE
Backed out changeset 9f02fcb3d28c (bug 1411121) Backed out changeset 9d8722dd9693 (bug 1411121) Backed out changeset d390f8888d71 (bug 1411121)
This commit is contained in:
Родитель
77253e619f
Коммит
b111f07e40
|
@ -14,7 +14,7 @@
|
|||
|
||||
interface nsIDOMWindow;
|
||||
|
||||
[scriptable, uuid(72006d06-a2a5-4250-ae92-04b2f0e2ab8d)]
|
||||
[scriptable, uuid(328daa3e-09e4-455f-bb6f-0a921766042f)]
|
||||
interface nsIPrintingPromptService : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -38,6 +38,7 @@ interface nsIPrintingPromptService : nsISupports
|
|||
* showPrintDialog - displays a native dialog
|
||||
* showPageSetup - displays a XUL dialog
|
||||
* showProgress - displays a XUL dialog
|
||||
* showPrinterProperties - n/a
|
||||
*
|
||||
* Summary for Windows Embedders:
|
||||
* Stated once again: There is no "fallback" native platform support in GFX for the
|
||||
|
@ -48,7 +49,7 @@ interface nsIPrintingPromptService : nsISupports
|
|||
*
|
||||
* Note: The Windows version Mozilla implements this service which is
|
||||
* automatically built and registered for you. You can use it as an example.
|
||||
* It is located at "widget/windows/nsPrintDialogService.cpp". That service
|
||||
* It is located at "mozilla/toolkit/components/printingui/win". That service
|
||||
* is capable of displaying a native print dialog and a XUL progress dialog.
|
||||
*
|
||||
* To fly your own dialog you may:
|
||||
|
@ -72,17 +73,20 @@ interface nsIPrintingPromptService : nsISupports
|
|||
* Mac OS9: showPrintDialog - displays a native dialog
|
||||
* showPageSetup - displays a native dialog
|
||||
* showProgress - displays a XUL dialog
|
||||
*
|
||||
* showPrinterProperties - n/a
|
||||
*
|
||||
* Mac OSX: showPrintDialog - displays a native dialog
|
||||
* showPageSetup - displays a native dialog
|
||||
* showProgress - not implemented (provided by OS)
|
||||
*
|
||||
* showPrinterProperties - n/a
|
||||
*
|
||||
* GTK: There are no native dialog for GTK.
|
||||
*
|
||||
* Defaults for platform service:
|
||||
* showPrintDialog - displays a native dialog
|
||||
* showPageSetup - displays a native dialog
|
||||
* Defaults for platform service:
|
||||
* showPrintDialog - displays a XUL dialog
|
||||
* showPageSetup - displays a XUL dialog
|
||||
* showProgress - displays a XUL dialog
|
||||
* showPrinterProperties - displays a XUL dialog
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -137,6 +141,20 @@ interface nsIPrintingPromptService : nsISupports
|
|||
in nsIPrintSettings printSettings,
|
||||
in nsIObserver aObs);
|
||||
|
||||
/**
|
||||
* Sometimes platforms need to bring up a special properties dialog for showing
|
||||
* print specific properties. Although the PrintSettings has a place to set the
|
||||
* printer name, here is is an argument to be clear as to what printer is being
|
||||
* asked to have the properties set for it. The Printer name in the PS is ignored.
|
||||
*
|
||||
* @param parent - a DOM windows the dialog will be parented to (required)
|
||||
* @param printerName - name of printer (required)
|
||||
* @param printSettings - PrintSettings for page setup (required)
|
||||
*/
|
||||
void showPrinterProperties(in mozIDOMWindowProxy parent,
|
||||
in wstring printerName,
|
||||
in nsIPrintSettings printSettings);
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -0,0 +1,408 @@
|
|||
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
var dialog;
|
||||
var printService = null;
|
||||
var gOriginalNumCopies = 1;
|
||||
|
||||
var paramBlock;
|
||||
var gPrefs = null;
|
||||
var gPrintSettings = null;
|
||||
var gWebBrowserPrint = null;
|
||||
var gPrintSetInterface = Components.interfaces.nsIPrintSettings;
|
||||
var doDebug = false;
|
||||
|
||||
// ---------------------------------------------------
|
||||
function initDialog() {
|
||||
dialog = {};
|
||||
|
||||
dialog.propertiesButton = document.getElementById("properties");
|
||||
dialog.descText = document.getElementById("descText");
|
||||
|
||||
dialog.printrangeGroup = document.getElementById("printrangeGroup");
|
||||
dialog.allpagesRadio = document.getElementById("allpagesRadio");
|
||||
dialog.rangeRadio = document.getElementById("rangeRadio");
|
||||
dialog.selectionRadio = document.getElementById("selectionRadio");
|
||||
dialog.frompageInput = document.getElementById("frompageInput");
|
||||
dialog.frompageLabel = document.getElementById("frompageLabel");
|
||||
dialog.topageInput = document.getElementById("topageInput");
|
||||
dialog.topageLabel = document.getElementById("topageLabel");
|
||||
|
||||
dialog.numCopiesInput = document.getElementById("numCopiesInput");
|
||||
|
||||
dialog.printframeGroup = document.getElementById("printframeGroup");
|
||||
dialog.aslaidoutRadio = document.getElementById("aslaidoutRadio");
|
||||
dialog.selectedframeRadio = document.getElementById("selectedframeRadio");
|
||||
dialog.eachframesepRadio = document.getElementById("eachframesepRadio");
|
||||
dialog.printframeGroupLabel = document.getElementById("printframeGroupLabel");
|
||||
|
||||
dialog.fileCheck = document.getElementById("fileCheck");
|
||||
dialog.printerLabel = document.getElementById("printerLabel");
|
||||
dialog.printerList = document.getElementById("printerList");
|
||||
|
||||
dialog.printButton = document.documentElement.getButton("accept");
|
||||
|
||||
// <data> elements
|
||||
dialog.printName = document.getElementById("printButton");
|
||||
dialog.fpDialog = document.getElementById("fpDialog");
|
||||
|
||||
dialog.enabled = false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function checkInteger(element) {
|
||||
var value = element.value;
|
||||
if (value && value.length > 0) {
|
||||
value = value.replace(/[^0-9]/g, "");
|
||||
if (!value) value = "";
|
||||
element.value = value;
|
||||
}
|
||||
if (!value || value < 1 || value > 999)
|
||||
dialog.printButton.setAttribute("disabled", "true");
|
||||
else
|
||||
dialog.printButton.removeAttribute("disabled");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function stripTrailingWhitespace(element) {
|
||||
var value = element.value;
|
||||
value = value.replace(/\s+$/, "");
|
||||
element.value = value;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function getPrinterDescription(printerName) {
|
||||
return gPrefs.getCharPref("print.printer_" + printerName + ".printer_description", "");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function listElement(aListElement) {
|
||||
this.listElement = aListElement;
|
||||
}
|
||||
|
||||
listElement.prototype =
|
||||
{
|
||||
clearList() {
|
||||
// remove the menupopup node child of the menulist.
|
||||
var popup = this.listElement.firstChild;
|
||||
if (popup) {
|
||||
this.listElement.removeChild(popup);
|
||||
}
|
||||
},
|
||||
|
||||
appendPrinterNames(aDataObject) {
|
||||
if ((null == aDataObject) || !aDataObject.hasMore()) {
|
||||
// disable dialog
|
||||
this.listElement.setAttribute("value", "");
|
||||
this.listElement.setAttribute("label",
|
||||
document.getElementById("printingBundle")
|
||||
.getString("noprinter"));
|
||||
|
||||
this.listElement.setAttribute("disabled", "true");
|
||||
dialog.printerLabel.setAttribute("disabled", "true");
|
||||
dialog.propertiesButton.setAttribute("disabled", "true");
|
||||
dialog.fileCheck.setAttribute("disabled", "true");
|
||||
dialog.printButton.setAttribute("disabled", "true");
|
||||
} else {
|
||||
// build popup menu from printer names
|
||||
var list = document.getElementById("printerList");
|
||||
do {
|
||||
let printerNameStr = aDataObject.getNext();
|
||||
list.appendItem(printerNameStr, printerNameStr, getPrinterDescription(printerNameStr));
|
||||
} while (aDataObject.hasMore());
|
||||
this.listElement.removeAttribute("disabled");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------
|
||||
function getPrinters() {
|
||||
var selectElement = new listElement(dialog.printerList);
|
||||
selectElement.clearList();
|
||||
|
||||
var printerEnumerator;
|
||||
try {
|
||||
printerEnumerator =
|
||||
Components.classes["@mozilla.org/gfx/printerenumerator;1"]
|
||||
.getService(Components.interfaces.nsIPrinterEnumerator)
|
||||
.printerNameList;
|
||||
} catch (e) { printerEnumerator = null; }
|
||||
|
||||
selectElement.appendPrinterNames(printerEnumerator);
|
||||
selectElement.listElement.value = printService.defaultPrinterName;
|
||||
|
||||
// make sure we load the prefs for the initially selected printer
|
||||
setPrinterDefaultsForSelectedPrinter();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------
|
||||
// update gPrintSettings with the defaults for the selected printer
|
||||
function setPrinterDefaultsForSelectedPrinter() {
|
||||
gPrintSettings.printerName = dialog.printerList.value;
|
||||
|
||||
dialog.descText.value = getPrinterDescription(gPrintSettings.printerName);
|
||||
|
||||
// First get any defaults from the printer
|
||||
printService.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings);
|
||||
|
||||
// now augment them with any values from last time
|
||||
printService.initPrintSettingsFromPrefs(gPrintSettings, true, gPrintSetInterface.kInitSaveAll);
|
||||
|
||||
if (doDebug) {
|
||||
dump("setPrinterDefaultsForSelectedPrinter: printerName='" + gPrintSettings.printerName + "', paperName='" + gPrintSettings.paperName + "'\n");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function displayPropertiesDialog() {
|
||||
gPrintSettings.numCopies = dialog.numCopiesInput.value;
|
||||
try {
|
||||
var printingPromptService = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPrintingPromptService);
|
||||
if (printingPromptService) {
|
||||
printingPromptService.showPrinterProperties(null, dialog.printerList.value, gPrintSettings);
|
||||
dialog.numCopiesInput.value = gPrintSettings.numCopies;
|
||||
}
|
||||
} catch (e) {
|
||||
dump("problems getting printingPromptService\n");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function doPrintRange(inx) {
|
||||
if (inx == 1) {
|
||||
dialog.frompageInput.removeAttribute("disabled");
|
||||
dialog.frompageLabel.removeAttribute("disabled");
|
||||
dialog.topageInput.removeAttribute("disabled");
|
||||
dialog.topageLabel.removeAttribute("disabled");
|
||||
} else {
|
||||
dialog.frompageInput.setAttribute("disabled", "true");
|
||||
dialog.frompageLabel.setAttribute("disabled", "true");
|
||||
dialog.topageInput.setAttribute("disabled", "true");
|
||||
dialog.topageLabel.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function loadDialog() {
|
||||
var print_copies = 1;
|
||||
var print_selection_radio_enabled = false;
|
||||
var print_frametype = gPrintSetInterface.kSelectedFrame;
|
||||
var print_howToEnableUI = gPrintSetInterface.kFrameEnableNone;
|
||||
var print_tofile = "";
|
||||
|
||||
try {
|
||||
gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"];
|
||||
if (printService) {
|
||||
printService = printService.getService();
|
||||
if (printService) {
|
||||
printService = printService.QueryInterface(Components.interfaces.nsIPrintSettingsService);
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// Note: getPrinters sets up the PrintToFile control
|
||||
getPrinters();
|
||||
|
||||
if (gPrintSettings) {
|
||||
print_tofile = gPrintSettings.printToFile;
|
||||
gOriginalNumCopies = gPrintSettings.numCopies;
|
||||
|
||||
print_copies = gPrintSettings.numCopies;
|
||||
print_frametype = gPrintSettings.printFrameType;
|
||||
print_howToEnableUI = gPrintSettings.howToEnableFrameUI;
|
||||
print_selection_radio_enabled = gPrintSettings.GetPrintOptions(gPrintSetInterface.kEnableSelectionRB);
|
||||
}
|
||||
|
||||
if (doDebug) {
|
||||
dump("loadDialog*********************************************\n");
|
||||
dump("print_tofile " + print_tofile + "\n");
|
||||
dump("print_frame " + print_frametype + "\n");
|
||||
dump("print_howToEnableUI " + print_howToEnableUI + "\n");
|
||||
dump("selection_radio_enabled " + print_selection_radio_enabled + "\n");
|
||||
}
|
||||
|
||||
dialog.printrangeGroup.selectedItem = dialog.allpagesRadio;
|
||||
if (print_selection_radio_enabled) {
|
||||
dialog.selectionRadio.removeAttribute("disabled");
|
||||
} else {
|
||||
dialog.selectionRadio.setAttribute("disabled", "true");
|
||||
}
|
||||
doPrintRange(dialog.rangeRadio.selected);
|
||||
dialog.frompageInput.value = 1;
|
||||
dialog.topageInput.value = 1;
|
||||
dialog.numCopiesInput.value = print_copies;
|
||||
|
||||
if (doDebug) {
|
||||
dump("print_howToEnableUI: " + print_howToEnableUI + "\n");
|
||||
}
|
||||
|
||||
// print frame
|
||||
if (print_howToEnableUI == gPrintSetInterface.kFrameEnableAll) {
|
||||
dialog.aslaidoutRadio.removeAttribute("disabled");
|
||||
|
||||
dialog.selectedframeRadio.removeAttribute("disabled");
|
||||
dialog.eachframesepRadio.removeAttribute("disabled");
|
||||
dialog.printframeGroupLabel.removeAttribute("disabled");
|
||||
|
||||
// initialize radio group
|
||||
dialog.printframeGroup.selectedItem = dialog.selectedframeRadio;
|
||||
|
||||
} else if (print_howToEnableUI == gPrintSetInterface.kFrameEnableAsIsAndEach) {
|
||||
dialog.aslaidoutRadio.removeAttribute("disabled"); // enable
|
||||
|
||||
dialog.selectedframeRadio.setAttribute("disabled", "true"); // disable
|
||||
dialog.eachframesepRadio.removeAttribute("disabled"); // enable
|
||||
dialog.printframeGroupLabel.removeAttribute("disabled"); // enable
|
||||
|
||||
// initialize
|
||||
dialog.printframeGroup.selectedItem = dialog.eachframesepRadio;
|
||||
|
||||
} else {
|
||||
dialog.aslaidoutRadio.setAttribute("disabled", "true");
|
||||
dialog.selectedframeRadio.setAttribute("disabled", "true");
|
||||
dialog.eachframesepRadio.setAttribute("disabled", "true");
|
||||
dialog.printframeGroupLabel.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
dialog.printButton.label = dialog.printName.getAttribute("label");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function onLoad() {
|
||||
// Init dialog.
|
||||
initDialog();
|
||||
|
||||
// param[0]: nsIPrintSettings object
|
||||
// param[1]: container for return value (1 = print, 0 = cancel)
|
||||
|
||||
gPrintSettings = window.arguments[0].QueryInterface(gPrintSetInterface);
|
||||
gWebBrowserPrint = window.arguments[1].QueryInterface(Components.interfaces.nsIWebBrowserPrint);
|
||||
paramBlock = window.arguments[2].QueryInterface(Components.interfaces.nsIDialogParamBlock);
|
||||
|
||||
// default return value is "cancel"
|
||||
paramBlock.SetInt(0, 0);
|
||||
|
||||
loadDialog();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function onAccept() {
|
||||
let promise;
|
||||
|
||||
if (gPrintSettings == null) {
|
||||
promise = Promise.resolve();
|
||||
} else {
|
||||
var print_howToEnableUI = gPrintSetInterface.kFrameEnableNone;
|
||||
|
||||
// save these out so they can be picked up by the device spec
|
||||
gPrintSettings.printerName = dialog.printerList.value;
|
||||
print_howToEnableUI = gPrintSettings.howToEnableFrameUI;
|
||||
gPrintSettings.printToFile = dialog.fileCheck.checked;
|
||||
|
||||
if (gPrintSettings.printToFile) {
|
||||
promise = chooseFile();
|
||||
} else {
|
||||
promise = Promise.resolve();
|
||||
}
|
||||
|
||||
promise = promise.then(() => {
|
||||
if (dialog.allpagesRadio.selected) {
|
||||
gPrintSettings.printRange = gPrintSetInterface.kRangeAllPages;
|
||||
} else if (dialog.rangeRadio.selected) {
|
||||
gPrintSettings.printRange = gPrintSetInterface.kRangeSpecifiedPageRange;
|
||||
} else if (dialog.selectionRadio.selected) {
|
||||
gPrintSettings.printRange = gPrintSetInterface.kRangeSelection;
|
||||
}
|
||||
gPrintSettings.startPageRange = dialog.frompageInput.value;
|
||||
gPrintSettings.endPageRange = dialog.topageInput.value;
|
||||
gPrintSettings.numCopies = dialog.numCopiesInput.value;
|
||||
|
||||
var frametype = gPrintSetInterface.kNoFrames;
|
||||
if (print_howToEnableUI != gPrintSetInterface.kFrameEnableNone) {
|
||||
if (dialog.aslaidoutRadio.selected) {
|
||||
frametype = gPrintSetInterface.kFramesAsIs;
|
||||
} else if (dialog.selectedframeRadio.selected) {
|
||||
frametype = gPrintSetInterface.kSelectedFrame;
|
||||
} else if (dialog.eachframesepRadio.selected) {
|
||||
frametype = gPrintSetInterface.kEachFrameSep;
|
||||
} else {
|
||||
frametype = gPrintSetInterface.kSelectedFrame;
|
||||
}
|
||||
}
|
||||
gPrintSettings.printFrameType = frametype;
|
||||
if (doDebug) {
|
||||
dump("onAccept*********************************************\n");
|
||||
dump("frametype " + frametype + "\n");
|
||||
dump("numCopies " + gPrintSettings.numCopies + "\n");
|
||||
dump("printRange " + gPrintSettings.printRange + "\n");
|
||||
dump("printerName " + gPrintSettings.printerName + "\n");
|
||||
dump("startPageRange " + gPrintSettings.startPageRange + "\n");
|
||||
dump("endPageRange " + gPrintSettings.endPageRange + "\n");
|
||||
dump("printToFile " + gPrintSettings.printToFile + "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
promise.then(() => {
|
||||
var saveToPrefs = false;
|
||||
|
||||
saveToPrefs = gPrefs.getBoolPref("print.save_print_settings");
|
||||
|
||||
if (saveToPrefs && printService != null) {
|
||||
var flags = gPrintSetInterface.kInitSavePaperSize |
|
||||
gPrintSetInterface.kInitSaveEdges |
|
||||
gPrintSetInterface.kInitSaveInColor |
|
||||
gPrintSetInterface.kInitSaveShrinkToFit |
|
||||
gPrintSetInterface.kInitSaveScaling;
|
||||
printService.savePrintSettingsToPrefs(gPrintSettings, true, flags);
|
||||
}
|
||||
|
||||
// set return value to "print"
|
||||
if (paramBlock) {
|
||||
paramBlock.SetInt(0, 1);
|
||||
} else {
|
||||
dump("*** FATAL ERROR: No paramBlock\n");
|
||||
}
|
||||
|
||||
window.close();
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function onCancel() {
|
||||
// set return value to "cancel"
|
||||
if (paramBlock) {
|
||||
paramBlock.SetInt(0, 0);
|
||||
} else {
|
||||
dump("*** FATAL ERROR: No paramBlock\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
function chooseFile() {
|
||||
return new Promise(resolve => {
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
||||
.createInstance(nsIFilePicker);
|
||||
fp.init(window, dialog.fpDialog.getAttribute("label"), nsIFilePicker.modeSave);
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
fp.open(rv => {
|
||||
if (rv != Components.interfaces.nsIFilePicker.returnCancel &&
|
||||
fp.file && fp.file.path) {
|
||||
gPrintSettings.toFileName = fp.file.path;
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<!DOCTYPE dialog SYSTEM "chrome://global/locale/printdialog.dtd">
|
||||
|
||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="onLoad();"
|
||||
ondialogaccept="return onAccept();"
|
||||
oncancel="return onCancel();"
|
||||
buttoniconaccept="print"
|
||||
title="&printDialog.title;"
|
||||
persist="screenX screenY"
|
||||
screenX="24" screenY="24">
|
||||
|
||||
<script type="application/javascript" src="chrome://global/content/printdialog.js"/>
|
||||
|
||||
<stringbundle id="printingBundle" src="chrome://global/locale/printing.properties"/>
|
||||
|
||||
<groupbox>
|
||||
<caption label="&printer.label;"/>
|
||||
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
<column/>
|
||||
</columns>
|
||||
|
||||
<rows>
|
||||
<row align="center">
|
||||
<hbox align="center" pack="end">
|
||||
<label id="printerLabel"
|
||||
value="&printerInput.label;"
|
||||
accesskey="&printerInput.accesskey;"
|
||||
control="printerList"/>
|
||||
</hbox>
|
||||
<menulist id="printerList" flex="1" type="description" oncommand="setPrinterDefaultsForSelectedPrinter();"/>
|
||||
<button id="properties"
|
||||
label="&propertiesButton.label;"
|
||||
accesskey="&propertiesButton.accesskey;"
|
||||
icon="properties"
|
||||
oncommand="displayPropertiesDialog();"/>
|
||||
</row>
|
||||
<row align="center">
|
||||
<hbox align="center" pack="end">
|
||||
<label id="descTextLabel" control="descText" value="&descText.label;"/>
|
||||
</hbox>
|
||||
<label id="descText"/>
|
||||
<checkbox id="fileCheck"
|
||||
checked="false"
|
||||
label="&fileCheck.label;"
|
||||
accesskey="&fileCheck.accesskey;"
|
||||
pack="end"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</groupbox>
|
||||
|
||||
<hbox>
|
||||
<groupbox flex="1">
|
||||
<caption label="&printrangeGroup.label;"/>
|
||||
|
||||
<radiogroup id="printrangeGroup">
|
||||
<radio id="allpagesRadio"
|
||||
label="&allpagesRadio.label;"
|
||||
accesskey="&allpagesRadio.accesskey;"
|
||||
oncommand="doPrintRange(0)"/>
|
||||
<hbox align="center">
|
||||
<radio id="rangeRadio"
|
||||
label="&rangeRadio.label;"
|
||||
accesskey="&rangeRadio.accesskey;"
|
||||
oncommand="doPrintRange(1)"/>
|
||||
<label id="frompageLabel"
|
||||
control="frompageInput"
|
||||
value="&frompageInput.label;"
|
||||
accesskey="&frompageInput.accesskey;"/>
|
||||
<textbox id="frompageInput" style="width:5em;" onkeyup="checkInteger(this)"/>
|
||||
<label id="topageLabel"
|
||||
control="topageInput"
|
||||
value="&topageInput.label;"
|
||||
accesskey="&topageInput.accesskey;"/>
|
||||
<textbox id="topageInput" style="width:5em;" onkeyup="checkInteger(this)"/>
|
||||
</hbox>
|
||||
<radio id="selectionRadio"
|
||||
label="&selectionRadio.label;"
|
||||
accesskey="&selectionRadio.accesskey;"
|
||||
oncommand="doPrintRange(2)"/>
|
||||
</radiogroup>
|
||||
</groupbox>
|
||||
|
||||
<groupbox flex="1">
|
||||
<caption label="&copies.label;"/>
|
||||
<hbox align="center">
|
||||
<label control="numCopiesInput"
|
||||
value="&numCopies.label;"
|
||||
accesskey="&numCopies.accesskey;"/>
|
||||
<textbox id="numCopiesInput" style="width:5em;" onkeyup="checkInteger(this)"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</hbox>
|
||||
|
||||
<groupbox flex="1">
|
||||
<caption label="&printframeGroup.label;" id="printframeGroupLabel"/>
|
||||
<radiogroup id="printframeGroup">
|
||||
<radio id="aslaidoutRadio"
|
||||
label="&aslaidoutRadio.label;"
|
||||
accesskey="&aslaidoutRadio.accesskey;"/>
|
||||
<radio id="selectedframeRadio"
|
||||
label="&selectedframeRadio.label;"
|
||||
accesskey="&selectedframeRadio.accesskey;"/>
|
||||
<radio id="eachframesepRadio"
|
||||
label="&eachframesepRadio.label;"
|
||||
accesskey="&eachframesepRadio.accesskey;"/>
|
||||
</radiogroup>
|
||||
</groupbox>
|
||||
|
||||
<!-- used to store titles and labels -->
|
||||
<data style="display:none;" id="printButton" label="&printButton.label;"/>
|
||||
<data style="display:none;" id="fpDialog" label="&fpDialog.title;"/>
|
||||
|
||||
</dialog>
|
||||
|
|
@ -0,0 +1,373 @@
|
|||
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
var dialog;
|
||||
var gPrintBundle;
|
||||
var gPrintSettings = null;
|
||||
var gPrintSettingsInterface = Components.interfaces.nsIPrintSettings;
|
||||
var gPaperArray;
|
||||
var gPrefs;
|
||||
var gParamBlock;
|
||||
|
||||
var gPrintSetInterface = Components.interfaces.nsIPrintSettings;
|
||||
var doDebug = true;
|
||||
|
||||
// ---------------------------------------------------
|
||||
function checkDouble(element, maxVal) {
|
||||
var value = element.value;
|
||||
if (value && value.length > 0) {
|
||||
value = value.replace(/[^\.|^0-9]/g, "");
|
||||
if (!value) {
|
||||
element.value = "";
|
||||
} else if (value > maxVal) {
|
||||
element.value = maxVal;
|
||||
} else {
|
||||
element.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function isListOfPrinterFeaturesAvailable() {
|
||||
return gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures", false);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function getDoubleStr(val, dec) {
|
||||
var str = val.toString();
|
||||
var inx = str.indexOf(".");
|
||||
return str.substring(0, inx + dec + 1);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function initDialog() {
|
||||
gPrintBundle = document.getElementById("printBundle");
|
||||
|
||||
dialog = {};
|
||||
|
||||
dialog.paperList = document.getElementById("paperList");
|
||||
dialog.paperGroup = document.getElementById("paperGroup");
|
||||
|
||||
dialog.jobTitleLabel = document.getElementById("jobTitleLabel");
|
||||
dialog.jobTitleGroup = document.getElementById("jobTitleGroup");
|
||||
dialog.jobTitleInput = document.getElementById("jobTitleInput");
|
||||
|
||||
dialog.colorGroup = document.getElementById("colorGroup");
|
||||
dialog.colorRadioGroup = document.getElementById("colorRadioGroup");
|
||||
dialog.colorRadio = document.getElementById("colorRadio");
|
||||
dialog.grayRadio = document.getElementById("grayRadio");
|
||||
|
||||
dialog.topInput = document.getElementById("topInput");
|
||||
dialog.bottomInput = document.getElementById("bottomInput");
|
||||
dialog.leftInput = document.getElementById("leftInput");
|
||||
dialog.rightInput = document.getElementById("rightInput");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function round10(val) {
|
||||
return Math.round(val * 10) / 10;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------
|
||||
function paperListElement(aPaperListElement) {
|
||||
this.paperListElement = aPaperListElement;
|
||||
}
|
||||
|
||||
paperListElement.prototype =
|
||||
{
|
||||
clearPaperList() {
|
||||
// remove the menupopup node child of the menulist.
|
||||
this.paperListElement.firstChild.remove();
|
||||
},
|
||||
|
||||
appendPaperNames(aDataObject) {
|
||||
var popupNode = document.createElement("menupopup");
|
||||
for (var i = 0;i < aDataObject.length;i++) {
|
||||
var paperObj = aDataObject[i];
|
||||
var itemNode = document.createElement("menuitem");
|
||||
var label;
|
||||
try {
|
||||
label = gPrintBundle.getString(paperObj.name);
|
||||
} catch (e) {
|
||||
/* No name in string bundle ? Then build one manually (this
|
||||
* usually happens when gPaperArray was build by createPaperArrayFromPrinterFeatures() ...) */
|
||||
if (paperObj.inches) {
|
||||
label = paperObj.name + " (" + round10(paperObj.width) + "x" + round10(paperObj.height) + " inch)";
|
||||
} else {
|
||||
label = paperObj.name + " (" + paperObj.width + "x" + paperObj.height + " mm)";
|
||||
}
|
||||
}
|
||||
itemNode.setAttribute("label", label);
|
||||
itemNode.setAttribute("value", i);
|
||||
popupNode.appendChild(itemNode);
|
||||
}
|
||||
this.paperListElement.appendChild(popupNode);
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------
|
||||
function createPaperArrayFromDefaults() {
|
||||
var paperNames = ["letterSize", "legalSize", "exectiveSize", "a5Size", "a4Size", "a3Size", "a2Size", "a1Size", "a0Size"];
|
||||
// var paperNames = ["&letterRadio.label;", "&legalRadio.label;", "&exectiveRadio.label;", "&a4Radio.label;", "&a3Radio.label;"];
|
||||
var paperWidths = [ 8.5, 8.5, 7.25, 148.0, 210.0, 287.0, 420.0, 594.0, 841.0];
|
||||
var paperHeights = [11.0, 14.0, 10.50, 210.0, 297.0, 420.0, 594.0, 841.0, 1189.0];
|
||||
var paperInches = [true, true, true, false, false, false, false, false, false];
|
||||
|
||||
gPaperArray = [];
|
||||
|
||||
for (var i = 0;i < paperNames.length;i++) {
|
||||
var obj = {};
|
||||
obj.name = paperNames[i];
|
||||
obj.width = paperWidths[i];
|
||||
obj.height = paperHeights[i];
|
||||
obj.inches = paperInches[i];
|
||||
|
||||
/* Calculate the width/height in millimeters */
|
||||
if (paperInches[i]) {
|
||||
obj.width_mm = paperWidths[i] * 25.4;
|
||||
obj.height_mm = paperHeights[i] * 25.4;
|
||||
} else {
|
||||
obj.width_mm = paperWidths[i];
|
||||
obj.height_mm = paperHeights[i];
|
||||
}
|
||||
gPaperArray[i] = obj;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function createPaperArrayFromPrinterFeatures() {
|
||||
var printername = gPrintSettings.printerName;
|
||||
if (doDebug) {
|
||||
dump("createPaperArrayFromPrinterFeatures for " + printername + ".\n");
|
||||
}
|
||||
|
||||
gPaperArray = [];
|
||||
|
||||
var numPapers = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper.count");
|
||||
|
||||
if (doDebug) {
|
||||
dump("processing " + numPapers + " entries...\n");
|
||||
}
|
||||
|
||||
for (var i = 0;i < numPapers;i++) {
|
||||
var obj = {};
|
||||
obj.name = gPrefs.getCharPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".name");
|
||||
obj.width_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".width_mm");
|
||||
obj.height_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".height_mm");
|
||||
obj.inches = gPrefs.getBoolPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".is_inch");
|
||||
|
||||
/* Calculate the width/height in paper's native units (either inches or millimeters) */
|
||||
if (obj.inches) {
|
||||
obj.width = obj.width_mm / 25.4;
|
||||
obj.height = obj.height_mm / 25.4;
|
||||
} else {
|
||||
obj.width = obj.width_mm;
|
||||
obj.height = obj.height_mm;
|
||||
}
|
||||
|
||||
gPaperArray[i] = obj;
|
||||
|
||||
if (doDebug) {
|
||||
dump("paper index=" + i + ", name=" + obj.name + ", width=" + obj.width + ", height=" + obj.height + ".\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function createPaperArray() {
|
||||
if (isListOfPrinterFeaturesAvailable()) {
|
||||
createPaperArrayFromPrinterFeatures();
|
||||
} else {
|
||||
createPaperArrayFromDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function createPaperSizeList(selectedInx) {
|
||||
var selectElement = new paperListElement(dialog.paperList);
|
||||
selectElement.clearPaperList();
|
||||
|
||||
selectElement.appendPaperNames(gPaperArray);
|
||||
|
||||
if (selectedInx > -1) {
|
||||
selectElement.paperListElement.selectedIndex = selectedInx;
|
||||
}
|
||||
|
||||
// dialog.paperList = selectElement;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function loadDialog() {
|
||||
var print_paper_unit = 0;
|
||||
var print_paper_width = 0.0;
|
||||
var print_paper_height = 0.0;
|
||||
var print_paper_name = "";
|
||||
var print_color = true;
|
||||
var print_jobtitle = "";
|
||||
|
||||
gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
if (gPrintSettings) {
|
||||
print_paper_unit = gPrintSettings.paperSizeUnit;
|
||||
print_paper_width = gPrintSettings.paperWidth;
|
||||
print_paper_height = gPrintSettings.paperHeight;
|
||||
print_paper_name = gPrintSettings.paperName;
|
||||
print_color = gPrintSettings.printInColor;
|
||||
print_jobtitle = gPrintSettings.title;
|
||||
}
|
||||
|
||||
if (doDebug) {
|
||||
dump("loadDialog******************************\n");
|
||||
dump("paperSizeType " + print_paper_unit + "\n");
|
||||
dump("paperWidth " + print_paper_width + "\n");
|
||||
dump("paperHeight " + print_paper_height + "\n");
|
||||
dump("paperName " + print_paper_name + "\n");
|
||||
dump("print_color " + print_color + "\n");
|
||||
dump("print_jobtitle " + print_jobtitle + "\n");
|
||||
}
|
||||
|
||||
createPaperArray();
|
||||
|
||||
var paperSelectedInx = 0;
|
||||
for (var i = 0;i < gPaperArray.length;i++) {
|
||||
if (print_paper_name == gPaperArray[i].name) {
|
||||
paperSelectedInx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (doDebug) {
|
||||
if (i == gPaperArray.length)
|
||||
dump("loadDialog: No paper found.\n");
|
||||
else
|
||||
dump("loadDialog: found paper '" + gPaperArray[paperSelectedInx].name + "'.\n");
|
||||
}
|
||||
|
||||
createPaperSizeList(paperSelectedInx);
|
||||
|
||||
/* Enable/disable and/or hide/unhide widgets based in the information
|
||||
* whether the selected printer and/or print module supports the matching
|
||||
* feature or not */
|
||||
if (isListOfPrinterFeaturesAvailable()) {
|
||||
// job title
|
||||
if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_jobtitle"))
|
||||
dialog.jobTitleInput.removeAttribute("disabled");
|
||||
else
|
||||
dialog.jobTitleInput.setAttribute("disabled", "true");
|
||||
if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_jobtitle_change"))
|
||||
dialog.jobTitleGroup.removeAttribute("hidden");
|
||||
else
|
||||
dialog.jobTitleGroup.setAttribute("hidden", "true");
|
||||
|
||||
// paper size
|
||||
if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_paper_size"))
|
||||
dialog.paperList.removeAttribute("disabled");
|
||||
else
|
||||
dialog.paperList.setAttribute("disabled", "true");
|
||||
if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_paper_size_change"))
|
||||
dialog.paperGroup.removeAttribute("hidden");
|
||||
else
|
||||
dialog.paperGroup.setAttribute("hidden", "true");
|
||||
|
||||
// color/grayscale radio
|
||||
if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".can_change_printincolor"))
|
||||
dialog.colorRadioGroup.removeAttribute("disabled");
|
||||
else
|
||||
dialog.colorRadioGroup.setAttribute("disabled", "true");
|
||||
if (gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".supports_printincolor_change"))
|
||||
dialog.colorGroup.removeAttribute("hidden");
|
||||
else
|
||||
dialog.colorGroup.setAttribute("hidden", "true");
|
||||
}
|
||||
|
||||
if (print_color) {
|
||||
dialog.colorRadioGroup.selectedItem = dialog.colorRadio;
|
||||
} else {
|
||||
dialog.colorRadioGroup.selectedItem = dialog.grayRadio;
|
||||
}
|
||||
|
||||
dialog.jobTitleInput.value = print_jobtitle;
|
||||
|
||||
dialog.topInput.value = gPrintSettings.edgeTop.toFixed(2);
|
||||
dialog.bottomInput.value = gPrintSettings.edgeBottom.toFixed(2);
|
||||
dialog.leftInput.value = gPrintSettings.edgeLeft.toFixed(2);
|
||||
dialog.rightInput.value = gPrintSettings.edgeRight.toFixed(2);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function onLoad() {
|
||||
// Init dialog.
|
||||
initDialog();
|
||||
|
||||
gPrintSettings = window.arguments[0].QueryInterface(gPrintSetInterface);
|
||||
gParamBlock = window.arguments[1].QueryInterface(Components.interfaces.nsIDialogParamBlock);
|
||||
|
||||
if (doDebug) {
|
||||
if (gPrintSettings == null) alert("PrintSettings is null!");
|
||||
if (gParamBlock == null) alert("nsIDialogParam is null!");
|
||||
}
|
||||
|
||||
// default return value is "cancel"
|
||||
gParamBlock.SetInt(0, 0);
|
||||
|
||||
loadDialog();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
function onAccept() {
|
||||
var print_paper_unit = gPrintSettingsInterface.kPaperSizeInches;
|
||||
var print_paper_width = 0.0;
|
||||
var print_paper_height = 0.0;
|
||||
var print_paper_name = "";
|
||||
|
||||
if (gPrintSettings != null) {
|
||||
var paperSelectedInx = dialog.paperList.selectedIndex;
|
||||
if (gPaperArray[paperSelectedInx].inches) {
|
||||
print_paper_unit = gPrintSettingsInterface.kPaperSizeInches;
|
||||
} else {
|
||||
print_paper_unit = gPrintSettingsInterface.kPaperSizeMillimeters;
|
||||
}
|
||||
print_paper_width = gPaperArray[paperSelectedInx].width;
|
||||
print_paper_height = gPaperArray[paperSelectedInx].height;
|
||||
print_paper_name = gPaperArray[paperSelectedInx].name;
|
||||
|
||||
gPrintSettings.paperSizeUnit = print_paper_unit;
|
||||
gPrintSettings.paperWidth = print_paper_width;
|
||||
gPrintSettings.paperHeight = print_paper_height;
|
||||
gPrintSettings.paperName = print_paper_name;
|
||||
|
||||
// save these out so they can be picked up by the device spec
|
||||
gPrintSettings.printInColor = dialog.colorRadio.selected;
|
||||
gPrintSettings.title = dialog.jobTitleInput.value;
|
||||
|
||||
gPrintSettings.edgeTop = dialog.topInput.value;
|
||||
gPrintSettings.edgeBottom = dialog.bottomInput.value;
|
||||
gPrintSettings.edgeLeft = dialog.leftInput.value;
|
||||
gPrintSettings.edgeRight = dialog.rightInput.value;
|
||||
|
||||
if (doDebug) {
|
||||
dump("onAccept******************************\n");
|
||||
dump("paperSizeUnit " + print_paper_unit + "\n");
|
||||
dump("paperWidth " + print_paper_width + "\n");
|
||||
dump("paperHeight " + print_paper_height + "\n");
|
||||
dump("paperName '" + print_paper_name + "'\n");
|
||||
|
||||
dump("printInColor " + gPrintSettings.printInColor + "\n");
|
||||
}
|
||||
} else {
|
||||
dump("************ onAccept gPrintSettings: " + gPrintSettings + "\n");
|
||||
}
|
||||
|
||||
if (gParamBlock) {
|
||||
// set return value to "ok"
|
||||
gParamBlock.SetInt(0, 1);
|
||||
} else {
|
||||
dump("*** FATAL ERROR: paramBlock missing\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<!DOCTYPE dialog SYSTEM "chrome://global/locale/printjoboptions.dtd">
|
||||
|
||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="onLoad();"
|
||||
ondialogaccept="return onAccept();"
|
||||
title="&printJobOptions.title;"
|
||||
persist="screenX screenY"
|
||||
screenX="24" screenY="24">
|
||||
|
||||
<script type="application/javascript" src="chrome://global/content/printjoboptions.js"/>
|
||||
|
||||
<stringbundle id="printBundle" src="chrome://global/locale/printPageSetup.properties"/>
|
||||
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
<column flex="1"/>
|
||||
</columns>
|
||||
|
||||
<rows>
|
||||
<row id="jobTitleGroup">
|
||||
<hbox align="center" pack="end">
|
||||
<label id="jobTitleLabel"
|
||||
value="&jobTitleInput.label;"
|
||||
accesskey="&jobTitleInput.accesskey;"
|
||||
control="jobTitleInput"/>
|
||||
</hbox>
|
||||
<textbox id="jobTitleInput" flex="1"/>
|
||||
</row>
|
||||
|
||||
<row id="paperGroup">
|
||||
<hbox align="center" pack="end">
|
||||
<label id="paperLabel"
|
||||
value="&paperInput.label;"
|
||||
accesskey="&paperInput.accesskey;"
|
||||
control="paperList"/>
|
||||
</hbox>
|
||||
<menulist id="paperList" flex="1">
|
||||
<menupopup/>
|
||||
</menulist>
|
||||
</row>
|
||||
|
||||
<row id="colorGroup">
|
||||
<hbox align="center" pack="end">
|
||||
<label control="colorRadioGroup" value="&colorGroup.label;"/>
|
||||
</hbox>
|
||||
<radiogroup id="colorRadioGroup" orient="horizontal">
|
||||
<radio id="grayRadio"
|
||||
label="&grayRadio.label;"
|
||||
accesskey="&grayRadio.accesskey;"/>
|
||||
<radio id="colorRadio"
|
||||
label="&colorRadio.label;"
|
||||
accesskey="&colorRadio.accesskey;"/>
|
||||
</radiogroup>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<groupbox flex="1">
|
||||
<caption label="&edgeMarginInput.label;"/>
|
||||
<hbox>
|
||||
<hbox align="center">
|
||||
<label id="topLabel"
|
||||
value="&topInput.label;"
|
||||
accesskey="&topInput.accesskey;"
|
||||
control="topInput"/>
|
||||
<textbox id="topInput" style="width:5em;" onkeyup="checkDouble(this, 0.5)"/>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<label id="bottomLabel"
|
||||
value="&bottomInput.label;"
|
||||
accesskey="&bottomInput.accesskey;"
|
||||
control="bottomInput"/>
|
||||
<textbox id="bottomInput" style="width:5em;" onkeyup="checkDouble(this, 0.5)"/>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<label id="leftLabel"
|
||||
value="&leftInput.label;"
|
||||
accesskey="&leftInput.accesskey;"
|
||||
control="leftInput"/>
|
||||
<textbox id="leftInput" style="width:5em;" onkeyup="checkDouble(this, 0.5)"/>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<label id="rightLabel"
|
||||
value="&rightInput.label;"
|
||||
accesskey="&rightInput.accesskey;"
|
||||
control="rightInput"/>
|
||||
<textbox id="rightInput" style="width:5em;" onkeyup="checkDouble(this, 0.5)"/>
|
||||
</hbox>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</row>
|
||||
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
</dialog>
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
toolkit.jar:
|
||||
#ifndef XP_MACOSX
|
||||
#ifdef XP_UNIX
|
||||
content/global/printdialog.js (content/printdialog.js)
|
||||
content/global/printdialog.xul (content/printdialog.xul)
|
||||
content/global/printjoboptions.js (content/printjoboptions.js)
|
||||
content/global/printjoboptions.xul (content/printjoboptions.xul)
|
||||
#endif
|
||||
content/global/printPageSetup.js (content/printPageSetup.js)
|
||||
content/global/printPageSetup.xul (content/printPageSetup.xul)
|
||||
content/global/printPreviewProgress.js (content/printPreviewProgress.js)
|
||||
|
|
|
@ -188,6 +188,14 @@ nsPrintingProxy::ShowPageSetup(mozIDOMWindowProxy *parent,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingProxy::ShowPrinterProperties(mozIDOMWindowProxy *parent,
|
||||
const char16_t *printerName,
|
||||
nsIPrintSettings *printSettings)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPrintingProxy::SavePrintSettings(nsIPrintSettings* aPS,
|
||||
bool aUsePrinterNamePrefix,
|
||||
|
|
|
@ -72,6 +72,12 @@ nsPrintingPromptService::ShowPageSetup(mozIDOMWindowProxy *parent, nsIPrintSetti
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPrinterProperties(mozIDOMWindowProxy *parent, const char16_t *printerName, nsIPrintSettings *printSettings)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// nsPrintingPromptService::nsIWebProgressListener
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
#include "nsPrintingPromptService.h"
|
||||
|
||||
#include "nsArray.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
|
@ -15,8 +18,40 @@
|
|||
#include "nsPrintProgress.h"
|
||||
#include "nsPrintProgressParams.h"
|
||||
|
||||
static const char *kPrintDialogURL = "chrome://global/content/printdialog.xul";
|
||||
static const char *kPrintProgressDialogURL = "chrome://global/content/printProgress.xul";
|
||||
static const char *kPrtPrvProgressDialogURL = "chrome://global/content/printPreviewProgress.xul";
|
||||
static const char *kPageSetupDialogURL = "chrome://global/content/printPageSetup.xul";
|
||||
static const char *kPrinterPropertiesURL = "chrome://global/content/printjoboptions.xul";
|
||||
|
||||
/****************************************************************
|
||||
************************* ParamBlock ***************************
|
||||
****************************************************************/
|
||||
|
||||
class ParamBlock {
|
||||
|
||||
public:
|
||||
ParamBlock()
|
||||
{
|
||||
mBlock = 0;
|
||||
}
|
||||
~ParamBlock()
|
||||
{
|
||||
NS_IF_RELEASE(mBlock);
|
||||
}
|
||||
nsresult Init() {
|
||||
return CallCreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID, &mBlock);
|
||||
}
|
||||
nsIDialogParamBlock * operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return mBlock; }
|
||||
operator nsIDialogParamBlock * () const { return mBlock; }
|
||||
|
||||
private:
|
||||
nsIDialogParamBlock *mBlock;
|
||||
};
|
||||
|
||||
/****************************************************************
|
||||
***************** nsPrintingPromptService **********************
|
||||
****************************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsPrintingPromptService, nsIPrintingPromptService, nsIWebProgressListener)
|
||||
|
||||
|
@ -44,13 +79,21 @@ nsPrintingPromptService::ShowPrintDialog(mozIDOMWindowProxy *parent,
|
|||
NS_ENSURE_ARG(webBrowserPrint);
|
||||
NS_ENSURE_ARG(printSettings);
|
||||
|
||||
// Try to access a component dialog
|
||||
nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
|
||||
NS_PRINTDIALOGSERVICE_CONTRACTID));
|
||||
if (dlgPrint)
|
||||
return dlgPrint->Show(nsPIDOMWindowOuter::From(parent),
|
||||
printSettings, webBrowserPrint);
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
// Show the built-in dialog instead
|
||||
ParamBlock block;
|
||||
nsresult rv = block.Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
block->SetInt(0, 0);
|
||||
return DoDialog(parent, block, webBrowserPrint, printSettings, kPrintDialogURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -100,15 +143,110 @@ nsPrintingPromptService::ShowPageSetup(mozIDOMWindowProxy *parent,
|
|||
{
|
||||
NS_ENSURE_ARG(printSettings);
|
||||
|
||||
// Try to access a component dialog
|
||||
nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
|
||||
NS_PRINTDIALOGSERVICE_CONTRACTID));
|
||||
if (dlgPrint)
|
||||
return dlgPrint->ShowPageSetup(nsPIDOMWindowOuter::From(parent),
|
||||
printSettings);
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
ParamBlock block;
|
||||
nsresult rv = block.Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
block->SetInt(0, 0);
|
||||
return DoDialog(parent, block, nullptr, printSettings, kPageSetupDialogURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPrinterProperties(mozIDOMWindowProxy *parent,
|
||||
const char16_t *printerName,
|
||||
nsIPrintSettings *printSettings)
|
||||
{
|
||||
/* fixme: We simply ignore the |aPrinter| argument here
|
||||
* We should get the supported printer attributes from the printer and
|
||||
* populate the print job options dialog with these data instead of using
|
||||
* the "default set" here.
|
||||
* However, this requires changes on all platforms and is another big chunk
|
||||
* of patches ... ;-(
|
||||
*/
|
||||
NS_ENSURE_ARG(printerName);
|
||||
NS_ENSURE_ARG(printSettings);
|
||||
|
||||
ParamBlock block;
|
||||
nsresult rv = block.Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
block->SetInt(0, 0);
|
||||
return DoDialog(parent, block, nullptr, printSettings, kPrinterPropertiesURL);
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPrintingPromptService::DoDialog(mozIDOMWindowProxy *aParent,
|
||||
nsIDialogParamBlock *aParamBlock,
|
||||
nsIWebBrowserPrint *aWebBrowserPrint,
|
||||
nsIPrintSettings* aPS,
|
||||
const char *aChromeURL)
|
||||
{
|
||||
NS_ENSURE_ARG(aParamBlock);
|
||||
NS_ENSURE_ARG(aPS);
|
||||
NS_ENSURE_ARG(aChromeURL);
|
||||
|
||||
if (!mWatcher)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get a parent, if at all possible
|
||||
// (though we'd rather this didn't fail, it's OK if it does. so there's
|
||||
// no failure or null check.)
|
||||
nsCOMPtr<mozIDOMWindowProxy> activeParent;
|
||||
if (!aParent)
|
||||
{
|
||||
mWatcher->GetActiveWindow(getter_AddRefs(activeParent));
|
||||
aParent = activeParent;
|
||||
}
|
||||
|
||||
// create a nsIMutableArray of the parameters
|
||||
// being passed to the window
|
||||
nsCOMPtr<nsIMutableArray> array = nsArray::Create();
|
||||
|
||||
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(aPS));
|
||||
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
|
||||
array->AppendElement(psSupports);
|
||||
|
||||
if (aWebBrowserPrint) {
|
||||
nsCOMPtr<nsISupports> wbpSupports(do_QueryInterface(aWebBrowserPrint));
|
||||
NS_ASSERTION(wbpSupports, "nsIWebBrowserPrint must be a supports");
|
||||
array->AppendElement(wbpSupports);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(aParamBlock));
|
||||
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
|
||||
array->AppendElement(blkSupps);
|
||||
|
||||
nsCOMPtr<mozIDOMWindowProxy> dialog;
|
||||
nsresult rv = mWatcher->OpenWindow(aParent, aChromeURL, "_blank",
|
||||
"centerscreen,chrome,modal,titlebar", array,
|
||||
getter_AddRefs(dialog));
|
||||
|
||||
// if aWebBrowserPrint is not null then we are printing
|
||||
// so we want to pass back NS_ERROR_ABORT on cancel
|
||||
if (NS_SUCCEEDED(rv) && aWebBrowserPrint)
|
||||
{
|
||||
int32_t status;
|
||||
aParamBlock->GetInt(0, &status);
|
||||
return status == 0?NS_ERROR_ABORT:NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// nsIWebProgressListener
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t aStateFlags, nsresult aStatus)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
// Printing Progress Includes
|
||||
#include "nsPrintProgress.h"
|
||||
#include "nsPrintProgressParams.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
|
||||
class nsIDOMWindow;
|
||||
|
@ -42,6 +43,12 @@ protected:
|
|||
virtual ~nsPrintingPromptService();
|
||||
|
||||
private:
|
||||
nsresult DoDialog(mozIDOMWindowProxy *aParent,
|
||||
nsIDialogParamBlock *aParamBlock,
|
||||
nsIWebBrowserPrint *aWebBrowserPrint,
|
||||
nsIPrintSettings* aPS,
|
||||
const char *aChromeURL);
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> mWatcher;
|
||||
nsCOMPtr<nsIPrintProgress> mPrintProgress;
|
||||
nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
|
||||
|
|
|
@ -116,6 +116,12 @@ nsPrintingPromptService::ShowPageSetup(mozIDOMWindowProxy *parent, nsIPrintSetti
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPrinterProperties(mozIDOMWindowProxy *parent, const char16_t *printerName, nsIPrintSettings *printSettings)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// nsIWebProgressListener
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!-- extracted from printdialog.xul -->
|
||||
|
||||
<!ENTITY printButton.label "Print">
|
||||
|
||||
<!ENTITY printDialog.title "Print">
|
||||
|
||||
<!ENTITY fpDialog.title "Save File">
|
||||
|
||||
<!ENTITY fileCheck.label "Print to File">
|
||||
<!ENTITY fileCheck.accesskey "F">
|
||||
<!ENTITY propertiesButton.label "Properties…">
|
||||
<!ENTITY propertiesButton.accesskey "o">
|
||||
<!ENTITY descText.label "Printer Description:">
|
||||
<!ENTITY printer.label "Printer">
|
||||
<!ENTITY printerInput.label "Printer Name:">
|
||||
<!ENTITY printerInput.accesskey "N">
|
||||
|
||||
<!ENTITY printrangeGroup.label "Print Range">
|
||||
<!ENTITY allpagesRadio.label "All Pages">
|
||||
<!ENTITY allpagesRadio.accesskey "A">
|
||||
<!ENTITY rangeRadio.label "Pages">
|
||||
<!ENTITY rangeRadio.accesskey "P">
|
||||
<!ENTITY frompageInput.label "from">
|
||||
<!ENTITY frompageInput.accesskey "r">
|
||||
<!ENTITY topageInput.label "to">
|
||||
<!ENTITY topageInput.accesskey "t">
|
||||
<!ENTITY selectionRadio.label "Selection">
|
||||
<!ENTITY selectionRadio.accesskey "S">
|
||||
|
||||
<!ENTITY copies.label "Copies">
|
||||
<!ENTITY numCopies.label "Number of copies:">
|
||||
<!ENTITY numCopies.accesskey "c">
|
||||
|
||||
<!ENTITY printframeGroup.label "Print Frames">
|
||||
<!ENTITY aslaidoutRadio.label "As laid out on the screen">
|
||||
<!ENTITY aslaidoutRadio.accesskey "u">
|
||||
<!ENTITY selectedframeRadio.label "The selected frame">
|
||||
<!ENTITY selectedframeRadio.accesskey "m">
|
||||
<!ENTITY eachframesepRadio.label "Each frame separately">
|
||||
<!ENTITY eachframesepRadio.accesskey "E">
|
|
@ -0,0 +1,29 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!-- extracted from printjoboptions.xul -->
|
||||
|
||||
<!ENTITY printJobOptions.title "Printer Properties">
|
||||
|
||||
<!ENTITY paperInput.label "Paper Size:">
|
||||
<!ENTITY paperInput.accesskey "P">
|
||||
|
||||
<!ENTITY jobTitleInput.label "Job Title:">
|
||||
<!ENTITY jobTitleInput.accesskey "J">
|
||||
|
||||
<!ENTITY colorGroup.label "Color:">
|
||||
<!ENTITY grayRadio.label "Grayscale">
|
||||
<!ENTITY grayRadio.accesskey "G">
|
||||
<!ENTITY colorRadio.label "Color">
|
||||
<!ENTITY colorRadio.accesskey "C">
|
||||
|
||||
<!ENTITY edgeMarginInput.label "Gap from edge of paper to Margin">
|
||||
<!ENTITY topInput.label "Top:">
|
||||
<!ENTITY topInput.accesskey "T">
|
||||
<!ENTITY bottomInput.label "Bottom:">
|
||||
<!ENTITY bottomInput.accesskey "B">
|
||||
<!ENTITY leftInput.label "Left:">
|
||||
<!ENTITY leftInput.accesskey "L">
|
||||
<!ENTITY rightInput.label "Right:">
|
||||
<!ENTITY rightInput.accesskey "R">
|
|
@ -70,6 +70,8 @@
|
|||
locale/@AB_CD@/global/notification.dtd (%chrome/global/notification.dtd)
|
||||
locale/@AB_CD@/global/preferences.dtd (%chrome/global/preferences.dtd)
|
||||
#ifndef MOZ_FENNEC
|
||||
locale/@AB_CD@/global/printdialog.dtd (%chrome/global/printdialog.dtd)
|
||||
locale/@AB_CD@/global/printjoboptions.dtd (%chrome/global/printjoboptions.dtd)
|
||||
locale/@AB_CD@/global/printPageSetup.dtd (%chrome/global/printPageSetup.dtd)
|
||||
locale/@AB_CD@/global/printPreview.dtd (%chrome/global/printPreview.dtd)
|
||||
locale/@AB_CD@/global/printPreviewProgress.dtd (%chrome/global/printPreviewProgress.dtd)
|
||||
|
|
Загрузка…
Ссылка в новой задаче