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.

2136 lines
56 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. char *rgchModuleName = "KPDLMS";
  8. #define PRINTDRIVER
  9. #include <print.h>
  10. #include "mdevice.h"
  11. #include "gdidefs.inc"
  12. #include "unidrv.h"
  13. #ifndef _INC_WINDOWSX
  14. #include <windowsx.h>
  15. #endif
  16. #include "kpdlms.h"
  17. #include "reg_def.h"
  18. //#include "mydebug.h"
  19. #define BM_DEVICE 0x8080
  20. #define SHIFTJIS_CHARSET 128
  21. #define CCHMAXCMDLEN 128
  22. #define COMP_TH 3
  23. typedef struct
  24. {
  25. BYTE fGeneral; // General purpose bitfield
  26. BYTE bCmdCbId; // Callback ID; 0 iff no callback
  27. WORD wCount; // # of EXTCD structures following
  28. WORD wLength; // length of the command
  29. } CD, *PCD, FAR *LPCD;
  30. typedef struct
  31. {
  32. SIZEL sizlExtent;
  33. POINTFX pfxOrigin;
  34. POINTFX pfxCharInc;
  35. } BITMAPMETRICS, FAR *LPBITMAPMETRICS;
  36. #ifndef WINNT
  37. typedef BYTE huge *LPDIBITS;
  38. #else
  39. typedef BYTE *LPDIBITS;
  40. #endif //WINNT
  41. // add for FAX BEGINDOC & ENDDOC
  42. #define NAME_LENGTH 33
  43. #define ID_LENGTH 17
  44. #define MULTI_SCALE "Multi Scale"
  45. #ifdef WINNT
  46. #include <stdio.h>
  47. #undef wsprintf
  48. #define wsprintf sprintf
  49. LPWRITESPOOLBUF WriteSpoolBuf;
  50. LPALLOCMEM UniDrvAllocMem;
  51. LPFREEMEM UniDrvFreeMem;
  52. #undef GlobalFreePtr
  53. #define GlobalFreePtr UniDrvFreeMem
  54. #define DrvGetPrinterData(a,b,c,d,e,f) TRUE
  55. #define DrvSetPrinterData(a,b,c,d,e) TRUE
  56. #define SWAPW(x) (((WORD)(x)<<8) | ((WORD)(x)>>8))
  57. #define FLAG_SBCS 1
  58. #define FLAG_DBCS 2
  59. BYTE ShiftJis[256] = {
  60. // +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
  61. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //00
  62. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //10
  63. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //20
  64. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //30
  65. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //40
  66. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //50
  67. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //60
  68. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //70
  69. 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, //80
  70. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, //90
  71. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //A0
  72. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //B0
  73. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //C0
  74. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //D0
  75. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, //E0
  76. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 //F0
  77. };
  78. BYTE IsDBCSLeadByteNPDL(
  79. BYTE Ch)
  80. {
  81. return ShiftJis[Ch];
  82. }
  83. WORD SJis2JisNPDL(
  84. WORD usCode)
  85. {
  86. union {
  87. USHORT bBuffer;
  88. struct tags{
  89. UCHAR al;
  90. UCHAR ah;
  91. } s;
  92. } u;
  93. // Replace code values which cannot be mapped into 0x2121 - 0x7e7e
  94. // (94 x 94 cahracter plane) with Japanese defult character, which
  95. // is KATAKANA MIDDLE DOT.
  96. if (usCode >= 0xf040) {
  97. usCode = 0x8145;
  98. }
  99. u.bBuffer = usCode;
  100. u.s.al -= u.s.al >= 0x80 ;
  101. u.s.al -= 0x1F ;
  102. u.s.ah &= 0xBF ;
  103. u.s.ah <<= 1 ;
  104. u.s.ah += 0x21-0x02 ;
  105. if (u.s.al > 0x7E )
  106. {
  107. u.s.al -= (0x7F-0x21) ;
  108. u.s.ah++;
  109. }
  110. return (u.bBuffer);
  111. }
  112. // In case it is a single byte font, we will some of the characters
  113. // (e.g. Yen-mark) to the actual printer font codepoint. Note since
  114. // the GPC data sets 0 to default CTT ID value, single byte codes
  115. // are in codepage 1252 (Latin1) values.
  116. WORD
  117. Ltn1ToAnk(
  118. WORD wCode )
  119. {
  120. // Not a good mapping table now.
  121. switch ( wCode ) {
  122. case 0xa5: // YEN MARK
  123. wCode = 0x5c;
  124. break;
  125. default:
  126. if ( wCode >= 0x7f)
  127. wCode = 0xa5;
  128. }
  129. return wCode;
  130. }
  131. #endif // WINNT
  132. #if 0
  133. int Table[]={
  134. 0, 175, 349, 523, 698, 872, 1045, 1219, 1392, 1564,
  135. 1736, 1908, 2079, 2250, 2419, 2588, 2756, 2924, 3090, 3256,
  136. 3420, 3584, 3746, 3907, 4067, 4226, 4384, 4540, 4695, 4848,
  137. 5000, 5150, 5299, 5446, 5592, 5736, 5878, 6018, 6157, 6293,
  138. 6428, 6561, 6691, 6820, 6947, 7071, 7193, 7314, 7431, 7547,
  139. 7660, 7771, 7880, 7986, 8090, 8192, 8290, 8387, 8480, 8572,
  140. 8660, 8746, 8829, 8910, 8988, 9063, 9135, 9205, 9272, 9336,
  141. 9397, 9455, 9511, 9563, 9613, 9659, 9703, 9744, 9781, 9816,
  142. 9848, 9877, 9903, 9925, 9945, 9962, 9976, 9986, 9994, 9998,
  143. 10000};
  144. int NEAR PASCAL Tbl(int x)
  145. {
  146. int a, b;
  147. a = Table[x / 10];
  148. b = Table[x / 10 + 1] - a;
  149. return a + (x % 10) * b / 10;
  150. }
  151. int NEAR PASCAL Tsin(int x)
  152. {
  153. if(x <= 900) return Tbl(x);
  154. if(x <= 1800) return Tbl(1800 - x);
  155. if(x <=2700) return -Tbl(x - 1800);
  156. return -Tbl(3600 - x);
  157. }
  158. int NEAR PASCAL Tcos(int x)
  159. {
  160. if(x <= 900) return Tbl(900 - x);
  161. if(x <= 1800) return -Tbl(x - 900);
  162. if(x < 2700) return -Tbl(2700 - x);
  163. return Tbl(x - 2700);
  164. }
  165. #endif
  166. //-------------------------------------------------------------------
  167. // m2d
  168. // Action:convert master unit to device unit
  169. //-------------------------------------------------------------------
  170. int NEAR PASCAL m2d(int x, WORD res)
  171. {
  172. // 300 only : sueyas
  173. return x;
  174. #if 0
  175. if(res == 400) return x / 3;
  176. if(res == 600) return x >> 1;
  177. return x / 5;
  178. #endif
  179. }
  180. #ifndef WINNT
  181. VOID NEAR PASCAL memcpy(LPSTR lpDst, LPSTR lpSrc, WORD wLen)
  182. {
  183. while(wLen--) *lpDst++ = *lpSrc++;
  184. }
  185. #endif //WINNT
  186. //------------------------------------------------------------------
  187. // REL1
  188. // Action : compress image data
  189. //------------------------------------------------------------------
  190. WORD NEAR PASCAL RLE1(
  191. LPBYTE lpDst,
  192. LPBYTE lpSrc,
  193. WORD wLen)
  194. {
  195. LPBYTE lpTemp, lpEnd, lpDsto;
  196. WORD len, deflen;
  197. lpDsto = lpDst;
  198. lpEnd = lpSrc + wLen;
  199. while(lpSrc < lpEnd)
  200. {
  201. lpTemp = lpSrc++;
  202. if(lpSrc == lpEnd)
  203. {
  204. *lpDst++ = 0x41;
  205. *lpDst++ = *lpTemp;
  206. break;
  207. }
  208. if(*lpTemp == *lpSrc)
  209. {
  210. lpSrc++;
  211. while(lpSrc < lpEnd && *lpTemp == *lpSrc) lpSrc++;
  212. len = lpSrc - lpTemp;
  213. if(len < 63)
  214. {
  215. *lpDst++ = 0x80 + (BYTE)len;
  216. goto T1;
  217. }
  218. *lpDst++ = 0xbf;
  219. len -= 63;
  220. while(len >= 255)
  221. {
  222. *lpDst++ = 0xff;
  223. len -= 255;
  224. }
  225. *lpDst++ = (BYTE)len;
  226. T1:
  227. *lpDst++ = *lpTemp;
  228. continue;
  229. }
  230. lpSrc++;
  231. while(lpSrc < lpEnd)
  232. {
  233. if(*lpSrc == *(lpSrc - 1))
  234. {
  235. lpSrc--;
  236. break;
  237. }
  238. lpSrc++;
  239. }
  240. deflen = len = lpSrc - lpTemp;
  241. if(len < 63)
  242. {
  243. *lpDst++ = 0x40 + (BYTE)len;
  244. goto T2;
  245. }
  246. *lpDst++ = 0x7f;
  247. len -= 63;
  248. while(len >= 255)
  249. {
  250. *lpDst++ = 0xff;
  251. len -= 255;
  252. }
  253. *lpDst++ = (BYTE)len;
  254. T2:
  255. memcpy(lpDst, lpTemp, deflen);
  256. lpDst += deflen;
  257. }
  258. return (WORD)(lpDst - lpDsto);
  259. }
  260. //-------------------------------------------------------------------
  261. // CBFilterGraphics
  262. // Action : Compress Bitmap Data
  263. //-------------------------------------------------------------------
  264. WORD FAR PASCAL CBFilterGraphics(
  265. LPDV lpdv,
  266. LPBYTE lpBuf,
  267. WORD wLen)
  268. {
  269. WORD wlen, wDatalen, wCounter;
  270. BYTE ch[CCHMAXCMDLEN];
  271. LPNPDL2MDV lpnp;
  272. LPBYTE lpLBuff;
  273. LPBYTE lpBuff, lpTemp, lpBuffo, lpEnd;
  274. LPBYTE lpBuff2, lpBuff2o;
  275. if(!lpdv->fMdv) return wLen;
  276. lpnp = (LPNPDL2MDV)lpdv->lpMdv;
  277. if(lpnp->fComp == FALSE)
  278. {
  279. if( lpnp->fMono || (lpnp->Color == COLOR_8) ){
  280. WriteSpoolBuf(lpdv, lpBuf, wLen);
  281. }
  282. else{
  283. WORD i;
  284. LPSTR lpTmp, lpBuf2;
  285. BYTE bR, bG, bB;
  286. BOOL fAlternate= FALSE;
  287. lpTmp = lpBuf;
  288. lpBuf2 = lpBuf;
  289. // Change order to RGB -> BGR
  290. for( i = 0; i < wLen; lpBuf+=3, i+=3 ){
  291. // if (fAlternate){
  292. // fAlternate = FALSE;
  293. // continue;
  294. // }else
  295. // fAlternate = TRUE;
  296. bR = (BYTE)*lpBuf;
  297. bG = (BYTE)*(lpBuf+1);
  298. bB = (BYTE)*(lpBuf+2);
  299. *lpBuf2 = (BYTE)bB;
  300. *(lpBuf2+1) = (BYTE)bG;
  301. *(lpBuf2+2) = (BYTE)bR;
  302. lpBuf2+=3;
  303. }
  304. WriteSpoolBuf(lpdv, lpTmp, wLen);
  305. // WriteSpoolBuf(lpdv, lpTmp, wLen/2);
  306. }
  307. return wLen;
  308. }
  309. #ifdef WINNT
  310. memcpy(lpnp->lpBuff, lpBuf, wLen);
  311. lpnp->lpBuff += wLen;
  312. if (lpnp->lpBuff
  313. < lpnp->lpLBuff + lpnp->wBitmapX + lpnp->wBitmapLen)
  314. return wLen;
  315. #else // WINNT
  316. if(!lpnp->wBitmapYC) return wLen;
  317. lpnp->lpBuff += wLen;
  318. memcpy(lpnp->lpBuff, lpBuf, wLen);
  319. if(--lpnp->wBitmapYC) return wLen;
  320. #endif // WINNT
  321. wCounter = lpnp->wBitmapY;
  322. lpLBuff = lpnp->lpLBuff;
  323. #ifdef WINNT
  324. lpBuffo = lpBuff = lpTemp = lpLBuff + lpnp->wBitmapX;
  325. #else // WINNT
  326. lpBuffo = lpBuff = lpTemp = lpLBuff + wLen;
  327. #endif // WINNT
  328. lpBuff2o = lpBuff2 = lpBuff + lpnp->wBitmapLen;
  329. do
  330. {
  331. #ifdef WINNT
  332. lpEnd = lpBuff + lpnp->wBitmapX;
  333. #else // WINNT
  334. lpEnd = lpBuff + wLen;
  335. #endif // WINNT
  336. while(lpBuff < lpEnd)
  337. {
  338. while(lpBuff < lpEnd && *lpLBuff != *lpBuff)
  339. {
  340. lpLBuff++;
  341. lpBuff++;
  342. }
  343. wlen = lpBuff - lpTemp;
  344. if(wlen)
  345. {
  346. lpBuff2 += RLE1(lpBuff2, lpTemp, wlen);
  347. lpTemp = lpBuff;
  348. }
  349. if(lpBuff == lpEnd) break;
  350. while(lpBuff < lpEnd && *lpLBuff == *lpBuff)
  351. {
  352. lpLBuff++;
  353. lpBuff++;
  354. }
  355. wlen = lpBuff - lpTemp;
  356. if(wlen < 63)
  357. {
  358. *lpBuff2++ = (BYTE)wlen;
  359. goto T;
  360. }
  361. *lpBuff2++ = 0x3f;
  362. wlen -= 63;
  363. while(wlen >= 255)
  364. {
  365. *lpBuff2++ = (BYTE)0xff;
  366. wlen -= 255;
  367. }
  368. *lpBuff2++ = (BYTE)wlen;
  369. T:
  370. lpTemp = lpBuff;
  371. }
  372. *lpBuff2++ = (BYTE)0x80;
  373. wDatalen = (WORD)(lpBuff2 - lpBuff2o);
  374. if(wDatalen > lpnp->wBitmapLen)
  375. {
  376. #ifdef WINNT
  377. wlen = wsprintf(ch, FS_I, (lpnp->wBitmapX << 3),
  378. lpnp->wBitmapY, lpnp->wBitmapLen, lpnp->wRes);
  379. lpnp->wCurrentAddMode = 0;
  380. #else // WINNT
  381. wlen = wsprintf(ch, FS_I, (wLen << 3), lpnp->wBitmapY,
  382. lpnp->wBitmapLen, lpnp->wRes);
  383. #endif // WINNT
  384. WriteSpoolBuf(lpdv, ch, wlen);
  385. WriteSpoolBuf(lpdv, lpBuffo, lpnp->wBitmapLen);
  386. GlobalFreePtr(lpnp->lpLBuff);
  387. return wLen;
  388. }
  389. }
  390. while(--wCounter);
  391. #ifdef WINNT
  392. wlen = wsprintf(ch, FS_I_2, (lpnp->wBitmapX << 3), lpnp->wBitmapY,
  393. wDatalen, lpnp->wRes);
  394. lpnp->wCurrentAddMode = 0;
  395. #else // WINNT
  396. wlen = wsprintf(ch, FS_I_2, (wLen << 3), lpnp->wBitmapY, wDatalen,
  397. lpnp->wRes);
  398. #endif // WINNT
  399. WriteSpoolBuf(lpdv, ch, wlen);
  400. WriteSpoolBuf(lpdv, lpBuff2o, wDatalen);
  401. GlobalFreePtr(lpnp->lpLBuff);
  402. return wLen;
  403. }
  404. //-------------------------------------------------------------------
  405. // fnOEMTTBitmap
  406. // Action: Dummy
  407. //-------------------------------------------------------------------
  408. BOOL FAR PASCAL fnOEMTTBitmap(
  409. LPDV lpdv,
  410. LPFONTINFO lpFont,
  411. LPDRAWMODE lpDrawMode)
  412. {
  413. return TRUE;
  414. }
  415. //-------------------------------------------------------------------
  416. // fnOEMGetFontCmd
  417. // Action: Dummy
  418. //-------------------------------------------------------------------
  419. BOOL FAR PASCAL fnOEMGetFontCmd(
  420. LPDV lpdv,
  421. WORD wCmdCbId,
  422. LPSTR lpfont,
  423. BOOL fSelect,
  424. LPBYTE lpBuf,
  425. LPWORD lpwSize)
  426. {
  427. return TRUE;
  428. }
  429. //-------------------------------------------------------------------
  430. // OEMSendScalableFontCmd
  431. // Action: send NPDL2-style font selection command.
  432. //-------------------------------------------------------------------
  433. VOID FAR PASCAL OEMSendScalableFontCmd(
  434. LPDV lpdv,
  435. LPCD lpcd, // offset to the command heap
  436. LPFONTINFO lpFont)
  437. {
  438. short ocmd;
  439. BYTE i;
  440. long tmpPointsx, tmpPointsy;
  441. LPSTR lpcmd;
  442. BYTE rgcmd[CCHMAXCMDLEN]; // build command here
  443. BOOL fDBCS;
  444. LPNPDL2MDV lpnp;
  445. if(!lpcd || !lpFont) return;
  446. if(!lpdv->fMdv) return;
  447. lpnp = (LPNPDL2MDV)lpdv->lpMdv;
  448. // be careful about integer overflow.
  449. lpcmd = (LPSTR)(lpcd + 1);
  450. tmpPointsy = (long)lpFont->dfPixHeight * 720 / (long)lpnp->wRes;
  451. ocmd = i = 0;
  452. while(lpcmd[i] !='#')
  453. {
  454. rgcmd[ocmd] = lpcmd[i];
  455. ocmd++;
  456. i++;
  457. }
  458. i++;
  459. lpnp->fVertFont = lpnp->fPlus = FALSE;
  460. switch(lpcmd[i])
  461. {
  462. case 'R':
  463. lpnp->fPlus = TRUE;
  464. tmpPointsx = (long)lpFont->dfAvgWidth * 1200 / (long)lpnp->wRes;
  465. break;
  466. case 'P':
  467. fDBCS = FALSE;
  468. tmpPointsx = ((long)lpFont->dfAvgWidth * 1200 + 600) /
  469. (long)lpnp->wRes;
  470. break;
  471. case 'W':
  472. lpnp->fVertFont = TRUE;
  473. case 'Q':
  474. fDBCS = TRUE;
  475. tmpPointsx = (long)lpFont->dfAvgWidth * 1440 / (long)lpnp->wRes;
  476. break;
  477. case 'Y':
  478. lpnp->fVertFont = TRUE;
  479. case 'S':
  480. lpnp->fPlus = TRUE;
  481. tmpPointsx = (long)lpFont->dfAvgWidth * 1440 / (long)lpnp->wRes;
  482. break;
  483. }
  484. if(lpnp->fPlus)
  485. {
  486. if(tmpPointsy > 9999) tmpPointsy = 9999;
  487. else if(tmpPointsy < 10) tmpPointsy = 10;
  488. if(tmpPointsx > 9999) tmpPointsx = 9999;
  489. else if(tmpPointsx < 10) tmpPointsx = 10;
  490. lpnp->wScale = tmpPointsx == tmpPointsy;
  491. lpnp->lPointsx = tmpPointsx;
  492. lpnp->lPointsy = tmpPointsy;
  493. if(lpnp->fVertFont)
  494. {
  495. if(lpnp->wScale)
  496. ocmd += wsprintf(&rgcmd[ocmd], FS_12S2, tmpPointsy,
  497. tmpPointsx);
  498. }
  499. else
  500. ocmd += wsprintf(&rgcmd[ocmd], "%04ld-%04ld", tmpPointsx,
  501. tmpPointsy);
  502. goto SEND_COM;
  503. }
  504. lpnp->wScale = 1;
  505. if(tmpPointsy > 9999)
  506. {
  507. tmpPointsy = 9999;
  508. goto MAKE_COM;
  509. }
  510. if(tmpPointsy < 10)
  511. {
  512. tmpPointsy = 10;
  513. goto MAKE_COM;
  514. }
  515. lpnp->wScale = (int)(tmpPointsx / tmpPointsy);
  516. if(lpnp->wScale > 8) lpnp->wScale = 8;
  517. MAKE_COM:
  518. ocmd += wsprintf(&rgcmd[ocmd], "%04ld", tmpPointsy);
  519. SEND_COM:
  520. // write spool builded command
  521. WriteSpoolBuf(lpdv, rgcmd, ocmd);
  522. i++;
  523. ocmd = 0;
  524. while(lpcmd[i] !='#')
  525. {
  526. rgcmd[ocmd] = lpcmd[i];
  527. ocmd++;
  528. i++;
  529. }
  530. ocmd += wsprintf(&rgcmd[ocmd], "%04ld,", (fDBCS ? lpFont->dfAvgWidth * 2 : lpFont->dfAvgWidth));
  531. ocmd += wsprintf(&rgcmd[ocmd], "%04ld.", lpFont->dfPixHeight);
  532. WriteSpoolBuf(lpdv, rgcmd, ocmd);
  533. #if 0
  534. if(!lpnp->fPlus)
  535. {
  536. char *bcom[] = {"1/2", "1/1", "2/1", "3/1",
  537. "4/1", "4/1", "6/1", "6/1", "8/1"};
  538. if(lpnp->fVertFont)
  539. {
  540. if(lpnp->wScale == 1)
  541. {
  542. ocmd = wsprintf(rgcmd, FS_M_T, (LPSTR)bcom[lpnp->wScale]);
  543. WriteSpoolBuf(lpdv, rgcmd, ocmd);
  544. }
  545. }
  546. else
  547. {
  548. ocmd = wsprintf(rgcmd, FS_M_Y, (LPSTR)bcom[lpnp->wScale]);
  549. WriteSpoolBuf(lpdv, rgcmd, ocmd);
  550. }
  551. }
  552. #endif
  553. // save for FS_SINGLE_BYTE and FS_DOUBLE_BYTE
  554. lpnp->sSBCSX = lpnp->sSBCSXMove = lpFont->dfAvgWidth;
  555. lpnp->sDBCSX = lpnp->sDBCSXMove = lpFont->dfAvgWidth << 1;
  556. lpnp->sSBCSYMove = lpnp->sDBCSYMove = 0;
  557. #ifdef WINNT
  558. lpnp->wCurrentAddMode = 0;
  559. #endif
  560. }
  561. //-------------------------------------------------------------------
  562. // fnOEMOutputCmd
  563. // Action :
  564. //-------------------------------------------------------------------
  565. VOID FAR PASCAL fnOEMOutputCmd(
  566. LPDV lpdv,
  567. WORD wCmdCbId,
  568. LPDWORD lpdwParams)
  569. {
  570. WORD wlen;
  571. BYTE ch[CCHMAXCMDLEN];
  572. LPNPDL2MDV lpnp;
  573. if(!lpdv->fMdv) return;
  574. lpnp = (LPNPDL2MDV)lpdv->lpMdv;
  575. switch(wCmdCbId)
  576. {
  577. case COLOR_8:
  578. lpnp->Color = COLOR_8;
  579. break;
  580. case COLOR_TRUE:
  581. lpnp->Color = COLOR_TRUE;
  582. break;
  583. case KAICHO4:
  584. lpnp->Kaicho = 2;
  585. break;
  586. case KAICHO8:
  587. lpnp->Kaicho = 3;
  588. break;
  589. // *** Resolutions RES *** //
  590. case RES_600:
  591. case RES_400:
  592. case RES_240:
  593. lpnp->wRes = wCmdCbId == RES_600 ? 600 :
  594. (wCmdCbId == RES_400 ? 400 : 240);
  595. wlen = wsprintf(ch, RESO_PAGE_KANJI, lpnp->wRes);
  596. WriteSpoolBuf(lpdv, ch, wlen);
  597. break;
  598. case RES_300:
  599. lpnp->wRes = 300;
  600. WriteSpoolBuf(lpdv, "\x1CYSU1,300,0;\x1CZ", 14);
  601. WriteSpoolBuf(lpdv, "\x1C<1/300,i.", 10);
  602. if (lpnp->fMono == FALSE){
  603. WriteSpoolBuf(lpdv, "\x1B\x43\x30", 3);
  604. WriteSpoolBuf(lpdv, "\x1CYOP2,13;", 9);
  605. WriteSpoolBuf(lpdv, "QB0,255,255,255,0,0,0;", 22);
  606. WriteSpoolBuf(lpdv, "XX1;\x1CZ", 6);
  607. }
  608. break;
  609. case RES_SENDBLOCK:
  610. {
  611. WORD size, x, y;
  612. if(!lpdwParams) return;
  613. size = (WORD)*lpdwParams;
  614. y = (WORD)*(lpdwParams + 1);
  615. x = (WORD)*(lpdwParams + 2);
  616. if( lpnp->fMono || (lpnp->Color == COLOR_8) ){
  617. wlen = wsprintf(ch, "\034R\034i%d,%d,0,1/1,1/1,%d,300.", x * 8, y, size );
  618. WriteSpoolBuf(lpdv, ch, wlen);
  619. #ifdef WINNT
  620. lpnp->wCurrentAddMode = 0;
  621. #endif
  622. }
  623. else{
  624. wlen = wsprintf(ch, "\034!E%d,%d,%d,%d,%d,%d,%d,%d.",
  625. lpnp->Kaicho, lpnp->CursorX, lpnp->CursorY,
  626. x/3, y, x/3, y, size );
  627. //x/3, y, (x/3)/2, y/2, size/2 );
  628. WriteSpoolBuf(lpdv, ch, wlen);
  629. }
  630. }
  631. break;
  632. case RES_BLOCKOUT2:
  633. {
  634. WORD size, x, y;
  635. if(!lpdwParams) return;
  636. size = (WORD)*lpdwParams;
  637. y = (WORD)*(lpdwParams + 1);
  638. x = (WORD)*(lpdwParams + 2);
  639. #ifdef WINNT
  640. lpnp->wBitmapX = x;
  641. lpnp->wBitmapY = y;
  642. #else // WINNT
  643. lpnp->wBitmapY = lpnp->wBitmapYC = y
  644. #endif // WINNT
  645. lpnp->wBitmapLen = size;
  646. if(x < COMP_TH) goto NOCOMP;
  647. #ifndef WINNT
  648. lpnp->hBuff = GlobalAlloc(GHND, x * 3 + (size << 1) + y);
  649. if(!lpnp->hBuff) goto NOCOMP;
  650. lpnp->lpLBuff = lpnp->lpBuff = (LPSTR)GlobalLock(lpnp->hBuff);
  651. if(!lpnp->lpBuff)
  652. {
  653. GlobalFree(lpnp->hBuff);
  654. goto NOCOMP;
  655. }
  656. #else // WINNT
  657. lpnp->lpLBuff = (LPSTR)UniDrvAllocMem(x * 3 + (size << 1) + y);
  658. if (lpnp->lpBuff == NULL)
  659. {
  660. goto NOCOMP;
  661. }
  662. memset(lpnp->lpLBuff, 0, (x * 3 + (size << 1) + y));
  663. lpnp->lpBuff = lpnp->lpLBuff + lpnp->wBitmapX;
  664. #endif // WINNT
  665. lpnp->fComp = TRUE;
  666. break;
  667. NOCOMP:
  668. lpnp->fComp = FALSE;
  669. wlen = wsprintf(ch, FS_I, (x << 3), y, size, lpnp->wRes);
  670. WriteSpoolBuf(lpdv, ch, wlen);
  671. #ifdef WINNT
  672. lpnp->wCurrentAddMode = 0;
  673. #endif
  674. }
  675. break;
  676. // *** Page Control PC *** //
  677. case PC_TYPE_F:
  678. {
  679. DWORD dwTmp, dwType, dwData;
  680. char szBuff[80];
  681. short nDouhou;
  682. WriteSpoolBuf(lpdv, ESC_RESET);
  683. if(DrvGetPrinterData(lpnp->szDevName, FAX_ON, &dwType, (LPBYTE)&dwTmp,
  684. sizeof(DWORD), &dwData))
  685. dwTmp = 0;
  686. if(dwTmp)
  687. {
  688. lpnp->fFax = TRUE;
  689. dwTmp = 0;
  690. DrvSetPrinterData(lpnp->szDevName, FAX_ON, REG_DWORD,
  691. (LPBYTE)&dwTmp, sizeof(DWORD));
  692. WriteSpoolBuf(lpdv, FX_INIT);
  693. if(DrvGetPrinterData(lpnp->szDevName, FAX_USEBOOK, &dwType,
  694. (LPBYTE)&dwTmp, sizeof(DWORD), &dwData))
  695. nDouhou = 0;
  696. else
  697. nDouhou = (int)dwTmp;
  698. dwTmp = 0;
  699. DrvSetPrinterData(lpnp->szDevName, FAX_USEBOOK, REG_DWORD,
  700. (LPBYTE)&dwTmp, sizeof(DWORD));
  701. if(nDouhou)
  702. {
  703. int i = 0;
  704. char telBuf[40];
  705. while(1)
  706. {
  707. i++;
  708. wsprintf(telBuf, FAX_TEL, i);
  709. if(DrvGetPrinterData(lpnp->szDevName, telBuf, &dwType,
  710. szBuff, sizeof(szBuff),
  711. &dwData))
  712. break;
  713. wlen = wsprintf(ch, FX_TEL, (LPSTR)szBuff);
  714. WriteSpoolBuf(lpdv, ch, wlen);
  715. }
  716. }
  717. else
  718. {
  719. if(DrvGetPrinterData(lpnp->szDevName, FAX_IDDSTTEL, &dwType,
  720. szBuff, sizeof(szBuff), &dwData))
  721. szBuff[0] = 0;
  722. if(szBuff[0])
  723. {
  724. wlen = wsprintf(ch, FX_TEL, (LPSTR)szBuff);
  725. WriteSpoolBuf(lpdv, ch, wlen);
  726. }
  727. }
  728. szBuff[0] = 0;
  729. DrvSetPrinterData(lpnp->szDevName, FAX_DSTTEL, REG_SZ, szBuff, 1);
  730. DrvSetPrinterData(lpnp->szDevName, FAX_IDDSTTEL, REG_SZ, szBuff,
  731. 1);
  732. if(DrvGetPrinterData(lpnp->szDevName, FAX_RES, &dwType,
  733. (LPBYTE)&dwTmp, sizeof(DWORD), &dwData))
  734. dwTmp = 0;
  735. wlen = wsprintf(ch, FX_QUA, (int)dwTmp);
  736. WriteSpoolBuf(lpdv, ch, wlen);
  737. if(DrvGetPrinterData(lpnp->szDevName, FAX_MYNAME, &dwType, szBuff,
  738. sizeof(szBuff), &dwData))
  739. szBuff[0] = 0;
  740. if(szBuff[0])
  741. {
  742. wlen = wsprintf(ch, FX_MY, (LPSTR)szBuff);
  743. WriteSpoolBuf(lpdv, ch, wlen);
  744. }
  745. if(DrvGetPrinterData(lpnp->szDevName, FAX_ID, &dwType, szBuff,
  746. sizeof(szBuff), &dwData))
  747. szBuff[0] = 0;
  748. if(szBuff[0])
  749. {
  750. wlen = wsprintf(ch, FX_ID, (LPSTR)szBuff);
  751. WriteSpoolBuf(lpdv, ch, wlen);
  752. }
  753. WriteSpoolBuf(lpdv, FX_SETEND);
  754. }
  755. }
  756. break;
  757. case PC_END_F:
  758. if(lpnp->fFax == TRUE)
  759. {
  760. WriteSpoolBuf(lpdv, FX_DATAEND);
  761. lpnp->fFax = FALSE;
  762. }
  763. WriteSpoolBuf(lpdv, FS_RESO0_RESET);
  764. break;
  765. case PC_ENDPAGE :
  766. wlen = wsprintf(ch, FS_ENDPAGE, lpnp->wCopies);
  767. WriteSpoolBuf(lpdv, ch, wlen);
  768. break;
  769. case PC_MULT_COPIES_N:
  770. case PC_MULT_COPIES_C:
  771. // FS_COPIES is neccesary for each page
  772. if(!lpdwParams) return;
  773. if(wCmdCbId == PC_MULT_COPIES_C)
  774. {
  775. int iCharSet;
  776. #ifndef WINNT
  777. iCharSet = GetProfileInt("system.font", "CharSet", 1);
  778. if(iCharSet == 8) WriteSpoolBuf(lpdv, FS_JIS78);
  779. else WriteSpoolBuf(lpdv, FS_JIS90);
  780. #else
  781. WriteSpoolBuf(lpdv, FS_JIS90);
  782. #endif //WINNT
  783. }
  784. lpnp->wCopies = (WORD)*lpdwParams;
  785. wlen = wsprintf(ch, INIT_DOC, lpnp->wRes, lpnp->wRes);
  786. WriteSpoolBuf(lpdv, ch, wlen);
  787. break;
  788. case PC_PRN_DIRECTION:
  789. {
  790. short sEsc, sEsc90;
  791. short ESin[] = {0, 1, 0, -1};
  792. short ECos[] = {1, 0, -1, 0};
  793. if(!lpdwParams) return;
  794. lpnp->sEscapement = (short)*lpdwParams % 360;
  795. sEsc = lpnp->sEscapement;
  796. sEsc90 = lpnp->sEscapement/90;
  797. #if 0
  798. //if gpc supported any degree character rotation, available here.
  799. if(!(sEsc % 900))
  800. {
  801. #endif
  802. lpnp->sSBCSXMove = lpnp->sSBCSX * ECos[sEsc90];
  803. lpnp->sSBCSYMove = -lpnp->sSBCSX * ESin[sEsc90];
  804. lpnp->sDBCSXMove = lpnp->sDBCSX * ECos[sEsc90];
  805. lpnp->sDBCSYMove = -lpnp->sDBCSX * ESin[sEsc90];
  806. #if 0
  807. //if gpc supported any degree character rotation, available here.
  808. }
  809. else
  810. {
  811. lpnp->sSBCSXMove = Scale(lpnp->sSBCSX, RCos(1000, sEsc), 1000);
  812. lpnp->sSBCSYMove = Scale(-lpnp->sSBCSX, RSin(1000, sEsc), 1000);
  813. lpnp->sDBCSXMove = Scale(lpnp->sDBCSX, RCos(1000, sEsc), 1000);
  814. lpnp->sDBCSYMove = Scale(-lpnp->sDBCSX, RSin(1000, sEsc), 1000);
  815. }
  816. #endif
  817. }
  818. break;
  819. // *** Cursor Movement CM *** //
  820. case CM_XY_ABS:
  821. {
  822. int x, y;
  823. if(!lpdwParams) return;
  824. x = m2d((int)*lpdwParams, lpnp->wRes);
  825. y = m2d((int)*(lpdwParams + 1), lpnp->wRes);
  826. lpnp->CursorX = x;
  827. lpnp->CursorY = y;
  828. wlen = wsprintf(ch, FS_E, x, y);
  829. WriteSpoolBuf(lpdv, ch, wlen);
  830. }
  831. break;
  832. // *** Font Simulation FS *** //
  833. case FS_DOUBLE_BYTE:
  834. #ifndef WINNT
  835. wlen = wsprintf(ch, FS_ADDRMODE_ON, lpnp->sDBCSXMove,
  836. lpnp->sDBCSYMove);
  837. WriteSpoolBuf(lpdv, ch, wlen);
  838. if(lpnp->fVertFont)
  839. {
  840. WriteSpoolBuf(lpdv, ESC_KANJITATE);
  841. if(lpnp->wScale == 1) break;
  842. if(!lpnp->fPlus)
  843. {
  844. char *bcom[] = {"1/2", "1/1", "2/1", "3/1",
  845. "4/1", "4/1", "6/1", "6/1", "8/1"};
  846. wlen = wsprintf(ch, FS_M_T, (LPSTR)bcom[lpnp->wScale]);
  847. WriteSpoolBuf(lpdv, ch, wlen);
  848. break;
  849. }
  850. else wlen = wsprintf(ch, FS_12S2, lpnp->lPointsy, lpnp->lPointsx);
  851. WriteSpoolBuf(lpdv, ch, wlen);
  852. }
  853. #endif
  854. break;
  855. case FS_SINGLE_BYTE:
  856. #ifndef WINNT
  857. wlen = wsprintf(ch, FS_ADDRMODE_ON, lpnp->sSBCSXMove,
  858. lpnp->sSBCSYMove);
  859. WriteSpoolBuf(lpdv, ch, wlen);
  860. if(lpnp->fVertFont)
  861. {
  862. WriteSpoolBuf(lpdv, ESC_KANJIYOKO);
  863. if(lpnp->wScale == 1) break;
  864. if(!lpnp->fPlus)
  865. {
  866. char *bcom[] = {"1/2", "1/1", "2/1", "3/1",
  867. "4/1", "4/1", "6/1", "6/1", "8/1"};
  868. wlen = wsprintf(ch, FS_M_Y, (LPSTR)bcom[lpnp->wScale]);
  869. WriteSpoolBuf(lpdv, ch, wlen);
  870. break;
  871. }
  872. else wlen = wsprintf(ch, FS_12S2, lpnp->lPointsx, lpnp->lPointsy);
  873. WriteSpoolBuf(lpdv, ch, wlen);
  874. }
  875. #endif
  876. break;
  877. // *** Vector Page VP *** //
  878. case VP_INIT_VECT:
  879. if(lpnp->wRes == 400)
  880. {
  881. WriteSpoolBuf(lpdv, VEC_INIT_400);
  882. return;
  883. }
  884. if(lpnp->wRes == 600)
  885. {
  886. WriteSpoolBuf(lpdv, VEC_INIT_600);
  887. return;
  888. }
  889. WriteSpoolBuf(lpdv, VEC_INIT_240);
  890. return;
  891. case VP_CLIP:
  892. {
  893. int left, top, right, bottom;
  894. if(!lpdwParams) return;
  895. left = m2d((int)*lpdwParams, lpnp->wRes);
  896. top = m2d((int)*(lpdwParams + 1), lpnp->wRes);
  897. right = m2d((int)*(lpdwParams + 2), lpnp->wRes);
  898. bottom = m2d((int)*(lpdwParams + 3), lpnp->wRes);
  899. wlen = wsprintf(ch, VEC_CLIP, left, top, right, bottom);
  900. WriteSpoolBuf(lpdv, ch, wlen);
  901. }
  902. break;
  903. #if 0
  904. case VP_TRANSPARENT:
  905. lpnp->fTrans = TRUE;
  906. if(lpnp->fFill == FALSE) WriteSpoolBuf(lpdv, VEC_TRANS);
  907. else WriteSpoolBuf(lpdv, VEC_OPAQUE);
  908. break;
  909. #endif
  910. case VP_OPAQUE:
  911. // lpnp->fTrans = FALSE;
  912. if(lpnp->fCurve == TRUE && lpnp->fFill == TRUE)
  913. WriteSpoolBuf(lpdv, VEC_OPLINE);
  914. else
  915. WriteSpoolBuf(lpdv, VEC_OPAQUE);
  916. break;
  917. // *** Carousel CAR *** //
  918. case CAR_SELECT_PEN_COLOR:
  919. lpnp->wPenColor = *lpdwParams ? SG_BLACK : SG_WHITE;
  920. if(lpnp->wBrStyle == PP_SOLID)
  921. wlen = wsprintf(ch, VEC_SG, lpnp->wPenColor, lpnp->wPenColor);
  922. else
  923. wlen = wsprintf(ch, VEC_SG_PEN, lpnp->wPenColor);
  924. WriteSpoolBuf(lpdv, ch, wlen);
  925. break;
  926. case CAR_SET_PEN_WIDTH:
  927. {
  928. int width;
  929. if(!lpdwParams) return;
  930. width = m2d((int)*lpdwParams, lpnp->wRes);
  931. wlen = wsprintf(ch, VEC_PEN_WIDTH, width);
  932. #if 0
  933. // for Opaque Style Pen and Line Width
  934. lpnp->wPenWidth = m2d((int)*lpdwParams, lpnp->wRes);;
  935. if(lpnp->wPenWidth < 2)
  936. {
  937. WriteSpoolBuf(lpdv, VEC_PEN_WIDTH_1);
  938. break;
  939. }
  940. wlen = wsprintf(ch, VEC_PEN_WIDTH, lpnp->wPenWidth);
  941. #endif
  942. WriteSpoolBuf(lpdv, ch, wlen);
  943. }
  944. break;
  945. // *** Line Info LI *** //
  946. #if 0
  947. // for Opaque Style Pen and Line Width
  948. case LI_SELECT_SOLID:
  949. case LI_SELECT_DASH:
  950. case LI_SELECT_DOT:
  951. case LI_SELECT_DASHDOT:
  952. case LI_SELECT_DASHDOTDOT:
  953. {
  954. short n[] = {0, 2, 100, 5, 6};
  955. lpnp->wPenStyle = n[wCmdCbId - LI_SELECT_SOLID];
  956. if(!lpnp->wPenStyle)
  957. {
  958. WriteSpoolBuf(lpdv, VEC_LT_SOLID);
  959. break;
  960. }
  961. wlen = wsprintf(ch, VEC_LT_STYLE, lpnp->wPenStyle);
  962. WriteSpoolBuf(lpdv, ch, wlen);
  963. }
  964. break;
  965. #endif
  966. // *** Brush Info BI *** //
  967. // add 11/28 for PC-PR2000/6W (Naka)
  968. // merged 94/12/20 by DAI
  969. case BI_SELECT_SOLID:
  970. lpnp->wBrStyle = PP_SOLID;
  971. wlen = wsprintf(ch, VEC_SG_BR, lpnp->wPenColor);
  972. WriteSpoolBuf(lpdv, ch, wlen);
  973. break;
  974. // add 11/28 for PC-PR2000/6W (Naka)
  975. // merged 94/12/20 by DAI
  976. case BI_SELECT_HS_HORIZONTAL:
  977. case BI_SELECT_HS_VERTICAL:
  978. case BI_SELECT_HS_FDIAGONAL:
  979. case BI_SELECT_HS_BDIAGONAL:
  980. case BI_SELECT_HS_CROSS:
  981. case BI_SELECT_HS_DIAGCROSS:
  982. {
  983. short i;
  984. struct
  985. {
  986. WORD pp;
  987. WORD rp;
  988. LPSTR vec;
  989. int size;
  990. } BrTbl[]={{PP_HORIZONTAL, RP_HORIZONTAL, VEC_RP_HORIZONTAL},
  991. {PP_VERTICAL, RP_VERTICAL, VEC_RP_VERTICAL },
  992. {PP_FDIAGONAL, RP_FDIAGONAL, VEC_RP_FDIAGONAL },
  993. {PP_BDIAGONAL, RP_BDIAGONAL, VEC_RP_BDIAGONAL },
  994. {PP_CROSS, RP_CROSS, VEC_RP_CROSS },
  995. {PP_DIAGCROSS, RP_DIAGCROSS, VEC_RP_DIAGCROSS }};
  996. i = wCmdCbId - BI_SELECT_HS_HORIZONTAL;
  997. lpnp->wBrStyle = BrTbl[i].pp;
  998. if(!(lpnp->fBrCreated & BrTbl[i].rp))
  999. {
  1000. WriteSpoolBuf(lpdv, BrTbl[i].vec, BrTbl[i].size);
  1001. lpnp->fBrCreated |= BrTbl[i].rp;
  1002. }
  1003. switch(lpnp->dwMulti)
  1004. {
  1005. case 0:
  1006. wlen = wsprintf(ch, VEC_PP, lpnp->wBrStyle);
  1007. break;
  1008. case 1:
  1009. wlen = wsprintf(ch, VEC_PP2, lpnp->wBrStyle);
  1010. break;
  1011. case 2:
  1012. wlen = wsprintf(ch, VEC_PP3, lpnp->wBrStyle);
  1013. }
  1014. WriteSpoolBuf(lpdv, ch, wlen);
  1015. }
  1016. break;
  1017. case BI_CREATE_BYTE_2:
  1018. if(!lpdwParams) return;
  1019. wlen = wsprintf(ch, VEC_RP_BYTE, (BYTE)~*lpdwParams);
  1020. WriteSpoolBuf(lpdv, ch, wlen);
  1021. break;
  1022. case BI_SELECT_BRUSHSTYLE:
  1023. if(!lpdwParams) return;
  1024. lpnp->wBrStyle = (WORD)*lpdwParams + PP_USERPATERN;
  1025. switch(lpnp->dwMulti)
  1026. {
  1027. case 0:
  1028. wlen = wsprintf(ch, VEC_PP, lpnp->wBrStyle);
  1029. break;
  1030. case 1:
  1031. wlen = wsprintf(ch, VEC_PP2, lpnp->wBrStyle);
  1032. break;
  1033. case 2:
  1034. wlen = wsprintf(ch, VEC_PP3, lpnp->wBrStyle);
  1035. }
  1036. WriteSpoolBuf(lpdv, ch, wlen);
  1037. break;
  1038. // *** Vector Output VO *** //
  1039. // add 11/28 for PC-PR2000/6W (Naka)
  1040. // merged 94/12/20 by DAI
  1041. case VO_RECT:
  1042. {
  1043. short x1, y1, dx, dy;
  1044. x1 = m2d((short)*lpdwParams, lpnp->wRes);
  1045. y1 = m2d((short)*(lpdwParams + 1), lpnp->wRes);
  1046. dx = m2d((short)*(lpdwParams + 4), lpnp->wRes);
  1047. dy = m2d((short)*(lpdwParams + 5), lpnp->wRes);
  1048. if(!dx && !dy) dx = dy = 1;
  1049. wlen = wsprintf(ch, VEC_RECT, x1, y1, dx, dy, dx,dy);
  1050. WriteSpoolBuf(lpdv, ch, wlen);
  1051. }
  1052. break;
  1053. case VO_RECT_P:
  1054. {
  1055. short x1, y1, x2, y2, n;
  1056. if(lpnp->fCurve == FALSE)
  1057. {
  1058. lpnp->fFill = lpnp->fStroke = FALSE;
  1059. lpnp->fCurve = TRUE;
  1060. return;
  1061. }
  1062. lpnp->fCurve = FALSE;
  1063. if(lpnp->fFill == FALSE && lpnp->fStroke == FALSE) return;
  1064. x1 = m2d((short)*lpdwParams, lpnp->wRes);
  1065. y1 = m2d((short)*(lpdwParams + 1), lpnp->wRes);
  1066. x2 = m2d((short)*(lpdwParams + 2), lpnp->wRes);
  1067. y2 = m2d((short)*(lpdwParams + 3), lpnp->wRes);
  1068. if(x1 == x2 && y1 == y2 )
  1069. {
  1070. x2++;
  1071. y2++;
  1072. }
  1073. if(lpnp->fFill == TRUE) n = lpnp->fStroke == TRUE ? 2 : 1;
  1074. else n = 0;
  1075. wlen = wsprintf(ch, VEC_RECT_P, x1, y1, x2, y2, n);
  1076. WriteSpoolBuf(lpdv, ch, wlen);
  1077. #if 0
  1078. // for opaque style line
  1079. if(n == 1 || lpnp->fTrans == TRUE || lpnp->wPenWidth > 1 ||
  1080. !lpnp->wPenStyle)
  1081. {
  1082. WriteSpoolBuf(lpdv, ch, wlen);
  1083. break;
  1084. }
  1085. if(lpnp->wPenColor == SG_BLACK)
  1086. {
  1087. WriteSpoolBuf(lpdv, VEC_LT_WHITE);
  1088. WriteSpoolBuf(lpdv, ch, wlen);
  1089. wlen = wsprintf(ch, VEC_LT_STYLE_B, lpnp->wPenStyle);
  1090. WriteSpoolBuf(lpdv, ch, wlen);
  1091. wlen = wsprintf(ch, VEC_RECT_P, x1, y1, x2, y2, 0);
  1092. WriteSpoolBuf(lpdv, ch, wlen);
  1093. }
  1094. else
  1095. {
  1096. WriteSpoolBuf(lpdv, VEC_LT_SOLID);
  1097. WriteSpoolBuf(lpdv, ch, wlen);
  1098. wlen = wsprintf(ch, VEC_LT_STYLE, lpnp->wPenStyle);
  1099. WriteSpoolBuf(lpdv, ch, wlen);
  1100. }
  1101. #endif
  1102. }
  1103. break;
  1104. // for NPDL2+ vector graphics mode(add Naka 95/5/11)
  1105. case VO_CIRCLE:
  1106. {
  1107. short n;
  1108. short sX;
  1109. short sXr;
  1110. short sY;
  1111. short sR;
  1112. if(lpnp->fCurve == FALSE)
  1113. {
  1114. lpnp->fFill = lpnp->fStroke = FALSE;
  1115. lpnp->fCurve = TRUE;
  1116. return;
  1117. }
  1118. lpnp->fCurve = FALSE;
  1119. if(lpnp->fFill == FALSE && lpnp->fStroke == FALSE) return;
  1120. sX = m2d((short)*lpdwParams, lpnp->wRes);
  1121. sY = m2d((short)*(lpdwParams + 1), lpnp->wRes);
  1122. sR = m2d((short)*(lpdwParams + 2), lpnp->wRes);
  1123. if(lpnp->fFill == TRUE) n = lpnp->fStroke == TRUE ? 2 : 1;
  1124. else n = 0;
  1125. sXr = sX + sR; // starting point of the circle (X coordinate)
  1126. wlen = wsprintf(ch, VEC_ELLIP, sX, sY, sR, sR, sXr, sY, sXr, sY, n);
  1127. WriteSpoolBuf(lpdv, ch, wlen);
  1128. #if 0
  1129. // for opaque style line
  1130. if(n == 1 || lpnp->fTrans == TRUE || lpnp->wPenWidth > 1 ||
  1131. !lpnp->wPenStyle)
  1132. {
  1133. WriteSpoolBuf(lpdv, ch, wlen);
  1134. break;
  1135. }
  1136. if(lpnp->wPenColor == SG_BLACK)
  1137. {
  1138. WriteSpoolBuf(lpdv, VEC_LT_WHITE);
  1139. WriteSpoolBuf(lpdv, ch, wlen);
  1140. wlen = wsprintf(ch, VEC_LT_STYLE_B, lpnp->wPenStyle);
  1141. WriteSpoolBuf(lpdv, ch, wlen);
  1142. wlen = wsprintf(ch, VEC_ELLIP, sR, sR, sX, sY, sX, sY, 0);
  1143. WriteSpoolBuf(lpdv, ch, wlen);
  1144. }
  1145. else
  1146. {
  1147. WriteSpoolBuf(lpdv, VEC_LT_SOLID);
  1148. WriteSpoolBuf(lpdv, ch, wlen);
  1149. wlen = wsprintf(ch, VEC_LT_STYLE, lpnp->wPenStyle);
  1150. WriteSpoolBuf(lpdv, ch, wlen);
  1151. }
  1152. #endif
  1153. }
  1154. break;
  1155. // for NPDL2+ vector graphics mode(add Naka 95/5/8)
  1156. case VO_ELLIPSE:
  1157. {
  1158. short n;
  1159. short sEllX1;
  1160. short sEllY1;
  1161. short sEllX2;
  1162. short sEllY2;
  1163. short sEllX;
  1164. short sEllY;
  1165. short sCENTERX;
  1166. short sCENTERY;
  1167. short sR;
  1168. if(lpnp->fCurve == FALSE)
  1169. {
  1170. lpnp->fFill = lpnp->fStroke = FALSE;
  1171. lpnp->fCurve = TRUE;
  1172. return;
  1173. }
  1174. lpnp->fCurve = FALSE;
  1175. if(lpnp->fFill == FALSE && lpnp->fStroke == FALSE) return;
  1176. sEllX1 = m2d((short)*lpdwParams, lpnp->wRes);
  1177. sEllY1 = m2d((short)*(lpdwParams + 1), lpnp->wRes);
  1178. sEllX2 = m2d((short)*(lpdwParams + 2), lpnp->wRes);
  1179. sEllY2 = m2d((short)*(lpdwParams + 3), lpnp->wRes);
  1180. sCENTERX = (sEllX1 + sEllX2) >> 1;
  1181. sCENTERY = (sEllY1 + sEllY2) >> 1;
  1182. sEllX = (sEllX2 - sEllX1) >> 1;
  1183. sEllY = (sEllY2 - sEllY1) >> 1;
  1184. sR = sCENTERX + sEllX;
  1185. if(lpnp->fFill == TRUE) n = lpnp->fStroke == TRUE ? 2 : 1;
  1186. else n = 0;
  1187. wlen = wsprintf(ch, VEC_ELLIP, sCENTERX, sCENTERY, sEllX, sEllY,
  1188. sEllX2, sCENTERY, sEllX2, sCENTERY, n);
  1189. WriteSpoolBuf(lpdv, ch, wlen);
  1190. #if 0
  1191. // for opaque style line
  1192. if(n == 1 || lpnp->fTrans == TRUE || lpnp->wPenWidth > 1 ||
  1193. !lpnp->wPenStyle)
  1194. {
  1195. WriteSpoolBuf(lpdv, ch, wlen);
  1196. break;
  1197. }
  1198. if(lpnp->wPenColor == SG_BLACK)
  1199. {
  1200. WriteSpoolBuf(lpdv, VEC_LT_WHITE);
  1201. WriteSpoolBuf(lpdv, ch, wlen);
  1202. wlen = wsprintf(ch, VEC_LT_STYLE_B, lpnp->wPenStyle);
  1203. WriteSpoolBuf(lpdv, ch, wlen);
  1204. wlen = wsprintf(ch, VEC_ELLIP, sEllX, sEllY, sEllX2, sCENTERY,
  1205. sEllX2, sCENTERY, 0);
  1206. WriteSpoolBuf(lpdv, ch, wlen);
  1207. }
  1208. else
  1209. {
  1210. WriteSpoolBuf(lpdv, VEC_LT_SOLID);
  1211. WriteSpoolBuf(lpdv, ch, wlen);
  1212. wlen = wsprintf(ch, VEC_LT_STYLE, lpnp->wPenStyle);
  1213. WriteSpoolBuf(lpdv, ch, wlen);
  1214. }
  1215. #endif
  1216. }
  1217. break;
  1218. #if 0
  1219. // for NPDL2+ vector graphics mode(add Naka 95/5/9)
  1220. case VO_E_PIE:
  1221. case VO_E_ARC:
  1222. case VO_E_CHORD:
  1223. {
  1224. short n;
  1225. short i;
  1226. short sPIEX1;
  1227. short sPIEY1;
  1228. short sPIEX2;
  1229. short sPIEY2;
  1230. long X1;
  1231. long Y1;
  1232. long X2;
  1233. long Y2;
  1234. int iDegree;
  1235. short sCENTERX;
  1236. short sCENTERY;
  1237. short rx;
  1238. short ry;
  1239. if(lpnp->fCurve == FALSE)
  1240. {
  1241. lpnp->fFill = lpnp->fStroke = FALSE;
  1242. lpnp->fCurve = TRUE;
  1243. return;
  1244. }
  1245. lpnp->fCurve = FALSE;
  1246. if(lpnp->fFill == FALSE && lpnp->fStroke == FALSE) return;
  1247. i = wCmdCbId - VO_ELLIPSE;
  1248. if(i == 2 && lpnp->fStroke == FALSE) return;
  1249. sPIEX1 = m2d((short)*lpdwParams, lpnp->wRes);
  1250. sPIEY1 = m2d((short)*(lpdwParams + 1), lpnp->wRes);
  1251. sPIEX2 = m2d((short)*(lpdwParams + 2), lpnp->wRes);
  1252. sPIEY2 = m2d((short)*(lpdwParams + 3), lpnp->wRes);
  1253. X1 = (short)*(lpdwParams + 4); // transformed(r=5000) scale
  1254. Y1 = (short)*(lpdwParams + 5); // transformed(r=5000) scale
  1255. iDegree = (short)*(lpdwParams + 6); // transformed(r=5000) degree
  1256. if(!iDegree) return;
  1257. if(iDegree < 0) iDegree += 3600;
  1258. sCENTERX = (sPIEX1 + sPIEX2) >> 1;
  1259. sCENTERY = (sPIEY1 + sPIEY2) >> 1;
  1260. rx = (sPIEX2 - sPIEX1) >> 1;
  1261. ry = (sPIEY2 - sPIEY1) >> 1;
  1262. wlen = wsprintf(ch, VEC_CENTER, sCENTERX, sCENTERY);
  1263. WriteSpoolBuf(lpdv, ch, wlen);
  1264. X2 = (X1 * Tcos(iDegree) - Y1 * Tsin(iDegree)) / 10000;
  1265. Y2 = (X1 * Tsin(iDegree) + Y1 * Tcos(iDegree)) / 10000;
  1266. X1 = (long)rx * X1 / 5000 + (long)sCENTERX;
  1267. Y1 = (long)ry * Y1 / 5000 + (long)sCENTERY;
  1268. X2 = (long)rx * X2 / 5000 + (long)sCENTERX;
  1269. Y2 = (long)ry * Y2 / 5000 + (long)sCENTERY;
  1270. if(lpnp->fFill == TRUE) n = lpnp->fStroke == TRUE ? 2 : 1;
  1271. else n = 0;
  1272. switch(i)
  1273. {
  1274. case 1:
  1275. wlen = wsprintf(ch, VEC_E_PIE, rx, ry, (short)X1, (short)Y1,
  1276. (short)X2, (short)Y2, n);
  1277. #if 0
  1278. // for opaque style line
  1279. if(n == 1 || lpnp->fTrans == TRUE || lpnp->wPenWidth > 1 ||
  1280. !lpnp->wPenStyle)
  1281. {
  1282. WriteSpoolBuf(lpdv, ch, wlen);
  1283. break;
  1284. }
  1285. if(lpnp->wPenColor == SG_BLACK)
  1286. {
  1287. WriteSpoolBuf(lpdv, VEC_LT_WHITE);
  1288. WriteSpoolBuf(lpdv, ch, wlen);
  1289. wlen = wsprintf(ch, VEC_LT_STYLE_B, lpnp->wPenStyle);
  1290. WriteSpoolBuf(lpdv, ch, wlen);
  1291. wlen = wsprintf(ch, VEC_E_PIE, rx, ry, (short)X1, (short)Y1,
  1292. (short)X2, (short)Y2, 0);
  1293. WriteSpoolBuf(lpdv, ch, wlen);
  1294. }
  1295. else
  1296. {
  1297. WriteSpoolBuf(lpdv, VEC_LT_SOLID);
  1298. wlen = wsprintf(ch, VEC_E_PIE, rx, ry, (short)X1, (short)Y1,
  1299. (short)X2, (short)Y2, n);
  1300. WriteSpoolBuf(lpdv, ch, wlen);
  1301. wlen = wsprintf(ch, VEC_LT_STYLE, lpnp->wPenStyle);
  1302. WriteSpoolBuf(lpdv, ch, wlen);
  1303. }
  1304. #endif
  1305. break;
  1306. case 2:
  1307. wlen = wsprintf(ch, VEC_E_ARC, rx, ry, (short)X1, (short)Y1,
  1308. (short)X2, (short)Y2);
  1309. #if 0
  1310. // for opaque style line
  1311. {
  1312. BYTE chtmp[CCHMAXCMDLEN];
  1313. wlen = wsprintf(chtmp, VEC_E_ARC, rx, ry, (short)X1, (short)Y1,
  1314. (short)X2, (short)Y2);
  1315. if(lpnp->fTrans == TRUE || lpnp->wPenWidth > 1 || !lpnp->wPenStyle)
  1316. {
  1317. WriteSpoolBuf(lpdv, chtmp, wlen);
  1318. break;
  1319. }
  1320. if(lpnp->wPenColor == SG_BLACK)
  1321. {
  1322. WriteSpoolBuf(lpdv, VEC_LT_WHITE);
  1323. WriteSpoolBuf(lpdv, chtmp, wlen);
  1324. wlen = wsprintf(ch, VEC_LT_STYLE_B, lpnp->wPenStyle);
  1325. WriteSpoolBuf(lpdv, ch, wlen);
  1326. WriteSpoolBuf(lpdv, chtmp, wlen);
  1327. }
  1328. else
  1329. {
  1330. WriteSpoolBuf(lpdv, VEC_LT_SOLID);
  1331. WriteSpoolBuf(lpdv, chtmp, wlen);
  1332. WriteSpoolBuf(lpdv, ch, wlen);
  1333. wlen = wsprintf(ch, VEC_LT_STYLE, lpnp->wPenStyle);
  1334. WriteSpoolBuf(lpdv, ch, wlen);
  1335. }
  1336. }
  1337. #endif
  1338. break;
  1339. case 3:
  1340. wlen = wsprintf(ch, VEC_ELLIP, rx, ry, (short)X1, (short)Y1,
  1341. (short)X2, (short)Y2, n);
  1342. #if 0
  1343. // for opaque style line
  1344. if(n == 1 || lpnp->fTrans == TRUE || lpnp->wPenWidth > 1 ||
  1345. !lpnp->wPenStyle)
  1346. {
  1347. WriteSpoolBuf(lpdv, ch, wlen);
  1348. break;
  1349. }
  1350. if(lpnp->wPenColor == SG_BLACK)
  1351. {
  1352. WriteSpoolBuf(lpdv, VEC_LT_WHITE);
  1353. WriteSpoolBuf(lpdv, ch, wlen);
  1354. wlen = wsprintf(ch, VEC_LT_STYLE_B, lpnp->wPenStyle);
  1355. WriteSpoolBuf(lpdv, ch, wlen);
  1356. wlen = wsprintf(ch, VEC_ELLIP, rx, ry, (short)X1, (short)Y1,
  1357. (short)X2, (short)Y2, 0);
  1358. WriteSpoolBuf(lpdv, ch, wlen);
  1359. }
  1360. else
  1361. {
  1362. WriteSpoolBuf(lpdv, VEC_LT_SOLID);
  1363. WriteSpoolBuf(lpdv, ch, wlen);
  1364. wlen = wsprintf(ch, VEC_LT_STYLE, lpnp->wPenStyle);
  1365. WriteSpoolBuf(lpdv, ch, wlen);
  1366. }
  1367. #endif
  1368. break;
  1369. }
  1370. WriteSpoolBuf(lpdv, ch, wlen);
  1371. }
  1372. break;
  1373. #endif
  1374. // *** Poly Vector Output PV *** //
  1375. case PV_BEGIN:
  1376. {
  1377. int x, y;
  1378. if(!lpdwParams) return;
  1379. x = m2d((int)*lpdwParams, lpnp->wRes);
  1380. y = m2d((int)*(lpdwParams + 1), lpnp->wRes);
  1381. wlen = wsprintf(ch, VEC_BEGIN, x, y);
  1382. WriteSpoolBuf(lpdv, ch, wlen);
  1383. }
  1384. break;
  1385. case PV_CONTINUE:
  1386. {
  1387. int x, y;
  1388. if(!lpdwParams) return;
  1389. x = m2d((int)*(lpdwParams + 4), lpnp->wRes);
  1390. y = m2d((int)*(lpdwParams + 5), lpnp->wRes);
  1391. wlen = wsprintf(ch, VEC_CONTINUE, x, y);
  1392. WriteSpoolBuf(lpdv, ch, wlen);
  1393. }
  1394. break;
  1395. #if 0
  1396. // for Poly Bezier
  1397. case PV_BEGIN_BEZ:
  1398. {
  1399. int x, y;
  1400. if(!lpdwParams) return;
  1401. x = m2d((int)*lpdwParams, lpnp->wRes);
  1402. y = m2d((int)*(lpdwParams + 1), lpnp->wRes);
  1403. wlen = wsprintf(ch, VEC_BEGIN_BEZ, x, y);
  1404. WriteSpoolBuf(lpdv, ch, wlen);
  1405. }
  1406. break;
  1407. case PV_CONTINUE_BEZ:
  1408. {
  1409. int x1, y1, x2, y2, x3, y3;
  1410. if(!lpdwParams) return;
  1411. x1 = m2d((int)*(lpdwParams + 2), lpnp->wRes);
  1412. y1 = m2d((int)*(lpdwParams + 3), lpnp->wRes);
  1413. x2 = m2d((int)*(lpdwParams + 4), lpnp->wRes);
  1414. y2 = m2d((int)*(lpdwParams + 5), lpnp->wRes);
  1415. x3 = m2d((int)*(lpdwParams + 6), lpnp->wRes);
  1416. y3 = m2d((int)*(lpdwParams + 7), lpnp->wRes);
  1417. wlen = wsprintf(ch, VEC_CONTINUE_BEZ, x, y);
  1418. WriteSpoolBuf(lpdv, ch, wlen);
  1419. }
  1420. break;
  1421. #endif
  1422. // *** Vector SupportVS *** //
  1423. case VS_STROKE:
  1424. lpnp->fStroke = TRUE;
  1425. if(lpnp->fCurve == TRUE) return;
  1426. WriteSpoolBuf(lpdv, VEC_STROKE);
  1427. #if 0
  1428. // for opaque style line
  1429. if(lpnp->fTrans == TRUE || lpnp->wPenWidth > 1 || !lpnp->wPenStyle)
  1430. {
  1431. WriteSpoolBuf(lpdv, VEC_STROKE);
  1432. return;
  1433. }
  1434. if(lpnp->wPenColor == SG_BLACK)
  1435. {
  1436. WriteSpoolBuf(lpdv, VEC_SG_PEN_W);
  1437. wlen = wsprintf(ch, VEC_STROKE_OPA_W, (short)lpnp->wPenStyle);
  1438. WriteSpoolBuf(lpdv, ch, wlen);
  1439. WriteSpoolBuf(lpdv, VEC_SG_PEN_B);
  1440. WriteSpoolBuf(lpdv, VEC_STROKE);
  1441. }
  1442. else
  1443. {
  1444. wlen = wsprintf(ch, VEC_STROKE_OPA_W, (short)lpnp->wPenStyle);
  1445. WriteSpoolBuf(lpdv, ch, wlen);
  1446. }
  1447. #endif
  1448. break;
  1449. #if 0
  1450. case VS_WINDFILL:
  1451. lpnp->fFill = TRUE;
  1452. WriteSpoolBuf(lpdv, VEC_WINDFILL);
  1453. break;
  1454. #endif
  1455. case VS_ALTFILL:
  1456. lpnp->fFill = TRUE;
  1457. if(lpnp->fCurve == TRUE) return;
  1458. WriteSpoolBuf(lpdv, VEC_ALTFILL);
  1459. break;
  1460. }
  1461. }
  1462. #ifndef WINNT
  1463. //-------------------------------------------------------------------
  1464. // Function: Enable()
  1465. // Action : call UniEnable and setup Mdv
  1466. //-------------------------------------------------------------------
  1467. short CALLBACK Enable(
  1468. LPDV lpdv,
  1469. WORD style,
  1470. LPSTR lpModel,
  1471. LPSTR lpPort,
  1472. LPDM lpStuff)
  1473. {
  1474. CUSTOMDATA cd;
  1475. short sRet;
  1476. GLOBALHANDLE hTmp;
  1477. LPSTR lpTmp;
  1478. LPNPDL2MDV lpnp;
  1479. DWORD dwMulti, dwType, dwData;
  1480. cd.cbSize = sizeof(CUSTOMDATA);
  1481. cd.hMd = GetModuleHandle((LPSTR)rgchModuleName);
  1482. cd.fnOEMDump = NULL;
  1483. cd.fnOEMOutputChar = NULL;
  1484. sRet = UniEnable(lpdv, style, lpModel, lpPort, lpStuff, &cd);
  1485. if(lpdv && lpdv->iType == BM_DEVICE && !lpdv->fMdv && sRet && !style)
  1486. {
  1487. hTmp = GlobalAlloc(GPTR, sizeof(NPDL2MDV));
  1488. if(!hTmp) return sRet;
  1489. lpTmp = GlobalLock(hTmp);
  1490. if(!lpTmp)
  1491. {
  1492. GlobalFree(hTmp);
  1493. return sRet;
  1494. }
  1495. lpdv->fMdv = TRUE;
  1496. lpdv->lpMdv = lpTmp;
  1497. lpnp = (LPNPDL2MDV)lpdv->lpMdv;
  1498. lpnp->hKeep = hTmp;
  1499. lpnp->wPenColor = SG_BLACK;
  1500. lpnp->wBrStyle = PP_SOLID;
  1501. lpnp->fStroke = FALSE;
  1502. lpnp->fFill = FALSE;
  1503. lpnp->fCurve = FALSE;
  1504. lstrcpy(lpnp->szDevName, lpModel);
  1505. if(DrvGetPrinterData(lpModel, MULTI_SCALE, &dwType, (LPBYTE)&dwMulti,
  1506. sizeof(DWORD), (LPDWORD)&dwData))
  1507. dwMulti = 0;
  1508. lpnp->dwMulti = dwMulti;
  1509. }
  1510. return sRet;
  1511. }
  1512. //-------------------------------------------------------------------
  1513. // Function: Disable()
  1514. // Action : free Mdv and call Mdv
  1515. //-------------------------------------------------------------------
  1516. void WINAPI Disable(
  1517. LPDV lpdv)
  1518. {
  1519. if(lpdv && lpdv->iType == BM_DEVICE && lpdv->fMdv)
  1520. {
  1521. LPNPDL2MDV lpnp;
  1522. lpnp = (LPNPDL2MDV)lpdv->lpMdv;
  1523. GlobalUnlock(lpnp->hKeep);
  1524. GlobalFree(lpnp->hKeep);
  1525. }
  1526. UniDisable(lpdv);
  1527. }
  1528. #endif // WINNT
  1529. #ifdef WINNT
  1530. short OEMOutputChar( lpdv, lpstr, len, rcID )
  1531. LPDV lpdv;
  1532. LPSTR lpstr;
  1533. WORD len;
  1534. WORD rcID;
  1535. {
  1536. WORD wlen;
  1537. WORD i;
  1538. WORD wTmpChar;
  1539. LPSTR lpTmpStr;
  1540. BYTE ch[512];
  1541. LPNPDL2MDV lpnp;
  1542. BOOL fDBCSFont;
  1543. wlen = 0;
  1544. lpTmpStr = lpstr;
  1545. lpnp = (LPNPDL2MDV)lpdv->lpMdv;
  1546. if( rcID != lpnp->wOldFontID )
  1547. {
  1548. lpnp->wCurrentAddMode = 0;
  1549. lpnp->wOldFontID = rcID;
  1550. }
  1551. switch(rcID)
  1552. {
  1553. case 5: // Courier
  1554. case 6: // Helv
  1555. case 7: // TmsRmn
  1556. case 8: // TmsRmn Italic
  1557. fDBCSFont = FALSE;
  1558. break;
  1559. default:
  1560. fDBCSFont = TRUE;
  1561. }
  1562. for(i = 0; i < len;i ++)
  1563. {
  1564. if((fDBCSFont == TRUE) && IsDBCSLeadByteNPDL(*lpTmpStr))
  1565. {
  1566. if(lpnp->wCurrentAddMode != FLAG_DBCS)
  1567. {
  1568. WORD wLen;
  1569. BYTE cH[CCHMAXCMDLEN];
  1570. wLen = wsprintf(cH, FS_ADDRMODE_ON, lpnp->sDBCSXMove,
  1571. lpnp->sDBCSYMove);
  1572. WriteSpoolBuf(lpdv, cH, wLen);
  1573. if(lpnp->fVertFont)
  1574. {
  1575. WriteSpoolBuf(lpdv, ESC_KANJITATE);
  1576. if(lpnp->wScale != 1)
  1577. {
  1578. if(!lpnp->fPlus)
  1579. {
  1580. char *bcom[] = {"1/2", "1/1", "2/1", "3/1",
  1581. "4/1", "4/1", "6/1", "6/1", "8/1"};
  1582. wLen = wsprintf(cH, FS_M_T, (LPSTR)bcom[lpnp->wScale]);
  1583. }
  1584. else wLen = wsprintf(cH, FS_12S2, lpnp->lPointsy, lpnp->lPointsx);
  1585. WriteSpoolBuf(lpdv, cH, wLen);
  1586. }
  1587. }
  1588. lpnp->wCurrentAddMode = FLAG_DBCS;
  1589. }
  1590. wTmpChar = SJis2JisNPDL(SWAPW((WORD)*(LPWORD)lpTmpStr));
  1591. *(LPWORD)(ch+wlen) = SWAPW(wTmpChar);
  1592. wlen+=2;
  1593. lpTmpStr+=2;
  1594. i++;
  1595. }
  1596. else
  1597. {
  1598. if(lpnp->wCurrentAddMode != FLAG_SBCS)
  1599. {
  1600. WORD wLen;
  1601. BYTE cH[CCHMAXCMDLEN];
  1602. wLen = wsprintf(cH, FS_ADDRMODE_ON, lpnp->sSBCSXMove,
  1603. lpnp->sSBCSYMove);
  1604. WriteSpoolBuf(lpdv, cH, wLen);
  1605. if(lpnp->fVertFont)
  1606. {
  1607. WriteSpoolBuf(lpdv, ESC_KANJIYOKO);
  1608. if(lpnp->wScale != 1)
  1609. {
  1610. if(!lpnp->fPlus)
  1611. {
  1612. char *bcom[] = {"1/2", "1/1", "2/1", "3/1",
  1613. "4/1", "4/1", "6/1", "6/1", "8/1"};
  1614. wLen = wsprintf(cH, FS_M_Y, (LPSTR)bcom[lpnp->wScale]);
  1615. }
  1616. else wLen = wsprintf(cH, FS_12S2, lpnp->lPointsx, lpnp->lPointsy);
  1617. WriteSpoolBuf(lpdv, cH, wLen);
  1618. }
  1619. }
  1620. lpnp->wCurrentAddMode = FLAG_SBCS;
  1621. }
  1622. wTmpChar = (WORD)((0x00ff)&(*lpTmpStr));
  1623. if (!fDBCSFont) {
  1624. wTmpChar = Ltn1ToAnk( wTmpChar );
  1625. }
  1626. *(LPWORD)(ch+wlen) = SWAPW(wTmpChar);
  1627. wlen+=2;
  1628. lpTmpStr++;
  1629. }
  1630. }
  1631. WriteSpoolBuf(lpdv, ch, wlen);
  1632. return wlen;
  1633. }
  1634. /*************************** Function Header *******************************
  1635. * MiniDrvEnablePDEV
  1636. *
  1637. * HISTORY:
  1638. * 30 Apl 1996 -by- Sueya Sugihara [sueyas]
  1639. * Created it, from NT/DDI spec.
  1640. *
  1641. ***************************************************************************/
  1642. BOOL
  1643. MiniDrvEnablePDEV(
  1644. LPDV lpdv,
  1645. ULONG *pdevcaps)
  1646. {
  1647. int i;
  1648. LPSTR lpTmp;
  1649. LPNPDL2MDV lpnp;
  1650. lpTmp = UniDrvAllocMem(sizeof(NPDL2MDV));
  1651. if(!lpTmp)
  1652. {
  1653. return FALSE;
  1654. }
  1655. lpdv->fMdv = TRUE;
  1656. lpdv->lpMdv = lpTmp;
  1657. lpnp = (LPNPDL2MDV)lpdv->lpMdv;
  1658. lpnp->wPenColor = SG_BLACK;
  1659. lpnp->wBrStyle = PP_SOLID;
  1660. lpnp->fStroke = FALSE;
  1661. lpnp->fFill = FALSE;
  1662. lpnp->fCurve = FALSE;
  1663. lpnp->dwMulti = 0;
  1664. lpnp->fComp = FALSE;
  1665. lpnp->Color = 0;
  1666. lpnp->wCurrentAddMode = 0;
  1667. lpnp->wOldFontID = 0;
  1668. // Check if user selects MONO
  1669. if( (((PGDIINFO)pdevcaps)->cBitsPixel == 1) &&
  1670. (((PGDIINFO)pdevcaps)->cPlanes == 1))
  1671. lpnp->fMono = TRUE;
  1672. else{
  1673. lpnp->fMono = FALSE;
  1674. }
  1675. return TRUE;
  1676. }
  1677. /*************************** Function Header *******************************
  1678. * MiniDrvDisablePDEV
  1679. *
  1680. * HISTORY:
  1681. * 30 Apl 1996 -by- Sueya Sugihara [sueyas]
  1682. * Created it, from NT/DDI spec.
  1683. *
  1684. ***************************************************************************/
  1685. VOID
  1686. MiniDrvDisablePDEV(
  1687. LPDV lpdv)
  1688. {
  1689. LPNPDL2MDV lpnp;
  1690. if ( lpdv && lpdv->fMdv )
  1691. {
  1692. UniDrvFreeMem( lpdv->lpMdv );
  1693. }
  1694. }
  1695. DRVFN
  1696. MiniDrvFnTab[] =
  1697. {
  1698. { INDEX_MiniDrvEnablePDEV, (PFN)MiniDrvEnablePDEV },
  1699. { INDEX_MiniDrvDisablePDEV, (PFN)MiniDrvDisablePDEV },
  1700. { INDEX_OEMWriteSpoolBuf, (PFN)CBFilterGraphics },
  1701. { INDEX_OEMSendScalableFontCmd, (PFN)OEMSendScalableFontCmd },
  1702. { INDEX_OEMGetFontCmd, (PFN)fnOEMGetFontCmd },
  1703. { INDEX_OEMOutputCmd, (PFN)fnOEMOutputCmd },
  1704. { INDEX_OEMOutputChar, (PFN)OEMOutputChar },
  1705. { INDEX_OEMTTBitmap, (PFN)fnOEMTTBitmap }
  1706. };
  1707. BOOL
  1708. MiniDrvEnableDriver(
  1709. MINIDRVENABLEDATA *pEnableData
  1710. )
  1711. {
  1712. if (pEnableData == NULL)
  1713. return FALSE;
  1714. if (pEnableData->cbSize == 0)
  1715. {
  1716. pEnableData->cbSize = sizeof (MINIDRVENABLEDATA);
  1717. return TRUE;
  1718. }
  1719. if (pEnableData->cbSize < sizeof (MINIDRVENABLEDATA)
  1720. || HIBYTE(pEnableData->DriverVersion)
  1721. < HIBYTE(MDI_DRIVER_VERSION))
  1722. {
  1723. // Wrong size and/or mismatched version
  1724. return FALSE;
  1725. }
  1726. // Load callbacks provided by the Unidriver
  1727. if (!bLoadUniDrvCallBack(pEnableData,
  1728. INDEX_UniDrvWriteSpoolBuf, (PFN *) &WriteSpoolBuf)
  1729. ||!bLoadUniDrvCallBack(pEnableData,
  1730. INDEX_UniDrvAllocMem, (PFN *) &UniDrvAllocMem)
  1731. ||!bLoadUniDrvCallBack(pEnableData,
  1732. INDEX_UniDrvFreeMem, (PFN *) &UniDrvFreeMem))
  1733. {
  1734. return FALSE;
  1735. }
  1736. pEnableData->cMiniDrvFn
  1737. = sizeof (MiniDrvFnTab) / sizeof(MiniDrvFnTab[0]);
  1738. pEnableData->pMiniDrvFn = MiniDrvFnTab;
  1739. return TRUE;
  1740. }
  1741. #endif //WINNT