From 9222ec3cced71bbef25876324ed207de1645e2e3 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 1 Mar 2007 14:29:47 +0000 Subject: [PATCH] wineps.drv: Many MacOSX generated ppd files don't include a *ColorDevice line. Treat these as if they were colour. --- dlls/wineps.drv/color.c | 4 ++-- dlls/wineps.drv/driver.c | 2 +- dlls/wineps.drv/init.c | 4 ++-- dlls/wineps.drv/ppd.c | 8 ++++++-- dlls/wineps.drv/psdrv.h | 11 ++++++++++- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/dlls/wineps.drv/color.c b/dlls/wineps.drv/color.c index 9a7cdb779a0..3dbbe20febd 100644 --- a/dlls/wineps.drv/color.c +++ b/dlls/wineps.drv/color.c @@ -84,7 +84,7 @@ BOOL PSDRV_CopyColor(PSCOLOR *col1, PSCOLOR *col2) * PSDRV_CreateColor * * Creates a PostScript colour from a COLORREF. - * Result is grey scale if ColorDevice field of ppd is FALSE else an + * Result is grey scale if ColorDevice field of ppd is CD_False else an * rgb colour is produced. */ void PSDRV_CreateColor( PSDRV_PDEVICE *physDev, PSCOLOR *pscolor, @@ -100,7 +100,7 @@ void PSDRV_CreateColor( PSDRV_PDEVICE *physDev, PSCOLOR *pscolor, g = ((wincolor >> 8) & 0xff) / 256.0; b = ((wincolor >> 16) & 0xff) / 256.0; - if(physDev->pi->ppd->ColorDevice) { + if(physDev->pi->ppd->ColorDevice != CD_False) { pscolor->type = PSCOLOR_RGB; pscolor->value.rgb.r = r; pscolor->value.rgb.g = g; diff --git a/dlls/wineps.drv/driver.c b/dlls/wineps.drv/driver.c index fececd73ff3..124070e8dda 100644 --- a/dlls/wineps.drv/driver.c +++ b/dlls/wineps.drv/driver.c @@ -632,7 +632,7 @@ DWORD PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszP /* Printer supports colour printing - 1 if yes, 0 if no (Win2k/XP only) */ case DC_COLORDEVICE: - return pi->ppd->ColorDevice; + return (pi->ppd->ColorDevice != CD_False) ? TRUE : FALSE; /* Identification number of the printer manufacturer for use with ICM (Win9x only) */ case DC_MANUFACTURER: diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 1bd56ca1409..bd9c16c4e18 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -430,7 +430,7 @@ INT PSDRV_GetDeviceCaps( PSDRV_PDEVICE *physDev, INT cap ) case VERTRES: return physDev->vertRes; case BITSPIXEL: - return physDev->pi->ppd->ColorDevice ? 8 : 1; + return (physDev->pi->ppd->ColorDevice != CD_False) ? 8 : 1; case PLANES: return 1; case NUMBRUSHES: @@ -442,7 +442,7 @@ INT PSDRV_GetDeviceCaps( PSDRV_PDEVICE *physDev, INT cap ) case NUMFONTS: return 39; case NUMCOLORS: - return (physDev->pi->ppd->ColorDevice ? 256 : -1); + return (physDev->pi->ppd->ColorDevice != CD_False) ? 256 : -1; case PDEVICESIZE: return sizeof(PSDRV_PDEVICE); case CURVECAPS: diff --git a/dlls/wineps.drv/ppd.c b/dlls/wineps.drv/ppd.c index 9b7169b97d0..a5aea3b962d 100644 --- a/dlls/wineps.drv/ppd.c +++ b/dlls/wineps.drv/ppd.c @@ -572,6 +572,8 @@ PPD *PSDRV_ParsePPD(char *fname) return NULL; } + ppd->ColorDevice = CD_NotSpecified; + /* * The Windows PostScript drivers create the following "virtual bin" for * every PostScript printer @@ -599,8 +601,10 @@ PPD *PSDRV_ParsePPD(char *fname) else if(!strcmp("*ColorDevice", tuple.key)) { if(!strcasecmp(tuple.value, "true")) - ppd->ColorDevice = TRUE; - TRACE("ColorDevice = %d\n", (int)ppd->ColorDevice); + ppd->ColorDevice = CD_True; + else + ppd->ColorDevice = CD_False; + TRACE("ColorDevice = %s\n", ppd->ColorDevice == CD_True ? "True" : "False"); } else if((!strcmp("*DefaultResolution", tuple.key)) || diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 74abe3955fa..7794a890bf7 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -191,10 +191,19 @@ typedef struct _tagDUPLEX { struct _tagDUPLEX *next; } DUPLEX; +/* Many MacOSX based ppd files don't include a *ColorDevice line, so + we use a tristate here rather than a boolean. Code that + cares is expected to treat these as if they were colour. */ +typedef enum { + CD_NotSpecified, + CD_False, + CD_True +} COLORDEVICE; + typedef struct { char *NickName; int LanguageLevel; - BOOL ColorDevice; + COLORDEVICE ColorDevice; int DefaultResolution; signed int LandscapeOrientation; char *JCLBegin;