2021-07-11 15:18:50 +03:00
|
|
|
.pragma library
|
|
|
|
.import seaprint.mimer 1.0 as Mimer
|
|
|
|
.import seaprint.convertchecker 1.0 as ConvertChecker
|
2022-04-25 14:49:26 +03:00
|
|
|
.import "strings.js" as Strings
|
2021-03-06 17:43:01 +03:00
|
|
|
|
2021-07-11 15:18:50 +03:00
|
|
|
// TODO move to IppPrinter?
|
|
|
|
function supported_formats(printer, considerAdditionalFormats)
|
2019-12-01 22:27:00 +03:00
|
|
|
{
|
2020-06-07 15:54:15 +03:00
|
|
|
var formats = printer.attrs["document-format-supported"].value;
|
|
|
|
if(considerAdditionalFormats)
|
|
|
|
{
|
|
|
|
formats=formats+printer.additionalDocumentFormats;
|
|
|
|
}
|
|
|
|
|
2021-07-11 15:18:50 +03:00
|
|
|
var raster = (has(formats, Mimer.Mimer.PWG) || has(formats, Mimer.Mimer.URF));
|
2020-08-02 12:35:18 +03:00
|
|
|
|
2020-02-16 16:01:19 +03:00
|
|
|
var mimetypes = [];
|
2021-03-06 17:43:01 +03:00
|
|
|
var pdf = false;
|
|
|
|
var postscript = false;
|
|
|
|
var office = false;
|
|
|
|
var images = false;
|
2021-06-12 13:45:58 +03:00
|
|
|
var plaintext = false;
|
2021-03-06 17:43:01 +03:00
|
|
|
|
2021-07-11 15:18:50 +03:00
|
|
|
if(has(formats, Mimer.Mimer.PDF) ||
|
2021-11-20 19:31:03 +03:00
|
|
|
(has(formats, Mimer.Mimer.Postscript) || raster ))
|
2021-03-06 17:43:01 +03:00
|
|
|
{
|
|
|
|
pdf = true;
|
2021-07-11 15:18:50 +03:00
|
|
|
mimetypes.push(Mimer.Mimer.PDF);
|
2021-03-06 17:43:01 +03:00
|
|
|
}
|
2022-05-02 22:10:03 +03:00
|
|
|
|
2021-07-11 15:18:50 +03:00
|
|
|
if(has(formats, Mimer.Mimer.Postscript))
|
2021-03-06 17:43:01 +03:00
|
|
|
{
|
|
|
|
postscript = true;
|
2021-07-11 15:18:50 +03:00
|
|
|
mimetypes.push(Mimer.Mimer.Postscript);
|
2021-03-06 17:43:01 +03:00
|
|
|
}
|
2021-03-06 14:59:47 +03:00
|
|
|
|
2022-05-02 22:10:03 +03:00
|
|
|
if(pdf || has(formats, Mimer.Mimer.Plaintext))
|
|
|
|
{
|
|
|
|
plaintext = true;
|
|
|
|
mimetypes.push(Mimer.Mimer.Plaintext);
|
|
|
|
}
|
|
|
|
|
|
|
|
if((ConvertChecker.ConvertChecker.calligra) && pdf)
|
2021-03-06 17:43:01 +03:00
|
|
|
{
|
|
|
|
office = true;
|
2021-07-11 15:18:50 +03:00
|
|
|
mimetypes = mimetypes.concat(Mimer.Mimer.OfficeFormats);
|
2021-03-06 17:43:01 +03:00
|
|
|
}
|
2020-09-10 21:01:21 +03:00
|
|
|
|
2021-07-11 15:18:50 +03:00
|
|
|
if (raster || has(formats, Mimer.Mimer.JPEG) || has(formats, Mimer.Mimer.PNG) ||
|
2021-11-20 19:31:03 +03:00
|
|
|
has(formats, Mimer.Mimer.PDF) || has(formats, Mimer.Mimer.Postscript))
|
2021-03-06 17:43:01 +03:00
|
|
|
{
|
|
|
|
images = true;
|
2021-07-11 15:18:50 +03:00
|
|
|
mimetypes.push(Mimer.Mimer.JPEG);
|
|
|
|
mimetypes.push(Mimer.Mimer.PNG);
|
|
|
|
mimetypes.push(Mimer.Mimer.TIFF);
|
|
|
|
mimetypes.push(Mimer.Mimer.GIF);
|
2021-03-06 17:43:01 +03:00
|
|
|
}
|
2020-02-16 16:15:48 +03:00
|
|
|
|
2021-06-12 13:45:58 +03:00
|
|
|
return {pdf: pdf, postscript: postscript, plaintext: plaintext, office: office, images: images, mimetypes: mimetypes};
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function has(arrayish, what)
|
|
|
|
{
|
2020-05-09 15:24:51 +03:00
|
|
|
return arrayish.indexOf(what) != -1;
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
2020-01-03 15:37:51 +03:00
|
|
|
|
2022-04-25 14:49:26 +03:00
|
|
|
function ippName(name, value, printerStrings)
|
2020-01-03 15:37:51 +03:00
|
|
|
{
|
2021-03-21 00:45:58 +03:00
|
|
|
if(value==undefined)
|
|
|
|
{
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2020-01-03 15:37:51 +03:00
|
|
|
switch(name) {
|
|
|
|
case "job-state":
|
|
|
|
switch(value) {
|
|
|
|
case 3:
|
|
|
|
return qsTr("pending");
|
|
|
|
case 4:
|
|
|
|
return qsTr("pending-held");
|
|
|
|
case 5:
|
|
|
|
return qsTr("processing");
|
|
|
|
case 6:
|
|
|
|
return qsTr("processing-stopped");
|
|
|
|
case 7:
|
|
|
|
return qsTr("canceled");
|
|
|
|
case 8:
|
|
|
|
return qsTr("aborted");
|
|
|
|
case 9:
|
|
|
|
return qsTr("completed");
|
|
|
|
default:
|
|
|
|
return qsTr("unknown state ")+value
|
|
|
|
}
|
2020-09-29 22:47:37 +03:00
|
|
|
case "printer-state":
|
|
|
|
switch(value) {
|
|
|
|
case 3:
|
|
|
|
return qsTr("Idle");
|
|
|
|
case 4:
|
|
|
|
return qsTr("Processing");
|
|
|
|
case 5:
|
|
|
|
return qsTr("Stopped");
|
|
|
|
default:
|
|
|
|
return qsTr("Unknown State ")+value
|
|
|
|
}
|
2020-01-03 15:37:51 +03:00
|
|
|
case "print-quality":
|
|
|
|
switch(value) {
|
|
|
|
case 3:
|
|
|
|
return qsTr("draft");
|
|
|
|
case 4:
|
|
|
|
return qsTr("normal");
|
|
|
|
case 5:
|
|
|
|
return qsTr("high");
|
|
|
|
default:
|
|
|
|
return qsTr("unknown quality ")+value
|
|
|
|
}
|
|
|
|
case "orientation-requested":
|
|
|
|
switch(value) {
|
|
|
|
case 3:
|
|
|
|
return qsTr("portrait");
|
|
|
|
case 4:
|
|
|
|
return qsTr("landscape");
|
|
|
|
case 5:
|
|
|
|
return qsTr("reverse landscape");
|
|
|
|
case 6:
|
|
|
|
return qsTr("reverse portrait");
|
|
|
|
default:
|
|
|
|
return qsTr("unknown orientation ")+value
|
|
|
|
}
|
|
|
|
case "printer-resolution":
|
|
|
|
var units = "";
|
|
|
|
if(value.units==3) {
|
|
|
|
units=qsTr("dpi");
|
|
|
|
} else if (units==4){
|
|
|
|
units=qsTr("dots/cm")
|
|
|
|
}
|
|
|
|
return ""+value.x+"x"+value.y+units;
|
2020-04-30 23:20:31 +03:00
|
|
|
case "media":
|
2022-04-25 14:49:26 +03:00
|
|
|
if(Strings.media.hasOwnProperty(value))
|
2020-04-30 23:20:31 +03:00
|
|
|
{
|
2022-04-25 14:49:26 +03:00
|
|
|
return Strings.media[value];
|
2020-04-30 23:20:31 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
2021-07-09 18:44:16 +03:00
|
|
|
case "media-type":
|
2022-04-25 14:49:26 +03:00
|
|
|
if(Strings.mediaType.hasOwnProperty(value))
|
2021-07-09 18:44:16 +03:00
|
|
|
{
|
2022-04-25 14:49:26 +03:00
|
|
|
return Strings.mediaType[value];
|
2021-07-09 18:44:16 +03:00
|
|
|
}
|
2022-04-25 14:49:26 +03:00
|
|
|
else if(printerStrings != undefined && printerStrings.hasOwnProperty("media-type."+value))
|
2022-01-15 00:14:06 +03:00
|
|
|
{
|
2022-04-25 14:49:26 +03:00
|
|
|
return printerStrings["media-type."+value];
|
2022-01-15 00:14:06 +03:00
|
|
|
}
|
2021-07-09 18:44:16 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
2020-09-29 22:47:37 +03:00
|
|
|
case "printer-state-reasons":
|
2022-04-25 14:49:26 +03:00
|
|
|
if(Strings.printerStateReasons.hasOwnProperty(value))
|
2020-09-29 22:47:37 +03:00
|
|
|
{
|
2022-04-25 14:49:26 +03:00
|
|
|
return Strings.printerStateReasons[value];
|
2020-09-29 22:47:37 +03:00
|
|
|
}
|
2020-10-04 15:36:01 +03:00
|
|
|
else if (endsWith("-report", value))
|
|
|
|
{
|
2022-04-25 14:49:26 +03:00
|
|
|
return ippName(name, value.substr(0, value.length-"-report".length))+" (" + qsTr("Report") + ")"
|
2020-10-04 15:36:01 +03:00
|
|
|
}
|
|
|
|
else if (endsWith("-warning", value))
|
|
|
|
{
|
2022-04-25 14:49:26 +03:00
|
|
|
return ippName(name, value.substr(0, value.length-"-warning".length))+" (" + qsTr("Warning") + ")"
|
2020-10-04 15:36:01 +03:00
|
|
|
}
|
|
|
|
else if (endsWith("-error", value))
|
|
|
|
{
|
2022-04-25 14:49:26 +03:00
|
|
|
return ippName(name, value.substr(0, value.length-"-error".length))+" (" + qsTr("Error") + ")"
|
2020-10-04 15:36:01 +03:00
|
|
|
}
|
2020-09-29 22:47:37 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
2020-06-07 18:58:47 +03:00
|
|
|
case "sides":
|
|
|
|
switch(value) {
|
|
|
|
case "one-sided":
|
|
|
|
return qsTr("one-sided");
|
|
|
|
case "two-sided-long-edge":
|
|
|
|
return qsTr("two-sided");
|
|
|
|
case "two-sided-short-edge":
|
|
|
|
return qsTr("two-sided flipped");
|
|
|
|
default:
|
|
|
|
return value
|
|
|
|
}
|
2020-10-04 19:16:21 +03:00
|
|
|
case "multiple-document-handling":
|
|
|
|
switch(value) {
|
|
|
|
case "single-document":
|
|
|
|
return qsTr("single document");
|
|
|
|
case "separate-documents-uncollated-copies":
|
|
|
|
return qsTr("uncollated");
|
|
|
|
case "separate-documents-collated-copies":
|
|
|
|
return qsTr("collated");
|
|
|
|
case "single-document-new-sheet":
|
|
|
|
return qsTr("single document (new sheet)");
|
|
|
|
default:
|
|
|
|
return value
|
|
|
|
}
|
|
|
|
|
2020-06-07 18:58:47 +03:00
|
|
|
case "print-color-mode":
|
|
|
|
switch(value) {
|
|
|
|
case "auto":
|
|
|
|
return qsTr("automatic");
|
|
|
|
case "auto-monochrome":
|
|
|
|
return qsTr("auto monochrome");
|
|
|
|
case "bi-level":
|
|
|
|
return qsTr("bi-level");
|
|
|
|
case "color":
|
|
|
|
return qsTr("color");
|
|
|
|
case "highlight":
|
|
|
|
return qsTr("highlight");
|
|
|
|
case "monochrome":
|
|
|
|
return qsTr("monochrome");
|
|
|
|
case "process-bi-level":
|
|
|
|
return qsTr("process bi-level");
|
|
|
|
case "process-monochrome":
|
|
|
|
return qsTr("process monochrome");
|
|
|
|
default:
|
|
|
|
return value
|
|
|
|
}
|
2021-07-09 23:13:49 +03:00
|
|
|
case "print-scaling":
|
|
|
|
switch(value) {
|
|
|
|
case "auto":
|
|
|
|
return qsTr("auto");
|
|
|
|
case "auto-fit":
|
|
|
|
return qsTr("auto (fit)");
|
|
|
|
case "fill":
|
|
|
|
return qsTr("fill");
|
|
|
|
case "fit":
|
|
|
|
return qsTr("fit");
|
|
|
|
case "none":
|
|
|
|
return qsTr("none");
|
|
|
|
default:
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2020-06-04 22:31:46 +03:00
|
|
|
case "document-format":
|
|
|
|
switch(value) {
|
2021-07-11 15:18:50 +03:00
|
|
|
case Mimer.Mimer.OctetStream:
|
2020-06-06 17:12:42 +03:00
|
|
|
return qsTr("auto-sense");
|
2021-07-11 15:18:50 +03:00
|
|
|
case Mimer.Mimer.PDF:
|
2020-06-04 22:31:46 +03:00
|
|
|
return qsTr("PDF");
|
2021-07-11 15:18:50 +03:00
|
|
|
case Mimer.Mimer.Postscript:
|
2020-06-04 22:31:46 +03:00
|
|
|
return qsTr("Postscript");
|
2022-05-02 22:10:03 +03:00
|
|
|
case Mimer.Mimer.Plaintext:
|
|
|
|
return qsTr("Plaintext");
|
2021-07-11 15:18:50 +03:00
|
|
|
case Mimer.Mimer.PWG:
|
2020-06-04 22:31:46 +03:00
|
|
|
return qsTr("PWG-raster");
|
2021-07-11 15:18:50 +03:00
|
|
|
case Mimer.Mimer.URF:
|
2020-06-04 22:31:46 +03:00
|
|
|
return qsTr("URF-raster");
|
2021-07-11 15:18:50 +03:00
|
|
|
case Mimer.Mimer.PNG:
|
2020-06-04 22:31:46 +03:00
|
|
|
return qsTr("PNG");
|
2021-07-11 15:18:50 +03:00
|
|
|
case Mimer.Mimer.JPEG:
|
2020-06-04 22:31:46 +03:00
|
|
|
return qsTr("JPEG");
|
2021-07-11 15:18:50 +03:00
|
|
|
case Mimer.Mimer.GIF:
|
2020-06-04 22:31:46 +03:00
|
|
|
return qsTr("GIF");
|
|
|
|
default:
|
|
|
|
return value;
|
|
|
|
}
|
2021-07-11 13:46:27 +03:00
|
|
|
case "media-top-margin":
|
|
|
|
case "media-bottom-margin":
|
|
|
|
case "media-left-margin":
|
|
|
|
case "media-right-margin":
|
|
|
|
return ""+(value/100)+"mm"
|
2020-06-06 17:12:42 +03:00
|
|
|
case "media-source":
|
|
|
|
if(value.indexOf("tray-")==0)
|
|
|
|
{
|
|
|
|
return qsTr("tray")+" "+value.split("-")[1];
|
|
|
|
}
|
2021-07-09 18:19:32 +03:00
|
|
|
else if(value.indexOf("roll-")==0)
|
|
|
|
{
|
|
|
|
return qsTr("roll")+" "+value.split("-")[1];
|
|
|
|
}
|
2020-06-07 18:58:47 +03:00
|
|
|
else
|
2020-06-06 17:12:42 +03:00
|
|
|
{
|
2020-06-07 18:58:47 +03:00
|
|
|
switch(value) {
|
2021-07-09 18:19:32 +03:00
|
|
|
case "alternate":
|
|
|
|
return qsTr("alternate");
|
|
|
|
case "alternate-roll":
|
|
|
|
return qsTr("alternate-roll");
|
2020-06-07 18:58:47 +03:00
|
|
|
case "auto":
|
|
|
|
return qsTr("automatic");
|
|
|
|
case "bottom":
|
|
|
|
return qsTr("bottom");
|
2021-07-09 18:19:32 +03:00
|
|
|
case "by-pass-tray":
|
|
|
|
return qsTr("by-pass tray");
|
2020-06-07 18:58:47 +03:00
|
|
|
case "center":
|
|
|
|
return qsTr("center");
|
2021-07-09 18:19:32 +03:00
|
|
|
case "disc":
|
|
|
|
return qsTr("disc");
|
|
|
|
case "envelope":
|
|
|
|
return qsTr("envelope");
|
|
|
|
case "hagaki":
|
|
|
|
return qsTr("hagaki");
|
|
|
|
case "large-capacity":
|
|
|
|
return qsTr("large capacity");
|
|
|
|
case "left":
|
|
|
|
return qsTr("left");
|
2020-06-07 18:58:47 +03:00
|
|
|
case "main":
|
|
|
|
return qsTr("main");
|
2021-07-09 18:19:32 +03:00
|
|
|
case "main-roll":
|
|
|
|
return qsTr("main roll");
|
2020-06-07 18:58:47 +03:00
|
|
|
case "manual":
|
|
|
|
return qsTr("manual");
|
|
|
|
case "middle":
|
|
|
|
return qsTr("middle");
|
|
|
|
case "photo":
|
|
|
|
return qsTr("photo");
|
|
|
|
case "rear":
|
|
|
|
return qsTr("rear");
|
|
|
|
case "right":
|
|
|
|
return qsTr("right");
|
|
|
|
case "side":
|
|
|
|
return qsTr("side");
|
|
|
|
case "top":
|
|
|
|
return qsTr("top");
|
|
|
|
default:
|
|
|
|
return value;
|
|
|
|
}
|
2020-06-06 17:12:42 +03:00
|
|
|
}
|
2021-07-09 18:19:32 +03:00
|
|
|
case "output-bin":
|
|
|
|
if(value.indexOf("tray-")==0)
|
|
|
|
{
|
|
|
|
return qsTr("tray")+" "+value.split("-")[1];
|
|
|
|
}
|
|
|
|
else if(value.indexOf("stacker-")==0)
|
|
|
|
{
|
|
|
|
return qsTr("stacker")+" "+value.split("-")[1];
|
|
|
|
}
|
|
|
|
else if(value.indexOf("mailbox-")==0)
|
|
|
|
{
|
|
|
|
return qsTr("mailbox")+" "+value.split("-")[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch(value) {
|
|
|
|
case "auto":
|
|
|
|
return qsTr("automatic");
|
|
|
|
case "top":
|
|
|
|
return qsTr("top");
|
|
|
|
case "middle":
|
|
|
|
return qsTr("middle");
|
|
|
|
case "bottom":
|
|
|
|
return qsTr("bottom");
|
|
|
|
case "side":
|
|
|
|
return qsTr("side");
|
|
|
|
case "left":
|
|
|
|
return qsTr("left");
|
|
|
|
case "right":
|
|
|
|
return qsTr("right");
|
|
|
|
case "center":
|
|
|
|
return qsTr("center");
|
|
|
|
case "rear":
|
|
|
|
return qsTr("rear");
|
|
|
|
case "face-up":
|
|
|
|
return qsTr("face-up");
|
|
|
|
case "face-down":
|
|
|
|
return qsTr("face-down");
|
|
|
|
case "large-capacity":
|
|
|
|
return qsTr("large capacity");
|
|
|
|
case "my-mailbox":
|
|
|
|
return qsTr("my mailbox");
|
|
|
|
default:
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
2020-01-03 15:37:51 +03:00
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
2020-01-05 15:24:25 +03:00
|
|
|
|
|
|
|
function endsWith(ending, string)
|
|
|
|
{
|
|
|
|
return string.lastIndexOf(ending) == (string.length - ending.length);
|
|
|
|
}
|
2020-04-30 23:20:31 +03:00
|
|
|
|
2022-05-02 22:10:03 +03:00
|
|
|
var pdfTargets = [Mimer.Mimer.OctetStream, Mimer.Mimer.PDF, Mimer.Mimer.Postscript, Mimer.Mimer.PWG, Mimer.Mimer.URF];
|
|
|
|
|
|
|
|
|
2020-06-04 22:31:46 +03:00
|
|
|
function canConvertPdfTo(type)
|
|
|
|
{
|
2022-05-02 22:10:03 +03:00
|
|
|
return has(pdfTargets, type)
|
2020-06-04 22:31:46 +03:00
|
|
|
}
|
|
|
|
|
2021-02-13 23:59:46 +03:00
|
|
|
function canTransferPostscriptAs(type)
|
|
|
|
{
|
2021-07-11 15:18:50 +03:00
|
|
|
var targets = [Mimer.Mimer.OctetStream, Mimer.Mimer.Postscript];
|
2021-02-13 23:59:46 +03:00
|
|
|
return has(targets, type)
|
|
|
|
}
|
|
|
|
|
2022-05-02 22:10:03 +03:00
|
|
|
function canConvertPlaintextTo(type)
|
2021-03-06 14:59:47 +03:00
|
|
|
{
|
2022-05-02 22:10:03 +03:00
|
|
|
var targets = pdfTargets;
|
|
|
|
targets.push(Mimer.Mimer.Plaintext);
|
2021-03-06 14:59:47 +03:00
|
|
|
return has(targets, type)
|
|
|
|
}
|
|
|
|
|
2022-05-02 22:10:03 +03:00
|
|
|
|
|
|
|
function canConvertOfficeDocumentTo(type)
|
|
|
|
{
|
|
|
|
return has(pdfTargets, type)
|
|
|
|
}
|
|
|
|
|
2020-06-04 22:31:46 +03:00
|
|
|
function canConvertImageTo(type)
|
|
|
|
{
|
2021-07-11 15:18:50 +03:00
|
|
|
var targets = [Mimer.Mimer.OctetStream, Mimer.Mimer.JPEG, Mimer.Mimer.PNG, Mimer.Mimer.PWG, Mimer.Mimer.URF, Mimer.Mimer.PDF, Mimer.Mimer.Postscript];
|
2020-06-04 22:31:46 +03:00
|
|
|
return has(targets, type)
|
|
|
|
}
|
|
|
|
|
2020-06-05 20:05:11 +03:00
|
|
|
function unitsIsDpi(resolution)
|
|
|
|
{
|
|
|
|
return resolution.units == 3;
|
|
|
|
}
|
|
|
|
|
2021-12-03 21:33:28 +03:00
|
|
|
function knownPaperSize(mediaName)
|
2021-12-02 22:00:43 +03:00
|
|
|
{
|
2022-04-25 14:49:26 +03:00
|
|
|
return Strings.media.hasOwnProperty(mediaName);
|
2021-12-02 22:00:43 +03:00
|
|
|
}
|
|
|
|
|
2020-06-05 20:05:11 +03:00
|
|
|
|
2021-07-31 13:18:41 +03:00
|
|
|
function fixupChoices(name, choices, mimeType)
|
2020-06-04 22:31:46 +03:00
|
|
|
{
|
|
|
|
switch(name) {
|
|
|
|
case "document-format":
|
2021-07-11 15:18:50 +03:00
|
|
|
if(mimeType == Mimer.Mimer.PDF)
|
2020-06-04 22:31:46 +03:00
|
|
|
{
|
2021-11-20 19:31:03 +03:00
|
|
|
return choices.filter(canConvertPdfTo)
|
2020-06-04 22:31:46 +03:00
|
|
|
}
|
2021-07-11 15:18:50 +03:00
|
|
|
else if(mimeType == Mimer.Mimer.Plaintext)
|
2021-06-12 13:45:58 +03:00
|
|
|
{
|
2022-05-02 22:10:03 +03:00
|
|
|
return choices.filter(canConvertPlaintextTo)
|
2021-06-12 13:45:58 +03:00
|
|
|
}
|
2021-07-11 15:18:50 +03:00
|
|
|
else if(mimeType == Mimer.Mimer.Postscript)
|
2021-02-13 23:59:46 +03:00
|
|
|
{
|
|
|
|
return choices.filter(canTransferPostscriptAs)
|
|
|
|
}
|
2021-07-11 15:18:50 +03:00
|
|
|
else if(Mimer.Mimer.isOffice(mimeType))
|
2021-03-06 14:59:47 +03:00
|
|
|
{
|
|
|
|
return choices.filter(canConvertOfficeDocumentTo)
|
|
|
|
}
|
2021-07-11 15:18:50 +03:00
|
|
|
else if(Mimer.Mimer.isImage(mimeType))
|
2020-06-04 22:31:46 +03:00
|
|
|
{
|
|
|
|
return choices.filter(canConvertImageTo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-11 15:18:50 +03:00
|
|
|
return [Mimer.Mimer.OctetStream];
|
2020-06-04 22:31:46 +03:00
|
|
|
}
|
2020-06-05 20:05:11 +03:00
|
|
|
case "printer-resolution":
|
|
|
|
return choices.filter(unitsIsDpi);
|
2020-10-04 19:16:21 +03:00
|
|
|
case "multiple-document-handling" :
|
|
|
|
// Only collation settings valid, multiple documents not used
|
|
|
|
return choices.filter(function(elem) {return elem.indexOf("collated") != -1});
|
2021-07-19 17:14:33 +03:00
|
|
|
case "number-up":
|
|
|
|
if(choices.constructor.name === "Object")
|
|
|
|
{
|
|
|
|
var choice_array = [];
|
|
|
|
for(var i=choices.low; i <= choices.high; i++)
|
|
|
|
{
|
|
|
|
choice_array.push(i);
|
|
|
|
}
|
|
|
|
return choice_array;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return choices;
|
|
|
|
}
|
2021-12-02 22:00:43 +03:00
|
|
|
case "media":
|
2021-12-03 21:33:28 +03:00
|
|
|
return choices.filter(knownPaperSize);
|
2020-06-04 22:31:46 +03:00
|
|
|
default:
|
|
|
|
return choices;
|
|
|
|
}
|
|
|
|
}
|
2020-04-30 23:20:31 +03:00
|
|
|
|
2020-10-10 18:32:44 +03:00
|
|
|
function isWaringState(printer)
|
|
|
|
{
|
|
|
|
if(printer.attrs["printer-state"].value > 4)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-11 17:13:14 +03:00
|
|
|
|
2021-05-25 20:56:38 +03:00
|
|
|
if(printer.attrs.hasOwnProperty("printer-state-reasons"))
|
2020-10-10 18:32:44 +03:00
|
|
|
{
|
2021-05-25 20:56:38 +03:00
|
|
|
for(var i in printer.attrs["printer-state-reasons"].value)
|
2020-10-11 17:13:14 +03:00
|
|
|
{
|
2021-05-25 20:56:38 +03:00
|
|
|
var value = printer.attrs["printer-state-reasons"].value[i];
|
|
|
|
if(value != "none" && !(endsWith("-report", value)))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-11 17:13:14 +03:00
|
|
|
}
|
2020-10-10 18:32:44 +03:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-02-13 19:30:19 +03:00
|
|
|
function unknownForEmptyString(s)
|
|
|
|
{
|
|
|
|
if(s === "")
|
|
|
|
{
|
|
|
|
return qsTr("Unknown");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-21 21:20:09 +03:00
|
|
|
function existsAndNotEmpty(attrName, printer)
|
|
|
|
{
|
|
|
|
if(printer.attrs.hasOwnProperty(attrName))
|
|
|
|
{
|
|
|
|
return printer.attrs[attrName].value != ""
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 18:25:08 +03:00
|
|
|
function basename(filewithpath)
|
|
|
|
{
|
|
|
|
return filewithpath.substring(filewithpath.lastIndexOf("/")+1);
|
|
|
|
}
|