sane.ds: Added support for ICAP_UNITS.

This commit is contained in:
Jeremy White 2009-02-25 20:58:34 -06:00 committed by Alexandre Julliard
parent 982482e7e8
commit f75b5ebba6
2 changed files with 54 additions and 2 deletions

View File

@ -154,7 +154,7 @@ static TW_UINT16 TWAIN_GetSupportedCaps(pTW_CAPABILITY pCapability)
{ {
TW_ARRAY *a; TW_ARRAY *a;
static const UINT16 supported_caps[] = { CAP_SUPPORTEDCAPS, CAP_XFERCOUNT, CAP_UICONTROLLABLE, static const UINT16 supported_caps[] = { CAP_SUPPORTEDCAPS, CAP_XFERCOUNT, CAP_UICONTROLLABLE,
ICAP_XFERMECH, ICAP_PIXELTYPE, ICAP_BITDEPTH, ICAP_COMPRESSION, ICAP_PIXELFLAVOR, ICAP_XFERMECH, ICAP_PIXELTYPE, ICAP_UNITS, ICAP_BITDEPTH, ICAP_COMPRESSION, ICAP_PIXELFLAVOR,
ICAP_XRESOLUTION, ICAP_YRESOLUTION }; ICAP_XRESOLUTION, ICAP_YRESOLUTION };
pCapability->hContainer = GlobalAlloc (0, FIELD_OFFSET( TW_ARRAY, ItemList[sizeof(supported_caps)] )); pCapability->hContainer = GlobalAlloc (0, FIELD_OFFSET( TW_ARRAY, ItemList[sizeof(supported_caps)] ));
@ -311,6 +311,49 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio
return twCC; return twCC;
} }
/* ICAP_UNITS */
static TW_UINT16 SANE_ICAPUnits (pTW_CAPABILITY pCapability, TW_UINT16 action)
{
TW_UINT32 val;
TW_UINT16 twCC = TWCC_BADCAP;
TRACE("ICAP_UNITS\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 = set_onevalue(pCapability, TWTY_UINT16, TWUN_INCHES);
break;
case MSG_SET:
twCC = msg_set(pCapability, &val);
if (twCC == TWCC_SUCCESS)
{
if (val != TWUN_INCHES)
{
ERR("Sane supports only SANE_UNIT_DPI\n");
twCC = TWCC_BADVALUE;
}
}
break;
case MSG_GETDEFAULT:
case MSG_RESET:
/* .. fall through intentional .. */
case MSG_GETCURRENT:
twCC = set_onevalue(pCapability, TWTY_UINT16, TWUN_INCHES);
break;
}
return twCC;
}
/* ICAP_BITDEPTH */ /* ICAP_BITDEPTH */
static TW_UINT16 SANE_ICAPBitDepth(pTW_CAPABILITY pCapability, TW_UINT16 action) static TW_UINT16 SANE_ICAPBitDepth(pTW_CAPABILITY pCapability, TW_UINT16 action)
{ {
@ -581,6 +624,10 @@ TW_UINT16 SANE_SaneCapability (pTW_CAPABILITY pCapability, TW_UINT16 action)
twCC = SANE_ICAPPixelType (pCapability, action); twCC = SANE_ICAPPixelType (pCapability, action);
break; break;
case ICAP_UNITS:
twCC = SANE_ICAPUnits (pCapability, action);
break;
case ICAP_BITDEPTH: case ICAP_BITDEPTH:
twCC = SANE_ICAPBitDepth(pCapability, action); twCC = SANE_ICAPBitDepth(pCapability, action);
break; break;

View File

@ -109,6 +109,9 @@ static void check_get(TW_CAPABILITY *pCapability, TW_INT32 actual_support,
TW_ONEVALUE *onev = (TW_ONEVALUE *) p; TW_ONEVALUE *onev = (TW_ONEVALUE *) p;
ok(onev->Item == orig_value || !(actual_support & TWQC_GETCURRENT), "MSG_GET of 0x%x returned 0x%x, expecting 0x%x\n", ok(onev->Item == orig_value || !(actual_support & TWQC_GETCURRENT), "MSG_GET of 0x%x returned 0x%x, expecting 0x%x\n",
pCapability->Cap, onev->Item, orig_value); pCapability->Cap, onev->Item, orig_value);
trace("MSG_GET of 0x%x returned val 0x%x, type %d\n", pCapability->Cap, onev->Item, onev->ItemType);
if (suggested_set_value)
*suggested_set_value = onev->Item;
} }
else if (pCapability->ConType == TWON_ENUMERATION) else if (pCapability->ConType == TWON_ENUMERATION)
{ {
@ -473,8 +476,10 @@ static void test_single_source(TW_IDENTITY *appid, TW_IDENTITY *source)
if (capabilities[ICAP_PIXELTYPE]) if (capabilities[ICAP_PIXELTYPE])
test_onevalue_cap(appid, source, ICAP_PIXELTYPE, TWTY_UINT16, test_onevalue_cap(appid, source, ICAP_PIXELTYPE, TWTY_UINT16,
TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET); TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET);
todo_wine
ok(capabilities[ICAP_UNITS], "ICAP_UNITS not supported\n"); ok(capabilities[ICAP_UNITS], "ICAP_UNITS not supported\n");
if (capabilities[ICAP_UNITS])
test_onevalue_cap(appid, source, ICAP_UNITS, TWTY_UINT16,
TWQC_GET | TWQC_SET | TWQC_GETDEFAULT | TWQC_GETCURRENT | TWQC_RESET);
ok(capabilities[ICAP_XFERMECH], "ICAP_XFERMECH not supported\n"); ok(capabilities[ICAP_XFERMECH], "ICAP_XFERMECH not supported\n");
if (capabilities[ICAP_XFERMECH]) if (capabilities[ICAP_XFERMECH])
test_onevalue_cap(appid, source, ICAP_XFERMECH, TWTY_UINT16, test_onevalue_cap(appid, source, ICAP_XFERMECH, TWTY_UINT16,