1 # -*- Mode
: Java
; tab
-width
: 4; indent
-tabs
-mode
: nil
; c
-basic
-offset
: 4 -*-
2 # ***** BEGIN LICENSE BLOCK
*****
3 # Version
: MPL
1.1/GPL 2.0/LGPL
2.1
5 # The contents
of this file are subject to the Mozilla Public License Version
6 # 1.1 (the
"License"); you may not
use this file except
in compliance
with
7 # the License
. You may obtain a copy
of the License at
8 # http
://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an
"AS IS" basis
,
11 # WITHOUT WARRANTY OF ANY KIND
, either express or implied
. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is mozilla
.org printing front
-end
.
17 # The Initial Developer
of the Original Code is
18 # Netscape Communications Corporation
.
19 # Portions created by the Initial Developer are
Copyright (C
) 2002
20 # the Initial Developer
. All Rights Reserved
.
23 # Masaki Katakai
<katakai
@japan
.sun
.com
>
24 # Roland Mainz
<roland
.mainz
@informatik
.med
.uni
-giessen
.de
>
25 # Asko Tontti
<atontti
@cc
.hut
.fi
>
27 # Alternatively
, the contents
of this file may be used under the terms
of
28 # either the GNU General Public License Version
2 or
later (the
"GPL"), or
29 # the GNU Lesser General Public License Version
2.1 or
later (the
"LGPL"),
30 # in which
case the provisions
of the GPL or the LGPL are applicable instead
31 # of those above
. If you wish to allow
use of your version
of this file only
32 # under the terms
of either the GPL or the LGPL
, and not to allow others to
33 # use your version
of this file under the terms
of the MPL
, indicate your
34 # decision by deleting the provisions above and replace them
with the notice
35 # and other provisions required by the GPL or the LGPL
. If you
do not
delete
36 # the provisions above
, a recipient may
use your version
of this file under
37 # the terms
of any one
of the MPL
, the GPL or the LGPL
.
39 # ***** END LICENSE BLOCK
*****
44 var gPrintSettings
= null;
45 var gPrintSettingsInterface
= Components
.interfaces
.nsIPrintSettings
;
52 var default_command
= "lpr";
53 var gPrintSetInterface
= Components
.interfaces
.nsIPrintSettings
;
56 //---------------------------------------------------
57 function checkDouble(element
, maxVal
)
59 var value
= element
.value
;
60 if (value
&& value
.length
> 0) {
61 value
= value
.replace(/[^\.|^0-9]/g,"");
66 element
.value
= maxVal
;
68 element
.value
= value
;
74 //---------------------------------------------------
75 function isListOfPrinterFeaturesAvailable()
77 var has_printerfeatures
= false;
80 has_printerfeatures
= gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".has_special_printerfeatures");
84 return has_printerfeatures
;
87 //---------------------------------------------------
88 function getDoubleStr(val
, dec
)
90 var str
= val
.toString();
91 var inx
= str
.indexOf(".");
92 return str
.substring(0, inx
+dec
+1);
95 //---------------------------------------------------
98 gPrintBundle
= document
.getElementById("printBundle");
102 dialog
.paperList
= document
.getElementById("paperList");
103 dialog
.paperGroup
= document
.getElementById("paperGroup");
105 dialog
.plexList
= document
.getElementById("plexList");
106 dialog
.plexGroup
= document
.getElementById("plexGroup");
108 dialog
.resolutionList
= document
.getElementById("resolutionList");
109 dialog
.resolutionGroup
= document
.getElementById("resolutionGroup");
111 dialog
.jobTitleLabel
= document
.getElementById("jobTitleLabel");
112 dialog
.jobTitleGroup
= document
.getElementById("jobTitleGroup");
113 dialog
.jobTitleInput
= document
.getElementById("jobTitleInput");
115 dialog
.cmdLabel
= document
.getElementById("cmdLabel");
116 dialog
.cmdGroup
= document
.getElementById("cmdGroup");
117 dialog
.cmdInput
= document
.getElementById("cmdInput");
119 dialog
.colorspaceList
= document
.getElementById("colorspaceList");
120 dialog
.colorspaceGroup
= document
.getElementById("colorspaceGroup");
122 dialog
.colorGroup
= document
.getElementById("colorGroup");
123 dialog
.colorRadioGroup
= document
.getElementById("colorRadioGroup");
124 dialog
.colorRadio
= document
.getElementById("colorRadio");
125 dialog
.grayRadio
= document
.getElementById("grayRadio");
127 dialog
.fontsGroup
= document
.getElementById("fontsGroup");
128 dialog
.downloadFonts
= document
.getElementById("downloadFonts");
130 dialog
.topInput
= document
.getElementById("topInput");
131 dialog
.bottomInput
= document
.getElementById("bottomInput");
132 dialog
.leftInput
= document
.getElementById("leftInput");
133 dialog
.rightInput
= document
.getElementById("rightInput");
136 //---------------------------------------------------
137 function round10(val
)
139 return Math
.round(val
* 10) / 10;
143 //---------------------------------------------------
144 function paperListElement(aPaperListElement
)
146 this.paperListElement
= aPaperListElement
;
149 paperListElement
.prototype =
154 // remove the menupopup node child of the menulist.
155 this.paperListElement
.removeChild(this.paperListElement
.firstChild
);
159 function (aDataObject
)
161 var popupNode
= document
.createElement("menupopup");
162 for (var i
=0;i
<aDataObject
.length
;i
++) {
163 var paperObj
= aDataObject
[i
];
164 var itemNode
= document
.createElement("menuitem");
167 label
= gPrintBundle
.getString(paperObj
.name
);
170 /* No name in string bundle ? Then build one manually (this
171 * usually happens when gPaperArray was build by createPaperArrayFromPrinterFeatures() ...) */
172 if (paperObj
.inches
) {
173 label
= paperObj
.name
+ " (" + round10(paperObj
.width
) + "x" + round10(paperObj
.height
) + " inch)";
176 label
= paperObj
.name
+ " (" + paperObj
.width
+ "x" + paperObj
.height
+ " mm)";
179 itemNode
.setAttribute("label", label
);
180 itemNode
.setAttribute("value", i
);
181 popupNode
.appendChild(itemNode
);
183 this.paperListElement
.appendChild(popupNode
);
187 //---------------------------------------------------
188 function createPaperArrayFromDefaults()
190 var paperNames
= ["letterSize", "legalSize", "exectiveSize", "a5Size", "a4Size", "a3Size", "a2Size", "a1Size", "a0Size"];
191 //var paperNames = ["&letterRadio.label;", "&legalRadio.label;", "&exectiveRadio.label;", "&a4Radio.label;", "&a3Radio.label;"];
192 var paperWidths
= [ 8.5, 8.5, 7.25, 148.0, 210.0, 287.0, 420.0, 594.0, 841.0];
193 var paperHeights
= [11.0, 14.0, 10.50, 210.0, 297.0, 420.0, 594.0, 841.0, 1189.0];
194 var paperInches
= [true, true, true, false, false, false, false, false, false];
195 // this is deprecated
196 var paperEnums
= [0, 1, 2, 3, 4, 5, 6, 7, 8];
198 gPaperArray
= new Array();
200 for (var i
=0;i
<paperNames
.length
;i
++) {
201 var obj
= new Object();
202 obj
.name
= paperNames
[i
];
203 obj
.width
= paperWidths
[i
];
204 obj
.height
= paperHeights
[i
];
205 obj
.inches
= paperInches
[i
];
207 /* Calculate the width/height in millimeters */
208 if (paperInches[i]) {
209 obj.width_mm = paperWidths[i] * 25.4;
210 obj.height_mm = paperHeights[i] * 25.4;
213 obj.width_mm = paperWidths[i];
214 obj.height_mm = paperHeights[i];
216 gPaperArray[i] = obj;
220 //---------------------------------------------------
221 function createPaperArrayFromPrinterFeatures()
223 var printername = gPrintSettings.printerName;
225 dump("createPaperArrayFromPrinterFeatures for " + printername + ".\n");
228 gPaperArray = new Array();
230 var numPapers = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper.count");
233 dump("processing " + numPapers + " entries...\n");
236 for (var i=0;i<numPapers;i++) {
237 var obj = new Object();
238 obj.name = gPrefs.getCharPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".name");
239 obj.width_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".width_mm");
240 obj.height_mm = gPrefs.getIntPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".height_mm");
241 obj.inches = gPrefs.getBoolPref("print.tmp.printerfeatures." + printername + ".paper." + i + ".is_inch");
243 /* Calculate the width/height in paper's native units (either inches or millimeters) */
245 obj.width = obj.width_mm / 25.4;
246 obj.height = obj.height_mm / 25.4;
249 obj.width = obj.width_mm;
250 obj.height = obj.height_mm;
253 gPaperArray[i] = obj;
256 dump("paper index=" + i + ", name=" + obj.name + ", width=" + obj.width + ", height=" + obj.height + ".\n");
261 //---------------------------------------------------
262 function createPaperArray()
264 if (isListOfPrinterFeaturesAvailable()) {
265 createPaperArrayFromPrinterFeatures();
268 createPaperArrayFromDefaults();
272 //---------------------------------------------------
273 function createPaperSizeList(selectedInx)
275 var selectElement = new paperListElement(dialog.paperList);
276 selectElement.clearPaperList();
278 selectElement.appendPaperNames(gPaperArray);
280 if (selectedInx > -1) {
281 selectElement.paperListElement.selectedIndex = selectedInx;
284 //dialog.paperList = selectElement;
287 //---------------------------------------------------
288 function plexListElement(aPlexListElement)
290 this.plexListElement = aPlexListElement;
293 plexListElement.prototype =
298 // remove the menupopup node child of the menulist.
299 this.plexListElement.removeChild(this.plexListElement.firstChild);
303 function (aDataObject)
305 var popupNode = document.createElement("menupopup");
306 for (var i=0;i<aDataObject.length;i++) {
307 var plexObj = aDataObject[i];
308 var itemNode = document.createElement("menuitem");
311 label = gPrintBundle.getString(plexObj.name);
314 /* No name in string bundle ? Then build one manually (this
315 * usually happens when gPlexArray was build by createPlexArrayFromPrinterFeatures() ...) */
316 label
= plexObj
.name
;
318 itemNode
.setAttribute("label", label
);
319 itemNode
.setAttribute("value", i
);
320 popupNode
.appendChild(itemNode
);
322 this.plexListElement
.appendChild(popupNode
);
327 //---------------------------------------------------
328 function createPlexArrayFromDefaults()
330 var plexNames
= ["default"];
332 gPlexArray
= new Array();
334 for (var i
=0;i
<plexNames
.length
;i
++) {
335 var obj
= new Object();
336 obj
.name
= plexNames
[i
];
342 //---------------------------------------------------
343 function createPlexArrayFromPrinterFeatures()
345 var printername
= gPrintSettings
.printerName
;
347 dump("createPlexArrayFromPrinterFeatures for " + printername
+ ".\n");
350 gPlexArray
= new Array();
352 var numPlexs
= gPrefs
.getIntPref("print.tmp.printerfeatures." + printername
+ ".plex.count");
355 dump("processing " + numPlexs
+ " entries...\n");
358 for ( var i
=0 ; i
< numPlexs
; i
++ ) {
359 var obj
= new Object();
360 obj
.name
= gPrefs
.getCharPref("print.tmp.printerfeatures." + printername
+ ".plex." + i
+ ".name");
365 dump("plex index=" + i
+ ", name='" + obj
.name
+ "'.\n");
370 //---------------------------------------------------
371 function createPlexArray()
373 if (isListOfPrinterFeaturesAvailable()) {
374 createPlexArrayFromPrinterFeatures();
377 createPlexArrayFromDefaults();
381 //---------------------------------------------------
382 function createPlexNameList(selectedInx
)
384 var selectElement
= new plexListElement(dialog
.plexList
);
385 selectElement
.clearPlexList();
387 selectElement
.appendPlexNames(gPlexArray
);
389 if (selectedInx
> -1) {
390 selectElement
.plexListElement
.selectedIndex
= selectedInx
;
393 //dialog.plexList = selectElement;
396 //---------------------------------------------------
397 function resolutionListElement(aResolutionListElement
)
399 this.resolutionListElement
= aResolutionListElement
;
402 resolutionListElement
.prototype =
407 // remove the menupopup node child of the menulist.
408 this.resolutionListElement
.removeChild(this.resolutionListElement
.firstChild
);
411 appendResolutionNames
:
412 function (aDataObject
)
414 var popupNode
= document
.createElement("menupopup");
415 for (var i
=0;i
<aDataObject
.length
;i
++) {
416 var resolutionObj
= aDataObject
[i
];
417 var itemNode
= document
.createElement("menuitem");
420 label
= gPrintBundle
.getString(resolutionObj
.name
);
423 /* No name in string bundle ? Then build one manually (this
424 * usually happens when gResolutionArray was build by createResolutionArrayFromPrinterFeatures() ...) */
425 label
= resolutionObj
.name
;
427 itemNode
.setAttribute("label", label
);
428 itemNode
.setAttribute("value", i
);
429 popupNode
.appendChild(itemNode
);
431 this.resolutionListElement
.appendChild(popupNode
);
436 //---------------------------------------------------
437 function createResolutionArrayFromDefaults()
439 var resolutionNames
= ["default"];
441 gResolutionArray
= new Array();
443 for (var i
=0;i
<resolutionNames
.length
;i
++) {
444 var obj
= new Object();
445 obj
.name
= resolutionNames
[i
];
447 gResolutionArray
[i
] = obj
;
451 //---------------------------------------------------
452 function createResolutionArrayFromPrinterFeatures()
454 var printername
= gPrintSettings
.printerName
;
456 dump("createResolutionArrayFromPrinterFeatures for " + printername
+ ".\n");
459 gResolutionArray
= new Array();
461 var numResolutions
= gPrefs
.getIntPref("print.tmp.printerfeatures." + printername
+ ".resolution.count");
464 dump("processing " + numResolutions
+ " entries...\n");
467 for ( var i
=0 ; i
< numResolutions
; i
++ ) {
468 var obj
= new Object();
469 obj
.name
= gPrefs
.getCharPref("print.tmp.printerfeatures." + printername
+ ".resolution." + i
+ ".name");
471 gResolutionArray
[i
] = obj
;
474 dump("resolution index=" + i
+ ", name='" + obj
.name
+ "'.\n");
479 //---------------------------------------------------
480 function createResolutionArray()
482 if (isListOfPrinterFeaturesAvailable()) {
483 createResolutionArrayFromPrinterFeatures();
486 createResolutionArrayFromDefaults();
490 //---------------------------------------------------
491 function createResolutionNameList(selectedInx
)
493 var selectElement
= new resolutionListElement(dialog
.resolutionList
);
494 selectElement
.clearResolutionList();
496 selectElement
.appendResolutionNames(gResolutionArray
);
498 if (selectedInx
> -1) {
499 selectElement
.resolutionListElement
.selectedIndex
= selectedInx
;
502 //dialog.resolutionList = selectElement;
505 //---------------------------------------------------
506 function colorspaceListElement(aColorspaceListElement
)
508 this.colorspaceListElement
= aColorspaceListElement
;
511 colorspaceListElement
.prototype =
516 // remove the menupopup node child of the menulist.
517 this.colorspaceListElement
.removeChild(this.colorspaceListElement
.firstChild
);
520 appendColorspaceNames
:
521 function (aDataObject
)
523 var popupNode
= document
.createElement("menupopup");
524 for (var i
=0;i
<aDataObject
.length
;i
++) {
525 var colorspaceObj
= aDataObject
[i
];
526 var itemNode
= document
.createElement("menuitem");
529 label
= gPrintBundle
.getString(colorspaceObj
.name
);
532 /* No name in string bundle ? Then build one manually (this
533 * usually happens when gColorspaceArray was build by createColorspaceArrayFromPrinterFeatures() ...) */
534 label
= colorspaceObj
.name
;
536 itemNode
.setAttribute("label", label
);
537 itemNode
.setAttribute("value", i
);
538 popupNode
.appendChild(itemNode
);
540 this.colorspaceListElement
.appendChild(popupNode
);
545 //---------------------------------------------------
546 function createColorspaceArrayFromDefaults()
548 var colorspaceNames
= ["default"];
550 gColorspaceArray
= new Array();
552 for (var i
=0;i
<colorspaceNames
.length
;i
++) {
553 var obj
= new Object();
554 obj
.name
= colorspaceNames
[i
];
556 gColorspaceArray
[i
] = obj
;
560 //---------------------------------------------------
561 function createColorspaceArrayFromPrinterFeatures()
563 var printername
= gPrintSettings
.printerName
;
565 dump("createColorspaceArrayFromPrinterFeatures for " + printername
+ ".\n");
568 gColorspaceArray
= new Array();
570 var numColorspaces
= gPrefs
.getIntPref("print.tmp.printerfeatures." + printername
+ ".colorspace.count");
573 dump("processing " + numColorspaces
+ " entries...\n");
576 for ( var i
=0 ; i
< numColorspaces
; i
++ ) {
577 var obj
= new Object();
578 obj
.name
= gPrefs
.getCharPref("print.tmp.printerfeatures." + printername
+ ".colorspace." + i
+ ".name");
580 gColorspaceArray
[i
] = obj
;
583 dump("colorspace index=" + i
+ ", name='" + obj
.name
+ "'.\n");
588 //---------------------------------------------------
589 function createColorspaceArray()
591 if (isListOfPrinterFeaturesAvailable()) {
592 createColorspaceArrayFromPrinterFeatures();
595 createColorspaceArrayFromDefaults();
599 //---------------------------------------------------
600 function createColorspaceNameList(selectedInx
)
602 var selectElement
= new colorspaceListElement(dialog
.colorspaceList
);
603 selectElement
.clearColorspaceList();
605 selectElement
.appendColorspaceNames(gColorspaceArray
);
607 if (selectedInx
> -1) {
608 selectElement
.colorspaceListElement
.selectedIndex
= selectedInx
;
611 //dialog.colorspaceList = selectElement;
614 //---------------------------------------------------
615 function loadDialog()
617 var print_paper_type
= 0;
618 var print_paper_unit
= 0;
619 var print_paper_width
= 0.0;
620 var print_paper_height
= 0.0;
621 var print_paper_name
= "";
622 var print_plex_name
= "";
623 var print_resolution_name
= "";
624 var print_colorspace
= "";
625 var print_color
= true;
626 var print_downloadfonts
= true;
627 var print_command
= default_command
;
628 var print_jobtitle
= "";
630 gPrefs
= Components
.classes
["@mozilla.org/preferences-service;1"].getService(Components
.interfaces
.nsIPrefBranch
);
632 if (gPrintSettings
) {
633 print_paper_type
= gPrintSettings
.paperSizeType
;
634 print_paper_unit
= gPrintSettings
.paperSizeUnit
;
635 print_paper_width
= gPrintSettings
.paperWidth
;
636 print_paper_height
= gPrintSettings
.paperHeight
;
637 print_paper_name
= gPrintSettings
.paperName
;
638 print_plex_name
= gPrintSettings
.plexName
;
639 print_resolution_name
= gPrintSettings
.resolutionName
;
640 print_colorspace
= gPrintSettings
.colorspace
;
641 print_color
= gPrintSettings
.printInColor
;
642 print_downloadfonts
= gPrintSettings
.downloadFonts
;
643 print_command
= gPrintSettings
.printCommand
;
644 print_jobtitle
= gPrintSettings
.title
;
648 dump("loadDialog******************************\n");
649 dump("paperSizeType "+print_paper_unit
+"\n");
650 dump("paperWidth "+print_paper_width
+"\n");
651 dump("paperHeight "+print_paper_height
+"\n");
652 dump("paperName "+print_paper_name
+"\n");
653 dump("plexName "+print_plex_name
+"\n");
654 dump("resolutionName "+print_resolution_name
+"\n");
655 dump("colorspace "+print_colorspace
+"\n");
656 dump("print_color "+print_color
+"\n");
657 dump("print_downloadfonts "+print_downloadfonts
+"\n");
658 dump("print_command "+print_command
+"\n");
659 dump("print_jobtitle "+print_jobtitle
+"\n");
664 var paperSelectedInx
= 0;
665 for (var i
=0;i
<gPaperArray
.length
;i
++) {
666 if (print_paper_name
== gPaperArray
[i
].name
) {
667 paperSelectedInx
= i
;
673 if (i
== gPaperArray
.length
)
674 dump("loadDialog: No paper found.\n");
676 dump("loadDialog: found paper '"+gPaperArray
[paperSelectedInx
].name
+"'.\n");
679 createPaperSizeList(paperSelectedInx
);
682 var plexSelectedInx
= 0;
683 for (var i
=0;i
<gPlexArray
.length
;i
++) {
684 if (print_plex_name
== gPlexArray
[i
].name
) {
691 if (i
== gPlexArray
.length
)
692 dump("loadDialog: No plex found.\n");
694 dump("loadDialog: found plex '"+gPlexArray
[plexSelectedInx
].name
+"'.\n");
697 createResolutionArray();
698 var resolutionSelectedInx
= 0;
699 for (var i
=0;i
<gResolutionArray
.length
;i
++) {
700 if (print_resolution_name
== gResolutionArray
[i
].name
) {
701 resolutionSelectedInx
= i
;
707 if (i
== gResolutionArray
.length
)
708 dump("loadDialog: No resolution found.\n");
710 dump("loadDialog: found resolution '"+gResolutionArray
[resolutionSelectedInx
].name
+"'.\n");
713 createColorspaceArray();
714 var colorspaceSelectedInx
= 0;
715 for (var i
=0;i
<gColorspaceArray
.length
;i
++) {
716 if (print_colorspace
== gColorspaceArray
[i
].name
) {
717 colorspaceSelectedInx
= i
;
723 if (i
== gColorspaceArray
.length
)
724 dump("loadDialog: No colorspace found.\n");
726 dump("loadDialog: found colorspace '"+gColorspaceArray
[colorspaceSelectedInx
].name
+"'.\n");
729 createPlexNameList(plexSelectedInx
);
730 createResolutionNameList(resolutionSelectedInx
);
731 createColorspaceNameList(colorspaceSelectedInx
);
733 /* Enable/disable and/or hide/unhide widgets based in the information
734 * whether the selected printer and/or print module supports the matching
736 if (isListOfPrinterFeaturesAvailable()) {
738 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".can_change_jobtitle"))
739 dialog
.jobTitleInput
.removeAttribute("disabled");
741 dialog
.jobTitleInput
.setAttribute("disabled","true");
742 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".supports_jobtitle_change"))
743 dialog
.jobTitleGroup
.removeAttribute("hidden");
745 dialog
.jobTitleGroup
.setAttribute("hidden","true");
748 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".can_change_spoolercommand"))
749 dialog
.cmdInput
.removeAttribute("disabled");
751 dialog
.cmdInput
.setAttribute("disabled","true");
752 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".supports_spoolercommand_change"))
753 dialog
.cmdGroup
.removeAttribute("hidden");
755 dialog
.cmdGroup
.setAttribute("hidden","true");
758 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".can_change_paper_size"))
759 dialog
.paperList
.removeAttribute("disabled");
761 dialog
.paperList
.setAttribute("disabled","true");
762 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".supports_paper_size_change"))
763 dialog
.paperGroup
.removeAttribute("hidden");
765 dialog
.paperGroup
.setAttribute("hidden","true");
768 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".can_change_plex"))
769 dialog
.plexList
.removeAttribute("disabled");
771 dialog
.plexList
.setAttribute("disabled","true");
772 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".supports_plex_change"))
773 dialog
.plexGroup
.removeAttribute("hidden");
775 dialog
.plexGroup
.setAttribute("hidden","true");
778 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".can_change_resolution"))
779 dialog
.resolutionList
.removeAttribute("disabled");
781 dialog
.resolutionList
.setAttribute("disabled","true");
782 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".supports_resolution_change"))
783 dialog
.resolutionGroup
.removeAttribute("hidden");
785 dialog
.resolutionGroup
.setAttribute("hidden","true");
787 // color/grayscale radio
788 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".can_change_printincolor"))
789 dialog
.colorRadioGroup
.removeAttribute("disabled");
791 dialog
.colorRadioGroup
.setAttribute("disabled","true");
792 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".supports_printincolor_change"))
793 dialog
.colorGroup
.removeAttribute("hidden");
795 dialog
.colorGroup
.setAttribute("hidden","true");
798 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".can_change_colorspace"))
799 dialog
.colorspaceList
.removeAttribute("disabled");
801 dialog
.colorspaceList
.setAttribute("disabled","true");
802 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".supports_colorspace_change"))
803 dialog
.colorspaceGroup
.removeAttribute("hidden");
805 dialog
.colorspaceGroup
.setAttribute("hidden","true");
808 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".can_change_downloadfonts"))
809 dialog
.downloadFonts
.removeAttribute("disabled");
811 dialog
.downloadFonts
.setAttribute("disabled","true");
812 if (gPrefs
.getBoolPref("print.tmp.printerfeatures." + gPrintSettings
.printerName
+ ".supports_downloadfonts_change"))
813 dialog
.fontsGroup
.removeAttribute("hidden");
815 dialog
.fontsGroup
.setAttribute("hidden","true");
818 if (print_command
== "") {
819 print_command
= default_command
;
823 dialog
.colorRadioGroup
.selectedItem
= dialog
.colorRadio
;
825 dialog
.colorRadioGroup
.selectedItem
= dialog
.grayRadio
;
828 dialog
.downloadFonts
.checked
= print_downloadfonts
;
830 dialog
.cmdInput
.value
= print_command
;
831 dialog
.jobTitleInput
.value
= print_jobtitle
;
833 dialog
.topInput
.value
= gPrintSettings
.edgeTop
.toFixed(2);
834 dialog
.bottomInput
.value
= gPrintSettings
.edgeBottom
.toFixed(2);
835 dialog
.leftInput
.value
= gPrintSettings
.edgeLeft
.toFixed(2);
836 dialog
.rightInput
.value
= gPrintSettings
.edgeRight
.toFixed(2);
839 //---------------------------------------------------
845 gPrintSettings
= window
.arguments
[0].QueryInterface(gPrintSetInterface
);
846 paramBlock
= window
.arguments
[1].QueryInterface(Components
.interfaces
.nsIDialogParamBlock
);
849 if (gPrintSettings
== null) alert("PrintSettings is null!");
850 if (paramBlock
== null) alert("nsIDialogParam is null!");
853 // default return value is "cancel"
854 paramBlock
.SetInt(0, 0);
859 //---------------------------------------------------
862 var print_paper_type
= gPrintSettingsInterface
.kPaperSizeDefined
;
863 var print_paper_unit
= gPrintSettingsInterface
.kPaperSizeInches
;
864 var print_paper_width
= 0.0;
865 var print_paper_height
= 0.0;
866 var print_paper_name
= "";
867 var print_plex_name
= "";
868 var print_resolution_name
= "";
869 var print_colorspace
= "";
871 if (gPrintSettings
!= null) {
872 var paperSelectedInx
= dialog
.paperList
.selectedIndex
;
873 var plexSelectedInx
= dialog
.plexList
.selectedIndex
;
874 var resolutionSelectedInx
= dialog
.resolutionList
.selectedIndex
;
875 var colorspaceSelectedInx
= dialog
.colorspaceList
.selectedIndex
;
876 if (gPaperArray
[paperSelectedInx
].inches
) {
877 print_paper_unit
= gPrintSettingsInterface
.kPaperSizeInches
;
879 print_paper_unit
= gPrintSettingsInterface
.kPaperSizeMillimeters
;
881 print_paper_width
= gPaperArray
[paperSelectedInx
].width
;
882 print_paper_height
= gPaperArray
[paperSelectedInx
].height
;
883 print_paper_name
= gPaperArray
[paperSelectedInx
].name
;
884 print_plex_name
= gPlexArray
[plexSelectedInx
].name
;
885 print_resolution_name
= gResolutionArray
[resolutionSelectedInx
].name
;
886 print_colorspace
= gColorspaceArray
[colorspaceSelectedInx
].name
;
888 gPrintSettings
.paperSizeType
= print_paper_type
;
889 gPrintSettings
.paperSizeUnit
= print_paper_unit
;
890 gPrintSettings
.paperWidth
= print_paper_width
;
891 gPrintSettings
.paperHeight
= print_paper_height
;
892 gPrintSettings
.paperName
= print_paper_name
;
893 gPrintSettings
.plexName
= print_plex_name
;
894 gPrintSettings
.resolutionName
= print_resolution_name
;
895 gPrintSettings
.colorspace
= print_colorspace
;
897 // save these out so they can be picked up by the device spec
898 gPrintSettings
.printInColor
= dialog
.colorRadio
.selected
;
899 gPrintSettings
.downloadFonts
= dialog
.downloadFonts
.checked
;
900 gPrintSettings
.printCommand
= dialog
.cmdInput
.value
;
901 gPrintSettings
.title
= dialog
.jobTitleInput
.value
;
903 gPrintSettings
.edgeTop
= dialog
.topInput
.value
;
904 gPrintSettings
.edgeBottom
= dialog
.bottomInput
.value
;
905 gPrintSettings
.edgeLeft
= dialog
.leftInput
.value
;
906 gPrintSettings
.edgeRight
= dialog
.rightInput
.value
;
909 dump("onAccept******************************\n");
910 dump("paperSizeType "+print_paper_type
+" (should be 1)\n");
911 dump("paperSizeUnit "+print_paper_unit
+"\n");
912 dump("paperWidth "+print_paper_width
+"\n");
913 dump("paperHeight "+print_paper_height
+"\n");
914 dump("paperName '"+print_paper_name
+"'\n");
915 dump("plexName '"+print_plex_name
+"'\n");
916 dump("resolutionName '"+print_resolution_name
+"'\n");
917 dump("colorspace '"+print_colorspace
+"'\n");
919 dump("printInColor "+gPrintSettings
.printInColor
+"\n");
920 dump("downloadFonts "+gPrintSettings
.downloadFonts
+"\n");
921 dump("printCommand '"+gPrintSettings
.printCommand
+"'\n");
924 dump("************ onAccept gPrintSettings: "+gPrintSettings
+"\n");
928 // set return value to "ok"
929 paramBlock
.SetInt(0, 1);
931 dump("*** FATAL ERROR: paramBlock missing\n");