sane.ds: Add partial stub support for ICAP_PIXELTYPE, with tests. Fixes a first crash in Adobe Acrobat scanning support.

This commit is contained in:
Jeremy White 2009-02-09 13:01:27 -06:00 committed by Alexandre Julliard
parent 22bab0aa3d
commit 272c1881dd
3 changed files with 56 additions and 2 deletions

View File

@ -125,7 +125,8 @@ static TW_UINT16 msg_get_enum(pTW_CAPABILITY pCapability, const TW_UINT32 *value
static TW_UINT16 TWAIN_GetSupportedCaps(pTW_CAPABILITY pCapability)
{
TW_ARRAY *a;
static const UINT16 supported_caps[] = { CAP_SUPPORTEDCAPS, CAP_XFERCOUNT, ICAP_XFERMECH };
static const UINT16 supported_caps[] = { CAP_SUPPORTEDCAPS, CAP_XFERCOUNT,
ICAP_XFERMECH, ICAP_PIXELTYPE };
pCapability->hContainer = GlobalAlloc (0, FIELD_OFFSET( TW_ARRAY, ItemList[sizeof(supported_caps)] ));
pCapability->ConType = TWON_ARRAY;
@ -235,6 +236,52 @@ static TW_UINT16 SANE_CAPXferCount (pTW_CAPABILITY pCapability, TW_UINT16 action
return twCC;
}
/* ICAP_PIXELTYPE */
static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 action)
{
static const TW_UINT32 possible_values[] = { TWPT_BW, TWPT_GRAY, TWPT_RGB };
TW_UINT32 val;
TW_UINT16 twCC = TWCC_BADCAP;
TRACE("ICAP_PIXELTYPE\n");
switch (action)
{
case MSG_QUERYSUPPORT:
twCC = set_onevalue(pCapability, TWTY_INT32,
TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET );
break;
case MSG_GET:
twCC = msg_get_enum(pCapability, possible_values, sizeof(possible_values) / sizeof(possible_values[0]),
TWTY_UINT16, activeDS.capXferMech, TWPT_BW);
break;
case MSG_SET:
twCC = msg_set(pCapability, &val);
if (twCC == TWCC_SUCCESS)
{
activeDS.capPixelType = (TW_UINT16) val;
FIXME("Partial Stub: PIXELTYPE set to %d, but ignored\n", val);
}
break;
case MSG_GETDEFAULT:
twCC = set_onevalue(pCapability, TWTY_UINT16, TWPT_BW);
break;
case MSG_RESET:
activeDS.capPixelType = TWPT_BW;
/* .. fall through intentional .. */
case MSG_GETCURRENT:
twCC = set_onevalue(pCapability, TWTY_UINT16, activeDS.capPixelType);
break;
}
return twCC;
}
TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action)
{
TW_UINT16 twCC = TWCC_CAPUNSUPPORTED;
@ -254,6 +301,10 @@ TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action)
twCC = SANE_CAPXferCount (pCapability, action);
break;
case ICAP_PIXELTYPE:
twCC = SANE_ICAPPixelType (pCapability, action);
break;
case ICAP_XFERMECH:
twCC = SANE_ICAPXferMech (pCapability, action);
break;

View File

@ -72,6 +72,7 @@ struct tagActiveDS
#endif
/* Capabilities */
TW_UINT16 capXferMech; /* ICAP_XFERMECH */
TW_UINT16 capPixelType; /* ICAP_PIXELTYPE */
} activeDS;
/* Helper functions */

View File

@ -341,8 +341,10 @@ static void test_single_source(TW_IDENTITY *appid, TW_IDENTITY *source)
ok(capabilities[ICAP_BITDEPTH], "ICAP_BITDEPTH not supported\n");
todo_wine
ok(capabilities[ICAP_BITORDER], "ICAP_BITORDER not supported\n");
todo_wine
ok(capabilities[ICAP_PIXELTYPE], "ICAP_PIXELTYPE not supported\n");
if (capabilities[ICAP_PIXELTYPE])
test_onevalue_cap(appid, source, ICAP_PIXELTYPE, TWTY_UINT16,
TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET);
todo_wine
ok(capabilities[ICAP_UNITS], "ICAP_UNITS not supported\n");
ok(capabilities[ICAP_XFERMECH], "ICAP_XFERMECH not supported\n");