Bug 1411121 - Part 2: Remove printdialog.xul and printjoboptions.xul. r=mconley

This patch will remove printing xul dialog and related files since a caller of
this xul dialog doesn't exist.
The printjoboptions.xul is only used by printdialog.xul.

MozReview-Commit-ID: B6VZuj3Lg1b

--HG--
extra : rebase_source : 7cf2e94c491147a2cb84616ab922adeb833cb447
This commit is contained in:
Mantaroh Yoshinaga 2017-11-06 09:27:05 +09:00
Родитель 71e345180e
Коммит 26d5a3372b
9 изменённых файлов: 0 добавлений и 1102 удалений

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

@ -60,10 +60,6 @@ var whitelist = [
{file: "chrome://global/locale/printPreviewProgress.dtd",
platforms: ["macosx"]},
{file: "chrome://global/locale/printProgress.dtd", platforms: ["macosx"]},
{file: "chrome://global/locale/printdialog.dtd",
platforms: ["macosx", "win"]},
{file: "chrome://global/locale/printjoboptions.dtd",
platforms: ["macosx", "win"]},
// devtools/client/inspector/bin/dev-server.js
{file: "chrome://devtools/content/inspector/markup/markup.xhtml",

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

@ -1,408 +0,0 @@
// -*- 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);
}
});
});
}

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

@ -1,126 +0,0 @@
<?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>

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

@ -1,373 +0,0 @@
// -*- 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;
}

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

@ -1,110 +0,0 @@
<?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,12 +4,6 @@
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)

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

@ -1,44 +0,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/. -->
<!-- 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">

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

@ -1,29 +0,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/. -->
<!-- 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,8 +70,6 @@
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)