xpfe/global/resources/content/printdialog.js,1.1 | . | Disk File |
Skipping to line 23 | . | |
* Asko Tontti <atontti@cc.hut.fi> |
. |
* Asko Tontti <atontti@cc.hut.fi> |
*/ |
. |
*/ |
|
. |
|
var dialog; |
. |
var dialog; |
var printService = null; |
. |
var printService = null; |
  |
. |
var gOriginalNumCopies = 1; |
  |
. |
|
  |
. |
var paramBlock; |
  |
. |
var gPrintSettings = null; |
  |
. |
|
|
. |
|
var default_file = "mozilla.ps"; |
. |
var default_file = "mozilla.ps"; |
var gPrintOptInterface = Components.interfaces.nsIPrintOptions; |
. |
var gPrintSetInterface = Components.interfaces.nsIPrintSettings; |
var doDebug = false; |
. |
var doDebug = true; |
|
. |
|
//--------------------------------------------------- |
. |
//--------------------------------------------------- |
function initDialog() |
. |
function initDialog() |
{ |
. |
{ |
dialog = new Object; |
. |
dialog = new Object; |
Skipping to line 185 | . | |
//--------------------------------------------------- |
. |
//--------------------------------------------------- |
function displayPropertiesDialog( ) |
. |
function displayPropertiesDialog( ) |
{ |
. |
{ |
var displayed = new Object; |
. |
var displayed = new Object; |
displayed.value = false; |
. |
displayed.value = false; |
printService.displayJobProperties(dialog.printerList.value, displayed); |
. |
gPrintSettings.numCopies = dialog.numCopiesInput.value; |
 
|
. |
printService.displayJobProperties(dialog.printerList.value, gPrintSettings,
displayed); |
  |
. |
dialog.numCopiesInput.value = gPrintSettings.numCopies; |
|
. |
|
if (doDebug) { |
. |
if (doDebug) { |
if (displayed) |
. |
if (displayed) |
dump("\nproperties dlg came up. displayed = "+displayed.value+"\n"); |
. |
dump("\nproperties dlg came up. displayed = "+displayed.value+"\n"); |
else |
. |
else |
Skipping to line 228 | . | |
{ |
. |
{ |
var print_tofile = false; |
. |
var print_tofile = false; |
var print_copies = 1; |
. |
var print_copies = 1; |
var print_file = default_file; |
. |
var print_file = default_file; |
var print_selection_radio_enabled = false; |
. |
var print_selection_radio_enabled = false; |
var print_frametype = gPrintOptInterface.kSelectedFrame; |
. |
var print_frametype = gPrintSetInterface.kSelectedFrame; |
var print_howToEnableUI = gPrintOptInterface.kFrameEnableNone; |
. |
var print_howToEnableUI = gPrintSetInterface.kFrameEnableNone; |
|
. |
|
try { |
. |
try { |
printService = Components.classes["@mozilla.org/gfx/printoptions;1"]; |
. |
printService = Components.classes["@mozilla.org/gfx/printoptions;1"]; |
if (printService) { |
. |
if (printService) { |
printService = printService.getService(); |
. |
printService = printService.getService(); |
Skipping to line 241 | . | |
printService = printService.QueryInterface(Components.interfaces.nsIPr
intOptions); |
. |
printService = printService.QueryInterface(Components.interfaces.nsIPr
intOptions); |
} |
. |
} |
} |
. |
} |
} catch(e) {} |
. |
} catch(e) {} |
|
. |
|
if (printService) { |
. |
if (gPrintSettings) { |
print_copies = printService.numCopies; |
. |
gOriginalNumCopies = gPrintSettings.numCopies; |
print_file = printService.toFileName; |
. |
print_copies = gPrintSettings.numCopies; |
print_tofile = printService.printToFile; |
. |
print_file = gPrintSettings.toFileName; |
print_frametype = printService.printFrameType; |
. |
print_tofile = gPrintSettings.printToFile; |
print_howToEnableUI = printService.howToEnableFrameUI; |
. |
print_frametype = gPrintSettings.printFrameType; |
print_selection_radio_enabled = printService.GetPrintOptions(gPrintOptInte
rface.kPrintOptionsEnableSelectionRB); |
. |
print_howToEnableUI = gPrintSettings.howToEnableFrameUI;
|
 
|
. |
print_selection_radio_enabled = gPrintSettings.GetPrintOptions(gPrintSetIn
terface.kEnableSelectionRB); |
} |
. |
} |
|
. |
|
if (doDebug) { |
. |
if (doDebug) { |
  |
. |
dump("loadDialog*********************************************\n"); |
dump("toFileName "+print_file+"\n"); |
. |
dump("toFileName "+print_file+"\n"); |
dump("printToFile "+print_tofile+"\n"); |
. |
dump("printToFile "+print_tofile+"\n"); |
dump("printToFile "+print_tofile+"\n"); |
. |
dump("printToFile "+print_tofile+"\n"); |
dump("print_frame "+print_frametype+"\n"); |
. |
dump("print_frame "+print_frametype+"\n"); |
dump("print_howToEnableUI "+print_howToEnableUI+"\n"); |
. |
dump("print_howToEnableUI "+print_howToEnableUI+"\n"); |
|
. |
  |
dump("selection_radio_enabled "+print_selection_radio_enabled+"\n"); |
. |
dump("selection_radio_enabled "+print_selection_radio_enabled+"\n"); |
} |
. |
} |
|
. |
|
if (print_file == "") { |
. |
if (print_file == "") { |
print_file = default_file; |
. |
print_file = default_file; |
Skipping to line 293 | . | |
if (doDebug) { |
. |
if (doDebug) { |
dump("print_howToEnableUI: "+print_howToEnableUI+"\n"); |
. |
dump("print_howToEnableUI: "+print_howToEnableUI+"\n"); |
} |
. |
} |
|
. |
|
// print frame |
. |
// print frame |
if (print_howToEnableUI == gPrintOptInterface.kFrameEnableAll) { |
. |
if (print_howToEnableUI == gPrintSetInterface.kFrameEnableAll) { |
dialog.aslaidoutRadio.removeAttribute("disabled"); |
. |
dialog.aslaidoutRadio.removeAttribute("disabled"); |
|
. |
|
dialog.selectedframeRadio.removeAttribute("disabled"); |
. |
dialog.selectedframeRadio.removeAttribute("disabled"); |
dialog.eachframesepRadio.removeAttribute("disabled"); |
. |
dialog.eachframesepRadio.removeAttribute("disabled"); |
dialog.printframeGroupLabel.removeAttribute("disabled"); |
. |
dialog.printframeGroupLabel.removeAttribute("disabled"); |
Skipping to line 305 | . | |
// initialize radio group |
. |
// initialize radio group |
dialog.printframeGroup.selectedItem = dialog.selectedframeRadio; |
. |
dialog.printframeGroup.selectedItem = dialog.selectedframeRadio; |
|
. |
|
} else if (print_howToEnableUI == gPrintOptInterface.kFrameEnableAsIsAndEach
) { |
. |
} else if (print_howToEnableUI == gPrintSetInterface.kFrameEnableAsIsAndEach
) { |
dialog.aslaidoutRadio.removeAttribute("disabled"); //enable |
. |
dialog.aslaidoutRadio.removeAttribute("disabled"); //enable |
|
. |
|
dialog.selectedframeRadio.setAttribute("disabled","true" ); // disable |
. |
dialog.selectedframeRadio.setAttribute("disabled","true" ); // disable |
dialog.eachframesepRadio.removeAttribute("disabled"); // enable |
. |
dialog.eachframesepRadio.removeAttribute("disabled"); // enable |
dialog.printframeGroupLabel.removeAttribute("disabled"); // enable |
. |
dialog.printframeGroupLabel.removeAttribute("disabled"); // enable |
Skipping to line 322 | . | |
dialog.printframeGroupLabel.setAttribute("disabled","true" ); |
. |
dialog.printframeGroupLabel.setAttribute("disabled","true" ); |
} |
. |
} |
|
. |
|
dialog.printButton.label = dialog.printName.getAttribute("label"); |
. |
dialog.printButton.label = dialog.printName.getAttribute("label"); |
} |
. |
} |
|
. |
|
var param; |
. |
  |
|
. |
  |
//--------------------------------------------------- |
. |
//--------------------------------------------------- |
function onLoad() |
. |
function onLoad() |
{ |
. |
{ |
// Init dialog. |
. |
// Init dialog. |
initDialog(); |
. |
initDialog(); |
Skipping to line 334 | . | |
param = window.arguments[0].QueryInterface(Components.interfaces.nsIDialogPa
ramBlock); |
. |
var ps = window.arguments[0].QueryInterface(gPrintSetInterface);
|
if( !param ) { |
. |
if (ps != null) { |
return; |
. |
gPrintSettings = ps; |
 
|
. |
paramBlock = window.arguments[1].QueryInterface(Components.interfaces.nsID
ialogParamBlock); |
  |
. |
} else { |
 
|
. |
var suppsArray = window.arguments[0].QueryInterface(Components.interfaces.
nsISupportsArray); |
  |
. |
if (suppsArray) { |
  |
. |
var supps = suppsArray.ElementAt(0); |
  |
. |
gPrintSettings = supps.QueryInterface(gPrintSetInterface); |
  |
. |
if( !gPrintSettings ) { |
  |
. |
return; |
  |
. |
} |
  |
. |
supps = suppsArray.ElementAt(1); |
 
|
. |
paramBlock = supps.QueryInterface(Components.interfaces.nsIDialogParamBl
ock); |
  |
. |
if( !paramBlock ) { |
  |
. |
return; |
  |
. |
} |
  |
. |
} else { |
  |
. |
return; |
  |
. |
} |
} |
. |
} |
|
. |
|
param.SetInt(0, 1 ); |
. |
paramBlock.SetInt(0, 0 ); |
|
. |
|
loadDialog(); |
. |
loadDialog(); |
} |
. |
} |
|
. |
|
//--------------------------------------------------- |
. |
//--------------------------------------------------- |
Skipping to line 363 | . | |
{ |
. |
{ |
|
. |
|
if (printService) { |
. |
if (gPrintSettings != null) { |
var print_howToEnableUI = gPrintOptInterface.kFrameEnableNone; |
. |
var print_howToEnableUI = gPrintSetInterface.kFrameEnableNone; |
|
. |
|
printService.printToFile = dialog.fileRadio.selected; |
. |
gPrintSettings.printToFile = dialog.fileRadio.selected; |
print_howToEnableUI = printService.howToEnableFrameUI; |
. |
print_howToEnableUI = gPrintSettings.howToEnableFrameUI; |
|
. |
|
// save these out so they can be picked up by the device spec |
. |
// save these out so they can be picked up by the device spec |
printService.toFileName = dialog.fileInput.value; |
. |
gPrintSettings.toFileName = dialog.fileInput.value; |
printService.printer = dialog.printerList.value; |
. |
gPrintSettings.printerName = dialog.printerList.value; |
|
. |
|
if (dialog.allpagesRadio.selected) { |
. |
if (dialog.allpagesRadio.selected) { |
printService.printRange = gPrintOptInterface.kRangeAllPages; |
. |
gPrintSettings.printRange = gPrintSetInterface.kRangeAllPages; |
} else if (dialog.rangeRadio.selected) { |
. |
} else if (dialog.rangeRadio.selected) { |
printService.printRange = gPrintOptInterface.kRangeSpecifiedPageRange;
|
. |
gPrintSettings.printRange = gPrintSetInterface.kRangeSpecifiedPageRange; |
} else if (dialog.selectionRadio.selected) { |
. |
} else if (dialog.selectionRadio.selected) { |
printService.printRange = gPrintOptInterface.kRangeSelection; |
. |
gPrintSettings.printRange = gPrintSetInterface.kRangeSelection; |
} |
. |
} |
printService.startPageRange = dialog.frompageInput.value; |
. |
gPrintSettings.startPageRange = dialog.frompageInput.value; |
printService.endPageRange = dialog.topageInput.value; |
. |
gPrintSettings.endPageRange = dialog.topageInput.value; |
printService.numCopies = dialog.numCopiesInput.value; |
. |
gPrintSettings.numCopies = dialog.numCopiesInput.value; |
|
. |
|
var frametype = gPrintOptInterface.kNoFrames; |
. |
var frametype = gPrintSetInterface.kNoFrames; |
if (print_howToEnableUI != gPrintOptInterface.kFrameEnableNone) { |
. |
if (print_howToEnableUI != gPrintSetInterface.kFrameEnableNone) { |
if (dialog.aslaidoutRadio.selected) { |
. |
if (dialog.aslaidoutRadio.selected) { |
frametype = gPrintOptInterface.kFramesAsIs; |
. |
frametype = gPrintSetInterface.kFramesAsIs; |
} else if (dialog.selectedframeRadio.selected) { |
. |
} else if (dialog.selectedframeRadio.selected) { |
frametype = gPrintOptInterface.kSelectedFrame; |
. |
frametype = gPrintSetInterface.kSelectedFrame; |
} else if (dialog.eachframesepRadio.selected) { |
. |
} else if (dialog.eachframesepRadio.selected) { |
frametype = gPrintOptInterface.kEachFrameSep; |
. |
frametype = gPrintSetInterface.kEachFrameSep; |
} else { |
. |
} else { |
frametype = gPrintOptInterface.kSelectedFrame; |
. |
frametype = gPrintSetInterface.kSelectedFrame; |
} |
. |
} |
} |
. |
} |
printService.printFrameType = frametype; |
. |
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"); |
  |
. |
} |
} else { |
. |
} else { |
dump("************ printService: "+printService+"\n"); |
. |
dump("************ gPrintSettings: "+gPrintSettings+"\n"); |
} |
. |
} |
|
. |
|
if (param) { |
. |
if (paramBlock) { |
param.SetInt(0, 0 ); |
. |
paramBlock.SetInt(0, 1 ); |
} |
. |
} |
|
. |
|
return true; |
. |
return true; |
} |
. |
} |
|
. |
|
Skipping to line 421 | . | |
function onCancel() |
. |
function onCancel() |
{ |
. |
{ |
if (param) { |
. |
//gPrintSettings.numCopies = gOriginalNumCopies; |
param.SetInt(0, 1 ); |
. |
|
  |
. |
if (paramBlock) { |
  |
. |
paramBlock.SetInt(0, 0 ); |
} |
. |
} |
return true; |
. |
return true; |
} |
. |
} |
|
. |
|
//--------------------------------------------------- |
. |
//--------------------------------------------------- |