# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- # ***** BEGIN LICENSE BLOCK ***** # Version: MPL 1.1/GPL 2.0/LGPL 2.1 # # The contents of this file are subject to the Mozilla Public License Version # 1.1 (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License # for the specific language governing rights and limitations under the # License. # # The Original Code is mozilla.org printing front-end. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 2002 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Masaki Katakai # Roland Mainz # Asko Tontti # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), # in which case the provisions of the GPL or the LGPL are applicable instead # of those above. If you wish to allow use of your version of this file only # under the terms of either the GPL or the LGPL, and not to allow others to # use your version of this file under the terms of the NPL, indicate your # decision by deleting the provisions above and replace them with the notice # and other provisions required by the GPL or the LGPL. If you do not delete # the provisions above, a recipient may use your version of this file under # the terms of any one of the NPL, the GPL or the LGPL. # # ***** END LICENSE BLOCK ***** */ # var dialog; var gPrintSettings = null; var gStringBundle = null; var gPrintSettingsInterface = Components.interfaces.nsIPrintSettings; var gPaperArray; var gPlexArray; var gResolutionArray; var gColorSpaceArray; var gPrefs; var default_command = "lpr"; 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() { var has_printerfeatures = false; try { has_printerfeatures = gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures"); } catch(ex) { } return has_printerfeatures; } //--------------------------------------------------- function getDoubleStr(val, dec) { var str = val.toString(); var inx = str.indexOf("."); return str.substring(0, inx+dec+1); } //--------------------------------------------------- function initDialog() { dialog = new Object; dialog.paperList = document.getElementById("paperList"); dialog.paperGroup = document.getElementById("paperGroup"); dialog.plexList = document.getElementById("plexList"); dialog.plexGroup = document.getElementById("plexGroup"); dialog.resolutionList = document.getElementById("resolutionList"); dialog.resolutionGroup = document.getElementById("resolutionGroup"); dialog.jobTitleLabel = document.getElementById("jobTitleLabel"); dialog.jobTitleGroup = document.getElementById("jobTitleGroup"); dialog.jobTitleInput = document.getElementById("jobTitleInput"); dialog.cmdLabel = document.getElementById("cmdLabel"); dialog.cmdGroup = document.getElementById("cmdGroup"); dialog.cmdInput = document.getElementById("cmdInput"); dialog.colorspaceList = document.getElementById("colorspaceList"); dialog.colorspaceGroup = document.getElementById("colorspaceGroup"); dialog.colorGroup = document.getElementById("colorGroup"); dialog.colorRadioGroup = document.getElementById("colorRadioGroup"); dialog.colorRadio = document.getElementById("colorRadio"); dialog.grayRadio = document.getElementById("grayRadio"); dialog.fontsGroup = document.getElementById("fontsGroup"); dialog.downloadFonts = document.getElementById("downloadFonts"); 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: function () { // remove the menupopup node child of the menulist. this.paperListElement.removeChild(this.paperListElement.firstChild); }, appendPaperNames: function (aDataObject) { var popupNode = document.createElement("menupopup"); for (var i=0;i -1) { selectElement.paperListElement.selectedIndex = selectedInx; } //dialog.paperList = selectElement; } //--------------------------------------------------- function plexListElement(aPlexListElement) { this.plexListElement = aPlexListElement; } plexListElement.prototype = { clearPlexList: function () { // remove the menupopup node child of the menulist. this.plexListElement.removeChild(this.plexListElement.firstChild); }, appendPlexNames: function (aDataObject) { var popupNode = document.createElement("menupopup"); for (var i=0;i -1) { selectElement.plexListElement.selectedIndex = selectedInx; } //dialog.plexList = selectElement; } //--------------------------------------------------- function resolutionListElement(aResolutionListElement) { this.resolutionListElement = aResolutionListElement; } resolutionListElement.prototype = { clearResolutionList: function () { // remove the menupopup node child of the menulist. this.resolutionListElement.removeChild(this.resolutionListElement.firstChild); }, appendResolutionNames: function (aDataObject) { var popupNode = document.createElement("menupopup"); for (var i=0;i -1) { selectElement.resolutionListElement.selectedIndex = selectedInx; } //dialog.resolutionList = selectElement; } //--------------------------------------------------- function colorspaceListElement(aColorspaceListElement) { this.colorspaceListElement = aColorspaceListElement; } colorspaceListElement.prototype = { clearColorspaceList: function () { // remove the menupopup node child of the menulist. this.colorspaceListElement.removeChild(this.colorspaceListElement.firstChild); }, appendColorspaceNames: function (aDataObject) { var popupNode = document.createElement("menupopup"); for (var i=0;i -1) { selectElement.colorspaceListElement.selectedIndex = selectedInx; } //dialog.colorspaceList = selectElement; } //--------------------------------------------------- function loadDialog() { var print_paper_type = 0; var print_paper_unit = 0; var print_paper_width = 0.0; var print_paper_height = 0.0; var print_paper_name = ""; var print_plex_name = ""; var print_resolution_name = ""; var print_colorspace = ""; var print_color = true; var print_downloadfonts = true; var print_command = default_command; var print_jobtitle = ""; gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); if (gPrintSettings) { print_paper_type = gPrintSettings.paperSizeType; print_paper_unit = gPrintSettings.paperSizeUnit; print_paper_width = gPrintSettings.paperWidth; print_paper_height = gPrintSettings.paperHeight; print_paper_name = gPrintSettings.paperName; print_plex_name = gPrintSettings.plexName; print_resolution_name = gPrintSettings.resolutionName; print_colorspace = gPrintSettings.colorspace; print_color = gPrintSettings.printInColor; print_downloadfonts = gPrintSettings.downloadFonts; print_command = gPrintSettings.printCommand; 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("plexName "+print_plex_name+"\n"); dump("resolutionName "+print_resolution_name+"\n"); dump("colorspace "+print_colorspace+"\n"); dump("print_color "+print_color+"\n"); dump("print_downloadfonts "+print_downloadfonts+"\n"); dump("print_command "+print_command+"\n"); dump("print_jobtitle "+print_jobtitle+"\n"); } createPaperArray(); var paperSelectedInx = 0; for (var i=0;i