]>
Commit | Line | Data |
---|---|---|
ba7599c9 AM |
1 | Author: till.kamppeter@gmail.com |
2 | ||
3 | --- a/scheduler/ipp.c | |
4 | +++ b/scheduler/ipp.c | |
5 | @@ -9639,6 +9639,11 @@ | |
6 | ipp_attribute_t *attr, /* Current attribute */ | |
7 | *attr2, /* Job attribute */ | |
8 | *prev2; /* Previous job attribute */ | |
9 | + int foundfirstpage; /* Did we find the first page already | |
10 | + in the PostScript input? */ | |
11 | + int num_copies; /* Number of copies according to | |
12 | + PostScript command in input file */ | |
13 | + char *s, *t, buffer[10]; | |
14 | ||
15 | ||
16 | /* | |
17 | @@ -9700,6 +9705,85 @@ | |
18 | } | |
19 | ||
20 | /* | |
21 | + * Read option settings embedded in the file... | |
22 | + */ | |
23 | + | |
24 | + foundfirstpage = 0; | |
25 | + | |
26 | + while (cupsFileGets(fp, line, sizeof(line))) | |
27 | + { | |
28 | + /* | |
29 | + * Stop at the second page, we read also the settings of the first PageSetup | |
30 | + * to work around a bug in OpenOffice.org. This app puts options intended | |
31 | + * for the whole document into the page setup of the first page | |
32 | + */ | |
33 | + | |
34 | + if (!strncmp(line, "%%Page:", 7)) | |
35 | + { | |
36 | + if (foundfirstpage == 1) | |
37 | + break; | |
38 | + foundfirstpage = 1; | |
39 | + } | |
40 | + | |
41 | + /* | |
42 | + * Add the embedded option settings to the option array... | |
43 | + */ | |
44 | + | |
45 | + s = NULL; | |
46 | + if (!strncmp(line, "%%BeginFeature:", 15)) | |
47 | + s = line + 15; | |
48 | + else if (!strncmp(line, "%%IncludeFeature:", 17)) | |
49 | + s = line + 17; | |
50 | + else if (!strncmp(line, "%%BeginNonPPDFeature:", 21)) | |
51 | + s = line + 21; | |
52 | + | |
53 | + if (s && (t = strstr(s, "NumCopies")) != NULL) | |
54 | + { | |
55 | + t += 9; | |
56 | + while ((*t == ' ') || (*t == '\t')) t++; | |
57 | + if (sscanf(t, "%9d", &num_copies) == 1) | |
58 | + { | |
59 | + sprintf(buffer, "%d", num_copies); | |
60 | + num_options = cupsAddOption("copies", buffer, num_options, &options); | |
61 | + } | |
62 | + } | |
63 | + else if (s) | |
64 | + { | |
65 | + while ((*s == ' ') || (*s == '\t')) s++; | |
66 | + if (*s == '*') s++; | |
67 | + t = s; | |
68 | + while (*t && (*t != ' ') && (*t != '\t')) t++; | |
69 | + if ((*t == ' ') || (*t == '\t')) *t = '='; | |
70 | + num_options = cupsParseOptions(s, num_options, &options); | |
71 | + } | |
72 | + | |
73 | + /* | |
74 | + * Read out "/#copies XXX def" and "/NumCopies XXX def" expressions from | |
75 | + * PostScript input. Some apps insert these expressions to set the | |
76 | + * number of copies. | |
77 | + */ | |
78 | + | |
79 | + s = NULL; | |
80 | + if ((s = strstr(line, "/#copies")) != NULL) | |
81 | + s += 8; | |
82 | + else if ((s = strstr(line, "/NumCopies")) != NULL) | |
83 | + s += 10; | |
84 | + if (s) | |
85 | + { | |
86 | + while ((*s == ' ') || (*s == '\t')) s++; | |
87 | + if (sscanf(s, "%9d %as ", &num_copies, &t) == 2) | |
88 | + { | |
89 | + if (!strncmp(t, "def", 3)) | |
90 | + { | |
91 | + sprintf(buffer, "%d", num_copies); | |
92 | + num_options = cupsAddOption("copies", buffer, num_options, &options); | |
93 | + } | |
94 | + free(t); | |
95 | + } | |
96 | + } | |
97 | + } | |
98 | + | |
99 | + /* | |
100 | * Done with the file; see if we have any options... | |
101 | */ | |
102 |