Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion cups/ppd-mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ cupsMarkOptions(
* print-color-mode, print-quality, and PageSize...
*/

int media_pagesize = 0, /* Did media= set PageSize? */
Comment thread
nmuggli marked this conversation as resolved.
Outdated
media_source = 0, /* Did media= set InputSlot? */
media_type = 0; /* Did media= set MediaType? */

media = cupsGetOption("media", num_options, options);
page_size = cupsGetOption("PageSize", num_options, options);
output_bin = cupsGetOption("output-bin", num_options, options);
Expand Down Expand Up @@ -128,15 +132,27 @@ cupsMarkOptions(
*/

if (!_cups_strncasecmp(s, "Custom.", 7) && ppdPageSize(ppd, s))
{
ppd_mark_option(ppd, "PageSize", s);
media_pagesize = 1;
}
else if ((ppd_keyword = _ppdCacheGetPageSize(cache, NULL, s, NULL)) != NULL)
{
ppd_mark_option(ppd, "PageSize", ppd_keyword);
media_pagesize = 1;
}

if (cache && cache->source_option && (ppd_keyword = _ppdCacheGetInputSlot(cache, NULL, s)) != NULL)
{
ppd_mark_option(ppd, cache->source_option, ppd_keyword);
media_source = 1;
}

if ((ppd_keyword = _ppdCacheGetMediaType(cache, NULL, s)) != NULL)
{
ppd_mark_option(ppd, "MediaType", ppd_keyword);
media_type = 1;
}
}
}

Expand Down Expand Up @@ -327,7 +343,9 @@ cupsMarkOptions(
}
else if (!_cups_strcasecmp(optptr->name, "mirror"))
ppd_mark_option(ppd, "MirrorPrint", optptr->value);
else if (!media || (_cups_strcasecmp(optptr->name, (cache && cache->source_option) ? cache->source_option : "InputSlot") && _cups_strcasecmp(optptr->name, "MediaType") && _cups_strcasecmp(optptr->name, "PageRegion") && _cups_strcasecmp(optptr->name, "PageSize")))
else if ((!media_pagesize || (_cups_strcasecmp(optptr->name, "PageSize") && _cups_strcasecmp(optptr->name, "PageRegion"))) &&
(!media_source || _cups_strcasecmp(optptr->name, (cache && cache->source_option) ? cache->source_option : "InputSlot")) &&
(!media_type || _cups_strcasecmp(optptr->name, "MediaType")))
ppd_mark_option(ppd, optptr->name, optptr->value);
}

Expand Down
83 changes: 83 additions & 0 deletions cups/testppd.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ main(int argc, /* I - Number of command-line arguments */
maxsize, /* Maximum size */
*size; /* Current size */
ppd_attr_t *attr; /* Current attribute */
ppd_choice_t *choice; /* Current choice */
_ppd_cache_t *pc; /* PPD cache */


Expand Down Expand Up @@ -630,6 +631,88 @@ main(int argc, /* I - Number of command-line arguments */
else
puts("PASS");

ppdMarkDefaults(ppd);
fputs("cupsMarkOptions(media=A4, InputSlot=Envelope): ", stdout);
num_options = cupsAddOption("media", "A4", 0, &options);
num_options = cupsAddOption("InputSlot", "Envelope", num_options, &options);
cupsMarkOptions(ppd, num_options, options);
cupsFreeOptions(num_options, options);

choice = ppdFindMarkedChoice(ppd, "InputSlot");
if (!choice || strcmp(choice->choice, "Envelope"))
{
printf("FAIL (%s)\n", choice ? choice->choice : "unknown");
status ++;
}
else
puts("PASS");

ppdMarkDefaults(ppd);
fputs("cupsMarkOptions(media=envelope, InputSlot=Tray): ", stdout);
num_options = cupsAddOption("media", "envelope", 0, &options);
num_options = cupsAddOption("InputSlot", "Tray", num_options, &options);
cupsMarkOptions(ppd, num_options, options);
cupsFreeOptions(num_options, options);

choice = ppdFindMarkedChoice(ppd, "InputSlot");
if (!choice || strcmp(choice->choice, "Envelope"))
{
printf("FAIL (%s)\n", choice ? choice->choice : "unknown");
status ++;
}
else
puts("PASS");

ppdMarkDefaults(ppd);
fputs("cupsMarkOptions(media=A4, PageSize=Letter): ", stdout);
num_options = cupsAddOption("media", "A4", 0, &options);
num_options = cupsAddOption("PageSize", "Letter", num_options, &options);
cupsMarkOptions(ppd, num_options, options);
cupsFreeOptions(num_options, options);

size = ppdPageSize(ppd, NULL);
if (!size || strcmp(size->name, "A4"))
{
printf("FAIL (%s)\n", size ? size->name : "unknown");
status ++;
}
else
puts("PASS");

ppdMarkDefaults(ppd);
fputs("cupsMarkOptions(media=A4, PageSize=bogus): ", stdout);
num_options = cupsAddOption("media", "A4", 0, &options);
num_options = cupsAddOption("PageSize", "bogus", num_options, &options);
cupsMarkOptions(ppd, num_options, options);
cupsFreeOptions(num_options, options);

size = ppdPageSize(ppd, NULL);
if (!size || strcmp(size->name, "A4"))
{
printf("FAIL (%s)\n", size ? size->name : "unknown");
status ++;
}
else
puts("PASS");

ppdMarkDefaults(ppd);
fputs("cupsMarkOptions(media=A4,envelope, PageSize=Letter, InputSlot=Tray): ", stdout);
num_options = cupsAddOption("media", "A4,envelope", 0, &options);
num_options = cupsAddOption("PageSize", "Letter", num_options, &options);
num_options = cupsAddOption("InputSlot", "Tray", num_options, &options);
cupsMarkOptions(ppd, num_options, options);
cupsFreeOptions(num_options, options);

size = ppdPageSize(ppd, NULL);
choice = ppdFindMarkedChoice(ppd, "InputSlot");
if (!size || strcmp(size->name, "A4") || !choice || strcmp(choice->choice, "Envelope"))
{
printf("FAIL (%s / %s)\n", size ? size->name : "unknown", choice ? choice->choice : "unknown");
status ++;
}
else
puts("PASS");

/*
* Custom sizes...
*/
Expand Down
Loading