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.

2321 lines
61 KiB

  1. //-----------------------------------------------------------------------------
  2. // This files contains the module name for this mini driver. Each mini driver
  3. // must have a unique module name. The module name is used to obtain the
  4. // module handle of this Mini Driver. The module handle is used by the
  5. // generic library to load in tables from the Mini Driver.
  6. //-----------------------------------------------------------------------------
  7. /*++
  8. Copyright (c) 1996-1998 Microsoft Corporation
  9. Module Name:
  10. cmdcb.c
  11. Abstract:
  12. Implementation of GPD command callback for "ncdlxxxx.gpd":
  13. OEMCommandCallback
  14. Environment:
  15. Windows NT Unidrv driver
  16. Revision History:
  17. 04/07/97 -zhanw-
  18. Created it.
  19. --*/
  20. #include "pdev.h"
  21. #include <strsafe.h>
  22. //
  23. // Misc definitions and declarations.
  24. //
  25. #define ALLOCMEM EngAllocMem
  26. #define FREEMEM EngFreeMem
  27. #define WRITESPOOLBUF(p, s, n) \
  28. ((p)->pDrvProcs->DrvWriteSpoolBuf(p, s, n))
  29. #define PARAM(p,n) \
  30. (*((p)+(n)))
  31. //
  32. // For debugging.
  33. //
  34. //#define DBG_OUTPUTCHARSTR 1
  35. //
  36. // command callback ID's
  37. //
  38. #define CMD_MOVE_X 23
  39. #define CMD_MOVE_Y 24
  40. #define CMD_BEGIN_RASTER 26
  41. #define CMD_RES_600 27
  42. #define CMD_RES_400 28
  43. #define CMD_RES_240 29
  44. #define CMD_SEND_BLOCK_DATA 30
  45. #define CMD_BEGIN_RASTER_NO_COMP 31
  46. #define CMD_INIT_COORDINATE 32
  47. #define CMD_PC_PRN_DIRECTION 50
  48. #define CMD_CR 51
  49. #define CMD_FF 52
  50. #define CMD_RES_300 65
  51. #define CMD_RES_200 66
  52. // #278517: RectFill
  53. #define CMD_RECTWIDTH 60
  54. #define CMD_RECTHEIGHT 61
  55. #define CMD_RECTWHITE 62
  56. #define CMD_RECTBLACK 63
  57. #define CMD_RECTGRAY 64
  58. #define CMD_DUPLEX_NONE 67
  59. #define CMD_DUPLEX_VERTICAL 68
  60. #define CMD_DUPLEX_HORIZONTAL 69
  61. #define CMD_MAIN_BACK1 70
  62. #define CMD_MAIN_BACK2 71
  63. #define CMD_MAIN_BACK3 72
  64. #define CMD_MAIN_BACK4 73
  65. #define CMD_0 74
  66. #define CMD_1 75
  67. #define CMD_2 76
  68. #define CMD_3 77
  69. #define CMD_4 78
  70. #define CMD_5 79
  71. #define CMD_6 80
  72. #define CMD_7 81
  73. #define CMD_8 82
  74. #define CMD_9 83
  75. #define CMD_10 84
  76. #define CMD_11 85
  77. #define CMD_12 86
  78. #define CMD_13 87
  79. #define CMD_14 88
  80. #define CMD_15 89
  81. #define CMD_16 90
  82. #define CMD_17 91
  83. #define CMD_18 92
  84. #define CMD_19 93
  85. #define CMD_20 94
  86. #define CMD_MAIN_BACK0 95
  87. #define CMD_MAIN_BACK11 96
  88. #define CMD_MAIN_BACK12 97
  89. #define CMD_MAIN_BACK13 98
  90. #define CMD_MAIN_BACK14 99
  91. #define CMD_DUPLEX_A1_600 100
  92. #define CMD_DUPLEX_A1_400 101
  93. #define CMD_DUPLEX_A1_300 102
  94. #define CMD_DUPLEX_A1_240 103
  95. #define CMD_DUPLEX_A1_200 104
  96. #define CMD_DUPLEX_A2_600 105
  97. #define CMD_DUPLEX_A2_400 106
  98. #define CMD_DUPLEX_A2_300 107
  99. #define CMD_DUPLEX_A2_240 108
  100. #define CMD_DUPLEX_A2_200 109
  101. #define CMD_DUPLEX_A3_600 110
  102. #define CMD_DUPLEX_A3_400 111
  103. #define CMD_DUPLEX_A3_300 112
  104. #define CMD_DUPLEX_A3_240 113
  105. #define CMD_DUPLEX_A3_200 114
  106. #define CMD_SORT_NONE 115
  107. #define CMD_SORT_COPY 116
  108. #define CMD_SORT_SORT 117
  109. #define CMD_SORT_BIN 118
  110. #define CMD_SORT_STACK 119
  111. #define CMD_JIS_90 120
  112. #define CMD_JIS_78 121
  113. // Text color add. 2000.12.28
  114. #define CMD_WHITE_ON 130
  115. #define CMD_WHITE_OFF 131
  116. // Under Line add 2001.2.2
  117. #define CMD_BOLD_ON 132
  118. #define CMD_ITALIC_ON 133
  119. #define CMD_CLEAR_ATTRIB_P 134
  120. #define CMD_ESORT_OFF 135
  121. #define CMD_ESORT_ON 136
  122. //////////////////////////////////////////////////////////////////////////
  123. // Function: BInitOEMExtraData
  124. //
  125. // Description: Initializes OEM Extra data.
  126. //
  127. //
  128. // Parameters:
  129. //
  130. // pOEMExtra Pointer to a OEM Extra data.
  131. //
  132. // dwSize Size of OEM extra data.
  133. //
  134. //
  135. // Returns: TRUE if successful; FALSE otherwise.
  136. //
  137. //
  138. // Comments:
  139. //
  140. //NOTICE-2002/03/28-hiroi-:
  141. // History:
  142. // 02/11/97 APresley Created.
  143. //
  144. //////////////////////////////////////////////////////////////////////////
  145. BOOL BInitOEMExtraData(POEMUD_EXTRADATA pOEMExtra)
  146. {
  147. // Initialize OEM Extra data.
  148. pOEMExtra->dmExtraHdr.dwSize = sizeof(OEMUD_EXTRADATA);
  149. pOEMExtra->dmExtraHdr.dwSignature = OEM_SIGNATURE;
  150. pOEMExtra->dmExtraHdr.dwVersion = OEM_VERSION;
  151. pOEMExtra->wRes = 1;
  152. pOEMExtra->pCompBuf = NULL;
  153. pOEMExtra->dwCompBufLen = 0;
  154. pOEMExtra->dwScanLen = 0;
  155. pOEMExtra->dwDeviceDestX = 0;
  156. pOEMExtra->dwDeviceDestY = 0;
  157. pOEMExtra->dwDevicePrevX = 0;
  158. pOEMExtra->dwDevicePrevY = 0;
  159. pOEMExtra->iGray = 0;
  160. pOEMExtra->cSubPath = 0;
  161. return TRUE;
  162. }
  163. //////////////////////////////////////////////////////////////////////////
  164. // Function: BMergeOEMExtraData
  165. //
  166. // Description: Validates and merges OEM Extra data.
  167. //
  168. //
  169. // Parameters:
  170. //
  171. // pdmIn pointer to an input OEM private devmode containing the settings
  172. // to be validated and merged. Its size is current.
  173. //
  174. // pdmOut pointer to the output OEM private devmode containing the
  175. // default settings.
  176. //
  177. //
  178. // Returns: TRUE if valid; FALSE otherwise.
  179. //
  180. //
  181. // Comments:
  182. //
  183. //NOTICE-2002/03/28-hiroi-:
  184. // History:
  185. // 02/11/97 APresley Created.
  186. // 04/08/97 ZhanW Modified the interface
  187. //
  188. //////////////////////////////////////////////////////////////////////////
  189. BOOL BMergeOEMExtraData(
  190. POEMUD_EXTRADATA pdmIn,
  191. POEMUD_EXTRADATA pdmOut
  192. )
  193. {
  194. if(pdmIn) {
  195. //
  196. // copy over the private fields, if they are valid
  197. //
  198. pdmOut->wRes = pdmIn->wRes;
  199. pdmOut->wScale = pdmIn->wScale;
  200. pdmOut->lPointsx = pdmIn->lPointsx;
  201. pdmOut->lPointsy = pdmIn->lPointsy;
  202. pdmOut->dwSBCSX = pdmIn->dwSBCSX;
  203. pdmOut->dwDBCSX = pdmIn->dwDBCSX;
  204. pdmOut->lSBCSXMove = pdmIn->lSBCSXMove;
  205. pdmOut->lSBCSYMove = pdmIn->lSBCSYMove;
  206. pdmOut->lDBCSXMove = pdmIn->lDBCSXMove;
  207. pdmOut->lDBCSYMove = pdmIn->lDBCSYMove;
  208. pdmOut->lPrevXMove = pdmIn->lPrevXMove;
  209. pdmOut->lPrevYMove = pdmIn->lPrevYMove;
  210. pdmOut->fGeneral = pdmIn->fGeneral;
  211. pdmOut->wCurrentAddMode = pdmIn->wCurrentAddMode;
  212. pdmOut->dwDeviceDestX = pdmIn->dwDeviceDestX;
  213. pdmOut->dwDeviceDestY = pdmIn->dwDeviceDestY;
  214. pdmOut->dwDevicePrevX = pdmIn->dwDevicePrevX;
  215. pdmOut->dwDevicePrevY = pdmIn->dwDevicePrevY;
  216. }
  217. return TRUE;
  218. }
  219. //-----------------------------------------------------------------------------
  220. //
  221. // Function: iDwtoA
  222. //
  223. // Description: Convert from numeral into a character
  224. //-----------------------------------------------------------------------------
  225. static int
  226. iDwtoA(LPSTR buf, DWORD n)
  227. {
  228. int i, j;
  229. for( i = 0; n; i++ ) {
  230. buf[i] = (char)(n % 10 + '0');
  231. n /= 10;
  232. }
  233. /* n was zero */
  234. if( i == 0 )
  235. buf[i++] = '0';
  236. for( j = 0; j < i / 2; j++ ) {
  237. int tmp;
  238. tmp = buf[j];
  239. buf[j] = buf[i - j - 1];
  240. buf[i - j - 1] = (char)tmp;
  241. }
  242. buf[i] = '\0';
  243. return i;
  244. }
  245. //-----------------------------------------------------------------------------
  246. //
  247. // Function: iDwtoA_FillZero
  248. //
  249. // Description: Convert from numeral into a character and
  250. // fill a field which was specified with 0
  251. //-----------------------------------------------------------------------------
  252. static int
  253. iDwtoA_FillZero(LPSTR buf, DWORD n, int fw)
  254. {
  255. int i , j, k, l;
  256. l = n; // for later
  257. for( i = 0; n; i++ ) {
  258. buf[i] = (char)(n % 10 + '0');
  259. n /= 10;
  260. }
  261. /* n was zero */
  262. if( i == 0 )
  263. buf[i++] = '0';
  264. for( j = 0; j < i / 2; j++ ) {
  265. int tmp;
  266. tmp = buf[j];
  267. buf[j] = buf[i - j - 1];
  268. buf[i - j - 1] = (char)tmp;
  269. }
  270. buf[i] = '\0';
  271. for( k = 0; l; k++ ) {
  272. l /= 10;
  273. }
  274. if( k < 1) k++;
  275. k = fw - k;
  276. if(k > 0){;
  277. for (j = i; 0 < j + 1; j--){
  278. buf[j + k] = buf[j];
  279. }
  280. for ( j = 0; j < k; j++){
  281. buf[j] = '0';
  282. }
  283. i = i + k;
  284. }
  285. return i;
  286. }
  287. //-----------------------------------------------------------------------------
  288. //
  289. // Function: memcopy
  290. //
  291. // Description: Copy the memory from Src to Dest
  292. //-----------------------------------------------------------------------------
  293. static int
  294. memcopy(LPSTR lpDst, LPSTR lpSrc, WORD wLen)
  295. {
  296. WORD rLen;
  297. rLen = wLen;
  298. while(wLen--) *lpDst++ = *lpSrc++;
  299. return rLen;
  300. }
  301. //-----------------------------------------------------------------------------
  302. //
  303. // Function: copynumber
  304. //
  305. // Description: Copy the memory from Src to Dest
  306. //-----------------------------------------------------------------------------
  307. void
  308. copynumber(LPSTR lpDst, LONG wLen)
  309. {
  310. LONG rLen;
  311. BYTE i,j;
  312. j = 0;
  313. rLen = wLen;
  314. if( rLen > 9 ){
  315. for(i=0;i<rLen;i+=10)
  316. {
  317. j++;
  318. }
  319. *lpDst = (j-1) + 0x30;
  320. i -= 10;
  321. rLen -=i;
  322. lpDst++;
  323. }
  324. j = (BYTE)rLen;
  325. *lpDst = 0x30 + j;
  326. return;
  327. }
  328. //------------------------------------------------------------------
  329. // RLE1
  330. // Action : compress image data with RLE1
  331. //------------------------------------------------------------------
  332. DWORD RLE1(
  333. PBYTE pDst,
  334. PBYTE pSrc,
  335. DWORD dwLen)
  336. {
  337. PBYTE pTemp, pEnd, pDsto;
  338. DWORD len, deflen;
  339. pDsto = pDst;
  340. pEnd = pSrc + dwLen;
  341. while(pSrc < pEnd)
  342. {
  343. pTemp = pSrc++;
  344. if(pSrc == pEnd)
  345. {
  346. *pDst++ = 0x41;
  347. *pDst++ = *pTemp;
  348. break;
  349. }
  350. if(*pTemp == *pSrc)
  351. {
  352. pSrc++;
  353. while(pSrc < pEnd && *pTemp == *pSrc) pSrc++;
  354. len = (DWORD)(pSrc - pTemp);
  355. if(len < 63)
  356. {
  357. *pDst++ = 0x80 + (BYTE)len;
  358. goto T1;
  359. }
  360. *pDst++ = 0xbf;
  361. len -= 63;
  362. while(len >= 255)
  363. {
  364. *pDst++ = 0xff;
  365. len -= 255;
  366. }
  367. *pDst++ = (BYTE)len;
  368. T1:
  369. *pDst++ = *pTemp;
  370. continue;
  371. }
  372. pSrc++;
  373. while(pSrc < pEnd)
  374. {
  375. if(*pSrc == *(pSrc - 1))
  376. {
  377. pSrc--;
  378. break;
  379. }
  380. pSrc++;
  381. }
  382. deflen = len = (DWORD)(pSrc - pTemp);
  383. if(len < 63)
  384. {
  385. *pDst++ = 0x40 + (BYTE)len;
  386. goto T2;
  387. }
  388. *pDst++ = 0x7f;
  389. len -= 63;
  390. while(len >= 255)
  391. {
  392. *pDst++ = 0xff;
  393. len -= 255;
  394. }
  395. *pDst++ = (BYTE)len;
  396. T2:
  397. memcpy(pDst, pTemp, deflen);
  398. pDst += deflen;
  399. }
  400. return (DWORD)(pDst - pDsto);
  401. }
  402. //------------------------------------------------------------------
  403. // RLC2Comp
  404. // Action : compress image data with RLE2
  405. //------------------------------------------------------------------
  406. DWORD
  407. RLC2Comp(
  408. PBYTE pOutBuf,
  409. PBYTE pInBuf,
  410. DWORD dwInLen,
  411. DWORD dwScanLen
  412. )
  413. {
  414. DWORD dwlen, dwDatalen, dwCounter;
  415. PBYTE pLBuff;
  416. PBYTE pBuff, pTemp, pBuffo, pEnd;
  417. PBYTE pBuff2, pBuff2o;
  418. VERBOSE(("RLC2Comp() In +++\r\n"));
  419. dwCounter = dwInLen / dwScanLen;
  420. pLBuff = pBuffo = pBuff = pTemp = pInBuf; // Copy Src first pointer
  421. pBuff2o = pBuff2 = pOutBuf; // Copy Dst first pointer
  422. /*
  423. * We compare contents of First line with 0x00
  424. */
  425. pEnd = pBuff + dwScanLen;
  426. while(pBuff < pEnd)
  427. {
  428. while(pBuff < pEnd && 0x00 != *pBuff)
  429. {
  430. pBuff++;
  431. }
  432. dwlen = (DWORD)(pBuff - pTemp);
  433. if(dwlen)
  434. {
  435. pBuff2 += RLE1(pBuff2, pTemp, dwlen);
  436. pTemp = pBuff;
  437. }
  438. if(pBuff == pEnd) break;
  439. while(pBuff < pEnd && 0x00 == *pBuff)
  440. {
  441. pBuff++;
  442. }
  443. dwlen = (DWORD)(pBuff - pTemp);
  444. if(dwlen < 63)
  445. {
  446. *pBuff2++ = (BYTE)dwlen;
  447. goto T1;
  448. }
  449. *pBuff2++ = 0x3f;
  450. dwlen -= 63;
  451. while(dwlen >= 255)
  452. {
  453. *pBuff2++ = (BYTE)0xff;
  454. dwlen -= 255;
  455. }
  456. *pBuff2++ = (BYTE)dwlen;
  457. T1:
  458. pTemp = pBuff;
  459. }
  460. dwCounter--;
  461. *pBuff2++ = (BYTE)0x80;
  462. dwDatalen = (DWORD)(pBuff2 - pBuff2o);
  463. // If the compressed bitmap size is larger than nomal bitmap size,
  464. // we don't compress
  465. if(dwDatalen > dwInLen)
  466. {
  467. VERBOSE(("goto NO_COMP\r\n"));
  468. goto NO_COMP;
  469. }
  470. if(!dwCounter)
  471. return dwDatalen;
  472. /*
  473. * We compare the 1 previous line with the present line
  474. */
  475. do
  476. {
  477. pEnd = pBuff + dwScanLen;
  478. while(pBuff < pEnd)
  479. {
  480. while(pBuff < pEnd && *pLBuff != *pBuff)
  481. {
  482. pLBuff++;
  483. pBuff++;
  484. }
  485. dwlen = (DWORD)(pBuff - pTemp);
  486. if(dwlen)
  487. {
  488. pBuff2 += RLE1(pBuff2, pTemp, dwlen);
  489. pTemp = pBuff;
  490. }
  491. if(pBuff == pEnd) break;
  492. while(pBuff < pEnd && *pLBuff == *pBuff)
  493. {
  494. pLBuff++;
  495. pBuff++;
  496. }
  497. dwlen = (DWORD)(pBuff - pTemp);
  498. if(dwlen < 63)
  499. {
  500. *pBuff2++ = (BYTE)dwlen;
  501. goto T2;
  502. }
  503. *pBuff2++ = 0x3f;
  504. dwlen -= 63;
  505. while(dwlen >= 255)
  506. {
  507. *pBuff2++ = (BYTE)0xff;
  508. dwlen -= 255;
  509. }
  510. *pBuff2++ = (BYTE)dwlen;
  511. T2:
  512. pTemp = pBuff;
  513. }
  514. *pBuff2++ = (BYTE)0x80;
  515. dwDatalen = (DWORD)(pBuff2 - pBuff2o);
  516. // If the compressed bitmap size is larger than nomal bitmap size,
  517. // we don't compress
  518. if(dwDatalen > dwInLen) // full buffer
  519. {
  520. VERBOSE(("goto NO_COMP\r\n"));
  521. goto NO_COMP;
  522. }
  523. }
  524. while(--dwCounter);
  525. VERBOSE(("RLC2Comp() COMP Out---\r\n\r\n"));
  526. return dwDatalen;
  527. NO_COMP:
  528. VERBOSE(("RLC2Comp() NO_COMP Out---\r\n\r\n"));
  529. return 0;
  530. }
  531. //-------------------------------------------------------------------
  532. // OEMFilterGraphics
  533. // Action : Compress Bitmap Data
  534. //-------------------------------------------------------------------
  535. BOOL
  536. APIENTRY
  537. OEMFilterGraphics(
  538. PDEVOBJ pdevobj,
  539. PBYTE pBuf,
  540. DWORD dwLen
  541. )
  542. {
  543. POEMUD_EXTRADATA pOEM;
  544. INT i;
  545. BYTE Cmd[128];
  546. PBYTE pOutBuf;
  547. DWORD dwOutLen;
  548. BYTE jCompMethod;
  549. VERBOSE(("OEMFilterGraphics() In +++++++++++++++++++++++++++++\r\n"));
  550. //
  551. // verify pdevobj okay
  552. //
  553. if(!VALID_PDEVOBJ(pdevobj)) return FALSE;
  554. //
  555. // fill in printer commands
  556. //
  557. pOEM = (POEMUD_EXTRADATA)(pdevobj->pOEMDM);
  558. // Sanity check.
  559. if (!pBuf || pOEM->dwScanLen == 0 || pOEM->wRes == 0) {
  560. ERR(("Invalid parameter.\r\n"));
  561. return FALSE;
  562. }
  563. // Prepare temp. buffer for compression.
  564. #ifdef BYPASS
  565. if ((!pOEM->pCompBuf || pOEM->dwCompBufLen < dwLen) &&
  566. !(pOEM->fGeneral & FG_NO_COMP)){
  567. #else
  568. if (!pOEM->pCompBuf || pOEM->dwCompBufLen < dwLen) {
  569. #endif // BYPASS
  570. if (pOEM->pCompBuf) {
  571. FREEMEM(pOEM->pCompBuf);
  572. }
  573. pOEM->pCompBuf = ALLOCMEM(0,
  574. (dwLen << 1) + (dwLen / pOEM->dwScanLen),
  575. (ULONG)'NCDL');
  576. pOEM->dwCompBufLen = dwLen;
  577. }
  578. // Try compression methods.
  579. dwOutLen = 0;
  580. if (pOEM->pCompBuf != NULL) {
  581. pOutBuf = pOEM->pCompBuf;
  582. // Try RLC2 method;
  583. if (dwOutLen == 0) {
  584. if ((dwOutLen = RLC2Comp(pOutBuf, pBuf,
  585. dwLen, pOEM->dwScanLen)) > 0)
  586. jCompMethod = '5';
  587. }
  588. }
  589. if (dwOutLen == 0) {
  590. // Any of the Compression menthod faild.
  591. // We will send data to the printer withtout
  592. // compression.
  593. pOutBuf = pBuf;
  594. dwOutLen = dwLen;
  595. jCompMethod = '0'; // Without compression.
  596. }
  597. /* Send a draw coordinate command to the printer. */
  598. i = 0;
  599. i += memcopy(&Cmd[i], "\034e", 2);
  600. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestX);
  601. Cmd[i++] = ',';
  602. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestY);
  603. Cmd[i++] = '.';
  604. /* Save the present coordinate. */
  605. pOEM->dwDevicePrevX = pOEM->dwDeviceDestX;
  606. pOEM->dwDevicePrevY = pOEM->dwDeviceDestY;
  607. /* Send an image data draw command. */
  608. i += memcopy(&Cmd[i], "\034i", 2);
  609. i += iDwtoA(&Cmd[i], (pOEM->dwScanLen << 3));
  610. Cmd[i++] = ',';
  611. i += iDwtoA(&Cmd[i], (dwLen / pOEM->dwScanLen));
  612. Cmd[i++] = ',';
  613. Cmd[i++] = jCompMethod;
  614. i += memcopy(&Cmd[i], ",1/1,1/1,", 9);
  615. i += iDwtoA(&Cmd[i], dwOutLen);
  616. Cmd[i++] = ',';
  617. i += iDwtoA(&Cmd[i], (MASTER_UNIT / pOEM->wRes));
  618. Cmd[i++] = '.';
  619. WRITESPOOLBUF(pdevobj, Cmd, i);
  620. /* Send an image data */
  621. WRITESPOOLBUF(pdevobj, pOutBuf, dwOutLen);
  622. VERBOSE(("OEMFilterGraphics() Out-------------------------------\r\n\r\n"));
  623. return TRUE;
  624. }
  625. //-----------------------------------------------------------------------------
  626. //
  627. // Function: OEMCommandCallback
  628. //
  629. //-----------------------------------------------------------------------------
  630. INT
  631. APIENTRY
  632. OEMCommandCallback(
  633. PDEVOBJ pdevobj,
  634. DWORD dwCmdCbID,
  635. DWORD dwCount,
  636. PDWORD pdwParams
  637. )
  638. {
  639. INT i;
  640. BYTE *bp;
  641. BYTE Cmd[128];
  642. POEMUD_EXTRADATA pOEM;
  643. INT iRet;
  644. DWORD dwDeviceDestX, dwDeviceDestY;
  645. UINT gray;
  646. LONG copynum;
  647. BYTE CopyCmd[2];
  648. //
  649. // verify pdevobj okay
  650. //
  651. if(!VALID_PDEVOBJ(pdevobj)) return 0;
  652. //
  653. // fill in printer commands
  654. //
  655. i = 0;
  656. pOEM = (POEMUD_EXTRADATA)(pdevobj->pOEMDM);
  657. iRet = 0;
  658. /*
  659. * There are four kinds of draw modes of this driver.When entering a
  660. * new draw mode, it send the commands which ends the previous draw mode
  661. * at the same time.
  662. * 1.FLAG_RASTER - raster image mode.The condition not to enter
  663. * a vector mode and a text mode.
  664. * Default condition is RASTER in this driver
  665. * 2.FLAG_SBCS - single byte text mode. IN: FSa, OUT:FSR
  666. * 3.FLAG_DBCS - double byte text mode. IN: FSa, OUT:FSR
  667. * 4.FLAG_VECTOR - vector mode. IN: FSY, OUT:FSZ
  668. */
  669. switch (dwCmdCbID) {
  670. case CMD_ESORT_OFF:
  671. i = 0;
  672. i += memcopy(&Cmd[i],"@PJL SET COLLATE=OFF\x0D\x0A",22);
  673. WRITESPOOLBUF(pdevobj, Cmd, i);
  674. pOEM->ESort_mode = 0;
  675. break;
  676. case CMD_ESORT_ON:
  677. i = 0;
  678. i += memcopy(&Cmd[i],"@PJL SET COLLATE=ON\x0D\x0A",21);
  679. WRITESPOOLBUF(pdevobj, Cmd, i);
  680. pOEM->ESort_mode = 1;
  681. break;
  682. case CMD_DUPLEX_NONE:
  683. i = 0;
  684. i += memcopy(&Cmd[i], "\x1C'S,,",5);
  685. WRITESPOOLBUF(pdevobj, Cmd, i);
  686. pOEM->Duplex_mode = 0;
  687. break;
  688. case CMD_DUPLEX_VERTICAL:
  689. i = 0;
  690. i += memcopy(&Cmd[i], "\x1C'B",3);
  691. WRITESPOOLBUF(pdevobj, Cmd, i);
  692. pOEM->Duplex_mode = 1;
  693. break;
  694. case CMD_DUPLEX_HORIZONTAL:
  695. i = 0;
  696. i += memcopy(&Cmd[i], "\x1C'B",3);
  697. WRITESPOOLBUF(pdevobj, Cmd, i);
  698. pOEM->Duplex_mode = 2;
  699. break;
  700. case CMD_MAIN_BACK0:
  701. i = 0;
  702. pOEM->Duplex_OU = 0;
  703. break;
  704. case CMD_MAIN_BACK1:
  705. i = 0;
  706. i += memcopy(&Cmd[i], ",F,1",4);
  707. WRITESPOOLBUF(pdevobj, Cmd, i);
  708. pOEM->Duplex_OU = 1;
  709. break;
  710. case CMD_MAIN_BACK2:
  711. i = 0;
  712. i += memcopy(&Cmd[i], ",F,2",4);
  713. WRITESPOOLBUF(pdevobj, Cmd, i);
  714. pOEM->Duplex_OU = 2;
  715. break;
  716. case CMD_MAIN_BACK3:
  717. i = 0;
  718. i += memcopy(&Cmd[i], ",F,3",4);
  719. WRITESPOOLBUF(pdevobj, Cmd, i);
  720. pOEM->Duplex_OU = 3;
  721. break;
  722. case CMD_MAIN_BACK4:
  723. i = 0;
  724. i += memcopy(&Cmd[i], ",F,4",4);
  725. WRITESPOOLBUF(pdevobj, Cmd, i);
  726. pOEM->Duplex_OU = 4;
  727. break;
  728. case CMD_MAIN_BACK11:
  729. i = 0;
  730. i += memcopy(&Cmd[i], ",B,1",4);
  731. WRITESPOOLBUF(pdevobj, Cmd, i);
  732. pOEM->Duplex_OU = 5;
  733. break;
  734. case CMD_MAIN_BACK12:
  735. i = 0;
  736. i += memcopy(&Cmd[i], ",B,2",4);
  737. WRITESPOOLBUF(pdevobj, Cmd, i);
  738. pOEM->Duplex_OU = 6;
  739. break;
  740. case CMD_MAIN_BACK13:
  741. i = 0;
  742. i += memcopy(&Cmd[i], ",B,3",4);
  743. WRITESPOOLBUF(pdevobj, Cmd, i);
  744. pOEM->Duplex_OU = 7;
  745. break;
  746. case CMD_MAIN_BACK14:
  747. i = 0;
  748. i += memcopy(&Cmd[i], ",B,4",4);
  749. WRITESPOOLBUF(pdevobj, Cmd, i);
  750. pOEM->Duplex_OU = 8;
  751. break;
  752. case CMD_0:
  753. i = 0;
  754. i += memcopy(&Cmd[i], ",0.",3);
  755. WRITESPOOLBUF(pdevobj, Cmd, i);
  756. pOEM->Margin = 0;
  757. break;
  758. case CMD_1:
  759. i = 0;
  760. i += memcopy(&Cmd[i], ",1.",3);
  761. WRITESPOOLBUF(pdevobj, Cmd, i);
  762. pOEM->Margin = 1;
  763. break;
  764. case CMD_2:
  765. i = 0;
  766. i += memcopy(&Cmd[i], ",2.",3);
  767. WRITESPOOLBUF(pdevobj, Cmd, i);
  768. pOEM->Margin = 2;
  769. break;
  770. case CMD_3:
  771. i = 0;
  772. i += memcopy(&Cmd[i], ",3.",3);
  773. WRITESPOOLBUF(pdevobj, Cmd, i);
  774. pOEM->Margin = 3;
  775. break;
  776. case CMD_4:
  777. i = 0;
  778. i += memcopy(&Cmd[i], ",4.",3);
  779. WRITESPOOLBUF(pdevobj, Cmd, i);
  780. pOEM->Margin = 4;
  781. break;
  782. case CMD_5:
  783. i = 0;
  784. i += memcopy(&Cmd[i], ",5.",3);
  785. WRITESPOOLBUF(pdevobj, Cmd, i);
  786. pOEM->Margin = 4;
  787. break;
  788. case CMD_6:
  789. i = 0;
  790. i += memcopy(&Cmd[i], ",6.",3);
  791. WRITESPOOLBUF(pdevobj, Cmd, i);
  792. pOEM->Margin = 6;
  793. break;
  794. case CMD_7:
  795. i = 0;
  796. i += memcopy(&Cmd[i], ",7.",3);
  797. WRITESPOOLBUF(pdevobj, Cmd, i);
  798. pOEM->Margin = 7;
  799. break;
  800. case CMD_8:
  801. i = 0;
  802. i += memcopy(&Cmd[i], ",8.",3);
  803. WRITESPOOLBUF(pdevobj, Cmd, i);
  804. pOEM->Margin = 8;
  805. break;
  806. case CMD_9:
  807. i = 0;
  808. i += memcopy(&Cmd[i], ",9.",3);
  809. WRITESPOOLBUF(pdevobj, Cmd, i);
  810. pOEM->Margin = 9;
  811. break;
  812. case CMD_10:
  813. i = 0;
  814. i += memcopy(&Cmd[i], ",10.",4);
  815. WRITESPOOLBUF(pdevobj, Cmd, i);
  816. pOEM->Margin = 10;
  817. break;
  818. case CMD_11:
  819. i = 0;
  820. i += memcopy(&Cmd[i], ",11.",4);
  821. WRITESPOOLBUF(pdevobj, Cmd, i);
  822. pOEM->Margin = 11;
  823. break;
  824. case CMD_12:
  825. i = 0;
  826. i += memcopy(&Cmd[i], ",12.",4);
  827. WRITESPOOLBUF(pdevobj, Cmd, i);
  828. pOEM->Margin = 12;
  829. break;
  830. case CMD_13:
  831. i = 0;
  832. i += memcopy(&Cmd[i], ",13.",4);
  833. WRITESPOOLBUF(pdevobj, Cmd, i);
  834. pOEM->Margin = 13;
  835. break;
  836. case CMD_14:
  837. i = 0;
  838. i += memcopy(&Cmd[i], ",14.",4);
  839. WRITESPOOLBUF(pdevobj, Cmd, i);
  840. pOEM->Margin = 14;
  841. break;
  842. case CMD_15:
  843. i = 0;
  844. i += memcopy(&Cmd[i], ",15.",4);
  845. WRITESPOOLBUF(pdevobj, Cmd, i);
  846. pOEM->Margin = 15;
  847. break;
  848. case CMD_16:
  849. i = 0;
  850. i += memcopy(&Cmd[i], ",16.",4);
  851. WRITESPOOLBUF(pdevobj, Cmd, i);
  852. pOEM->Margin = 16;
  853. break;
  854. case CMD_17:
  855. i = 0;
  856. i += memcopy(&Cmd[i], ",17.",4);
  857. WRITESPOOLBUF(pdevobj, Cmd, i);
  858. pOEM->Margin = 17;
  859. break;
  860. case CMD_18:
  861. i = 0;
  862. i += memcopy(&Cmd[i], ",18.",4);
  863. WRITESPOOLBUF(pdevobj, Cmd, i);
  864. pOEM->Margin = 18;
  865. break;
  866. case CMD_19:
  867. i = 0;
  868. i += memcopy(&Cmd[i], ",19.",4);
  869. WRITESPOOLBUF(pdevobj, Cmd, i);
  870. pOEM->Margin = 19;
  871. break;
  872. case CMD_20:
  873. i = 0;
  874. i += memcopy(&Cmd[i], ",20.",4);
  875. WRITESPOOLBUF(pdevobj, Cmd, i);
  876. pOEM->Margin = 20;
  877. break;
  878. case CMD_SORT_NONE:
  879. case CMD_SORT_COPY:
  880. case CMD_SORT_SORT:
  881. case CMD_SORT_BIN:
  882. case CMD_SORT_STACK:
  883. i = 0;
  884. goto dup;
  885. case CMD_DUPLEX_A1_600:
  886. case CMD_DUPLEX_A2_600:
  887. i = 0;
  888. i += memcopy(&Cmd[i], "\x1B\x63\x31\x1C&600.\x1C\x64\x32\x34\x30.",15);
  889. if(!pdwParams) return 0;
  890. copynum = PARAM(pdwParams, 0);
  891. if( pOEM->ESort_mode == 1){
  892. copynumber(&CopyCmd[0],copynum);
  893. }
  894. else{
  895. copynum = 1;
  896. CopyCmd[0] = 0x31;
  897. }
  898. i += memcopy(&Cmd[i],"\x1C\x78",2);
  899. if(copynum < 10 ){
  900. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  901. }else{
  902. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  903. i += memcopy(&Cmd[i],&CopyCmd[1],1);
  904. }
  905. i += memcopy(&Cmd[i], ".\x1C&600.",7);
  906. goto dup;
  907. case CMD_DUPLEX_A1_400:
  908. case CMD_DUPLEX_A2_400:
  909. i = 0;
  910. i += memcopy(&Cmd[i], "\x1B\x63\x31\x1C&400.\x1C\x64\x32\x34\x30.",15);
  911. if(!pdwParams) return 0;
  912. copynum = PARAM(pdwParams, 0);
  913. if( pOEM->ESort_mode == 1 ){
  914. copynumber(&CopyCmd[0],copynum);
  915. }
  916. else{
  917. copynum = 1;
  918. CopyCmd[0] = 0x31;
  919. }
  920. i += memcopy(&Cmd[i],"\x1C\x78",2);
  921. if(copynum < 10 ){
  922. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  923. }else{
  924. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  925. i += memcopy(&Cmd[i],&CopyCmd[1],1);
  926. }
  927. i += memcopy(&Cmd[i], ".\x1C&400.",7);
  928. goto dup;
  929. case CMD_DUPLEX_A1_300:
  930. case CMD_DUPLEX_A2_300:
  931. i = 0;
  932. i += memcopy(&Cmd[i], "\x1B\x63\x31\x1C&300.\x1C\x64\x32\x34\x30.",15);
  933. if(!pdwParams) return 0;
  934. copynum = PARAM(pdwParams, 0);
  935. if( pOEM->ESort_mode == 1){
  936. copynumber(&CopyCmd[0],copynum);
  937. }
  938. else{
  939. copynum = 1;
  940. CopyCmd[0] = 0x31;
  941. }
  942. i += memcopy(&Cmd[i],"\x1C\x78",2);
  943. if(copynum < 10 ){
  944. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  945. }else{
  946. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  947. i += memcopy(&Cmd[i],&CopyCmd[1],1);
  948. }
  949. i += memcopy(&Cmd[i], ".\x1C&300.",7);
  950. goto dup;
  951. case CMD_DUPLEX_A1_240:
  952. case CMD_DUPLEX_A2_240:
  953. i = 0;
  954. i += memcopy(&Cmd[i], "\x1B\x63\x31\x1C&240.\x1C\x64\x32\x34\x30.",15);
  955. if(!pdwParams) return 0;
  956. copynum = PARAM(pdwParams, 0);
  957. if( pOEM->ESort_mode == 1){
  958. copynumber(&CopyCmd[0],copynum);
  959. }
  960. else{
  961. CopyCmd[0] = 0x31;
  962. copynum = 1;
  963. }
  964. i += memcopy(&Cmd[i],"\x1C\x78",2);
  965. if(copynum < 10 ){
  966. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  967. }else{
  968. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  969. i += memcopy(&Cmd[i],&CopyCmd[1],1);
  970. }
  971. i += memcopy(&Cmd[i], ".\x1C&240.",7);
  972. goto dup;
  973. case CMD_DUPLEX_A1_200:
  974. case CMD_DUPLEX_A2_200:
  975. i = 0;
  976. i += memcopy(&Cmd[i], "\x1B\x63\x31\x1C&200.\x1C\x64\x32\x34\x30.",15);
  977. if(!pdwParams) return 0;
  978. copynum = PARAM(pdwParams, 0);
  979. if( pOEM->ESort_mode == 1){
  980. copynumber(&CopyCmd[0],copynum);
  981. }
  982. else{
  983. copynum = 1;
  984. CopyCmd[0] = 0x31;
  985. }
  986. i += memcopy(&Cmd[i],"\x1C\x78",2);
  987. if(copynum < 10 ){
  988. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  989. }else{
  990. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  991. i += memcopy(&Cmd[i],&CopyCmd[1],1);
  992. }
  993. i += memcopy(&Cmd[i], ".\x1C&200.",7);
  994. goto dup;
  995. case CMD_DUPLEX_A3_600:
  996. case CMD_DUPLEX_A3_400:
  997. case CMD_DUPLEX_A3_300:
  998. case CMD_DUPLEX_A3_240:
  999. case CMD_DUPLEX_A3_200:
  1000. i = 0;
  1001. i += memcopy(&Cmd[i], "\x1C&0.\x1B\x63\x31",7);
  1002. goto dup;
  1003. case CMD_JIS_90:
  1004. case CMD_JIS_78:
  1005. goto dup;
  1006. dup:
  1007. {
  1008. if( pOEM->Duplex_mode == 0 ){
  1009. i += memcopy(&Cmd[i], "\x1C'S,,",5);
  1010. }else{
  1011. i += memcopy(&Cmd[i], "\x1C'B",3);
  1012. }
  1013. if( pOEM->Duplex_OU == 1 ){
  1014. i += memcopy(&Cmd[i], ",F,1",4);
  1015. }
  1016. if( pOEM->Duplex_OU == 2 ){
  1017. i += memcopy(&Cmd[i], ",F,2",4);
  1018. }
  1019. if( pOEM->Duplex_OU == 3 ){
  1020. i += memcopy(&Cmd[i], ",F,3",4);
  1021. }
  1022. if( pOEM->Duplex_OU == 4 ){
  1023. i += memcopy(&Cmd[i], ",F,4",4);
  1024. }
  1025. if( pOEM->Duplex_OU == 5 ){
  1026. i += memcopy(&Cmd[i], ",B,1",4);
  1027. }
  1028. if( pOEM->Duplex_OU == 6 ){
  1029. i += memcopy(&Cmd[i], ",B,2",4);
  1030. }
  1031. if( pOEM->Duplex_OU == 7 ){
  1032. i += memcopy(&Cmd[i], ",B,3",4);
  1033. }
  1034. if( pOEM->Duplex_OU == 8 ){
  1035. i += memcopy(&Cmd[i], ",B,4",4);
  1036. }
  1037. if( pOEM->Margin == 0 ){
  1038. i += memcopy(&Cmd[i], ",0.",3);
  1039. }
  1040. if( pOEM->Margin == 1 ){
  1041. i += memcopy(&Cmd[i], ",1.",3);
  1042. }
  1043. if( pOEM->Margin == 2 ){
  1044. i += memcopy(&Cmd[i], ",2.",3);
  1045. }
  1046. if( pOEM->Margin == 3 ){
  1047. i += memcopy(&Cmd[i], ",3.",3);
  1048. }
  1049. if( pOEM->Margin == 4 ){
  1050. i += memcopy(&Cmd[i], ",4.",3);
  1051. }
  1052. if( pOEM->Margin == 5 ){
  1053. i += memcopy(&Cmd[i], ",5.",3);
  1054. }
  1055. if( pOEM->Margin == 6 ){
  1056. i += memcopy(&Cmd[i], ",6.",3);
  1057. }
  1058. if( pOEM->Margin == 7 ){
  1059. i += memcopy(&Cmd[i], ",7.",3);
  1060. }
  1061. if( pOEM->Margin == 8 ){
  1062. i += memcopy(&Cmd[i], ",8.",3);
  1063. }
  1064. if( pOEM->Margin == 9 ){
  1065. i += memcopy(&Cmd[i], ",9.",3);
  1066. }
  1067. if( pOEM->Margin == 10 ){
  1068. i += memcopy(&Cmd[i], ",10.",4);
  1069. }
  1070. if( pOEM->Margin == 11 ){
  1071. i += memcopy(&Cmd[i], ",11.",4);
  1072. }
  1073. if( pOEM->Margin == 12 ){
  1074. i += memcopy(&Cmd[i], ",12.",4);
  1075. }
  1076. if( pOEM->Margin == 13 ){
  1077. i += memcopy(&Cmd[i], ",13.",4);
  1078. }
  1079. if( pOEM->Margin == 14 ){
  1080. i += memcopy(&Cmd[i], ",14.",4);
  1081. }
  1082. if( pOEM->Margin == 15 ){
  1083. i += memcopy(&Cmd[i], ",15.",4);
  1084. }
  1085. if( pOEM->Margin == 16 ){
  1086. i += memcopy(&Cmd[i], ",16.",4);
  1087. }
  1088. if( pOEM->Margin == 17 ){
  1089. i += memcopy(&Cmd[i], ",17.",4);
  1090. }
  1091. if( pOEM->Margin == 18 ){
  1092. i += memcopy(&Cmd[i], ",18.",4);
  1093. }
  1094. if( pOEM->Margin == 19 ){
  1095. i += memcopy(&Cmd[i], ",19.",4);
  1096. }
  1097. if( pOEM->Margin == 20 ){
  1098. i += memcopy(&Cmd[i], ",20.",4);
  1099. }
  1100. switch (dwCmdCbID) {
  1101. case CMD_DUPLEX_A2_600:
  1102. i += memcopy(&Cmd[i], "\x1C\x66PAI.\x0C\x0D\x0A\x1B\x63\x31\x1C&600.\x1C\x64\x32\x34\x30.",24);
  1103. break;
  1104. case CMD_DUPLEX_A2_400:
  1105. i += memcopy(&Cmd[i], "\x1C\x66PAI.\x0C\x0D\x0A\x1B\x63\x31\x1C&400.\x1C\x64\x32\x34\x30.",24);
  1106. break;
  1107. case CMD_DUPLEX_A2_300:
  1108. i += memcopy(&Cmd[i], "\x1C\x66PAI.\x0C\x0D\x0A\x1B\x63\x31\x1C&300.\x1C\x64\x32\x34\x30.",24);
  1109. break;
  1110. case CMD_DUPLEX_A2_240:
  1111. i += memcopy(&Cmd[i], "\x1C\x66PAI.\x0C\x0D\x0A\x1B\x63\x31\x1C&240.\x1C\x64\x32\x34\x30.",24);
  1112. break;
  1113. case CMD_DUPLEX_A2_200:
  1114. i += memcopy(&Cmd[i], "\x1C\x66PAI.\x0C\x0D\x0A\x1B\x63\x31\x1C&200.\x1C\x64\x32\x34\x30.",24);
  1115. break;
  1116. case CMD_DUPLEX_A3_600:
  1117. if(!pdwParams) return 0;
  1118. copynum = PARAM(pdwParams, 0);
  1119. if( pOEM->ESort_mode == 1){
  1120. copynumber(&CopyCmd[0],copynum);
  1121. }
  1122. else{
  1123. copynum = 1;
  1124. CopyCmd[0] = 0x31;
  1125. }
  1126. i += memcopy(&Cmd[i],"\x1C\x78",2);
  1127. if(copynum < 10 ){
  1128. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  1129. }else{
  1130. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  1131. i += memcopy(&Cmd[i],&CopyCmd[1],1);
  1132. }
  1133. i += memcopy(&Cmd[i], ".\x1C&600.\x1C\x66PAI.\x0D\x0A",15);
  1134. break;
  1135. case CMD_DUPLEX_A3_400:
  1136. if(!pdwParams) return 0;
  1137. copynum = PARAM(pdwParams, 0);
  1138. if( pOEM->ESort_mode == 1){
  1139. copynumber(&CopyCmd[0],copynum);
  1140. }
  1141. else{
  1142. copynum = 1;
  1143. CopyCmd[0] = 0x31;
  1144. }
  1145. i += memcopy(&Cmd[i],"\x1C\x78",2);
  1146. if(copynum < 10 ){
  1147. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  1148. }else{
  1149. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  1150. i += memcopy(&Cmd[i],&CopyCmd[1],1);
  1151. }
  1152. i += memcopy(&Cmd[i], ".\x1C&400.\x1C\x66PAI.\x0D\x0A",15);
  1153. break;
  1154. case CMD_DUPLEX_A3_300:
  1155. i += memcopy(&Cmd[i], "\x1C\x78\x31.\x1C&300.\x1C\x66PAI.\x0D\x0A",18);
  1156. break;
  1157. case CMD_DUPLEX_A3_240:
  1158. if(!pdwParams) return 0;
  1159. copynum = PARAM(pdwParams, 0);
  1160. if( pOEM->ESort_mode == 1){
  1161. copynumber(&CopyCmd[0],copynum);
  1162. }
  1163. else{
  1164. copynum = 1;
  1165. CopyCmd[0] = 0x31;
  1166. }
  1167. i += memcopy(&Cmd[i],"\x1C\x78",2);
  1168. if(copynum < 10 ){
  1169. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  1170. }else{
  1171. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  1172. i += memcopy(&Cmd[i],&CopyCmd[1],1);
  1173. }
  1174. i += memcopy(&Cmd[i], ".\x1C&240.\x1C\x66PAI.\x0D\x0A",15);
  1175. break;
  1176. case CMD_DUPLEX_A3_200:
  1177. if(!pdwParams) return 0;
  1178. copynum = PARAM(pdwParams, 0);
  1179. if( pOEM->ESort_mode == 1){
  1180. copynumber(&CopyCmd[0],copynum);
  1181. }
  1182. else{
  1183. copynum = 1;
  1184. CopyCmd[0] = 0x31;
  1185. }
  1186. i += memcopy(&Cmd[i],"\x1C\x78",2);
  1187. if(copynum < 10 ){
  1188. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  1189. }else{
  1190. i += memcopy(&Cmd[i],&CopyCmd[0],1);
  1191. i += memcopy(&Cmd[i],&CopyCmd[1],1);
  1192. }
  1193. i += memcopy(&Cmd[i], ".\x1C&200.\x1C\x66PAI.\x0D\x0A",15);
  1194. break;
  1195. case CMD_SORT_NONE:
  1196. i += memcopy(&Cmd[i], "\x1C\x25\x45,1",5);
  1197. break;
  1198. case CMD_SORT_COPY:
  1199. i += memcopy(&Cmd[i], "\x1C\x25\x43,1",5);
  1200. break;
  1201. case CMD_SORT_SORT:
  1202. i += memcopy(&Cmd[i], "\x1C\x25\x53,1",5);
  1203. break;
  1204. case CMD_SORT_BIN:
  1205. i += memcopy(&Cmd[i], "\x1C\x25\x42,1",5);
  1206. break;
  1207. case CMD_SORT_STACK:
  1208. i += memcopy(&Cmd[i], "\x1C\x25\x54,1",5);
  1209. break;
  1210. case CMD_JIS_90:
  1211. i += memcopy(&Cmd[i], "\x1C\x30\x35\x46\x32-\x30\x32",8);
  1212. break;
  1213. case CMD_JIS_78:
  1214. i += memcopy(&Cmd[i], "\x1C\x30\x35\x46\x32-\x30\x30",8);
  1215. break;
  1216. }
  1217. switch (dwCmdCbID) {
  1218. case CMD_DUPLEX_A3_600:
  1219. case CMD_DUPLEX_A3_400:
  1220. case CMD_DUPLEX_A3_300:
  1221. case CMD_DUPLEX_A3_240:
  1222. case CMD_DUPLEX_A3_200:
  1223. i += memcopy(&Cmd[i], "\x0C\x1B\x63\x31\x1B\x25-12345X@PJL EOJ\x0D\x0A@PJL ENTER LANGUAGE=DEFAULT\x0D\x0A",52);
  1224. break;
  1225. }
  1226. WRITESPOOLBUF(pdevobj, Cmd, i);
  1227. break;
  1228. }
  1229. case CMD_CR:
  1230. pOEM->dwDeviceDestX = 0;
  1231. WRITESPOOLBUF(pdevobj, "\015", 1);
  1232. break;
  1233. case CMD_MOVE_X:
  1234. case CMD_MOVE_Y:
  1235. if (dwCount < 4)
  1236. return 0; // cannot do anything
  1237. if( pdwParams && PARAM(pdwParams, 2) && PARAM(pdwParams, 3) ) {
  1238. pOEM->dwDeviceDestX = PARAM(pdwParams, 0) /
  1239. (MASTER_UNIT / PARAM(pdwParams, 2));
  1240. pOEM->dwDeviceDestY = PARAM(pdwParams, 1) /
  1241. (MASTER_UNIT / PARAM(pdwParams, 3));
  1242. } else
  1243. return 0;
  1244. // Set return value
  1245. switch (dwCmdCbID) {
  1246. case CMD_MOVE_X:
  1247. iRet = (INT)pOEM->dwDeviceDestX;
  1248. break;
  1249. case CMD_MOVE_Y:
  1250. iRet = (INT)pOEM->dwDeviceDestY;
  1251. break;
  1252. }
  1253. break;
  1254. case CMD_RES_600:
  1255. i = 0;
  1256. i += memcopy(&Cmd[i], "\x1C<1/600,i.\x1CYSC;SU1,600,0;PM1,1;SG0;\x1CZ", 37);
  1257. WRITESPOOLBUF(pdevobj, Cmd, i);
  1258. pOEM->wRes = MASTER_UNIT / 600;
  1259. break;
  1260. case CMD_RES_400:
  1261. i = 0;
  1262. i += memcopy(&Cmd[i], "\x1C<1/400,i.\x1CYSC;SU1,400,0;PM1,1;SG0;\x1CZ", 37);
  1263. WRITESPOOLBUF(pdevobj, Cmd, i);
  1264. pOEM->wRes = MASTER_UNIT / 400;
  1265. break;
  1266. case CMD_RES_240:
  1267. i = 0;
  1268. i += memcopy(&Cmd[i], "\x1C<1/240,i.\x1CYSC;SU1,240,0;PM1,1;SG0;\x1CZ", 37);
  1269. WRITESPOOLBUF(pdevobj, Cmd, i);
  1270. pOEM->wRes = MASTER_UNIT / 240;
  1271. break;
  1272. case CMD_RES_300:
  1273. i = 0;
  1274. i += memcopy(&Cmd[i], "\x1C<1/300,i.\x1CYSC;SU1,300,0;PM1,1;SG0;\x1CZ", 37);
  1275. WRITESPOOLBUF(pdevobj, Cmd, i);
  1276. pOEM->wRes = MASTER_UNIT / 300;
  1277. break;
  1278. case CMD_RES_200:
  1279. i = 0;
  1280. i += memcopy(&Cmd[i], "\x1C<1/200,i.\x1CYSC;SU1,200,0;PM1,1;SG0;\x1CZ", 37);
  1281. WRITESPOOLBUF(pdevobj, Cmd, i);
  1282. pOEM->wRes = MASTER_UNIT / 200;
  1283. break;
  1284. case CMD_BEGIN_RASTER:
  1285. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1286. i = 0;
  1287. i += memcopy(&Cmd[i], "EP;FL;\034Z", 8);
  1288. WRITESPOOLBUF(pdevobj, Cmd, i);
  1289. pOEM->wCurrentAddMode = FLAG_RASTER;
  1290. }
  1291. else if (pOEM->wCurrentAddMode == FLAG_SBCS ||
  1292. pOEM->wCurrentAddMode == FLAG_DBCS){
  1293. i = 0;
  1294. i += memcopy(&Cmd[i], "\034R", 2);
  1295. WRITESPOOLBUF(pdevobj, Cmd, i);
  1296. pOEM->wCurrentAddMode = FLAG_RASTER;
  1297. }
  1298. break;
  1299. case CMD_SEND_BLOCK_DATA:
  1300. // Rememter length of the scan line.
  1301. if(!pdwParams) return 0;
  1302. pOEM->dwScanLen = PARAM(pdwParams, 0);
  1303. break;
  1304. #ifdef BYPASS
  1305. case CMD_BEGIN_RASTER_NO_COMP:
  1306. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1307. i = 0;
  1308. i += memcopy(&Cmd[i], "EP;FL;\034Z", 8);
  1309. WRITESPOOLBUF(pdevobj, Cmd, i);
  1310. pOEM->wCurrentAddMode = FLAG_RASTER;
  1311. }
  1312. else if (pOEM->wCurrentAddMode == FLAG_SBCS ||
  1313. pOEM->wCurrentAddMode == FLAG_DBCS){
  1314. i = 0;
  1315. i += memcopy(&Cmd[i], "\034R", 2);
  1316. WRITESPOOLBUF(pdevobj, Cmd, i);
  1317. pOEM->wCurrentAddMode = FLAG_RASTER;
  1318. }
  1319. pOEM->fGeneral |= FG_NO_COMP;
  1320. break;
  1321. #endif // BYPASS
  1322. case CMD_PC_PRN_DIRECTION:
  1323. {
  1324. LONG lEsc90;
  1325. LONG ESin[] = {0, 1, 0, -1};
  1326. LONG ECos[] = {1, 0, -1, 0};
  1327. if(!pdwParams) return 0;
  1328. lEsc90 = (PARAM(pdwParams, 0) % 360) / 90;
  1329. pOEM->lSBCSXMove = pOEM->dwSBCSX * ECos[lEsc90];
  1330. pOEM->lSBCSYMove = -(LONG)pOEM->dwSBCSX * ESin[lEsc90];
  1331. pOEM->lDBCSXMove = pOEM->dwDBCSX * ECos[lEsc90];
  1332. pOEM->lDBCSYMove = -(LONG)pOEM->dwDBCSX * ESin[lEsc90];
  1333. }
  1334. break;
  1335. case CMD_FF:
  1336. i = 0;
  1337. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1338. i += memcopy(&Cmd[i], "EP;FL;\x1CZ\x0D\x0C", 10);
  1339. WRITESPOOLBUF(pdevobj, Cmd, i);
  1340. pOEM->wCurrentAddMode = FLAG_RASTER;
  1341. }
  1342. else if (pOEM->wCurrentAddMode == FLAG_SBCS ||
  1343. pOEM->wCurrentAddMode == FLAG_DBCS){
  1344. i += memcopy(&Cmd[i], "\x1CR\x0D\x0C", 4);
  1345. WRITESPOOLBUF(pdevobj, Cmd, i);
  1346. pOEM->wCurrentAddMode = FLAG_RASTER;
  1347. }
  1348. else{
  1349. i += memcopy(&Cmd[i], "\x0D\x0C", 2);
  1350. WRITESPOOLBUF(pdevobj, Cmd, i);
  1351. pOEM->wCurrentAddMode = FLAG_RASTER;
  1352. }
  1353. break;
  1354. case CMD_INIT_COORDINATE:
  1355. pOEM->dwDeviceDestX = 0;
  1356. pOEM->dwDeviceDestY = 0;
  1357. pOEM->wCurrentAddMode = FLAG_RASTER;
  1358. pOEM->cSubPath = 0;
  1359. break;
  1360. case CMD_WHITE_ON:
  1361. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1362. i = 0;
  1363. i += memcopy(&Cmd[i], "EP;FL;\034Z", 8);
  1364. pOEM->wCurrentAddMode = FLAG_RASTER;
  1365. }
  1366. i += memcopy(&Cmd[i], "\034\"R.\034$100.", 10);
  1367. WRITESPOOLBUF(pdevobj, Cmd, i);
  1368. break;
  1369. case CMD_WHITE_OFF:
  1370. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1371. i = 0;
  1372. i += memcopy(&Cmd[i], "EP;FL;\034Z", 8);
  1373. pOEM->wCurrentAddMode = FLAG_RASTER;
  1374. }
  1375. i += memcopy(&Cmd[i], "\034\"O.\034$0.", 8);
  1376. WRITESPOOLBUF(pdevobj, Cmd, i);
  1377. break;
  1378. case CMD_BOLD_ON:
  1379. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1380. i = 0;
  1381. i += memcopy(&Cmd[i], "EP;FL;\034Z", 8);
  1382. pOEM->wCurrentAddMode = FLAG_RASTER;
  1383. }
  1384. i += memcopy(&Cmd[i], "\034c,,1.", 6);
  1385. WRITESPOOLBUF(pdevobj, Cmd, i);
  1386. break;
  1387. case CMD_ITALIC_ON:
  1388. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1389. i = 0;
  1390. i += memcopy(&Cmd[i], "EP;FL;\034Z", 8);
  1391. pOEM->wCurrentAddMode = FLAG_RASTER;
  1392. }
  1393. i += memcopy(&Cmd[i], "\034c,,2.", 6);
  1394. WRITESPOOLBUF(pdevobj, Cmd, i);
  1395. break;
  1396. case CMD_CLEAR_ATTRIB_P:
  1397. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1398. i = 0;
  1399. i += memcopy(&Cmd[i], "EP;FL;\034Z", 8);
  1400. pOEM->wCurrentAddMode = FLAG_RASTER;
  1401. }
  1402. i += memcopy(&Cmd[i], "\034c,,0,80.", 9);
  1403. WRITESPOOLBUF(pdevobj, Cmd, i);
  1404. break;
  1405. case CMD_RECTWIDTH:
  1406. if(!pdwParams || !pOEM->wRes ) return 0;
  1407. pOEM->dwRectWidth = PARAM(pdwParams, 0) / pOEM->wRes;
  1408. break;
  1409. case CMD_RECTHEIGHT:
  1410. if(!pdwParams || !pOEM->wRes ) return 0;
  1411. pOEM->dwRectHeight = PARAM(pdwParams, 0) / pOEM->wRes;
  1412. break;
  1413. case CMD_RECTWHITE:
  1414. gray = 100;
  1415. goto fill;
  1416. case CMD_RECTBLACK:
  1417. gray = 0;
  1418. goto fill;
  1419. case CMD_RECTGRAY:
  1420. if(!pdwParams) return 0;
  1421. gray = 100 - PARAM(pdwParams, 0);
  1422. goto fill;
  1423. fill:
  1424. {
  1425. // add 2000.12.28
  1426. // if rectangle size is zeor,we do not draw.
  1427. if(pOEM->dwRectWidth - 1 < 1 && pOEM->dwRectHeight - 1 < 1)
  1428. break;
  1429. i = 0;
  1430. /* Raster mode -> Vector mode in */
  1431. if (pOEM->wCurrentAddMode == FLAG_RASTER){
  1432. i += memcopy(&Cmd[i], "\x1CY", 2);
  1433. pOEM->wCurrentAddMode = FLAG_VECTOR;
  1434. if(pOEM->iGray != gray){
  1435. i += memcopy(&Cmd[i], "SG", 2); // Send Gray Scale
  1436. i += iDwtoA(&Cmd[i], gray);
  1437. Cmd[i++] = ';';
  1438. pOEM->iGray = gray;
  1439. }
  1440. i += memcopy(&Cmd[i], "NP;", 3);
  1441. pOEM->cSubPath = 0;
  1442. }
  1443. /* Text mode -> Vector mode in */
  1444. else if (pOEM->wCurrentAddMode == FLAG_SBCS ||
  1445. pOEM->wCurrentAddMode == FLAG_DBCS){
  1446. i += memcopy(&Cmd[i], "\x1CR\x1CY", 4);
  1447. pOEM->wCurrentAddMode = FLAG_VECTOR;
  1448. if(pOEM->iGray != gray){
  1449. i += memcopy(&Cmd[i], "SG", 2); // Send Gray Scale
  1450. i += iDwtoA(&Cmd[i], gray);
  1451. Cmd[i++] = ';';
  1452. pOEM->iGray = gray;
  1453. }
  1454. i += memcopy(&Cmd[i], "NP;", 3);
  1455. pOEM->cSubPath = 0;
  1456. }
  1457. /* add 2000.12.28 */
  1458. /* Already Vector mode and gray scale changed or
  1459. sub path count is over 500 */
  1460. if(pOEM->iGray != gray){
  1461. i += memcopy(&Cmd[i], "EP;FL;SG", 8);
  1462. i += iDwtoA(&Cmd[i], gray);
  1463. i += memcopy(&Cmd[i], ";NP;", 4);
  1464. pOEM->iGray = gray;
  1465. pOEM->cSubPath = 0;
  1466. }
  1467. else if(pOEM->cSubPath >= MAX_SUBPATH){
  1468. i += memcopy(&Cmd[i], "EP;FL;", 6);
  1469. i += memcopy(&Cmd[i], "NP;", 3);
  1470. pOEM->cSubPath = 0;
  1471. }
  1472. i += memcopy(&Cmd[i], "MA", 2);
  1473. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestX);
  1474. Cmd[i++] = ',';
  1475. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestY);
  1476. i += memcopy(&Cmd[i], ";PR", 3);
  1477. i += iDwtoA(&Cmd[i], pOEM->dwRectWidth - 1);
  1478. i += memcopy(&Cmd[i], ",0,0,", 5);
  1479. i += iDwtoA(&Cmd[i], pOEM->dwRectHeight - 1);
  1480. i += memcopy(&Cmd[i], ",-", 2);
  1481. i += iDwtoA(&Cmd[i], pOEM->dwRectWidth - 1);
  1482. i += memcopy(&Cmd[i], ",0;CP;", 6);
  1483. pOEM->cSubPath+=4; // rect is built by 4 line
  1484. pOEM->cSubPath = MAX_SUBPATH;
  1485. /* send RectFill command */
  1486. WRITESPOOLBUF(pdevobj, Cmd, i);
  1487. }
  1488. break;
  1489. }
  1490. return iRet;
  1491. }
  1492. //-----------------------------------------------------------------------------
  1493. //
  1494. // Function: OEMSendFontCmd
  1495. //
  1496. //-----------------------------------------------------------------------------
  1497. VOID
  1498. APIENTRY
  1499. OEMSendFontCmd(
  1500. PDEVOBJ pdevobj,
  1501. PUNIFONTOBJ pUFObj,
  1502. PFINVOCATION pFInv)
  1503. {
  1504. PGETINFO_STDVAR pSV;
  1505. DWORD adwStdVariable[2+2*4]; // it means dwSize + dwNumOfVariable +
  1506. // (dwStdVarID + lStdVariable) * n
  1507. DWORD dwIn, dwOut;
  1508. PBYTE pubCmd;
  1509. BYTE aubCmd[128];
  1510. POEMUD_EXTRADATA pOEM;
  1511. DWORD tmpPointsx, tmpPointsy;
  1512. PIFIMETRICS pIFI;
  1513. DWORD dwNeeded;
  1514. DWORD dwCount;
  1515. BOOL bFound = FALSE;
  1516. VERBOSE(("OEMSendFontCmd() entry.\r\n"));
  1517. VERBOSE((("CMD size:%ld\r\n"), pFInv->dwCount));
  1518. if(!pFInv->dwCount){
  1519. VERBOSE(("CMD size is Zero return\r\n"));
  1520. return;
  1521. }
  1522. pubCmd = pFInv->pubCommand;
  1523. dwCount = pFInv->dwCount;
  1524. pOEM = (POEMUD_EXTRADATA)(pdevobj->pOEMDM);
  1525. pIFI = pUFObj->pIFIMetrics;
  1526. //
  1527. // Get standard variables.
  1528. //
  1529. pSV = (PGETINFO_STDVAR)adwStdVariable;
  1530. pSV->dwSize = sizeof(GETINFO_STDVAR) + 2 * sizeof(DWORD) * (4 - 1);
  1531. pSV->dwNumOfVariable = 4;
  1532. pSV->StdVar[0].dwStdVarID = FNT_INFO_FONTHEIGHT;
  1533. pSV->StdVar[1].dwStdVarID = FNT_INFO_FONTWIDTH;
  1534. pSV->StdVar[2].dwStdVarID = FNT_INFO_TEXTYRES;
  1535. pSV->StdVar[3].dwStdVarID = FNT_INFO_TEXTXRES;
  1536. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_STDVARIABLE, pSV,
  1537. pSV->dwSize, &dwNeeded)) {
  1538. ERR(("UFO_GETINFO_STDVARIABLE failed.\r\n"));
  1539. return;
  1540. }
  1541. VERBOSE((("FONTHEIGHT=%d\r\n"), pSV->StdVar[0].lStdVariable));
  1542. VERBOSE((("FONTWIDTH=%d\r\n"), pSV->StdVar[1].lStdVariable));
  1543. if( !pSV->StdVar[2].lStdVariable ) return;
  1544. tmpPointsy = pSV->StdVar[0].lStdVariable * 720 / pSV->StdVar[2].lStdVariable;
  1545. dwIn = dwOut = 0;
  1546. /* vector mode ends.*/
  1547. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1548. dwOut += memcopy(&aubCmd[dwOut], "EP;FL;\034Z", 8);
  1549. }
  1550. /* make font select command */
  1551. while(dwCount--)
  1552. {
  1553. if(pubCmd[dwIn] !='#'){
  1554. aubCmd[dwOut] = pubCmd[dwIn];
  1555. dwOut++;
  1556. dwIn++;
  1557. }
  1558. else{
  1559. bFound = TRUE;
  1560. break;
  1561. }
  1562. }
  1563. if(bFound == TRUE)
  1564. dwIn++;
  1565. else
  1566. return; // mismatch font command
  1567. pOEM->fGeneral &= ~(FG_VERT | FG_PLUS | FG_DBCS);
  1568. switch(pubCmd[dwIn])
  1569. {
  1570. case 'O': // for OCR-B Font support
  1571. pOEM->fGeneral |= FG_PLUS;
  1572. tmpPointsy = tmpPointsx = 120 * pOEM->wRes; // Only 12pt
  1573. break;
  1574. case 'R': // NPDL2P SBCS
  1575. pOEM->fGeneral |= FG_PLUS;
  1576. tmpPointsx = pSV->StdVar[1].lStdVariable * 1200 /
  1577. pSV->StdVar[2].lStdVariable;
  1578. break;
  1579. case 'P': // NPDL2 SBCS
  1580. tmpPointsx = pSV->StdVar[1].lStdVariable * 1200 /
  1581. pSV->StdVar[2].lStdVariable;
  1582. break;
  1583. case 'W': // NPDL2 DBCS and FontCard
  1584. pOEM->fGeneral |= FG_VERT;
  1585. case 'Q':
  1586. pOEM->fGeneral |= FG_DBCS;
  1587. tmpPointsx = pSV->StdVar[1].lStdVariable * 1440 /
  1588. pSV->StdVar[2].lStdVariable;
  1589. break;
  1590. case 'Y': // NPDL2P DBCS and FontCard
  1591. pOEM->fGeneral |= FG_VERT;
  1592. case 'S':
  1593. pOEM->fGeneral |= (FG_PLUS | FG_DBCS);
  1594. tmpPointsx = pSV->StdVar[1].lStdVariable * 1440 /
  1595. pSV->StdVar[2].lStdVariable;
  1596. break;
  1597. }
  1598. if(pOEM->fGeneral & FG_PLUS)
  1599. {
  1600. if(tmpPointsy > 9999) tmpPointsy = 9999;
  1601. else if(tmpPointsy < 10) tmpPointsy = 10;
  1602. if(tmpPointsx > 9999) tmpPointsx = 9999;
  1603. else if(tmpPointsx < 10) tmpPointsx = 10;
  1604. pOEM->wScale = tmpPointsx == tmpPointsy;
  1605. pOEM->lPointsx = tmpPointsx;
  1606. pOEM->lPointsy = tmpPointsy;
  1607. if( !pOEM->wRes ) return;
  1608. if(pOEM->fGeneral & FG_VERT)
  1609. {
  1610. if(pOEM->wScale){
  1611. aubCmd[dwOut++] = '\034';
  1612. dwOut += memcopy(&aubCmd[dwOut], "12S2-", 5);
  1613. dwOut += iDwtoA_FillZero(&aubCmd[dwOut],
  1614. tmpPointsy / pOEM->wRes, 4);
  1615. aubCmd[dwOut++] = '-';
  1616. dwOut += iDwtoA_FillZero(&aubCmd[dwOut],
  1617. tmpPointsx / pOEM->wRes, 4);
  1618. }
  1619. }
  1620. else{
  1621. dwOut += iDwtoA_FillZero(&aubCmd[dwOut],
  1622. tmpPointsx / pOEM->wRes, 4);
  1623. aubCmd[dwOut++] = '-';
  1624. dwOut += iDwtoA_FillZero(&aubCmd[dwOut],
  1625. tmpPointsy / pOEM->wRes, 4);
  1626. }
  1627. goto SEND_COM;
  1628. }
  1629. pOEM->wScale = 1;
  1630. if(tmpPointsy > 9999)
  1631. {
  1632. tmpPointsy = 9999;
  1633. goto MAKE_COM;
  1634. }
  1635. if(tmpPointsy < 10)
  1636. {
  1637. tmpPointsy = 10;
  1638. goto MAKE_COM;
  1639. }
  1640. pOEM->wScale = (int)(((tmpPointsx * 10) / tmpPointsy + 5) / 10);
  1641. if(pOEM->wScale > 8) pOEM->wScale = 8;
  1642. MAKE_COM:
  1643. if(!pOEM->wRes) return;
  1644. dwOut += iDwtoA_FillZero(&aubCmd[dwOut], tmpPointsy / pOEM->wRes, 4);
  1645. SEND_COM:
  1646. if(!(pOEM->fGeneral & FG_PLUS))
  1647. {
  1648. char *bcom[] = {"1/2", "1/1", "2/1", "3/1",
  1649. "4/1", "4/1", "6/1", "6/1", "8/1"};
  1650. if(pOEM->fGeneral & FG_VERT)
  1651. {
  1652. if(pOEM->wScale == 1)
  1653. {
  1654. dwOut += memcopy(&aubCmd[dwOut], "\034m1/1,1/1.", 10);
  1655. }
  1656. }
  1657. else
  1658. {
  1659. aubCmd[dwOut++] = '\034';
  1660. dwOut += memcopy(&aubCmd[dwOut], "m1/1,", 5);
  1661. if(pOEM->wScale>=(sizeof(bcom)/sizeof(bcom[0]))) return;
  1662. dwOut += memcopy(&aubCmd[dwOut], (LPSTR)bcom[pOEM->wScale], 3);
  1663. aubCmd[dwOut++] = '.';
  1664. }
  1665. }
  1666. // write spool builded command
  1667. WRITESPOOLBUF(pdevobj, aubCmd, dwOut);
  1668. /*
  1669. * I expect the interval of the current letter and the next letter
  1670. * from the letter size.
  1671. */
  1672. if(!pOEM->wRes) return;
  1673. if(pOEM->fGeneral & FG_DBCS){
  1674. pOEM->dwDBCSX =
  1675. pOEM->lDBCSXMove =
  1676. (LONG)((pSV->StdVar[1].lStdVariable * 2.04) / pOEM->wRes);
  1677. pOEM->dwSBCSX =
  1678. pOEM->lSBCSXMove =
  1679. (LONG)(pSV->StdVar[1].lStdVariable * 1.03 / pOEM->wRes);
  1680. }
  1681. else{
  1682. pOEM->dwSBCSX =
  1683. pOEM->lSBCSXMove =
  1684. pSV->StdVar[1].lStdVariable / pOEM->wRes;
  1685. }
  1686. pOEM->lDBCSYMove = pOEM->lSBCSYMove = 0;
  1687. pOEM->wCurrentAddMode = FLAG_RASTER;
  1688. VERBOSE(("OEMSendFontCmd() end.\r\n"));
  1689. }
  1690. //-----------------------------------------------------------------------------
  1691. //
  1692. // Function: OEMOutputCharStr
  1693. //
  1694. //-----------------------------------------------------------------------------
  1695. VOID APIENTRY
  1696. OEMOutputCharStr(
  1697. PDEVOBJ pdevobj,
  1698. PUNIFONTOBJ pUFObj,
  1699. DWORD dwType,
  1700. DWORD dwCount,
  1701. PVOID pGlyph)
  1702. {
  1703. WORD wlen;
  1704. WORD j;
  1705. PIFIMETRICS pIFI;
  1706. POEMUD_EXTRADATA pOEM;
  1707. GETINFO_GLYPHSTRING GStr;
  1708. PTRANSDATA pTrans;
  1709. //NTRAID#NTBUG9-333653-2002/03/28-hiroi-#333653: Change I/F for GETINFO_GLYPHSTRING
  1710. // BYTE aubBuff[256];
  1711. PBYTE aubBuff;
  1712. DWORD dwI;
  1713. DWORD dwNeeded;
  1714. // Adjust baseline if font substituted form TureType font.
  1715. DWORD dwYAdj;
  1716. PGETINFO_STDVAR pSV;
  1717. DWORD adwStdVar[2+2*2];
  1718. BYTE Cmd[256];
  1719. int i;
  1720. VERBOSE(("OEMOutputCharStr() entry.\r\n"));
  1721. VERBOSE((("FONT Num=%d\r\n"), dwCount));
  1722. if(dwType != TYPE_GLYPHHANDLE){
  1723. VERBOSE((("NOT TYPE_GLYPHHANDLE\r\n")));
  1724. return;
  1725. }
  1726. pOEM = (POEMUD_EXTRADATA)(pdevobj->pOEMDM);
  1727. pIFI = pUFObj->pIFIMetrics;
  1728. //
  1729. // Call the Unidriver service routine to convert
  1730. // glyph-handles into the character code data.
  1731. //
  1732. //NTRAID#NTBUG9-333653-2002/03/28-hiroi-: Change I/F for GETINFO_GLYPHSTRING
  1733. GStr.dwSize = sizeof (GETINFO_GLYPHSTRING);
  1734. GStr.dwCount = dwCount;
  1735. GStr.dwTypeIn = TYPE_GLYPHHANDLE;
  1736. GStr.pGlyphIn = pGlyph;
  1737. GStr.dwTypeOut = TYPE_TRANSDATA;
  1738. GStr.pGlyphOut = NULL;
  1739. GStr.dwGlyphOutSize = 0;
  1740. if (pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  1741. GStr.dwSize, &dwNeeded) || !GStr.dwGlyphOutSize)
  1742. {
  1743. VERBOSE(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\r\n"));
  1744. return;
  1745. }
  1746. if ((aubBuff = MemAlloc(GStr.dwGlyphOutSize)) == NULL)
  1747. {
  1748. VERBOSE(("UNIFONTOBJ_GetInfo:MemAlloc failed.\r\n"));
  1749. return;
  1750. }
  1751. GStr.pGlyphOut = aubBuff;
  1752. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  1753. GStr.dwSize, &dwNeeded))
  1754. {
  1755. VERBOSE(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\r\n"));
  1756. goto out;
  1757. }
  1758. // Adjust baseline if font substituted from TrueType font.
  1759. if (pUFObj->dwFlags & UFOFLAG_TTSUBSTITUTED) {
  1760. pSV = (PGETINFO_STDVAR)adwStdVar;
  1761. pSV->dwSize = sizeof(GETINFO_STDVAR) + 2 * sizeof(DWORD) * (2 - 1);
  1762. pSV->dwNumOfVariable = 2;
  1763. pSV->StdVar[0].dwStdVarID = FNT_INFO_FONTHEIGHT;
  1764. pSV->StdVar[1].dwStdVarID = FNT_INFO_TEXTYRES;
  1765. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_STDVARIABLE, pSV,
  1766. pSV->dwSize, &dwNeeded)) {
  1767. ERR(("UFO_GETINFO_STDVARIABLE failed.\r\n"));
  1768. goto out;
  1769. }
  1770. if(!pOEM->wRes) goto out;
  1771. dwYAdj = (pSV->StdVar[0].lStdVariable * pIFI->fwdWinDescender /
  1772. pIFI->fwdUnitsPerEm) / pOEM->wRes;
  1773. } else
  1774. dwYAdj = 0;
  1775. /* Vector mode off */
  1776. if (pOEM->wCurrentAddMode == FLAG_VECTOR){
  1777. i = 0;
  1778. i += memcopy(&Cmd[i], "EP;FL;\034Z", 8);
  1779. WRITESPOOLBUF(pdevobj, Cmd, i);
  1780. pOEM->wCurrentAddMode = FLAG_RASTER;
  1781. }
  1782. /*
  1783. * Three kind of the character cords which is given by UNIDRV
  1784. * 1.SBCS
  1785. * 2.DBCS Kanji
  1786. * 3.DBCS ANK
  1787. */
  1788. pTrans = (PTRANSDATA)aubBuff;
  1789. for (dwI = 0; dwI < dwCount; dwI ++, pTrans++)
  1790. {
  1791. switch (pTrans->ubType & MTYPE_FORMAT_MASK)
  1792. {
  1793. case MTYPE_DIRECT:
  1794. /*
  1795. Pattern 1: SBCS
  1796. */
  1797. if(pOEM->wCurrentAddMode != FLAG_SBCS ||
  1798. pOEM->dwDeviceDestX + 1 < pOEM->dwDevicePrevX + pOEM->lPrevXMove ||
  1799. pOEM->dwDevicePrevX + pOEM->lPrevXMove < pOEM->dwDeviceDestX - 1 ||
  1800. pOEM->dwDeviceDestY + 1 < pOEM->dwDevicePrevY + pOEM->lPrevYMove ||
  1801. pOEM->dwDevicePrevY + pOEM->lPrevYMove < pOEM->dwDeviceDestY - 1)
  1802. {
  1803. i = 0;
  1804. i += memcopy(&Cmd[i], "\034e", 2);
  1805. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestX);
  1806. Cmd[i++] = ',';
  1807. // Adjust baseline if font substituted form TureType font.
  1808. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestY + dwYAdj);
  1809. Cmd[i++] = '.';
  1810. i += memcopy(&Cmd[i], "\034a", 2);
  1811. i += iDwtoA(&Cmd[i], pOEM->lSBCSXMove);
  1812. Cmd[i++] = ',';
  1813. i += iDwtoA(&Cmd[i], pOEM->lSBCSYMove);
  1814. Cmd[i++] = '.';
  1815. WRITESPOOLBUF(pdevobj, Cmd, i);
  1816. pOEM->wCurrentAddMode = FLAG_SBCS;
  1817. pOEM->lPrevXMove = pOEM->lSBCSXMove;
  1818. pOEM->lPrevYMove = pOEM->lSBCSYMove;
  1819. }
  1820. WRITESPOOLBUF(pdevobj, &pTrans->uCode.ubCode, 1);
  1821. break;
  1822. case MTYPE_PAIRED:
  1823. /*
  1824. Pattern 2: kanji
  1825. */
  1826. if(*pTrans->uCode.ubPairs)
  1827. {
  1828. if(pOEM->wCurrentAddMode != FLAG_DBCS ||
  1829. pOEM->dwDeviceDestX + 1 < pOEM->dwDevicePrevX + pOEM->lPrevXMove ||
  1830. pOEM->dwDevicePrevX + pOEM->lPrevXMove < pOEM->dwDeviceDestX - 1 ||
  1831. pOEM->dwDeviceDestY + 1 < pOEM->dwDevicePrevY + pOEM->lPrevYMove ||
  1832. pOEM->dwDevicePrevY + pOEM->lPrevYMove < pOEM->dwDeviceDestY - 1)
  1833. {
  1834. i = 0;
  1835. i += memcopy(&Cmd[i], "\034e", 2);
  1836. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestX);
  1837. Cmd[i++] = ',';
  1838. // Adjust baseline if font substituted form TureType font.
  1839. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestY + dwYAdj);
  1840. Cmd[i++] = '.';
  1841. i += memcopy(&Cmd[i], "\034a", 2);
  1842. i += iDwtoA(&Cmd[i], pOEM->lDBCSXMove);
  1843. Cmd[i++] = ',';
  1844. i += iDwtoA(&Cmd[i], pOEM->lDBCSYMove);
  1845. Cmd[i++] = '.';
  1846. if(pOEM->fGeneral & FG_VERT)
  1847. {
  1848. i += memcopy(&Cmd[i], "\033t", 2);
  1849. if(pOEM->wScale != 1)
  1850. {
  1851. if(!(pOEM->fGeneral & FG_PLUS))
  1852. {
  1853. char *bcom[] = {"1/2", "1/1", "2/1", "3/1",
  1854. "4/1", "4/1", "6/1", "6/1",
  1855. "8/1"};
  1856. Cmd[i++] = '\034';
  1857. Cmd[i++] = 'm';
  1858. if(pOEM->wScale >= (sizeof(bcom)/sizeof(bcom[0]))) goto out;
  1859. i += memcopy(&Cmd[i], (LPSTR)bcom[pOEM->wScale], 3);
  1860. i += memcopy(&Cmd[i], ",1/1.", 5);
  1861. }
  1862. else{
  1863. if(!pOEM->wRes) goto out;
  1864. Cmd[i++] = '\034';
  1865. i += memcopy(&Cmd[i], "12S2-", 5);
  1866. i += iDwtoA_FillZero(&Cmd[i],
  1867. pOEM->lPointsy / pOEM->wRes, 4);
  1868. Cmd[i++] = '-';
  1869. i += iDwtoA_FillZero(&Cmd[i],
  1870. pOEM->lPointsx / pOEM->wRes, 4);
  1871. }
  1872. }
  1873. }
  1874. WRITESPOOLBUF(pdevobj, Cmd, i);
  1875. pOEM->wCurrentAddMode = FLAG_DBCS;
  1876. pOEM->lPrevXMove = pOEM->lDBCSXMove;
  1877. pOEM->lPrevYMove = pOEM->lDBCSYMove;
  1878. }
  1879. }
  1880. /*
  1881. Pattern 3: ANK
  1882. */
  1883. else
  1884. {
  1885. if(pOEM->wCurrentAddMode != FLAG_SBCS ||
  1886. pOEM->dwDeviceDestX + 1 < pOEM->dwDevicePrevX + pOEM->lPrevXMove ||
  1887. pOEM->dwDevicePrevX + pOEM->lPrevXMove < pOEM->dwDeviceDestX - 1 ||
  1888. pOEM->dwDeviceDestY + 1 < pOEM->dwDevicePrevY + pOEM->lPrevYMove ||
  1889. pOEM->dwDevicePrevY + pOEM->lPrevYMove < pOEM->dwDeviceDestY - 1)
  1890. {
  1891. i = 0;
  1892. i += memcopy(&Cmd[i], "\034e", 2);
  1893. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestX);
  1894. Cmd[i++] = ',';
  1895. // Adjust baseline if font substituted from TureType font.
  1896. i += iDwtoA(&Cmd[i], pOEM->dwDeviceDestY + dwYAdj);
  1897. Cmd[i++] = '.';
  1898. i += memcopy(&Cmd[i], "\034a", 2);
  1899. i += iDwtoA(&Cmd[i], pOEM->lSBCSXMove);
  1900. Cmd[i++] = ',';
  1901. i += iDwtoA(&Cmd[i], pOEM->lSBCSYMove);
  1902. Cmd[i++] = '.';
  1903. /*
  1904. * ANK can't do vertical writing. We have to do
  1905. * vertical writing for holizontal writing compulsorily
  1906. */
  1907. if(pOEM->fGeneral & FG_VERT)
  1908. {
  1909. i += memcopy(&Cmd[i], "\033K", 2);
  1910. if(pOEM->wScale != 1)
  1911. {
  1912. if(!(pOEM->fGeneral & FG_PLUS))
  1913. {
  1914. char *bcom[] = {"1/2", "1/1", "2/1", "3/1",
  1915. "4/1", "4/1", "6/1", "6/1", "8/1"}; Cmd[i++] = '\034';
  1916. i += memcopy(&Cmd[i], "m1/1,", 5);
  1917. if(pOEM->wScale >= (sizeof(bcom)/sizeof(bcom[0]))) goto out;
  1918. i += memcopy(&Cmd[i], (LPSTR)bcom[pOEM->wScale], 3);
  1919. Cmd[i++] = '.';
  1920. }
  1921. else{
  1922. if(!pOEM->wRes) goto out;
  1923. Cmd[i++] = '\034';
  1924. i += memcopy(&Cmd[i], "12S2-", 5);
  1925. i += iDwtoA_FillZero(&Cmd[i],
  1926. pOEM->lPointsx / pOEM->wRes, 4);
  1927. Cmd[i++] = '-';
  1928. i += iDwtoA_FillZero(&Cmd[i],
  1929. pOEM->lPointsy / pOEM->wRes, 4);
  1930. }
  1931. }
  1932. }
  1933. WRITESPOOLBUF(pdevobj, Cmd, i);
  1934. pOEM->wCurrentAddMode = FLAG_SBCS;
  1935. pOEM->lPrevXMove = pOEM->lSBCSXMove;
  1936. pOEM->lPrevYMove = pOEM->lSBCSYMove;
  1937. }
  1938. }
  1939. WRITESPOOLBUF(pdevobj, pTrans->uCode.ubPairs, 2);
  1940. break;
  1941. }
  1942. pOEM->dwDevicePrevX = pOEM->dwDeviceDestX;
  1943. pOEM->dwDevicePrevY = pOEM->dwDeviceDestY;
  1944. pOEM->dwDeviceDestX += pOEM->lPrevXMove;
  1945. pOEM->dwDeviceDestY += pOEM->lPrevYMove;
  1946. }
  1947. // NTRAID#NTBUG9-741174-2002/11/20-yasuho-: Memory leak happened.
  1948. out:
  1949. //NTRAID#NTBUG9-333653-2002/03/28-hiroi-: Change I/F for GETINFO_GLYPHSTRING
  1950. MemFree(aubBuff);
  1951. VERBOSE(("OEMOutputCharStr() end.\r\n"));
  1952. }
  1953. // NTRAID#NTBUG9-741174-2002/11/20-yasuho-: Memory leak happened.
  1954. PDEVOEM APIENTRY
  1955. OEMEnablePDEV(
  1956. PDEVOBJ pdevobj,
  1957. PWSTR pPrinterName,
  1958. ULONG cPatterns,
  1959. HSURF *phsurfPatterns,
  1960. ULONG cjGdiInfo,
  1961. GDIINFO *pGdiInfo,
  1962. ULONG cjDevInfo,
  1963. DEVINFO *pDevInfo,
  1964. DRVENABLEDATA *pded)
  1965. {
  1966. if (NULL == pdevobj)
  1967. {
  1968. ERR(("OEMEnablePDEV: Invalid parameter(s).\n"));
  1969. return NULL;
  1970. }
  1971. return pdevobj->pOEMDM;
  1972. }
  1973. VOID
  1974. APIENTRY
  1975. OEMDisablePDEV(
  1976. PDEVOBJ pdevobj
  1977. )
  1978. /*++
  1979. Routine Description:
  1980. Implementation of DDI entry point OEMDisablePDEV.
  1981. Please refer to DDK documentation for more details.
  1982. Arguments:
  1983. Return Value:
  1984. NONE
  1985. --*/
  1986. {
  1987. POEMUD_EXTRADATA pOEM;
  1988. VERBOSE(("Entering OEMDisablePDEV...\n"));
  1989. //
  1990. // verify pdevobj okay
  1991. //
  1992. if(!VALID_PDEVOBJ(pdevobj)) return;
  1993. //
  1994. // fill in printer commands
  1995. //
  1996. pOEM = (POEMUD_EXTRADATA)(pdevobj->pOEMDM);
  1997. //
  1998. // Free up memory allocated for the temp. buffer
  1999. //
  2000. if (pOEM->pCompBuf) {
  2001. FREEMEM(pOEM->pCompBuf);
  2002. pOEM->pCompBuf = NULL;
  2003. pOEM->dwCompBufLen = 0;
  2004. }
  2005. }