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.

695 lines
21 KiB

  1. // =========================================================================
  2. //
  3. // CASIO PAGEPRESTO Universal Printer Driver for MS-Windows NT 5.0
  4. //
  5. // =========================================================================
  6. //// CAPPLERES.C file for CASIO PAGEPRESTO CAPPL/Base Common DLL
  7. #include "pdev.h"
  8. #include "capplid.h"
  9. #include "strsafe.h" // Security-Code 2002.3.6
  10. #if DBG
  11. # include "mydbg.h"
  12. #endif
  13. #define CCHMAXCMDLEN 256
  14. #define STR_SELECTRES_240_3K \
  15. "\x1B[1\x00\x03=5\x00\x1B[1\x00\x06=30240"
  16. #define STR_SELECTRES_400_3K \
  17. "\x1B[1\x00\x03=5\x00\x1B[1\x00\x06=30400"
  18. // ===== PaperSize =====
  19. #define STR_LETTER_2000 \
  20. "\x1B@0\x05\x1B@A\x07\x1B@B\x07"
  21. #define STR_LETTER_3000 \
  22. "\x1B[1\x00\x03@06\x1B[1\x00\x03@18"
  23. #define STR_A3_3000 \
  24. "\x1B[1\x00\x03@00\x1B[1\x00\x03@10"
  25. #define STR_A4_2000 \
  26. "\x1B@0\x03\x1B@A\x05\x1B@B\x05"
  27. #define STR_A4_3000 \
  28. "\x1B[1\x00\x03@02\x1B[1\x00\x03@13"
  29. #define STR_B4_2000 \
  30. "\x1B@0\x02\x1B@B\x04"
  31. #define STR_B4_3000 \
  32. "\x1B[1\x00\x03@01\x1B[1\x00\x03@11"
  33. #define STR_B5_2000 \
  34. "\x1B@0\x04\x1B@A\x06\x1B@B\x06"
  35. #define STR_B5_3000 \
  36. "\x1B[1\x00\x03@04\x1B[1\x00\x03@14"
  37. #define STR_A5_3000 \
  38. "\x1B[1\x00\x03@05\x1B[1\x00\x03@16"
  39. #define STR_POSTCARD_2000 \
  40. "\x1B@0\x0C\x1B@A\x0E\x1B@B\x0E"
  41. #define STR_POSTCARD_3000 \
  42. "\x1B[1\x00\x03@0;\x1B[1\x00\x03@1="
  43. #define STR_FREE_2000 \
  44. "\x1B@0\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
  45. "\x1B@A\x03\x00\x00\x00\x00" \
  46. "\x1B@B\x03\x00\x00\x00\x00"
  47. #define STR_FREE_3000 \
  48. "\x1B@0\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
  49. "\x1B[1\x00\x06@2\x00\x00\x00\x00" \
  50. "\x1B[1\x00\x03@1\x3F"
  51. // ===== MPF Setting =====
  52. #define OPT_NOSET "Option1"
  53. #define OPT_A3 "Option2"
  54. #define OPT_B4 "Option3"
  55. #define OPT_A4 "Option4"
  56. #define OPT_B5 "Option5"
  57. #define OPT_LETTER "Option6"
  58. #define OPT_POSTCARD "Option7"
  59. #define OPT_A5 "Option8"
  60. #define WRITESPOOLBUF(p, s, n) \
  61. ((p)->pDrvProcs->DrvWriteSpoolBuf(p, s, n))
  62. #define DRVGETDRIVERSETTING(p, t, o, s, n, r) \
  63. ((p)->pDrvProcs->DrvGetDriverSetting(p, t, o, s, n, r))
  64. #define PARAM(p,n) \
  65. (*((p)+(n)))
  66. #define MASTER_UNIT 1200
  67. // ===== AutoFeed =====
  68. const
  69. static BYTE AutoFeed_2000[] = { /* Auto Select */
  70. 0x33, /* A3 */
  71. 0x34, /* B4 */
  72. 0x35, /* A4 */
  73. 0x36, /* B5 */
  74. 0x33, /* Letter */
  75. 0x33, /* PostCard */
  76. 0x33, /* MPF */
  77. 0x33 /* A5 */
  78. };
  79. const
  80. static BYTE AutoFeed_3000[] = { /* Auto Select */
  81. 0x38, /* A3 */
  82. 0x34, /* B4 */
  83. 0x35, /* A4 */
  84. 0x36, /* B5 */
  85. 0x37, /* Letter */
  86. 0x37, /* PostCard */
  87. 0x37, /* MPF */
  88. 0x3B /* A5 */
  89. };
  90. BOOL
  91. BInitOEMExtraData(
  92. POEMUD_EXTRADATA pOEMExtra
  93. )
  94. {
  95. // Initialize OEM Extra data.
  96. pOEMExtra->dmExtraHdr.dwSize = sizeof(OEMUD_EXTRADATA);
  97. pOEMExtra->dmExtraHdr.dwSignature = OEM_SIGNATURE;
  98. pOEMExtra->dmExtraHdr.dwVersion = OEM_VERSION;
  99. return TRUE;
  100. }
  101. BOOL
  102. BMergeOEMExtraData(
  103. POEMUD_EXTRADATA pdmIn,
  104. POEMUD_EXTRADATA pdmOut
  105. )
  106. {
  107. return TRUE;
  108. }
  109. PDEVOEM APIENTRY
  110. OEMEnablePDEV(
  111. PDEVOBJ pdevobj,
  112. PWSTR pPrinterName,
  113. ULONG cPatterns,
  114. HSURF *phsurfPatterns,
  115. ULONG cjGdiInfo,
  116. GDIINFO *pGdiInfo,
  117. ULONG cjDevInfo,
  118. DEVINFO *pDevInfo,
  119. DRVENABLEDATA *pded)
  120. {
  121. PMYPDEV pOEM;
  122. VERBOSE(("OEMEnablePDEV - %08x\n", pdevobj));
  123. if(!pdevobj->pdevOEM)
  124. {
  125. if(!(pdevobj->pdevOEM = MemAllocZ(sizeof(MYPDEV))))
  126. {
  127. ERR(("Faild to allocate memory. (%d)\n",
  128. GetLastError()));
  129. return NULL;
  130. }
  131. }
  132. pOEM = (PMYPDEV)pdevobj->pdevOEM;
  133. pOEM->sRes = MASTER_UNIT / 240; // Default to 240dpi
  134. pOEM->jFreePaper = 0; // Default to No(0)
  135. // misc initializations, if any
  136. return pdevobj->pdevOEM;
  137. }
  138. VOID APIENTRY
  139. OEMDisablePDEV(
  140. PDEVOBJ pdevobj)
  141. {
  142. PMYPDEV pOEM = (PMYPDEV)pdevobj->pdevOEM;
  143. VERBOSE(("OEMDisablePDEV - %08x\n", pdevobj));
  144. if(pdevobj->pdevOEM)
  145. {
  146. MemFree(pdevobj->pdevOEM);
  147. pdevobj->pdevOEM = NULL;
  148. }
  149. return;
  150. }
  151. BOOL APIENTRY
  152. OEMResetPDEV(
  153. PDEVOBJ pdevobjOld,
  154. PDEVOBJ pdevobjNew)
  155. {
  156. PMYPDEV pOld, pNew;
  157. VERBOSE(("OEMResetPDEV - %08x, %08x\n", pdevobjOld, pdevobjNew));
  158. if (NULL == (pOld = (PMYPDEV)pdevobjOld->pdevOEM) ||
  159. NULL == (pNew = (PMYPDEV)pdevobjNew->pdevOEM)) {
  160. ERR(("Invalid PDEV\n"));
  161. return FALSE;
  162. }
  163. *pNew = *pOld;
  164. return TRUE;
  165. }
  166. static
  167. VOID
  168. EmitJobSetup(
  169. PDEVOBJ pdevobj,
  170. PMYPDEV pOEM
  171. ) {
  172. BYTE cmdbuf[CCHMAXCMDLEN];
  173. WORD wlen = 0;
  174. BYTE jOutput[64];
  175. DWORD dwNeeded;
  176. DWORD dwOptionsReturned;
  177. if (pOEM->dwGeneral & FG_HAS_EMUL) {
  178. // Alster emulation mode setting
  179. cmdbuf[wlen++] = 0x1B;
  180. cmdbuf[wlen++] = 'i';
  181. cmdbuf[wlen++] = 'w';
  182. cmdbuf[wlen++] = '0';
  183. }
  184. WRITESPOOLBUF(pdevobj, cmdbuf, wlen);
  185. if (!DRVGETDRIVERSETTING(
  186. pdevobj, "MPFSetting", jOutput,
  187. sizeof(BYTE) * 64, &dwNeeded, &dwOptionsReturned)) {
  188. WARNING(("DrvGetDriverSetting(1) Failed\n"));
  189. pOEM->jMPFSetting = MPF_NOSET;
  190. } else {
  191. if (!strcmp(jOutput, OPT_A3)) {
  192. pOEM->jMPFSetting = MPF_A3;
  193. VERBOSE(("MPF_A3\n"));
  194. } else if (!strcmp(jOutput, OPT_B4)) {
  195. pOEM->jMPFSetting = MPF_B4;
  196. VERBOSE(("MPF_B4\n"));
  197. } else if (!strcmp(jOutput, OPT_A4)) {
  198. pOEM->jMPFSetting = MPF_A4;
  199. VERBOSE(("MPF_A4\n"));
  200. } else if (!strcmp(jOutput, OPT_B5)) {
  201. pOEM->jMPFSetting = MPF_B5;
  202. VERBOSE(("MPF_B5\n"));
  203. } else if (!strcmp(jOutput, OPT_A5)) {
  204. pOEM->jMPFSetting = MPF_A5;
  205. VERBOSE(("MPF_A5\n"));
  206. } else if (!strcmp(jOutput, OPT_LETTER)) {
  207. pOEM->jMPFSetting = MPF_LETTER;
  208. VERBOSE(("MPF_LETTER\n"));
  209. } else if (!strcmp(jOutput, OPT_POSTCARD)) {
  210. pOEM->jMPFSetting = MPF_POSTCARD;
  211. VERBOSE(("MPF_POSTCARD\n"));
  212. } else {
  213. pOEM->jMPFSetting = MPF_NOSET;
  214. VERBOSE(("MPF_NOSET\n"));
  215. }
  216. }
  217. }
  218. static
  219. VOID
  220. LoadPaperSelectCmd(
  221. PDEVOBJ pdevobj,
  222. PMYPDEV pOEM,
  223. INT iPaperID
  224. ) {
  225. switch (iPaperID) {
  226. case PS_LETTER:
  227. if (pOEM->jModel == MD_CP2000) {
  228. if (pOEM->jMPFSetting == MPF_LETTER)
  229. pOEM->jAutoSelect = AutoFeed_2000[PS_MPF - PS_SEGMENT];
  230. else
  231. pOEM->jAutoSelect = AutoFeed_2000[iPaperID - PS_SEGMENT];
  232. pOEM->cmdPaperSize.cmd = STR_LETTER_2000;
  233. pOEM->cmdPaperSize.cmdlen = sizeof(STR_LETTER_2000) - 1;
  234. } else {
  235. if (pOEM->jMPFSetting == MPF_LETTER)
  236. pOEM->jAutoSelect = AutoFeed_3000[PS_MPF - PS_SEGMENT];
  237. else
  238. pOEM->jAutoSelect = AutoFeed_3000[iPaperID - PS_SEGMENT];
  239. pOEM->cmdPaperSize.cmd = STR_LETTER_3000;
  240. pOEM->cmdPaperSize.cmdlen = sizeof(STR_LETTER_3000) - 1;
  241. }
  242. break;
  243. case PS_A3:
  244. // CP-3000 Only
  245. if (pOEM->jMPFSetting == MPF_A3)
  246. pOEM->jAutoSelect = AutoFeed_3000[PS_MPF - PS_SEGMENT];
  247. else
  248. pOEM->jAutoSelect = AutoFeed_3000[iPaperID - PS_SEGMENT];
  249. pOEM->cmdPaperSize.cmd = STR_A3_3000;
  250. pOEM->cmdPaperSize.cmdlen = sizeof(STR_A3_3000) - 1;
  251. break;
  252. case PS_A4:
  253. if (pOEM->jModel == MD_CP2000) {
  254. if (pOEM->jMPFSetting == MPF_A4)
  255. pOEM->jAutoSelect = AutoFeed_2000[PS_MPF - PS_SEGMENT];
  256. else
  257. pOEM->jAutoSelect = AutoFeed_2000[iPaperID - PS_SEGMENT];
  258. pOEM->cmdPaperSize.cmd = STR_A4_2000;
  259. pOEM->cmdPaperSize.cmdlen = sizeof(STR_A4_2000) - 1;
  260. } else {
  261. if (pOEM->jMPFSetting == MPF_A4)
  262. pOEM->jAutoSelect = AutoFeed_3000[PS_MPF - PS_SEGMENT];
  263. else
  264. pOEM->jAutoSelect = AutoFeed_3000[iPaperID - PS_SEGMENT];
  265. pOEM->cmdPaperSize.cmd = STR_A4_3000;
  266. pOEM->cmdPaperSize.cmdlen = sizeof(STR_A4_3000) - 1;
  267. }
  268. break;
  269. case PS_B4:
  270. if (pOEM->jModel == MD_CP2000) {
  271. if (pOEM->jMPFSetting == MPF_B4)
  272. pOEM->jAutoSelect = AutoFeed_2000[PS_MPF - PS_SEGMENT];
  273. else
  274. pOEM->jAutoSelect = AutoFeed_2000[iPaperID - PS_SEGMENT];
  275. pOEM->cmdPaperSize.cmd = STR_B4_2000;
  276. pOEM->cmdPaperSize.cmdlen = sizeof(STR_B4_2000) - 1;
  277. } else {
  278. if (pOEM->jMPFSetting == MPF_B4)
  279. pOEM->jAutoSelect = AutoFeed_3000[PS_MPF - PS_SEGMENT];
  280. else
  281. pOEM->jAutoSelect = AutoFeed_3000[iPaperID - PS_SEGMENT];
  282. pOEM->cmdPaperSize.cmd = STR_B4_3000;
  283. pOEM->cmdPaperSize.cmdlen = sizeof(STR_B4_3000) - 1;
  284. }
  285. break;
  286. case PS_B5:
  287. if (pOEM->jModel == MD_CP2000) {
  288. if (pOEM->jMPFSetting == MPF_B5)
  289. pOEM->jAutoSelect = AutoFeed_2000[PS_MPF - PS_SEGMENT];
  290. else
  291. pOEM->jAutoSelect = AutoFeed_2000[iPaperID - PS_SEGMENT];
  292. pOEM->cmdPaperSize.cmd = STR_B5_2000;
  293. pOEM->cmdPaperSize.cmdlen = sizeof(STR_B5_2000) - 1;
  294. } else {
  295. if (pOEM->jMPFSetting == MPF_B5)
  296. pOEM->jAutoSelect = AutoFeed_3000[PS_MPF - PS_SEGMENT];
  297. else
  298. pOEM->jAutoSelect = AutoFeed_3000[iPaperID - PS_SEGMENT];
  299. pOEM->cmdPaperSize.cmd = STR_B5_3000;
  300. pOEM->cmdPaperSize.cmdlen = sizeof(STR_B5_3000) - 1;
  301. }
  302. break;
  303. case PS_A5:
  304. // CP-3000 Only
  305. if (pOEM->jMPFSetting == MPF_A5)
  306. pOEM->jAutoSelect = AutoFeed_3000[PS_MPF - PS_SEGMENT];
  307. else
  308. pOEM->jAutoSelect = AutoFeed_3000[iPaperID - PS_SEGMENT];
  309. pOEM->cmdPaperSize.cmd = STR_A5_3000;
  310. pOEM->cmdPaperSize.cmdlen = sizeof(STR_A5_3000) - 1;
  311. break;
  312. case PS_POSTCARD:
  313. if (pOEM->jModel == MD_CP2000) {
  314. if (pOEM->jMPFSetting == MPF_POSTCARD)
  315. pOEM->jAutoSelect = AutoFeed_2000[PS_MPF - PS_SEGMENT];
  316. else
  317. pOEM->jAutoSelect = AutoFeed_2000[iPaperID - PS_SEGMENT];
  318. pOEM->cmdPaperSize.cmd = STR_POSTCARD_2000;
  319. pOEM->cmdPaperSize.cmdlen = sizeof(STR_POSTCARD_2000) - 1;
  320. } else {
  321. if (pOEM->jMPFSetting == MPF_POSTCARD)
  322. pOEM->jAutoSelect = AutoFeed_3000[PS_MPF - PS_SEGMENT];
  323. else
  324. pOEM->jAutoSelect = AutoFeed_3000[iPaperID - PS_SEGMENT];
  325. pOEM->cmdPaperSize.cmd = STR_POSTCARD_3000;
  326. pOEM->cmdPaperSize.cmdlen = sizeof(STR_POSTCARD_3000) - 1;
  327. }
  328. break;
  329. }
  330. }
  331. INT APIENTRY
  332. OEMCommandCallback(
  333. PDEVOBJ pdevobj,
  334. DWORD dwCmdCbID,
  335. DWORD dwCount,
  336. PDWORD pdwParams
  337. )
  338. {
  339. PMYPDEV pOEM;
  340. BYTE cmdbuf[CCHMAXCMDLEN];
  341. WORD wlen;
  342. WORD wTemp, i;
  343. WORD wDestX, wDestY;
  344. INT iRet = 0;
  345. DWORD dwTemp;
  346. WORD wVirPapX1;
  347. WORD wVirPapY1;
  348. WORD wVirPapX2;
  349. WORD wVirPapY2;
  350. WORD wPapLenX;
  351. WORD wPapLenY;
  352. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  353. #if DBG
  354. {
  355. int i, max;
  356. for (i = 0; i < (max = sizeof(MyCallbackID) / sizeof(MyCallbackID[0])); i++) {
  357. if (MyCallbackID[i].dwID == dwCmdCbID){
  358. VERBOSE(("%s PARAMS: %d\n", MyCallbackID[i].S, dwCount));
  359. break;
  360. }
  361. }
  362. if (i == max)
  363. WARNING(("%d is Invalid ID\n", dwCmdCbID));
  364. }
  365. #endif
  366. ASSERT(VALID_PDEVOBJ(pdevobj));
  367. wlen = 0;
  368. //
  369. // fill in printer commands
  370. //
  371. switch (dwCmdCbID) {
  372. case RES_SELECTRES_240:
  373. pOEM->wOldX = pOEM->wOldY = 0;
  374. pOEM->sRes = MASTER_UNIT / 240;
  375. WRITESPOOLBUF(pdevobj, STR_SELECTRES_240_3K,
  376. sizeof(STR_SELECTRES_240_3K) - 1);
  377. break;
  378. case RES_SELECTRES_400:
  379. pOEM->wOldX = pOEM->wOldY = 0;
  380. pOEM->sRes = MASTER_UNIT / 400;
  381. WRITESPOOLBUF(pdevobj, STR_SELECTRES_400_3K,
  382. sizeof(STR_SELECTRES_400_3K) - 1);
  383. break;
  384. case CM_XM_ABS:
  385. case CM_YM_ABS:
  386. switch (dwCmdCbID) {
  387. case CM_XM_ABS:
  388. wDestX = (WORD)(PARAM(pdwParams, 0) / pOEM->sRes);
  389. wDestY = pOEM->wOldY;
  390. pOEM->wOldX = wDestX;
  391. break;
  392. case CM_YM_ABS:
  393. wDestX = pOEM->wOldX;
  394. wDestY = (WORD)(PARAM(pdwParams, 1) / pOEM->sRes);
  395. pOEM->wOldY = wDestY;
  396. break;
  397. }
  398. // ESC '\' '9' XX YY
  399. // wDestX = (WORD)(PARAM(pdwParams, 0) / pOEM->sRes);
  400. // wDestY = (WORD)(PARAM(pdwParams, 1) / pOEM->sRes);
  401. VERBOSE(("(wDestX, wDestY): (%d, %d)\n", wDestX, wDestY));
  402. cmdbuf[wlen++] = 0x1b;
  403. cmdbuf[wlen++] = 0x5c;
  404. cmdbuf[wlen++] = 0x39;
  405. cmdbuf[wlen++] = (BYTE)((wDestX >> 8) | 0x80);
  406. cmdbuf[wlen++] = (BYTE)(wDestX);
  407. cmdbuf[wlen++] = (BYTE)(wDestY >> 8);
  408. cmdbuf[wlen++] = (BYTE)(wDestY);
  409. WRITESPOOLBUF(pdevobj, cmdbuf, wlen);
  410. // Set return value accordingly. Unidrv expects
  411. // the values to be retuned in device's unit here.
  412. switch (dwCmdCbID) {
  413. case CM_XM_ABS:
  414. iRet = wDestX;
  415. break;
  416. case CM_YM_ABS:
  417. iRet = wDestY;
  418. break;
  419. }
  420. break;
  421. case PS_LETTER:
  422. case PS_A3:
  423. case PS_A4:
  424. case PS_B4:
  425. case PS_B5:
  426. case PS_A5:
  427. case PS_POSTCARD:
  428. pOEM->jFreePaper = 0; // No(0)
  429. LoadPaperSelectCmd(pdevobj, pOEM, (INT)dwCmdCbID);
  430. break;
  431. case PS_FREE:
  432. pOEM->jFreePaper = 1; // yes(1)
  433. if (pOEM->jModel == MD_CP2000) {
  434. pOEM->stFreePaperSize.wX = (WORD)(PARAM(pdwParams, 0) / pOEM->sRes); // dot
  435. pOEM->stFreePaperSize.wY = (WORD)(PARAM(pdwParams, 1) / pOEM->sRes);
  436. pOEM->jAutoSelect = AutoFeed_2000[PS_MPF - PS_SEGMENT]; // MPF
  437. } else {
  438. pOEM->stFreePaperSize.wX = (WORD)(PARAM(pdwParams, 0) / pOEM->sRes); // dot
  439. pOEM->stFreePaperSize.wY = (WORD)(PARAM(pdwParams, 1) / pOEM->sRes);
  440. dwTemp = PARAM(pdwParams, 0);
  441. // 2001/02/27 ->
  442. // dwTemp = (dwTemp * 254) / MASTER_UNIT; // 0.1mm a unit
  443. // pOEM->stFreePaperSize.wXmm = (WORD)((dwTemp + 5) / 10); // 1mm a unit, round
  444. dwTemp = (dwTemp * 2540) / MASTER_UNIT; // 0.01mm a unit
  445. pOEM->stFreePaperSize.wXmm = (WORD)((dwTemp + 99) / 100); // 1mm a unit, roundup
  446. // 2001/02/27 <-
  447. dwTemp = PARAM(pdwParams, 1);
  448. // 2001/02/27 ->
  449. // dwTemp = (dwTemp * 254) / MASTER_UNIT; // 0.1mm a unit
  450. // pOEM->stFreePaperSize.wYmm = (WORD)((dwTemp + 5) / 10); // 1mm a unit, round
  451. dwTemp = (dwTemp * 2540) / MASTER_UNIT; // 0.01mm a unit
  452. pOEM->stFreePaperSize.wYmm = (WORD)((dwTemp + 99) / 100); // 1mm a unit, roundup
  453. // 2001/02/27 <-
  454. pOEM->jAutoSelect = AutoFeed_3000[PS_MPF - PS_SEGMENT]; // MPF
  455. }
  456. break;
  457. case AUTOFEED:
  458. cmdbuf[wlen++] = 0x1B;
  459. cmdbuf[wlen++] = '@';
  460. cmdbuf[wlen++] = ')';
  461. cmdbuf[wlen++] = pOEM->jAutoSelect;
  462. WRITESPOOLBUF(pdevobj, cmdbuf, wlen);
  463. break;
  464. case CBID_PORT:
  465. case CBID_LAND:
  466. // Page Format
  467. cmdbuf[wlen++] = 0x1B;
  468. cmdbuf[wlen++] = '=';
  469. cmdbuf[wlen++] = '4';
  470. cmdbuf[wlen++] = 0x00;
  471. // Orientaion
  472. cmdbuf[wlen++] = 0x1B;
  473. cmdbuf[wlen++] = '@';
  474. if (dwCmdCbID == CBID_LAND)
  475. cmdbuf[wlen++] = '3';
  476. else
  477. cmdbuf[wlen++] = '2';
  478. WRITESPOOLBUF(pdevobj, cmdbuf, wlen);
  479. // PaperSize
  480. if (pOEM->jFreePaper == 0) {
  481. WRITESPOOLBUF(pdevobj, pOEM->cmdPaperSize.cmd, pOEM->cmdPaperSize.cmdlen);
  482. } else {
  483. if (pOEM->jModel == MD_CP2000) {
  484. if (dwCmdCbID == CBID_LAND) {
  485. wVirPapX1 = 0;
  486. wVirPapY1 = 0;
  487. wVirPapX2 = pOEM->stFreePaperSize.wY - ((240 / pOEM->sRes) * 2);
  488. wVirPapY2 = pOEM->stFreePaperSize.wX - ((400 / pOEM->sRes) * 2);
  489. wPapLenX = pOEM->stFreePaperSize.wY;
  490. wPapLenY = pOEM->stFreePaperSize.wX;
  491. } else {
  492. wVirPapX1 = 0;
  493. wVirPapY1 = 0;
  494. wVirPapX2 = pOEM->stFreePaperSize.wX - ((400 / pOEM->sRes) * 2);
  495. wVirPapY2 = pOEM->stFreePaperSize.wY - ((240 / pOEM->sRes) * 2);
  496. wPapLenX = pOEM->stFreePaperSize.wX;
  497. wPapLenY = pOEM->stFreePaperSize.wY;
  498. }
  499. wlen = 0;
  500. wlen = sizeof(STR_FREE_2000) - 1;
  501. memcpy(cmdbuf, STR_FREE_2000, wlen);
  502. // VirtualPaperSize
  503. cmdbuf[ 4] = HIBYTE(wVirPapX1); // X1
  504. cmdbuf[ 5] = LOBYTE(wVirPapX1);
  505. cmdbuf[ 6] = HIBYTE(wVirPapY1); // Y1
  506. cmdbuf[ 7] = LOBYTE(wVirPapY1);
  507. cmdbuf[ 8] = HIBYTE(wVirPapX2); // X2
  508. cmdbuf[ 9] = LOBYTE(wVirPapX2);
  509. cmdbuf[10] = HIBYTE(wVirPapY2); // Y2
  510. cmdbuf[11] = LOBYTE(wVirPapY2);
  511. // PaperSize (APF)
  512. cmdbuf[16] = HIBYTE(wPapLenX); // X1
  513. cmdbuf[17] = LOBYTE(wPapLenX);
  514. cmdbuf[18] = HIBYTE(wPapLenY); // Y1
  515. cmdbuf[19] = LOBYTE(wPapLenY);
  516. // MPF-PaperSize
  517. cmdbuf[24] = HIBYTE(wPapLenX); // X1
  518. cmdbuf[25] = LOBYTE(wPapLenX);
  519. cmdbuf[26] = HIBYTE(wPapLenY); // Y1
  520. cmdbuf[27] = LOBYTE(wPapLenY);
  521. WRITESPOOLBUF(pdevobj, cmdbuf, wlen);
  522. } else {
  523. if (dwCmdCbID == CBID_LAND) {
  524. wVirPapX1 = 0;
  525. wVirPapY1 = 0;
  526. wVirPapX2 = pOEM->stFreePaperSize.wY - ((240 / pOEM->sRes) * 2);
  527. wVirPapY2 = pOEM->stFreePaperSize.wX - ((240 / pOEM->sRes) * 2);
  528. wPapLenX = pOEM->stFreePaperSize.wYmm;
  529. wPapLenY = pOEM->stFreePaperSize.wXmm;
  530. } else {
  531. wVirPapX1 = 0;
  532. wVirPapY1 = 0;
  533. wVirPapX2 = pOEM->stFreePaperSize.wX - ((240 / pOEM->sRes) * 2);
  534. wVirPapY2 = pOEM->stFreePaperSize.wY - ((240 / pOEM->sRes) * 2);
  535. wPapLenX = pOEM->stFreePaperSize.wXmm;
  536. wPapLenY = pOEM->stFreePaperSize.wYmm;
  537. }
  538. wlen = sizeof(STR_FREE_3000) - 1;
  539. memcpy(cmdbuf, STR_FREE_3000, wlen);
  540. // VirtualPaperSize
  541. cmdbuf[ 4] = HIBYTE(wVirPapX1); // X1
  542. cmdbuf[ 5] = LOBYTE(wVirPapX1);
  543. cmdbuf[ 6] = HIBYTE(wVirPapY1); // Y1
  544. cmdbuf[ 7] = LOBYTE(wVirPapY1);
  545. cmdbuf[ 8] = HIBYTE(wVirPapX2); // X2
  546. cmdbuf[ 9] = LOBYTE(wVirPapX2);
  547. cmdbuf[10] = HIBYTE(wVirPapY2); // Y2
  548. cmdbuf[11] = LOBYTE(wVirPapY2);
  549. // MPF-PaperSize
  550. cmdbuf[19] = HIBYTE(wPapLenX); // X
  551. cmdbuf[20] = LOBYTE(wPapLenX);
  552. cmdbuf[21] = HIBYTE(wPapLenY); // Y
  553. cmdbuf[22] = LOBYTE(wPapLenY);
  554. WRITESPOOLBUF(pdevobj, cmdbuf, wlen);
  555. }
  556. }
  557. break;
  558. case PRN_2000:
  559. pOEM->jModel = MD_CP2000;
  560. pOEM->dwGeneral &= ~FG_HAS_EMUL;
  561. EmitJobSetup(pdevobj, pOEM);
  562. break;
  563. case PRN_2000W:
  564. pOEM->jModel = MD_CP2000;
  565. pOEM->dwGeneral |= FG_HAS_EMUL;
  566. EmitJobSetup(pdevobj, pOEM);
  567. break;
  568. case PRN_3000:
  569. pOEM->jModel = MD_CP3000;
  570. pOEM->dwGeneral |= FG_HAS_EMUL;
  571. EmitJobSetup(pdevobj, pOEM);
  572. break;
  573. }
  574. return iRet;
  575. }