Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

318 lines
11 KiB

  1. // devprop.cpp : Implementation of CDeviceProperty
  2. #include "pch.h"
  3. #include "wiafb.h"
  4. #include "devprop.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CDeviceProperty
  7. STDMETHODIMP CDeviceProperty::SetCurrentValue(LONG lValueID, VARIANT Value)
  8. {
  9. switch(lValueID){
  10. case XRESOLUTION_ID:
  11. m_pScannerSettings->CurrentXResolution = Value.lVal;
  12. break;
  13. case YRESOLUTION_ID:
  14. m_pScannerSettings->CurrentYResolution = Value.lVal;
  15. break;
  16. case XPOS_ID:
  17. m_pScannerSettings->CurrentXPos = Value.lVal;
  18. break;
  19. case YPOS_ID:
  20. m_pScannerSettings->CurrentYPos = Value.lVal;
  21. break;
  22. case XEXT_ID:
  23. m_pScannerSettings->CurrentXExtent = Value.lVal;
  24. break;
  25. case YEXT_ID:
  26. m_pScannerSettings->CurrentYExtent = Value.lVal;
  27. break;
  28. case BRIGHTNESS_ID:
  29. m_pScannerSettings->CurrentBrightness = Value.lVal;
  30. break;
  31. case CONTRAST_ID:
  32. m_pScannerSettings->CurrentContrast = Value.lVal;
  33. break;
  34. case DATA_TYPE_ID:
  35. m_pScannerSettings->CurrentDataType = (LONG)Value.iVal;
  36. break;
  37. case BIT_DEPTH_ID:
  38. m_pScannerSettings->CurrentBitDepth = (LONG)Value.iVal;
  39. break;
  40. case NEGATIVE_ID:
  41. m_pScannerSettings->bNegative = (BOOL)Value.boolVal;
  42. break;
  43. case PIXEL_PACKING_ID:
  44. m_pScannerSettings->RawPixelPackingOrder = (LONG)Value.iVal;
  45. break;
  46. case PIXEL_FORMAT_ID:
  47. m_pScannerSettings->RawPixelFormat = (LONG)Value.iVal;
  48. break;
  49. case DATA_ALIGN_ID:
  50. m_pScannerSettings->RawDataAlignment = (LONG)Value.iVal;
  51. break;
  52. case BED_WIDTH_ID:
  53. m_pScannerSettings->BedWidth = Value.lVal;
  54. break;
  55. case BED_HEIGHT_ID:
  56. m_pScannerSettings->BedHeight = Value.lVal;
  57. break;
  58. case XOPTICAL_ID:
  59. m_pScannerSettings->XOpticalResolution = Value.lVal;
  60. break;
  61. case YOPTICAL_ID:
  62. m_pScannerSettings->YOpticalResolution = Value.lVal;
  63. break;
  64. case ADF_ID:
  65. m_pScannerSettings->ADFSupport = Value.lVal;
  66. break;
  67. case TPA_ID:
  68. m_pScannerSettings->TPASupport = Value.lVal;
  69. break;
  70. case ADF_WIDTH_ID:
  71. m_pScannerSettings->FeederWidth = Value.lVal;
  72. break;
  73. case ADF_HEIGHT_ID:
  74. m_pScannerSettings->FeederHeight = Value.lVal;
  75. break;
  76. case ADF_VJUSTIFY_ID:
  77. m_pScannerSettings->VFeederJustification = Value.lVal;
  78. break;
  79. case ADF_HJUSTIFY_ID:
  80. m_pScannerSettings->HFeederJustification = Value.lVal;
  81. break;
  82. case ADF_MAX_PAGES_ID:
  83. m_pScannerSettings->MaxADFPageCapacity = Value.lVal;
  84. break;
  85. case FIRMWARE_VER_ID:
  86. //lstrcpy(m_pScannerSettings->FirmwareVersion,Value.cVal);
  87. break;
  88. default:
  89. return E_FAIL;
  90. }
  91. return S_OK;
  92. }
  93. STDMETHODIMP CDeviceProperty::GetCurrentValue(LONG lValueID, VARIANT *pvValue)
  94. {
  95. // default to LONG type
  96. pvValue->vt = VT_I4;
  97. switch(lValueID){
  98. case XRESOLUTION_ID:
  99. pvValue->lVal = m_pScannerSettings->CurrentXResolution;
  100. break;
  101. case YRESOLUTION_ID:
  102. pvValue->lVal = m_pScannerSettings->CurrentYResolution;
  103. break;
  104. case XPOS_ID:
  105. pvValue->lVal = m_pScannerSettings->CurrentXPos;
  106. break;
  107. case YPOS_ID:
  108. pvValue->lVal = m_pScannerSettings->CurrentYPos;
  109. break;
  110. case XEXT_ID:
  111. pvValue->lVal = m_pScannerSettings->CurrentXExtent;
  112. break;
  113. case YEXT_ID:
  114. pvValue->lVal = m_pScannerSettings->CurrentYExtent;
  115. break;
  116. case BRIGHTNESS_ID:
  117. pvValue->lVal = m_pScannerSettings->CurrentBrightness;
  118. break;
  119. case CONTRAST_ID:
  120. pvValue->lVal = m_pScannerSettings->CurrentContrast;
  121. break;
  122. case DATA_TYPE_ID:
  123. pvValue->vt = VT_I2;
  124. pvValue->iVal = (INT)m_pScannerSettings->CurrentDataType;
  125. break;
  126. case BIT_DEPTH_ID:
  127. pvValue->vt = VT_I2;
  128. pvValue->iVal = (INT)m_pScannerSettings->CurrentBitDepth;
  129. break;
  130. case NEGATIVE_ID:
  131. pvValue->lVal = (LONG)m_pScannerSettings->bNegative;
  132. break;
  133. case PIXEL_PACKING_ID:
  134. pvValue->lVal = m_pScannerSettings->RawPixelPackingOrder;
  135. break;
  136. case PIXEL_FORMAT_ID:
  137. pvValue->lVal = m_pScannerSettings->RawPixelFormat;
  138. break;
  139. case DATA_ALIGN_ID:
  140. pvValue->lVal = m_pScannerSettings->RawDataAlignment;
  141. break;
  142. case BED_WIDTH_ID:
  143. pvValue->lVal = m_pScannerSettings->BedWidth;
  144. break;
  145. case BED_HEIGHT_ID:
  146. pvValue->lVal = m_pScannerSettings->BedHeight;
  147. break;
  148. case XOPTICAL_ID:
  149. pvValue->lVal = m_pScannerSettings->XOpticalResolution;
  150. break;
  151. case YOPTICAL_ID:
  152. pvValue->lVal = m_pScannerSettings->YOpticalResolution;
  153. break;
  154. case ADF_ID:
  155. pvValue->lVal = m_pScannerSettings->ADFSupport;
  156. break;
  157. case TPA_ID:
  158. pvValue->lVal = m_pScannerSettings->TPASupport;
  159. break;
  160. case ADF_WIDTH_ID:
  161. pvValue->lVal = m_pScannerSettings->FeederWidth;
  162. break;
  163. case ADF_HEIGHT_ID:
  164. pvValue->lVal = m_pScannerSettings->FeederHeight;
  165. break;
  166. case ADF_VJUSTIFY_ID:
  167. pvValue->lVal = m_pScannerSettings->VFeederJustification;
  168. break;
  169. case ADF_HJUSTIFY_ID:
  170. pvValue->lVal = m_pScannerSettings->HFeederJustification;
  171. break;
  172. case ADF_MAX_PAGES_ID:
  173. pvValue->lVal = m_pScannerSettings->MaxADFPageCapacity;
  174. break;
  175. case FIRMWARE_VER_ID:
  176. //lstrcpy(m_pScannerSettings->FirmwareVersion,Value.cVal);
  177. break;
  178. default:
  179. return E_FAIL;
  180. }
  181. return S_OK;
  182. }
  183. STDMETHODIMP CDeviceProperty::SetValidRange(LONG lValueID, LONG lMin, LONG lMax, LONG lNom, LONG lInc)
  184. {
  185. switch(lValueID){
  186. case XRESOLUTION_ID:
  187. m_pScannerSettings->XSupportedResolutionsRange.lMax = lMax;
  188. m_pScannerSettings->XSupportedResolutionsRange.lMin = lMin;
  189. m_pScannerSettings->XSupportedResolutionsRange.lNom = lNom;
  190. m_pScannerSettings->XSupportedResolutionsRange.lStep = lInc;
  191. break;
  192. case YRESOLUTION_ID:
  193. m_pScannerSettings->YSupportedResolutionsRange.lMax = lMax;
  194. m_pScannerSettings->YSupportedResolutionsRange.lMin = lMin;
  195. m_pScannerSettings->YSupportedResolutionsRange.lNom = lNom;
  196. m_pScannerSettings->YSupportedResolutionsRange.lStep = lInc;
  197. break;
  198. case XPOS_ID:
  199. m_pScannerSettings->XPosRange.lMax = lMax;
  200. m_pScannerSettings->XPosRange.lMin = lMin;
  201. m_pScannerSettings->XPosRange.lNom = lNom;
  202. m_pScannerSettings->XPosRange.lStep = lInc;
  203. break;
  204. case YPOS_ID:
  205. m_pScannerSettings->YPosRange.lMax = lMax;
  206. m_pScannerSettings->YPosRange.lMin = lMin;
  207. m_pScannerSettings->YPosRange.lNom = lNom;
  208. m_pScannerSettings->YPosRange.lStep = lInc;
  209. break;
  210. case XEXT_ID:
  211. m_pScannerSettings->XExtentsRange.lMax = lMax;
  212. m_pScannerSettings->XExtentsRange.lMin = lMin;
  213. m_pScannerSettings->XExtentsRange.lNom = lNom;
  214. m_pScannerSettings->XExtentsRange.lStep = lInc;
  215. break;
  216. case YEXT_ID:
  217. m_pScannerSettings->YExtentsRange.lMax = lMax;
  218. m_pScannerSettings->YExtentsRange.lMin = lMin;
  219. m_pScannerSettings->YExtentsRange.lNom = lNom;
  220. m_pScannerSettings->YExtentsRange.lStep = lInc;
  221. break;
  222. case BRIGHTNESS_ID:
  223. m_pScannerSettings->BrightnessRange.lMax = lMax;
  224. m_pScannerSettings->BrightnessRange.lMin = lMin;
  225. m_pScannerSettings->BrightnessRange.lNom = lNom;
  226. m_pScannerSettings->BrightnessRange.lStep = lInc;
  227. break;
  228. case CONTRAST_ID:
  229. m_pScannerSettings->ContrastRange.lMax = lMax;
  230. m_pScannerSettings->ContrastRange.lMin = lMin;
  231. m_pScannerSettings->ContrastRange.lNom = lNom;
  232. m_pScannerSettings->ContrastRange.lStep = lInc;
  233. break;
  234. default:
  235. return E_FAIL;
  236. }
  237. return S_OK;
  238. }
  239. STDMETHODIMP CDeviceProperty::SetValidList(LONG lValueID, VARIANT Value)
  240. {
  241. HRESULT hr = S_OK;
  242. INT iNumValues = 0;
  243. INT index = 1;
  244. LONG lLBound = 0;
  245. LONG lUBound = 0;
  246. VARIANT *pVariant = NULL;
  247. //
  248. // incoming, array of VARIANTS:
  249. // use Value to get actual VARIANT Array
  250. //
  251. VARIANTARG *pVariantArg = Value.pvarVal;
  252. if(SafeArrayGetDim(pVariantArg->parray) != 1){
  253. return E_INVALIDARG;
  254. }
  255. //
  256. // get upper bounds of array
  257. //
  258. hr = SafeArrayGetUBound(pVariantArg->parray, 1, (long *)&lUBound);
  259. hr = SafeArrayAccessData(pVariantArg->parray, (void**)&pVariant);
  260. if (SUCCEEDED(hr)) {
  261. iNumValues = lUBound + 1;
  262. switch (lValueID) {
  263. case XRESOLUTION_ID:
  264. m_pScannerSettings->XSupportedResolutionsList = (PLONG)LocalAlloc(LPTR,(sizeof(LONG) * iNumValues));
  265. if (m_pScannerSettings->XSupportedResolutionsList) {
  266. m_pScannerSettings->XSupportedResolutionsList[0] = iNumValues;
  267. for (index = 0; index < iNumValues; index++) {
  268. m_pScannerSettings->XSupportedResolutionsList[index+1] = pVariant[index].iVal;
  269. }
  270. }
  271. break;
  272. case YRESOLUTION_ID:
  273. m_pScannerSettings->YSupportedResolutionsList = (PLONG)LocalAlloc(LPTR,(sizeof(LONG) * iNumValues));
  274. if (m_pScannerSettings->YSupportedResolutionsList) {
  275. m_pScannerSettings->YSupportedResolutionsList[0] = iNumValues;
  276. for (index = 0; index < iNumValues; index++) {
  277. m_pScannerSettings->YSupportedResolutionsList[index+1] = pVariant[index].iVal;
  278. }
  279. }
  280. break;
  281. case DATA_TYPE_ID:
  282. m_pScannerSettings->SupportedDataTypesList = (PLONG)LocalAlloc(LPTR,(sizeof(LONG) * iNumValues));
  283. if (m_pScannerSettings->SupportedDataTypesList) {
  284. m_pScannerSettings->SupportedDataTypesList[0] = iNumValues;
  285. for (index = 0; index < iNumValues; index++) {
  286. m_pScannerSettings->SupportedDataTypesList[index+1] = pVariant[index].iVal;
  287. }
  288. }
  289. break;
  290. default:
  291. hr = E_FAIL;
  292. break;
  293. }
  294. SafeArrayUnaccessData(pVariantArg->parray);
  295. }
  296. return hr;
  297. }
  298. STDMETHODIMP CDeviceProperty::TestCall()
  299. {
  300. ::MessageBox(NULL,TEXT("Test CALL"),TEXT("Test CALL"),MB_OK);
  301. return S_OK;
  302. }