diff options
Diffstat (limited to 'filter/pstops.c')
-rw-r--r-- | filter/pstops.c | 131 |
1 files changed, 37 insertions, 94 deletions
diff --git a/filter/pstops.c b/filter/pstops.c index a7bcc079..c0ed32d7 100644 --- a/filter/pstops.c +++ b/filter/pstops.c @@ -1,9 +1,9 @@ /* - * "$Id: pstops.c 9955 2011-09-02 18:14:34Z mike $" + * "$Id: pstops.c 10431 2012-04-23 19:19:19Z mike $" * * PostScript filter for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1993-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -126,11 +126,9 @@ typedef struct /**** Document information ****/ *ap_media_type, /* AP_FIRSTPAGE_MediaType value */ *ap_page_region, /* AP_FIRSTPAGE_PageRegion value */ *ap_page_size; /* AP_FIRSTPAGE_PageSize value */ - float brightness; /* brightness value */ int collate, /* Collate copies? */ emit_jcl, /* Emit JCL commands? */ - fitplot; /* Fit pages to media */ - float gamma; /* gamma value */ + fit_to_page; /* Fit pages to media */ const char *input_slot, /* InputSlot value */ *manual_feed, /* ManualFeed value */ *media_color, /* MediaColor value */ @@ -200,10 +198,7 @@ static ssize_t copy_trailer(cups_file_t *fp, pstops_doc_t *doc, static void do_prolog(pstops_doc_t *doc, ppd_file_t *ppd); static void do_setup(pstops_doc_t *doc, ppd_file_t *ppd); static void doc_printf(pstops_doc_t *doc, const char *format, ...) -#ifdef __GNUC__ -__attribute__ ((__format__ (__printf__, 2, 3))) -#endif /* __GNUC__ */ -; + __attribute__ ((__format__ (__printf__, 2, 3))); static void doc_puts(pstops_doc_t *doc, const char *s); static void doc_write(pstops_doc_t *doc, const char *s, size_t len); static void end_nup(pstops_doc_t *doc, int number); @@ -266,7 +261,7 @@ main(int argc, /* I - Number of command-line args */ if (argc < 6 || argc > 7) { _cupsLangPrintf(stderr, - _("Usage: %s job-id user title copies options file"), + _("Usage: %s job-id user title copies options [file]"), argv[0]); return (1); } @@ -983,7 +978,7 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */ puts("%%Trailer"); printf("%%%%Pages: %d\n", cupsArrayCount(doc->pages)); - if (doc->number_up > 1 || doc->fitplot) + if (doc->number_up > 1 || doc->fit_to_page) printf("%%%%BoundingBox: %.0f %.0f %.0f %.0f\n", PageLeft, PageBottom, PageRight, PageTop); else @@ -1387,7 +1382,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */ memcpy(bounding_box, doc->bounding_box, sizeof(bounding_box)); } - else if (doc->number_up == 1 && !doc->fitplot && Orientation) + else if (doc->number_up == 1 && !doc->fit_to_page && Orientation) { int temp_bbox[4]; /* Temporary bounding box */ @@ -1485,7 +1480,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */ * %%IncludeFeature: *MainKeyword OptionKeyword */ - if (doc->number_up == 1 &&!doc->fitplot) + if (doc->number_up == 1 &&!doc->fit_to_page) pageinfo->num_options = include_feature(ppd, line, pageinfo->num_options, &(pageinfo->options)); @@ -1562,14 +1557,14 @@ copy_page(cups_file_t *fp, /* I - File to read from */ { feature = 1; - if (doc->number_up > 1 || doc->fitplot) + if (doc->number_up > 1 || doc->fit_to_page) continue; } else if (!strncmp(line, "%%EndFeature", 12)) { feature = 0; - if (doc->number_up > 1 || doc->fitplot) + if (doc->number_up > 1 || doc->fit_to_page) continue; } else if (!strncmp(line, "%%IncludeFeature:", 17)) @@ -1585,7 +1580,7 @@ copy_page(cups_file_t *fp, /* I - File to read from */ if (line[0] != '%' && !feature) break; - if (!feature || (doc->number_up == 1 && !doc->fitplot)) + if (!feature || (doc->number_up == 1 && !doc->fit_to_page)) doc_write(doc, line, linelen); } @@ -1808,7 +1803,7 @@ copy_setup(cups_file_t *fp, /* I - File to read from */ * %%IncludeFeature: *MainKeyword OptionKeyword */ - if (doc->number_up == 1 && !doc->fitplot) + if (doc->number_up == 1 && !doc->fit_to_page) num_options = include_feature(ppd, line, num_options, &options); } else if (strncmp(line, "%%BeginSetup", 12)) @@ -1873,7 +1868,7 @@ copy_trailer(cups_file_t *fp, /* I - File to read from */ fprintf(stderr, "DEBUG: Wrote %d pages...\n", number); printf("%%%%Pages: %d\n", number); - if (doc->number_up > 1 || doc->fitplot) + if (doc->number_up > 1 || doc->fit_to_page) printf("%%%%BoundingBox: %.0f %.0f %.0f %.0f\n", PageLeft, PageBottom, PageRight, PageTop); else @@ -1991,16 +1986,6 @@ do_setup(pstops_doc_t *doc, /* I - Document information */ } /* - * Changes to the transfer function must be made AFTER any - * setpagedevice code... - */ - - if (doc->gamma != 1.0f || doc->brightness != 1.0f) - doc_printf(doc, "{ neg 1 add dup 0 lt { pop 1 } { %.3f exp neg 1 add } " - "ifelse %.3f mul } bind settransfer\n", - doc->gamma, doc->brightness); - - /* * Make sure we have rectclip and rectstroke procedures of some sort... */ @@ -2345,6 +2330,7 @@ set_pstops_options( ppd_option_t *option; /* PPD option */ ppd_choice_t *choice; /* PPD choice */ const char *content_type; /* Original content type */ + int max_copies; /* Maximum number of copies supported */ /* @@ -2402,31 +2388,6 @@ set_pstops_options( doc->page_size = choice->choice; /* - * brightness - */ - - if ((val = cupsGetOption("brightness", num_options, options)) != NULL) - { - /* - * Get brightness value from 10 to 1000. - */ - - intval = atoi(val); - - if (intval < 10 || intval > 1000) - { - _cupsLangPrintFilter(stderr, "ERROR", - _("Unsupported brightness value %s, using " - "brightness=100."), val); - doc->brightness = 1.0f; - } - else - doc->brightness = intval * 0.01f; - } - else - doc->brightness = 1.0f; - - /* * collate, multiple-document-handling */ @@ -2461,7 +2422,7 @@ set_pstops_options( doc->emit_jcl = 1; /* - * fitplot/fit-to-page/ipp-attribute-fidelity + * fit-to-page/ipp-attribute-fidelity * * (Only for original PostScript content) */ @@ -2471,44 +2432,16 @@ set_pstops_options( if (!_cups_strcasecmp(content_type, "application/postscript")) { - if ((val = cupsGetOption("fitplot", num_options, options)) != NULL && + if ((val = cupsGetOption("fit-to-page", num_options, options)) != NULL && !_cups_strcasecmp(val, "true")) - doc->fitplot = 1; - else if ((val = cupsGetOption("fit-to-page", num_options, options)) != NULL && - !_cups_strcasecmp(val, "true")) - doc->fitplot = 1; + doc->fit_to_page = 1; else if ((val = cupsGetOption("ipp-attribute-fidelity", num_options, options)) != NULL && !_cups_strcasecmp(val, "true")) - doc->fitplot = 1; + doc->fit_to_page = 1; } /* - * gamma - */ - - if ((val = cupsGetOption("gamma", num_options, options)) != NULL) - { - /* - * Get gamma value from 1 to 10000... - */ - - intval = atoi(val); - - if (intval < 1 || intval > 10000) - { - _cupsLangPrintFilter(stderr, "ERROR", - _("Unsupported gamma value %s, using gamma=1000."), - val); - doc->gamma = 1.0f; - } - else - doc->gamma = intval * 0.001f; - } - else - doc->gamma = 1.0f; - - /* * mirror/MirrorPrint */ @@ -2657,7 +2590,16 @@ set_pstops_options( * Now figure out if we have to force collated copies, etc. */ - if (ppd && ppd->manual_copies && Duplex && doc->copies > 1) + if ((attr = ppdFindAttr(ppd, "cupsMaxCopies", NULL)) != NULL) + max_copies = atoi(attr->value); + else if (ppd && ppd->manual_copies) + max_copies = 1; + else + max_copies = 9999; + + if (doc->copies > max_copies) + doc->collate = 1; + else if (ppd && ppd->manual_copies && Duplex && doc->copies > 1) { /* * Force collated copies when printing a duplexed document to @@ -2681,7 +2623,8 @@ set_pstops_options( doc->slow_collate = 1; - if ((choice = ppdFindMarkedChoice(ppd, "Collate")) != NULL && + if (doc->copies <= max_copies && + (choice = ppdFindMarkedChoice(ppd, "Collate")) != NULL && !_cups_strcasecmp(choice->choice, "True")) { /* @@ -2838,7 +2781,7 @@ start_nup(pstops_doc_t *doc, /* I - Document information */ pagew = PageRight - PageLeft; pagel = PageTop - PageBottom; - if (doc->fitplot) + if (doc->fit_to_page) { bboxx = bounding_box[0]; bboxy = bounding_box[1]; @@ -2885,18 +2828,18 @@ start_nup(pstops_doc_t *doc, /* I - Document information */ doc_printf(doc, "%.1f 0.0 translate -1 1 scale\n", PageWidth); /* - * Offset and scale as necessary for fitplot/fit-to-page/number-up... + * Offset and scale as necessary for fit_to_page/fit-to-page/number-up... */ if (Duplex && doc->number_up > 1 && ((number / doc->number_up) & 1)) doc_printf(doc, "%.1f %.1f translate\n", PageWidth - PageRight, PageBottom); - else if (doc->number_up > 1 || doc->fitplot) + else if (doc->number_up > 1 || doc->fit_to_page) doc_printf(doc, "%.1f %.1f translate\n", PageLeft, PageBottom); switch (doc->number_up) { default : - if (doc->fitplot) + if (doc->fit_to_page) { w = pagew; l = w * bboxl / bboxw; @@ -3222,7 +3165,7 @@ start_nup(pstops_doc_t *doc, /* I - Document information */ doc_puts(doc, "grestore\n"); } - if (doc->fitplot) + if (doc->fit_to_page) { /* * Offset the page by its bounding box... @@ -3232,7 +3175,7 @@ start_nup(pstops_doc_t *doc, /* I - Document information */ -bounding_box[1]); } - if (doc->fitplot || doc->number_up > 1) + if (doc->fit_to_page || doc->number_up > 1) { /* * Clip the page to the page's bounding box... @@ -3486,5 +3429,5 @@ write_options( /* - * End of "$Id: pstops.c 9955 2011-09-02 18:14:34Z mike $". + * End of "$Id: pstops.c 10431 2012-04-23 19:19:19Z mike $". */ |