]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add custom page size values to media-col-database 709/head
authorNathan Muggli <nmuggli@google.com>
Fri, 26 May 2023 18:36:45 +0000 (12:36 -0600)
committerNathan Muggli <nmuggli@google.com>
Fri, 26 May 2023 21:17:06 +0000 (15:17 -0600)
When creating the IPP attrs based on the PPD file, if the PPD file
supports custom page sizes update our media-col-database to contain a
media-size attr with the min/max range.

scheduler/printers.c

index 436d826317f2d994b3dfbbd9344da39d2625dee5..ea554c0e2bfd7c6275876176b26484d8de67fe3f 100644 (file)
@@ -4444,7 +4444,11 @@ load_ppd(cupsd_printer_t *p)             /* I - Printer */
       * media-col-database
       */
 
-      if ((attr = ippAddCollections(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-database", p->pc->num_sizes, NULL)) != NULL)
+      num_media = p->pc->num_sizes;
+      if (p->pc->custom_min_keyword)
+       num_media ++;
+
+      if ((attr = ippAddCollections(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-database", num_media, NULL)) != NULL)
       {
        /*
        * Add each page size without source or type...
@@ -4457,6 +4461,28 @@ load_ppd(cupsd_printer_t *p)             /* I - Printer */
          ippSetCollection(p->ppd_attrs, &attr, i, col);
          ippDelete(col);
        }
+
+       /*
+       * Add a range if the printer supports custom sizes.
+       */
+
+        if (p->pc->custom_min_keyword)
+       {
+         ipp_t *media_col = ippNew();
+         ipp_t *media_size = ippNew();
+         ippAddRange(media_size, IPP_TAG_PRINTER, "x-dimension", p->pc->custom_min_width, p->pc->custom_max_width);
+         ippAddRange(media_size, IPP_TAG_PRINTER, "y-dimension", p->pc->custom_min_length, p->pc->custom_max_length);
+         ippAddCollection(media_col, IPP_TAG_PRINTER, "media-size", media_size);
+
+         ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin", p->pc->custom_size.bottom);
+         ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-left-margin", p->pc->custom_size.left);
+         ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-right-margin", p->pc->custom_size.right);
+         ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-top-margin", p->pc->custom_size.top);
+
+         ippSetCollection(p->ppd_attrs, &attr, i, media_col);
+         ippDelete(media_size);
+         ippDelete(media_col);
+       }
       }
 
      /*