]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Support trim finishing options.
authorMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 24 Oct 2019 19:00:15 +0000 (15:00 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 24 Oct 2019 19:00:15 +0000 (15:00 -0400)
cups/ppd-cache.c

index c414ac8f3e44cc7f7725b20ac0743fd973238a93..5b7c76e850d871a39aeb9c16d48a958ca647d0a9 100644 (file)
@@ -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);
   }