]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Let PPD generator also parse "media-col-ready" IPP attribute
authorTill Kamppeter <till.kamppeter@gmail.com>
Thu, 12 Jan 2023 02:08:03 +0000 (23:08 -0300)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 12 Jan 2023 02:08:03 +0000 (23:08 -0300)
"media-col-ready" lists the loaded media, in contrary to "media-ready"
as list of complete descriptions of the media ("media-col" data
structure).  This often lists also variants like borderless (it is the
same physical paper).

This can for example make borderless printing work if
"media-col-database" is not available. See

   OpenPrinting/cups-filters#492

Backported from libcupsfilters (2.x), commit 3b9ec4aa55

cupsfilters/ppdgenerator.c

index 77defec08d39754baedcac5a84034a814fa518ab..dad6dbcf8bd7380f0edf95a700049c382e0b89b8 100644 (file)
@@ -1180,11 +1180,21 @@ cups_array_t* generate_sizes(ipp_t *response,
                            *x_dim, *y_dim;       /* Media dimensions */
   ipp_t                    *media_col,           /* Media collection */
                            *media_size;          /* Media size collection */
-  int                      i, count = 0;
+  int                      i, j, count = 0;
   pwg_media_t              *pwg;                 /* PWG media size */
   int                      left_def, right_def, bottom_def, top_def;
   ipp_attribute_t          *margin;  /* media-xxx-margin attribute */
   const char               *psname;
+  // 2 attributes which hold a list of media-col structures. Paesing is the
+  // same for them, so we use the same code. "media-col-database" is parsed
+  // first as it is more complete an accurate, "media-col-ready" is more
+  // a fallback if there is no "media-col-database".
+  const char * const col_attrs[] =
+  {
+    "media-col-database",
+    "media-col-ready",
+  };
+
 
   if ((attr = ippFindAttribute(response, "media-bottom-margin-supported",
                               IPP_TAG_INTEGER)) != NULL) {
@@ -1284,7 +1294,9 @@ cups_array_t* generate_sizes(ipp_t *response,
                        (cups_acopy_func_t)pwg_copy_size,
                        (cups_afree_func_t)free);
 
-  if ((attr = ippFindAttribute(response, "media-col-database",
+  // Go through all attributes which are lists of media-col structures
+  for (j = 0; j < sizeof(col_attrs) / sizeof(col_attrs[0]); j ++)
+  if ((attr = ippFindAttribute(response, col_attrs[j],
                               IPP_TAG_BEGIN_COLLECTION)) != NULL) {
     for (i = 0, count = ippGetCount(attr); i < count; i ++) {
       cups_size_t temp;   /* Current size */