From: Nathan Muggli Date: Fri, 26 May 2023 18:36:45 +0000 (-0600) Subject: Add custom page size values to media-col-database X-Git-Tag: v2.4.3~11^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc062ecbbe0a351d1815ff84c38cbd1c5efdb08d;p=thirdparty%2Fcups.git Add custom page size values to media-col-database 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. --- diff --git a/scheduler/printers.c b/scheduler/printers.c index 436d826317..ea554c0e2b 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -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); + } } /*