2 * Copyright 2000 Corel Corporation
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(twain);
26 TW_UINT16 TWAIN_SaneCapability (activeDS *pSource, pTW_CAPABILITY pCapability,
29 TW_UINT16 twCC = TWCC_SUCCESS;
31 TRACE("capability=%d action=%d\n", pCapability->Cap, action);
33 switch (pCapability->Cap)
38 case ACAP_AUDIOFILEFORMAT:
40 case ICAP_AUTOMATICBORDERDETECTION:
41 case ICAP_AUTOMATICDESKEW:
42 case ICAP_AUTODISCARDBLANKPAGES:
43 case ICAP_AUTOMATICROTATE:
44 case ICAP_FLIPROTATION:
45 case CAP_AUTOMATICCAPTURE:
46 case CAP_TIMEBEFOREFIRSTCAPTURE:
47 case CAP_TIMEBETWEENCAPTURES:
49 case CAP_CLEARBUFFERS:
50 case CAP_MAXBATCHBUFFERS:
51 case ICAP_BARCODEDETECTIONENABLED:
52 case ICAP_SUPPORTEDBARCODETYPES:
53 case ICAP_BARCODEMAXSEARCHPRIORITIES:
54 case ICAP_BARCODESEARCHPRIORITIES:
55 case ICAP_BARCODESEARCHMODE:
56 case ICAP_BARCODEMAXRETRIES:
57 case ICAP_BARCODETIMEOUT:
58 case CAP_EXTENDEDCAPS:
59 case CAP_SUPPORTEDCAPS:
62 case ICAP_PLANARCHUNKY:
63 case ICAP_BITORDERCODES:
64 case ICAP_CCITTKFACTOR:
65 case ICAP_COMPRESSION:
66 case ICAP_JPEGPIXELTYPE:
67 /*case ICAP_JPEGQUALITY:*/
68 case ICAP_PIXELFLAVORCODES:
70 case CAP_DEVICEONLINE:
71 case CAP_DEVICETIMEDATE:
72 case CAP_SERIALNUMBER:
73 case ICAP_EXPOSURETIME:
75 case ICAP_IMAGEFILTER:
78 case ICAP_NOISEFILTER:
80 case ICAP_PHYSICALHEIGHT:
81 case ICAP_PHYSICALWIDTH:
85 case CAP_PRINTERENABLED:
86 case CAP_PRINTERINDEX:
88 case CAP_PRINTERSTRING:
89 case CAP_PRINTERSUFFIX:
97 case ICAP_ORIENTATION:
103 case ICAP_BITDEPTHREDUCTION:
105 case ICAP_CUSTHALFTONE:
107 case ICAP_PIXELFLAVOR:
113 case ICAP_SUPPORTEDSIZES:
116 case CAP_FEEDERALIGNMENT:
117 case CAP_FEEDERENABLED:
118 case CAP_FEEDERLOADED:
119 case CAP_FEEDERORDER:
121 case CAP_PAPERBINDING:
122 case CAP_PAPERDETECTABLE:
123 case CAP_REACQUIREALLOWED:
125 case ICAP_PATCHCODEDETECTIONENABLED:
126 case ICAP_SUPPORTEDPATCHCODETYPES:
127 case ICAP_PATCHCODEMAXSEARCHPRIORITIES:
128 case ICAP_PATCHCODESEARCHPRIORITIES:
129 case ICAP_PATCHCODESEARCHMODE:
130 case ICAP_PATCHCODEMAXRETRIES:
131 case ICAP_PATCHCODETIMEOUT:
132 case CAP_BATTERYMINUTES:
133 case CAP_BATTERYPERCENTAGE:
134 case CAP_POWERDOWNTIME:
135 case CAP_POWERSUPPLY:
136 case ICAP_XNATIVERESOLUTION:
137 case ICAP_XRESOLUTION:
138 case ICAP_YNATIVERESOLUTION:
139 case ICAP_YRESOLUTION:
140 twCC = TWCC_CAPUNSUPPORTED;
143 /* This is a required capability that every source need to
144 support but we havev't implemented yet. */
147 /*case ICAP_COMPRESSION:*/
148 case ICAP_IMAGEFILEFORMAT:
150 twCC = TWCC_CAPUNSUPPORTED;
153 twCC = TWAIN_ICAPXferMech (pSource, pCapability, action);
155 case ICAP_UNDEFINEDIMAGESIZE:
156 case CAP_CAMERAPREVIEWUI:
157 case CAP_ENABLEDSUIONLY:
159 case CAP_UICONTROLLABLE:
160 twCC = TWCC_CAPUNSUPPORTED;
170 TW_BOOL TWAIN_OneValueSet (pTW_CAPABILITY pCapability, TW_UINT32 value)
172 pCapability->hContainer = (TW_HANDLE)GlobalAlloc (0, sizeof(TW_ONEVALUE));
174 if (pCapability->hContainer)
176 pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
177 pVal->ItemType = TWTY_UINT32;
179 GlobalUnlock ((HGLOBAL) pCapability->hContainer);
186 TW_BOOL TWAIN_OneValueGet (pTW_CAPABILITY pCapability, TW_UINT32 *pValue)
188 pTW_ONEVALUE pVal = GlobalLock ((HGLOBAL) pCapability->hContainer);
192 *pValue = pVal->Item;
193 GlobalUnlock ((HGLOBAL) pCapability->hContainer);
201 TW_UINT16 TWAIN_ICAPXferMech (activeDS *pSource, pTW_CAPABILITY pCapability,
204 TRACE("ICAP_XFERMECH\n");
209 if (pCapability->ConType == TWON_ONEVALUE)
211 if (!TWAIN_OneValueSet (pCapability, pSource->capXferMech))
212 return TWCC_LOWMEMORY;
216 if (pCapability->ConType == TWON_ONEVALUE)
218 TW_UINT32 xfermechtemp;
219 if (!TWAIN_OneValueGet (pCapability, &xfermechtemp))
220 return TWCC_LOWMEMORY;
221 pSource->capXferMech = xfermechtemp;
223 else if (pCapability->ConType == TWON_ENUMERATION)
229 if (!TWAIN_OneValueSet (pCapability, pSource->capXferMech))
230 return TWCC_LOWMEMORY;
233 if (!TWAIN_OneValueSet (pCapability, TWSX_NATIVE))
234 return TWCC_LOWMEMORY;
237 pSource->capXferMech = TWSX_NATIVE;