Skip to content

Commit 3df0023

Browse files
committed
Add custom default size to media-supported, media-size-supported, and media-col-database as well (Issue #1388)
1 parent 1165523 commit 3df0023

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

scheduler/printers.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3783,8 +3783,9 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
37833783
margins[16]; /* media-*-margin-supported values */
37843784
const char *filter, /* Current filter */
37853785
*mandatory; /* Current mandatory attribute */
3786-
ipp_attribute_t *media_col_ready, /* media-col-ready attribute */
3787-
*media_ready; /* media-ready attribute */
3786+
ipp_attribute_t *media_col_ready = NULL,
3787+
/* media-col-ready attribute */
3788+
*media_ready = NULL; /* media-ready attribute */
37883789
int num_urf; /* Number of urf-supported values */
37893790
const char *urf[16], /* urf-supported values */
37903791
*urf_prefix; /* Prefix string for value */
@@ -4360,6 +4361,8 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
43604361
num_media = p->pc->num_sizes;
43614362
if (p->pc->custom_min_keyword)
43624363
num_media += 2;
4364+
if (defsize && !strncmp(defsize->map.pwg, "custom_", 7))
4365+
num_media ++;
43634366

43644367
if ((attr = ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
43654368
"media-supported", num_media, NULL,
@@ -4372,6 +4375,13 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
43724375
i --, pwgsize ++, val ++)
43734376
val->string.text = _cupsStrAlloc(pwgsize->map.pwg);
43744377

4378+
if (defsize && !strncmp(defsize->map.pwg, "custom_", 7))
4379+
{
4380+
// Include default custom size in media-supported...
4381+
val->string.text = _cupsStrAlloc(defsize->map.pwg);
4382+
val ++;
4383+
}
4384+
43754385
if (p->pc->custom_min_keyword)
43764386
{
43774387
val->string.text = _cupsStrAlloc(p->pc->custom_min_keyword);
@@ -4387,6 +4397,8 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
43874397
num_media = p->pc->num_sizes;
43884398
if (p->pc->custom_min_keyword)
43894399
num_media ++;
4400+
if (defsize && !strncmp(defsize->map.pwg, "custom_", 7))
4401+
num_media ++;
43904402

43914403
if ((attr = ippAddCollections(p->ppd_attrs, IPP_TAG_PRINTER,
43924404
"media-size-supported", num_media,
@@ -4405,6 +4417,15 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
44054417
"y-dimension", pwgsize->length);
44064418
}
44074419

4420+
if (defsize && !strncmp(defsize->map.pwg, "custom_", 7))
4421+
{
4422+
// Include default custom size in media-size-supported...
4423+
val->collection = ippNew();
4424+
ippAddInteger(val->collection, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "x-dimension", defsize->width);
4425+
ippAddInteger(val->collection, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "y-dimension", defsize->length);
4426+
val ++;
4427+
}
4428+
44084429
if (p->pc->custom_min_keyword)
44094430
{
44104431
val->collection = ippNew();
@@ -4546,6 +4567,8 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
45464567
num_media = p->pc->num_sizes;
45474568
if (p->pc->custom_min_keyword)
45484569
num_media ++;
4570+
if (defsize && !strncmp(defsize->map.pwg, "custom_", 7))
4571+
num_media ++;
45494572

45504573
if ((attr = ippAddCollections(p->ppd_attrs, IPP_TAG_PRINTER, "media-col-database", num_media, NULL)) != NULL)
45514574
{
@@ -4561,6 +4584,16 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
45614584
ippDelete(col);
45624585
}
45634586

4587+
if (defsize && !strncmp(defsize->map.pwg, "custom_", 7))
4588+
{
4589+
// Include default custom size in media-col-database...
4590+
ipp_t *col = new_media_col(defsize);
4591+
4592+
ippSetCollection(p->ppd_attrs, &attr, i, col);
4593+
ippDelete(col);
4594+
i ++;
4595+
}
4596+
45644597
/*
45654598
* Add a range if the printer supports custom sizes.
45664599
*/
@@ -4623,7 +4656,7 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
46234656
}
46244657
}
46254658

4626-
if (defsize)
4659+
if (defsize && cupsArrayGetCount(ReadyPaperSizes) > 0)
46274660
{
46284661
// Add default size to media[-col]-ready as needed...
46294662
ipp_t *col = new_media_col(defsize);

0 commit comments

Comments
 (0)