summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sweet <michael.r.sweet@gmail.com>2016-12-14 09:39:28 -0500
committerMichael Sweet <michael.r.sweet@gmail.com>2016-12-14 09:39:28 -0500
commit7fad1ee92c65ee6f617249bd8e54c1688f8f0349 (patch)
treef2e5ba347f926b3213fcb7c77395b135562dfb04
parent073e58a9fb9a1b6a76961413d01f03407f37c4a6 (diff)
Suppress duplicate media sizes (Issue #4933)
-rw-r--r--CHANGES.txt4
-rw-r--r--cups/ppd-cache.c30
-rw-r--r--cups/pwg-media.c6
3 files changed, 35 insertions, 5 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 00dd75252..21ce4f98d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,11 +1,11 @@
-CHANGES.txt - 2.2.2 - 2016-11-18
+CHANGES.txt - 2.2.2 - 2016-12-14
--------------------------------
CHANGES IN CUPS V2.2.2
- Fixed some issues with the Zebra ZPL printer driver (Issue #4898)
- Fixed some issues with IPP Everywhere printer support (Issue #4893,
- Issue #4909, Issue #4916, Issue #4921)
+ Issue #4909, Issue #4916, Issue #4921, Issue #4933)
- The cups-lpd program did not catch all legacy usage of ISO-8859-1
(Issue #4899)
- Fixed builds on systems without a working poll() implementation
diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c
index cec060654..c035fbecb 100644
--- a/cups/ppd-cache.c
+++ b/cups/ppd-cache.c
@@ -2931,6 +2931,7 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
ipp_t *response) /* I - Get-Printer-Attributes response */
{
cups_file_t *fp; /* PPD file */
+ cups_array_t *sizes; /* Media sizes we've added */
ipp_attribute_t *attr, /* xxx-supported */
*defattr, /* xxx-default */
*x_dim, *y_dim; /* Media dimensions */
@@ -3185,6 +3186,9 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePrintf(fp, "*OpenUI *PageSize: PickOne\n"
"*OrderDependency: 10 AnySetup *PageSize\n"
"*DefaultPageSize: %s\n", ppdname);
+
+ sizes = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+
for (i = 0, count = ippGetCount(attr); i < count; i ++)
{
if (ippGetValueTag(attr) == IPP_TAG_BEGIN_COLLECTION)
@@ -3203,6 +3207,14 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
char twidth[256], /* Width string */
tlength[256]; /* Length string */
+ if (cupsArrayFind(sizes, (void *)pwg->ppd))
+ {
+ cupsFilePrintf(fp, "*%% warning: Duplicate size '%s' reported by printer.\n", pwg->ppd);
+ continue;
+ }
+
+ cupsArrayAdd(sizes, (void *)pwg->ppd);
+
_cupsStrFormatd(twidth, twidth + sizeof(twidth), pwg->width * 72.0 / 2540.0, loc);
_cupsStrFormatd(tlength, tlength + sizeof(tlength), pwg->length * 72.0 / 2540.0, loc);
@@ -3211,6 +3223,9 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
}
cupsFilePuts(fp, "*CloseUI: *PageSize\n");
+ cupsArrayDelete(sizes);
+ sizes = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+
cupsFilePrintf(fp, "*OpenUI *PageRegion: PickOne\n"
"*OrderDependency: 10 AnySetup *PageRegion\n"
"*DefaultPageRegion: %s\n", ppdname);
@@ -3232,6 +3247,11 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
char twidth[256], /* Width string */
tlength[256]; /* Length string */
+ if (cupsArrayFind(sizes, (void *)pwg->ppd))
+ continue;
+
+ cupsArrayAdd(sizes, (void *)pwg->ppd);
+
_cupsStrFormatd(twidth, twidth + sizeof(twidth), pwg->width * 72.0 / 2540.0, loc);
_cupsStrFormatd(tlength, tlength + sizeof(tlength), pwg->length * 72.0 / 2540.0, loc);
@@ -3240,6 +3260,9 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
}
cupsFilePuts(fp, "*CloseUI: *PageRegion\n");
+ cupsArrayDelete(sizes);
+ sizes = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+
cupsFilePrintf(fp, "*DefaultImageableArea: %s\n"
"*DefaultPaperDimension: %s\n", ppdname, ppdname);
for (i = 0, count = ippGetCount(attr); i < count; i ++)
@@ -3264,6 +3287,11 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
twidth[256], /* Width string */
tlength[256]; /* Length string */
+ if (cupsArrayFind(sizes, (void *)pwg->ppd))
+ continue;
+
+ cupsArrayAdd(sizes, (void *)pwg->ppd);
+
_cupsStrFormatd(tleft, tleft + sizeof(tleft), left * 72.0 / 2540.0, loc);
_cupsStrFormatd(tbottom, tbottom + sizeof(tbottom), bottom * 72.0 / 2540.0, loc);
_cupsStrFormatd(tright, tright + sizeof(tright), (pwg->width - right) * 72.0 / 2540.0, loc);
@@ -3275,6 +3303,8 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePrintf(fp, "*PaperDimension %s: \"%s %s\"\n", pwg->ppd, twidth, tlength);
}
}
+
+ cupsArrayDelete(sizes);
}
else
goto bad_ppd;
diff --git a/cups/pwg-media.c b/cups/pwg-media.c
index a064d2f97..1bdf68e9e 100644
--- a/cups/pwg-media.c
+++ b/cups/pwg-media.c
@@ -226,13 +226,13 @@ static pwg_media_t const cups_pwg_media[] =
_PWG_MEDIA_IN("oe_photo-l_3.5x5in", NULL, "3.5x5", 3.5, 5),
/* Other Metric Standard Sheet Media Sizes */
- _PWG_MEDIA_MM("om_small-photo_100x150mm", NULL, "om_small-photo", 100, 150),
+ _PWG_MEDIA_MM("om_small-photo_100x150mm", NULL, "100x150mm", 100, 150),
_PWG_MEDIA_MM("om_italian_110x230mm", NULL, "EnvItalian", 110, 230),
- _PWG_MEDIA_MM("om_large-photo_200x300", NULL, "om_large-photo", 200, 300),
+ _PWG_MEDIA_MM("om_large-photo_200x300", NULL, "200x300mm", 200, 300),
_PWG_MEDIA_MM("om_folio_210x330mm", "folio", "Folio", 210, 330),
_PWG_MEDIA_MM("om_folio-sp_215x315mm", NULL, "FolioSP", 215, 315),
_PWG_MEDIA_MM("om_invite_220x220mm", NULL, "EnvInvite", 220, 220),
- _PWG_MEDIA_MM("om_small-photo_100x200mm", NULL, "om_wide-photo", 100, 200),
+ _PWG_MEDIA_MM("om_small-photo_100x200mm", NULL, "100x200mm", 100, 200),
/* Disc Sizes */
_PWG_MEDIA_MM("disc_standard_40x118mm", NULL, "Disc", 118, 118)