summaryrefslogtreecommitdiff
path: root/cups
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2019-10-24 15:00:15 -0400
committerMichael R Sweet <michael.r.sweet@gmail.com>2019-10-24 15:00:15 -0400
commit45f72738bbd835dc2028e0d50c335ea27dfdc15c (patch)
treea14fa342a51c80f1f6933e3599cdd497ad9bf875 /cups
parent397eefaa69b7928bb616ecdd6e6d8a4221d2b5f3 (diff)
downloadcups-45f72738bbd835dc2028e0d50c335ea27dfdc15c.tar.gz
Support trim finishing options.
Diffstat (limited to 'cups')
-rw-r--r--cups/ppd-cache.c194
1 files changed, 130 insertions, 64 deletions
diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c
index c414ac8f3..5b7c76e85 100644
--- a/cups/ppd-cache.c
+++ b/cups/ppd-cache.c
@@ -4002,70 +4002,6 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
NULL, /* coat */
NULL /* laminate */
};
- static const char * const staple_keywords[] =
- { /* StapleLocation keywords */
- "SinglePortrait",
- "SingleRevLandscape",
- "SingleLandscape",
- "SingleRevPortrait",
- "EdgeStitchPortrait",
- "EdgeStitchLandscape",
- "EdgeStitchRevPortrait",
- "EdgeStitchRevLandscape",
- "DualPortrait",
- "DualLandscape",
- "DualRevPortrait",
- "DualRevLandscape",
- "TriplePortrait",
- "TripleLandscape",
- "TripleRevPortrait",
- "TripleRevLandscape"
- };
- static const char * const bind_keywords[] =
- { /* StapleLocation binding keywords */
- "BindPortrait",
- "BindLandscape",
- "BindRevPortrait",
- "BindRevLandscape"
- };
- static const char * const punch_keywords[] =
- { /* PunchMedia keywords */
- "SinglePortrait",
- "SingleRevLandscape",
- "SingleLandscape",
- "SingleRevPortrait",
- "DualPortrait",
- "DualLandscape",
- "DualRevPortrait",
- "DualRevLandscape",
- "TriplePortrait",
- "TripleLandscape",
- "TripleRevPortrait",
- "TripleRevLandscape",
- "QuadPortrait",
- "QuadLandscape",
- "QuadRevPortrait",
- "QuadRevLandscape",
- "MultiplePortrait",
- "MultipleLandscape",
- "MultipleRevPortrait",
- "MultipleRevLandscape"
- };
- static const char * const fold_keywords[] =
- { /* FoldType keywords */
- "Accordion",
- "DoubleGate",
- "Gate",
- "Half",
- "HalfZ",
- "LeftGate",
- "Letter",
- "Parallel",
- "XFold",
- "RightGate",
- "ZFold",
- "EngineeringZ"
- };
count = ippGetCount(attr);
names = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
@@ -4086,6 +4022,33 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
if (i < count)
{
+ static const char * const staple_keywords[] =
+ { /* StapleLocation keywords */
+ "SinglePortrait",
+ "SingleRevLandscape",
+ "SingleLandscape",
+ "SingleRevPortrait",
+ "EdgeStitchPortrait",
+ "EdgeStitchLandscape",
+ "EdgeStitchRevPortrait",
+ "EdgeStitchRevLandscape",
+ "DualPortrait",
+ "DualLandscape",
+ "DualRevPortrait",
+ "DualRevLandscape",
+ "TriplePortrait",
+ "TripleLandscape",
+ "TripleRevPortrait",
+ "TripleRevLandscape"
+ };
+ static const char * const bind_keywords[] =
+ { /* StapleLocation binding keywords */
+ "BindPortrait",
+ "BindLandscape",
+ "BindRevPortrait",
+ "BindRevLandscape"
+ };
+
cupsArrayAdd(fin_options, "*StapleLocation");
cupsFilePuts(fp, "*OpenUI *StapleLocation: PickOne\n");
@@ -4148,6 +4111,22 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
if (i < count)
{
+ static const char * const fold_keywords[] =
+ { /* FoldType keywords */
+ "Accordion",
+ "DoubleGate",
+ "Gate",
+ "Half",
+ "HalfZ",
+ "LeftGate",
+ "Letter",
+ "Parallel",
+ "XFold",
+ "RightGate",
+ "ZFold",
+ "EngineeringZ"
+ };
+
cupsArrayAdd(fin_options, "*FoldType");
cupsFilePuts(fp, "*OpenUI *FoldType: PickOne\n");
@@ -4212,6 +4191,30 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
if (i < count)
{
+ static const char * const punch_keywords[] =
+ { /* PunchMedia keywords */
+ "SinglePortrait",
+ "SingleRevLandscape",
+ "SingleLandscape",
+ "SingleRevPortrait",
+ "DualPortrait",
+ "DualLandscape",
+ "DualRevPortrait",
+ "DualRevLandscape",
+ "TriplePortrait",
+ "TripleLandscape",
+ "TripleRevPortrait",
+ "TripleRevLandscape",
+ "QuadPortrait",
+ "QuadLandscape",
+ "QuadRevPortrait",
+ "QuadRevLandscape",
+ "MultiplePortrait",
+ "MultipleLandscape",
+ "MultipleRevPortrait",
+ "MultipleRevLandscape"
+ };
+
cupsArrayAdd(fin_options, "*PunchMedia");
cupsFilePuts(fp, "*OpenUI *PunchMedia: PickOne\n");
@@ -4279,6 +4282,69 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePuts(fp, "*CloseUI: *Booklet\n");
}
+ /*
+ * CutMedia
+ */
+
+ for (i = 0; i < count; i ++)
+ {
+ value = ippGetInteger(attr, i);
+ keyword = ippEnumString("finishings", value);
+
+ if (!strcmp(keyword, "trim") || !strncmp(keyword, "trim-", 5))
+ break;
+ }
+
+ if (i < count)
+ {
+ static const char * const trim_keywords[] =
+ { /* CutMedia keywords */
+ "EndOfPage",
+ "EndOfDoc",
+ "EndOfSet",
+ "EndOfJob"
+ };
+
+ cupsArrayAdd(fin_options, "*CutMedia");
+
+ cupsFilePuts(fp, "*OpenUI *CutMedia: PickOne\n");
+ cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *CutMedia\n");
+ cupsFilePrintf(fp, "*%s.Translation CutMedia/%s: \"\"\n", lang->language, _cupsLangString(lang, _("Cut")));
+ cupsFilePuts(fp, "*DefaultCutMedia: None\n");
+ cupsFilePuts(fp, "*CutMedia None: \"\"\n");
+ cupsFilePrintf(fp, "*%s.CutMedia None/%s: \"\"\n", lang->language, _cupsLangString(lang, _("None")));
+
+ for (i = 0; i < count; i ++)
+ {
+ value = ippGetInteger(attr, i);
+ keyword = ippEnumString("finishings", value);
+
+ if (strcmp(keyword, "trim") && strncmp(keyword, "trim-", 5))
+ continue;
+
+ if (cupsArrayFind(names, (char *)keyword))
+ continue; /* Already did this finishing template */
+
+ cupsArrayAdd(names, (char *)keyword);
+
+ snprintf(msgid, sizeof(msgid), "finishings.%d", value);
+ if ((msgstr = _cupsLangString(lang, msgid)) == msgid || !strcmp(msgid, msgstr))
+ if ((msgstr = _cupsMessageLookup(strings, msgid)) == msgid)
+ msgstr = keyword;
+
+ if (value == IPP_FINISHINGS_TRIM)
+ ppd_keyword = "Auto";
+ else
+ ppd_keyword = trim_keywords[value - IPP_FINISHINGS_TRIM_AFTER_PAGES];
+
+ cupsFilePrintf(fp, "*CutMedia %s: \"\"\n", ppd_keyword);
+ cupsFilePrintf(fp, "*%s.CutMedia %s/%s: \"\"\n", lang->language, ppd_keyword, msgstr);
+ cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*CutMedia %s\"\n", value, keyword, ppd_keyword);
+ }
+
+ cupsFilePuts(fp, "*CloseUI: *CutMedia\n");
+ }
+
cupsArrayDelete(names);
}