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.

5309 lines
223 KiB

  1. /*++
  2. Copyright (c) 1996-2002 Microsoft Corp. & Ricoh Co., Ltd. All rights reserved.
  3. FILE: RPDLRES.C
  4. Abstract: Main file for OEM rendering plugin module.
  5. Functions: OEMCommandCallback
  6. bOEMSendFontCmd
  7. bOEMOutputCharStr
  8. OEMDownloadFontHeader
  9. OEMDownloadCharGlyph
  10. OEMTTDownloadMethod
  11. OEMCompression
  12. Environment: Windows NT Unidrv5 driver
  13. Revision History:
  14. 04/07/1997 -zhanw-
  15. Created it.
  16. 08/11/1997 -Masatoshi Kubokura-
  17. Began to modify for RPDL.
  18. 04/22/1999 -Masatoshi Kubokura-
  19. Last modified for Windows2000.
  20. 08/30/1999 -Masatoshi Kubokura-
  21. Began to modify for NT4SP6(Unidrv5.4).
  22. 09/27/1999 -Masatoshi Kubokura-
  23. Last modified for NT4SP6.
  24. 02/17/2000 -Masatoshi Kubokura-
  25. V.1.02 release
  26. 04/07/2000 -Masatoshi Kubokura-
  27. Fix bug of SET_IBM_EXT_BLOCK with 1200dpi printer (RPDL bug)
  28. 05/22/2000 -Masatoshi Kubokura-
  29. V.1.03 for NT4 release
  30. 06/30/2000 -Masatoshi Kubokura-
  31. V.1.04 release
  32. 01/22/2001 -Masatoshi Kubokura-
  33. V.1.05 release
  34. 02/05/2001 -Masatoshi Kubokura-
  35. Add "Thick Paper"
  36. 03/15/2001 -Masatoshi Kubokura-
  37. Fix RectangleFill bug
  38. Last modified for XP(Whistler).
  39. 06/29/2001 -Masatoshi Kubokura-
  40. V.1.07
  41. Fix RPDL staple bug.(NX800,810,910,MF2230,2730,3530e,3570e,4570e).
  42. Enable SET_PAPERDEST_FINISHER at GW model.
  43. 03/04/2002 -Masatoshi Kubokura-
  44. Include strsafe.h.
  45. Add FileNameBufSize as arg3 at RWFileData().
  46. Use safe_sprintfA() instead of sprintf().
  47. 03/27/2002 -Masatoshi Kubokura-
  48. Eliminate "#if 0".
  49. 04/02/2002 -Masatoshi Kubokura-
  50. Check pdevobj NULL pointer before using at OEMCommandCallback().
  51. 11/20-22/2002 -yasuho & Kubokura-
  52. Fix memory leak.
  53. Last modified for .NET Server.
  54. --*/
  55. #include <stdio.h>
  56. #include "pdev.h"
  57. #ifndef WINNT_40
  58. #include "strsafe.h" // @Mar/01/2002
  59. #endif // !WINNT_40
  60. #if DBG
  61. //#define DBG_OUTPUTCHARSTR 1
  62. //#define giDebugLevel DBG_VERBOSE // enable VERBOSE() in each file
  63. #endif
  64. //
  65. // Misc definitions and declarations.
  66. //
  67. #define STDVAR_BUFSIZE(n) \
  68. (sizeof (GETINFO_STDVAR) + sizeof(DWORD) * 2 * ((n) - 1)) // MSKK 1/24/98
  69. #define MASTER_TO_SPACING_UNIT(p, n) \
  70. ((n) / (p)->nResoRatio)
  71. #ifndef WINNT_40
  72. //#define sprintf wsprintfA // @Sep/30/98
  73. #define strcmp lstrcmpA // @Sep/30/98
  74. #endif // WINNT_40
  75. // External Functions' prototype
  76. // @Mar/01/2002 ->
  77. //extern BOOL RWFileData(PFILEDATA pFileData, LPWSTR pwszFileName, LONG type); // add pwszFileName @Aug/31/99
  78. extern BOOL RWFileData(PFILEDATA pFileData, LPWSTR pwszFileName, LONG FileNameBufSize, LONG type);
  79. extern INT safe_sprintfA(char* pszDest, size_t cchDest, const char* pszFormat, ...);
  80. // @Mar/01/2002 <-
  81. // Local Functions' prototype
  82. static BYTE IsDBCSLeadByteRPDL(BYTE Ch);
  83. static BYTE IsDifferentPRNFONT(BYTE Ch);
  84. static VOID DrawTOMBO(PDEVOBJ pdevobj, SHORT action);
  85. static VOID AssignIBMfont(PDEVOBJ pdevobj, SHORT rcID, SHORT action);
  86. static VOID SendFaxNum(PDEVOBJ pdevobj);
  87. #ifdef JISGTT
  88. static VOID jis2sjis(BYTE jis[], BYTE sjis[]);
  89. #endif // JISGTT
  90. static INT DRCompression(PBYTE pInBuf, PBYTE pOutBuf, DWORD dwInLen, DWORD dwOutLen,
  91. DWORD dwWidthByte, DWORD dwHeight);
  92. //
  93. // Static data to be used by this minidriver.
  94. //
  95. static BYTE ShiftJisRPDL[256] = {
  96. // +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
  97. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //00
  98. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //10
  99. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //20
  100. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //30
  101. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //40
  102. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //50
  103. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //60
  104. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //70
  105. 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, //80
  106. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, //90
  107. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //A0
  108. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //B0
  109. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //C0
  110. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //D0
  111. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, //E0
  112. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 //F0
  113. };
  114. // Some vertical device font differ from TrueType font
  115. static BYTE VerticalFontCheck[256] = {
  116. // +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
  117. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //00
  118. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //10
  119. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //20
  120. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //30
  121. 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, //40
  122. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //50
  123. 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, //60
  124. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, //70
  125. 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, //80
  126. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //90
  127. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //A0
  128. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //B0
  129. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //C0
  130. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, //D0
  131. 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //E0
  132. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 //F0
  133. };
  134. static BYTE UpdateDate[] = "04/04/2002";
  135. // OBSOLETE (described in GPD) @Feb/15/98 ->
  136. // Emulation Mode after printing
  137. //static BYTE *RPDLProgName[] = {
  138. // "1@R98", "1@R16", "1@RPS", "1@R55", // 0- 3
  139. // "1@RGL", "1@GL2", "1@R52", "1@R73", // 4- 7
  140. // "1@R35", "1@R01", // 8- 9
  141. // "0@P1", "0@P2", "0@P3", "0@P4", // 10-13
  142. // "0@P5", "0@P6", "0@P7", "0@P8", // 14-17
  143. // "0@P9", "0@P10", "0@P11", "0@P12", // 18-21
  144. // "0@P13", "0@P14", "0@P15", "0@P16" // 22-25
  145. //};
  146. //static BYTE *RPDLProgName2[] = {
  147. // "-1,1,1@R98", "-1,1,1@R16", "-1,1,1@RPS", "-1,1,1@R55", // 0- 3
  148. // "-1,1,1@RGL", "-1,1,1@GL2", "-1,1,1@R52", "-1,1,1@R73", // 4- 7
  149. // "-1,1,1@R35", "-1,1,1@R01", // 8- 9
  150. // "0,1,2@P1", "0,1,2@P2", "0,1,2@P3", "0,1,2@P4", // 10-13
  151. // "0,1,2@P5", "0,1,2@P6", "0,1,2@P7", "0,1,2@P8", // 14-17
  152. // "0,1,2@P9", "0,1,2@P10", "0,1,2@P11", "0,1,2@P12", // 18-21
  153. // "0,1,2@P13", "0,1,2@P14", "0,1,2@P15", "0,1,2@P16" // 22-25
  154. //};
  155. //#define PRG_RPGL 4
  156. // @Feb/15/98 <-
  157. // RPDL pagesize (unit:masterunit)
  158. static POINT RPDLPageSize[] = {
  159. {2688L*MASTERUNIT/240L, 3888L*MASTERUNIT/240L}, // A3
  160. {1872L*MASTERUNIT/240L, 2720L*MASTERUNIT/240L}, // A4
  161. {1280L*MASTERUNIT/240L, 1904L*MASTERUNIT/240L}, // A5
  162. { 880L*MASTERUNIT/240L, 1312L*MASTERUNIT/240L}, // A6
  163. {2336L*MASTERUNIT/240L, 3352L*MASTERUNIT/240L}, // B4
  164. {1600L*MASTERUNIT/240L, 2352L*MASTERUNIT/240L}, // B5
  165. {1104L*MASTERUNIT/240L, 1640L*MASTERUNIT/240L}, // B6
  166. {2528L*MASTERUNIT/240L, 4000L*MASTERUNIT/240L}, // Tabloid
  167. {1920L*MASTERUNIT/240L, 3280L*MASTERUNIT/240L}, // Legal
  168. {1920L*MASTERUNIT/240L, 2528L*MASTERUNIT/240L}, // Letter
  169. {1200L*MASTERUNIT/240L, 1968L*MASTERUNIT/240L}, // Statement
  170. {3969L*MASTERUNIT/240L, 5613L*MASTERUNIT/240L}, // A2->A3
  171. {6480L*MASTERUNIT/400L, 8960L*MASTERUNIT/400L}, // A2
  172. {6667L*MASTERUNIT/400L, 8448L*MASTERUNIT/400L}, // C
  173. {5587L*MASTERUNIT/400L, 7792L*MASTERUNIT/400L}, // B3 @Jan/07/98
  174. {2688L*MASTERUNIT/240L, 3888L*MASTERUNIT/240L}, // A3->A4 @Feb/04/98
  175. {2336L*MASTERUNIT/240L, 3352L*MASTERUNIT/240L}, // B4->A4 @Feb/04/98
  176. {6600L*MASTERUNIT/600L, 8160L*MASTERUNIT/600L}, // 11x15->A4 @Jan/27/2000
  177. { 880L*MASTERUNIT/240L, 1312L*MASTERUNIT/240L} // Postcard since NX700 @Feb/13/98
  178. };
  179. #define PAGESPACE_2IN1_100 12 // mm
  180. static WORD PageSpace_2IN1_67[] = {
  181. 30, 23, 22, 18, // A3,A4,A5,A6
  182. 25, 23, 19, 56, // B4,B5,B6,Tabloid
  183. 6, 6, 35, 6, // Legal(disable),Letter,Statement,A2->A3(disable)
  184. 6, 6, 6, 6, // A2(disable),C(disable),B3(disable),A3->A4(disable)
  185. 6, 6, 6 // B4->A4(disable),11x15->A4(disable),Postcard(disable)
  186. };
  187. static POINT RPDLPageSizeE2E[] = {
  188. {(2970000L/254L+5L)/10L*MASTERUNIT/100L, (4200000L/254L+5L)/10L*MASTERUNIT/100L}, // A3
  189. {(2100000L/254L+5L)/10L*MASTERUNIT/100L, (2970000L/254L+5L)/10L*MASTERUNIT/100L}, // A4
  190. {(1480000L/254L+5L)/10L*MASTERUNIT/100L, (2100000L/254L+5L)/10L*MASTERUNIT/100L}, // A5
  191. {(1050000L/254L+5L)/10L*MASTERUNIT/100L, (1480000L/254L+5L)/10L*MASTERUNIT/100L}, // A6
  192. {(2570000L/254L+5L)/10L*MASTERUNIT/100L, (3640000L/254L+5L)/10L*MASTERUNIT/100L}, // B4
  193. {(1820000L/254L+5L)/10L*MASTERUNIT/100L, (2570000L/254L+5L)/10L*MASTERUNIT/100L}, // B5
  194. {(1280000L/254L+5L)/10L*MASTERUNIT/100L, (1820000L/254L+5L)/10L*MASTERUNIT/100L}, // B6
  195. {110L*MASTERUNIT/10L, 170L*MASTERUNIT/10L}, // Tabloid
  196. { 85L*MASTERUNIT/10L, 140L*MASTERUNIT/10L}, // Legal
  197. { 85L*MASTERUNIT/10L, 110L*MASTERUNIT/10L}, // Letter
  198. { 55L*MASTERUNIT/10L, 85L*MASTERUNIT/10L}, // Statement
  199. {(4200000L/254L+5L)/10L*MASTERUNIT/100L, (5940000L/254L+5L)/10L*MASTERUNIT/100L}, // A2->A3
  200. {(4200000L/254L+5L)/10L*MASTERUNIT/100L, (5940000L/254L+5L)/10L*MASTERUNIT/100L}, // A2
  201. {170L*MASTERUNIT/10L, 220L*MASTERUNIT/10L}, // C
  202. {(3640000L/254L+5L)/10L*MASTERUNIT/100L, (5140000L/254L+5L)/10L*MASTERUNIT/100L}, // B3
  203. {(2970000L/254L+5L)/10L*MASTERUNIT/100L, (4200000L/254L+5L)/10L*MASTERUNIT/100L}, // A3->A4
  204. {(2570000L/254L+5L)/10L*MASTERUNIT/100L, (3640000L/254L+5L)/10L*MASTERUNIT/100L}, // B4->A4
  205. {110L*MASTERUNIT/10L, 150L*MASTERUNIT/10L}, // 11x15 -> A4 @Jan/27/2000
  206. {(1000000L/254L+5L)/10L*MASTERUNIT/100L, (1480000L/254L+5L)/10L*MASTERUNIT/100L} // Postcard since NX700
  207. };
  208. #define PAGESPACE_2IN1_100E2E 0 // mm
  209. static WORD PageSpace_2IN1_67E2E[] = {
  210. 18, 11, 10, 6, // A3,A4,A5,A6
  211. 15, 11, 9, 43, // B4,B5,B6,Tabloid
  212. 0, 0, 23, 0, // Legal(disable),Letter,Statement,A2->A3(disable)
  213. 0, 0, 0, 0, // A2(disable),C(disable),B3(disable),A3->A4(disable)
  214. 0, 0, 0 // B4->A4(disable),11x15->A4(disable),Postcard(disable)
  215. };
  216. #define RPDL_A3 0
  217. #define RPDL_A4 1
  218. #define RPDL_A5 2
  219. #define RPDL_A6 3 // A6/Postcard
  220. #define RPDL_B4 4
  221. #define RPDL_B5 5
  222. #define RPDL_B6 6
  223. #define RPDL_TABD 7
  224. #define RPDL_LEGL 8
  225. #define RPDL_LETR 9
  226. #define RPDL_STAT 10
  227. #define RPDL_A2A3 11
  228. #define RPDL_A2 12
  229. #define RPDL_C 13
  230. #define RPDL_B3 14
  231. #define RPDL_A3A4 15
  232. #define RPDL_B4A4 16
  233. #define RPDL_11x15A4 17 // @Jan/27/2000
  234. #define RPDL_POSTCARD 18 // Postcard since NX700
  235. #define RPDL_CUSTOMSIZE 99
  236. // RPDL command definition
  237. static BYTE BS[] = "\x08";
  238. static BYTE FF[] = "\x0C";
  239. static BYTE CR[] = "\x0D";
  240. static BYTE LF[] = "\x0A";
  241. static BYTE DOUBLE_BS[] = "\x08\x08";
  242. static BYTE DOUBLE_SPACE[] = "\x20\x20";
  243. static BYTE BEGIN_SEND_BLOCK_C[] = "\x1B\x12G3,%d,%d,,2,,,%u@";
  244. static BYTE BEGIN_SEND_BLOCK_NC[] = "\x1B\x12G3,%d,%d,,,@";
  245. static BYTE BEGIN_SEND_BLOCK_DRC[] = "\x1B\x12G3,%d,%d,,5,,@";
  246. static BYTE ESC_ROT0[] = "\x1B\x12\x46\x30\x20";
  247. static BYTE ESC_ROT90[] = "\x1B\x12\x46\x39\x30\x20";
  248. static BYTE ESC_VERT_ON[] = "\x1B\x12&2\x20";
  249. static BYTE ESC_VERT_OFF[] = "\x1B\x12&1\x20";
  250. static BYTE ESC_SHIFT_IN[] = "\x1B\x0F";
  251. static BYTE ESC_SHIFT_OUT[] = "\x1B\x0E";
  252. static BYTE ESC_CTRLCODE[] = "\x1B\x12K1\x20";
  253. static BYTE ESC_HALFDOWN[] = "\x1B\x55";
  254. static BYTE ESC_HALFUP[] = "\x1B\x44";
  255. static BYTE ESC_DOWN[] = "\x1B\x55\x1B\x55";
  256. static BYTE ESC_UP[] = "\x1B\x44\x1B\x44";
  257. static BYTE ESC_BOLD_ON[] = "\x1BO";
  258. static BYTE ESC_BOLD_OFF[] = "\x1B&";
  259. static BYTE ESC_ITALIC_ON[] = "\x1B\x12I-16\x20";
  260. static BYTE ESC_ITALIC_OFF[] = "\x1B\x12I0\x20";
  261. static BYTE ESC_WHITETEXT_ON[] = "\x1B\x12W5,0\x20";
  262. static BYTE ESC_WHITETEXT_OFF[] = "\x1B\x12W0,0\x20";
  263. static BYTE ESC_XM_ABS[] = "\x1B\x12H%d\x20";
  264. static BYTE ESC_XM_REL[] = "\x1B\x12\x20+%d\x20";
  265. static BYTE ESC_XM_RELLEFT[] = "\x1B\x12\x20-%d\x20";
  266. static BYTE ESC_YM_ABS[] = "\x1B\x12V%d\x20";
  267. static BYTE ESC_YM_REL[] = "\x1B\x12\x0A+%d\x20";
  268. static BYTE ESC_YM_RELUP[] = "\x1B\x12\x0A-%d\x20";
  269. static BYTE ESC_CLIPPING[] = "\x1B\x12*%d,%d,%d,%d\x20";
  270. static BYTE SELECT_PAPER_CUSTOM[] = "\x1B\x12\x3F\x35%ld,%ld\x1B\x20";
  271. static BYTE SELECT_PAPER_CUSTOM2[]= "\x1B\x12\x3F\x35%ld,%ld,%d\x1B\x20"; // %ld<-%d @Sep/27/2000, %d<-%c @Oct/13/2000
  272. static BYTE SELECT_TRAY_N[] = "\x1B\x19%d"; // %d<-%c @Oct/13/2000
  273. static BYTE SELECT_PAPER_HEAD[] = "\x1B\x12\x35\x32@";
  274. static BYTE SEL_TRAY_PAPER_HEAD[] = "\x1B\x12\x35@";
  275. static BYTE SELECT_PAPER_HEAD_IP1[] = "\x1B\x12\x35\x33@";
  276. static BYTE SELECT_PAPER_A1[] = "A1\x1B\x20";
  277. static BYTE SELECT_PAPER_A2[] = "A2\x1B\x20";
  278. static BYTE SELECT_PAPER_A3[] = "A3\x1B\x20";
  279. static BYTE SELECT_PAPER_A4[] = "A4\x1B\x20"; // @May/25/98
  280. static BYTE SELECT_PAPER_A4R[] = "A4R\x1B\x20";
  281. static BYTE SELECT_PAPER_A4X[] = "A4X\x1B\x20";
  282. static BYTE SELECT_PAPER_A4W[] = "A4R\x1B\x20\x1B\x12\x35@A4\x1B\x20";
  283. static BYTE SELECT_PAPER_A5[] = "A5\x1B\x20"; // @May/25/98
  284. static BYTE SELECT_PAPER_A5R[] = "A5R\x1B\x20";
  285. static BYTE SELECT_PAPER_A5X[] = "A5X\x1B\x20";
  286. static BYTE SELECT_PAPER_A5W[] = "A5R\x1B\x20\x1B\x12\x35@A5\x1B\x20";
  287. static BYTE SELECT_PAPER_A6[] = "A6\x1B\x20";
  288. static BYTE SELECT_PAPER_PC[] = "PC\x1B\x20"; // @May/25/98
  289. static BYTE SELECT_PAPER_PCR[] = "PCR\x1B\x20"; // @Feb/13/98
  290. static BYTE SELECT_PAPER_PCX[] = "PCX\x1B\x20"; // @Feb/13/98
  291. static BYTE SELECT_PAPER_B3[] = "B3\x1B\x20"; // @Jan/07/98
  292. static BYTE SELECT_PAPER_B4[] = "B4\x1B\x20";
  293. static BYTE SELECT_PAPER_B5[] = "B5\x1B\x20"; // @May/25/98
  294. static BYTE SELECT_PAPER_B5R[] = "B5R\x1B\x20";
  295. static BYTE SELECT_PAPER_B5X[] = "B5X\x1B\x20";
  296. static BYTE SELECT_PAPER_B5W[] = "B5R\x1B\x20\x1B\x12\x35@B5\x1B\x20";
  297. static BYTE SELECT_PAPER_B6[] = "B6\x1B\x20";
  298. static BYTE SELECT_PAPER_C[] = "FLT\x1B\x20";
  299. static BYTE SELECT_PAPER_TABD[] = "DLT\x1B\x20";
  300. static BYTE SELECT_PAPER_LEGL[] = "LG\x1B\x20";
  301. static BYTE SELECT_PAPER_LETR[] = "LT\x1B\x20"; // @May/25/98
  302. static BYTE SELECT_PAPER_LETRR[] = "LTR\x1B\x20";
  303. static BYTE SELECT_PAPER_LETRX[] = "LTX\x1B\x20";
  304. static BYTE SELECT_PAPER_LETRW[] = "LTR\x1B\x20\x1B\x12\x35@LT\x1B\x20";
  305. static BYTE SELECT_PAPER_STAT[] = "HL\x1B\x20"; // @May/25/98
  306. static BYTE SELECT_PAPER_STATR[] = "HLR\x1B\x20";
  307. static BYTE SELECT_PAPER_STATX[] = "HLX\x1B\x20";
  308. static BYTE SELECT_PAPER_STATW[] = "HLR\x1B\x20\x1B\x12\x35@HLT\x1B\x20";
  309. static BYTE SET_LIMITLESS_SUPPLY[]= "\x1B\x12Z2\x20";
  310. static BYTE RESET_LIMITLESS_SUPPLY[]= "\x1B\x12Z1\x20"; // @Sep/27/2000
  311. static BYTE SELECT_MANUALFEED[] = "\x1B\x19T";
  312. static BYTE SELECT_MULTIFEEDER[] = "\x1B\x19M";
  313. static BYTE SELECT_ROLL1[] = "\x1B\x12Y1,2\x20";
  314. static BYTE SELECT_ROLL2[] = "\x1B\x12Y1,4\x20";
  315. //static BYTE SET_EMULATION[] = "\x1B\x12!%s\x1B\x20";
  316. //static BYTE SET_EMULATION_GL_EX[] = "MS-1,6,11;";
  317. static BYTE SET_PORTRAIT[] = "\x1B\x12\x44\x31\x20";
  318. static BYTE SET_LANDSCAPE[] = "\x1B\x12\x44\x32\x20";
  319. static BYTE SET_LEFTMARGIN[] = "\x1B\x12YK,%d\x20";
  320. static BYTE SET_UPPERMARGIN[] = "\x1B\x12YL,%d\x20";
  321. static BYTE SET_LEFTMARGIN_9II[] = "\x1B\x12?Y,K:%d\x1B\x20";
  322. static BYTE SET_UPPERMARGIN_9II[] = "\x1B\x12?Y,L:%d\x1B\x20";
  323. static BYTE SET_MULTI_COPY[] = "\x1B\x12N%d\x20";
  324. // PRINTER SIDE ISSUE: MF3550 RPDL @Feb/22/99 ->
  325. // Since 'backslash' can't be printed in Japanese region ('KUNIBETSU'),
  326. // set 1st param to 1 for USA region.
  327. //static BYTE SET_IBM_EXT_BLOCK[] = "\x1B\x12?@,,1\x1B\x20";
  328. static BYTE SET_IBM_EXT_BLOCK[] = "\x1B\x12?@1,,1\x1B\x20";
  329. // @Feb/22/99 <-
  330. static BYTE SET_PAGEMAX_VALID[] = "\x1B\x12?+1\x1B\x20";
  331. static BYTE DUPLEX_ON[] = "\x1B\x12\x36\x31,1\x20";
  332. static BYTE DUPLEX_HORZ[] = "\x1B\x12YA3,1\x20";
  333. static BYTE DUPLEX_VERT[] = "\x1B\x12YA3,2\x20";
  334. static BYTE DUPLEX_VERT_R[] = "\x1B\x12YA3,3\x20";
  335. //static BYTE IMAGE_2IN1[] = "\x1B\x12\x36\x32,\x20";
  336. static BYTE IMAGE_OPT_OFF[] = "\x1B\x12\x36\x30,1,0\x20";
  337. static BYTE IMAGE_SCALING_100[] = "\x1B\x12YM,1\x20";
  338. static BYTE IMAGE_SCALING_88[] = "\x1B\x12YM,2\x20";
  339. static BYTE IMAGE_SCALING_80[] = "\x1B\x12YM,3\x20";
  340. static BYTE IMAGE_SCALING_75[] = "\x1B\x12YM,4\x20";
  341. static BYTE IMAGE_SCALING_70[] = "\x1B\x12YM,5\x20";
  342. static BYTE IMAGE_SCALING_67[] = "\x1B\x12YM,6\x20";
  343. static BYTE IMAGE_SCALING_115[] = "\x1B\x12YM,7\x20";
  344. static BYTE IMAGE_SCALING_122[] = "\x1B\x12YM,8\x20";
  345. static BYTE IMAGE_SCALING_141[] = "\x1B\x12YM,9\x20";
  346. static BYTE IMAGE_SCALING_200[] = "\x1B\x12YM,10\x20";
  347. static BYTE IMAGE_SCALING_283[] = "\x1B\x12YM,11\x20";
  348. static BYTE IMAGE_SCALING_400[] = "\x1B\x12YM,12\x20";
  349. static BYTE IMAGE_SCALING_122V[] = "\x1B\x12?M122,1\x1B\x20"; // variable ratio
  350. static BYTE IMAGE_SCALING_141V[] = "\x1B\x12?M141,1\x1B\x20";
  351. static BYTE IMAGE_SCALING_200V[] = "\x1B\x12?M200,1\x1B\x20";
  352. static BYTE IMAGE_SCALING_50V[] = "\x1B\x12?M50,1\x1B\x20";
  353. static BYTE IMAGE_SCALING_VAR[] = "\x1B\x12?M%d,1\x1B\x20";
  354. static BYTE SET_PAPERDEST_OUTTRAY[] = "\x1B\x12\x38\x33,2\x20";
  355. static BYTE SET_PAPERDEST_FINISHER[] = "\x1B\x12\x38\x46,2,%d\x20"; // %d<-1 @Jun/25/2001
  356. static BYTE SET_PAPERDEST_FINISHER_GW[] = "\x1B\x12\x38\x46,,%d\x20"; // @Jun/25/2001
  357. static BYTE SET_PAPERDEST_1BINSHIFT[] = "\x1B\x12\x38\x49,,1\x20"; // @Oct/10/2000
  358. // RPDL SPEC changed at NX900. @Jan/08/99 ->
  359. //static BYTE SET_SORT_ON[] = "\x1B\x12\x36,,1\x20";
  360. static BYTE SET_SORT_ON[] = "\x1B\x12\x36%d,,1\x20";
  361. // @Jan/08/99 <-
  362. static BYTE SET_STAPLE_ON[] = "\x1B\x12?O22,0,%d\x1B\x20";
  363. static BYTE SET_STAPLE_CORNER_ON[] = "\x1B\x12?O22,1,%d\x1B\x20";
  364. static BYTE SET_PUNCH_ON[] = "\x1B\x12?O32,%d\x1B\x20";
  365. static BYTE SELECT_MEDIATYPE[] = "\x1B\x12?6%c,%d\x1B\x20"; // %d<-%c @Oct/13/2000
  366. static BYTE COLLATE_DISABLE_ROT[] = "\x1B\x12?O11\x1B\x20"; // @May/27/98
  367. static BYTE COLLATE_ENABLE_ROT[] = "\x1B\x12?O12\x1B\x20"; // @Jul/31/98
  368. static BYTE SET_TEXTRECT_BLACK[] = "\x1B\x12P3,64\x20";
  369. static BYTE SET_TEXTRECT_WHITE[] = "\x1B\x12W0,3\x20\x1B\x12P3,1\x20"; // @Aug/15/98
  370. static BYTE SET_TEXTRECT_GRAY[] = "\x1B\x12P3,%d,1\x20"; // add ",1" @Aug/15/98
  371. static BYTE DRAW_TEXTRECT[] = "\x1B\x12R%d,%d,%d,%d\x20";
  372. static BYTE DRAW_TEXTRECT_R_P3[] = "\x1B\x12r%d,%d,%d\x20";
  373. static BYTE DRAW_TEXTRECT_R_P4[] = "\x1B\x12r%d,%d,%d,%d\x20";
  374. // @Jun/25/2001 ->
  375. static BYTE BEGINDOC_TOP[] = "\x1B\x12!1@R00\x1B\x20";
  376. static BYTE BEGINDOC_TOP_JOBDEF[] = "\x1B\x12!1@R00\x1B\x20\x1B\x12?JS@\x1B@\x1B@\x1B@\x1B@\x1B\x20";
  377. static BYTE BEGINDOC1_2[] = "\x1B\x34\x1B\x12YJ,3\x20";
  378. // @Jun/25/2001 <-
  379. static BYTE BEGINDOC1[] = "\x1B\x12!1@R00\x1B\x20\x1B\x34\x1B\x12YJ,3\x20";
  380. static BYTE BEGINDOC2_1[] = "\x1B\x12YP,1\x20\x1B\x12YQ,2\x20";
  381. static BYTE BEGINDOC2_2[] = "\x1B\x12YQ,2\x20";
  382. static BYTE BEGINDOC3[] = "\x1B\x12YA6,1\x20";
  383. static BYTE SELECT_RES240_1[] = "\x1B\x12YI,6\x20";
  384. static BYTE SELECT_RES240_2[] = "\x1B\x12YW,2\x20\x1B\x12YA4,2\x20\x1B\x12#3\x20";
  385. static BYTE SELECT_RES400_1[] = "\x1B\x12\x36\x30,1,0\x20\x1B\x12YI,7\x20\x1B\x12YW,1\x20";
  386. static BYTE SELECT_RES400_2[] = "\x1B\x12YA4,1\x20";
  387. static BYTE SELECT_RES400_3[] = "\x1B\x12#2\x20";
  388. static BYTE SELECT_RES600[] = "\x1B\x12\x36\x30,1,0\x20\x1B\x12YI,8\x20\x1B\x12YW,3\x20\x1B\x12YA4,3\x20\x1B\x12#4\x20";
  389. static BYTE SELECT_RES1200[] = "\x1B\x12\x36\x30,1,0\x20\x1B\x12YI,9\x20\x1B\x12YW,4\x20\x1B\x12YA4,4\x20\x1B\x12#5\x20"; // @Mar/02/99
  390. static BYTE SELECT_REGION_STD[] = "\x1B\x12YB,1\x20";
  391. static BYTE SELECT_REGION_E2E[] = "\x1B\x12YB,2\x20";
  392. static BYTE ENDDOC1[] = "\x1B\x12YB,1\x20\x1B\x12YI,1\x20\x1B\x12YJ,1\x20\x1B\x12YM,1\x20";
  393. static BYTE ENDDOC2_240DPI[] = "\x1B\x12YW,2\x20\x1B\x12YA4,2\x20";
  394. static BYTE ENDDOC2_SP9[] = "\x1B\x12YW,2\x20\x1B\x12YA4,1\x20";
  395. static BYTE ENDDOC2_400DPI[] = "\x1B\x12YW,1\x20\x1B\x12YA4,1\x20";
  396. static BYTE ENDDOC3[] = "\x1B\x12#0\x20";
  397. static BYTE ENDDOC4[] = "\x1B\x12\x36\x30,0,0\x20";
  398. static BYTE ENDDOC4_FINISHER[] = "\x1B\x12\x36\x30,0\x20";
  399. static BYTE ENDDOC_JOBDEF_END[] = "\x1B\x12?JE@\x1B@\x1B@\x1B@\x1B@\x1B\x20"; // @Jan/08/99
  400. static BYTE ENDDOC5[] = "\x1B\x1AI";
  401. static BYTE SELECT_SMOOTHING2[] = "\x1B\x12YA2,2\x20";
  402. // If you change FONT_NAME, see AssignIBMfont().
  403. static BYTE SET_IBM_FONT_SCALE[] = "\x1B\x12\x43%d,M,%ld,%ld,4@I55\x20";
  404. static BYTE SET_IBM_FONT_SCALE_H_ONLY[] = "\x1B\x12\x43%d,M,,%ld,4@I55\x20"; // @Jan/29/99
  405. static BYTE *SET_IBM_FONT_NAME[] = {"CHUMINCYO\x1B\x20",
  406. "MINCYO-BOLD\x1B\x20",
  407. "MINCYO-E B\x1B\x20",
  408. "GOTHIC\x1B\x20",
  409. "GOTHIC-M\x1B\x20",
  410. "GOTHIC-E B\x1B\x20",
  411. "MARUGOTHIC\x1B\x20",
  412. "MARUGOTHIC-M\x1B\x20",
  413. "MARUGOTHIC-L\x1B\x20",
  414. "GYOUSHO\x1B\x20",
  415. "KAISHO\x1B\x20",
  416. "KYOUKASHO\x1B\x20"};
  417. static BYTE SET_JIS_FONT_SCALE[] = "\x1B\x12\x43\x5A,M,%ld,%ld@";
  418. static BYTE SET_JIS_FONT_SCALE_H_ONLY[] = "\x1B\x12\x43\x5A,M,,%ld@"; // @Jan/29/99
  419. static BYTE *SET_JIS_FONT_NAME[] = {"CHUMINCYO\x1B\x20",
  420. "MINCYO-BOLD\x1B\x20",
  421. "MINCYO-EXTRA BOLD\x1B\x20",
  422. "GOTHIC\x1B\x20",
  423. "GOTHIC-MEDIUM\x1B\x20",
  424. "GOTHIC-EXTRA BOLD\x1B\x20",
  425. "MARUGOTHIC\x1B\x20",
  426. "MARUGOTHIC-MEDIUM\x1B\x20",
  427. "MARUGOTHIC-LIGHT\x1B\x20",
  428. "GYOUSHO\x1B\x20",
  429. "KAISHO\x1B\x20",
  430. "KYOUKASHO\x1B\x20"};
  431. #ifdef DOWNLOADFONT
  432. //static BYTE DLFONT_MALLOC[] = "\x1B\x12/128,8\x20";
  433. static BYTE DLFONT_MALLOC[] = "\x1B\x12/%d,%d\x20";
  434. static BYTE DLFONT_SEND_BLOCK[] = "\x1B\x12G7,%d,%d,%d,@";
  435. static BYTE DLFONT_SEND_BLOCK_DRC[] = "\x1B\x12G7,%d,%d,%d,5,,,%d@";
  436. static BYTE DLFONT_PRINT[] = "\x1B\x12g%d,,%d\x20";
  437. #endif // DOWNLOADFONT
  438. static BYTE ENTER_VECTOR[] = "\x1B\x33";
  439. static BYTE EXIT_VECTOR[] = "\x1B\x34";
  440. static BYTE TERMINATOR[] = ";";
  441. static BYTE MOVE_ABSOLUTE[] = "MA%d,%d";
  442. static BYTE BAR_CHECKDIGIT[] = "BC1";
  443. static BYTE BAR_H_SET[] = "BH%d";
  444. static BYTE BAR_W_SET_JAN[] = "JW%d";
  445. static BYTE BAR_W_SET_2OF5[] = "TW";
  446. static BYTE BAR_W_SET_C39[] = "CW";
  447. static BYTE BAR_W_SET_NW7[] = "NW";
  448. static BYTE BAR_W_PARAMS[] = "%d,%d,%d,%d,%d";
  449. static BYTE BAR_ROT90[ ] = "RO90";
  450. static BYTE BAR_ROT270[] = "RO270";
  451. // @Dec/07/99 FK#50 ->
  452. static BYTE BAR_W_SET_CUST[] = "CS";
  453. // @Dec/07/99 FK#50 <-
  454. static BYTE *BAR_TYPE[] = {"JL", // JAN(STANDARD)
  455. "JS", // JAN(SHORT)
  456. "TI%d,", // 2of5(INDUSTRIAL)
  457. "TX%d,", // 2of5(MATRIX)
  458. "TL%d,", // 2of5(ITF)
  459. "CD%d,", // CODE39
  460. "NB%d,", // NW-7
  461. // @Dec/07/99 FK#50 ->
  462. "CU%d,", // CUSTOMER
  463. "CE%d", // CODE128(B)
  464. "JU", // UPC(A)
  465. "JE" // UPC(W)
  466. // @Dec/07/99 FK#50 <-
  467. };
  468. static BYTE *BAR_NOFONT[] = {"FJ1,-1", // JAN(STANDARD)
  469. "FJ1,-1", // JAN(SHORT)
  470. "FT2,-1", // 2of5(INDUSTRIAL)
  471. "FT2,-1", // 2of5(MATRIX)
  472. "FT2,-1", // 2of5(ITF)
  473. "FC2,-1", // CODE39
  474. "FN2,-1", // NW-7
  475. // @Dec/07/99 FK#50 ->
  476. "", // CUSTOMER
  477. "FC2,-1", // CODE128
  478. "FJ1,-1", // UPC(A)
  479. "FJ1,-1" // UPC(W)
  480. // @Dec/07/99 FK#50 <-
  481. };
  482. static BYTE PEN_WIDTH[] = "LW%d"; // @Sep/14/98
  483. static BYTE DRAW_TOMBO_POLYLINE[] = "MA%d,%dMRPD%d,%d,%d,%d"; // @Sep/14/98
  484. // @Jun/25/2001 ->
  485. //static BYTE BEGINFAX_HEAD[] = "\x1B\x12!1@R00\x1B\x20\x1B\x12?F1,%d,%d,%d,180,1,";
  486. static BYTE BEGINFAX_HEAD[] = "\x1B\x12?F1,%d,%d,%d,180,1,";
  487. // @Jun/25/2001 <-
  488. static BYTE BEGINFAX_CH[] = "@%d:";
  489. static BYTE BEGINFAX_EXTNUM[] = "%s-";
  490. static BYTE BEGINFAX_TAIL[] = ",%08d,RPDLMINI,%d,1,2,1,1,,1,%d,%s,1,,1,,,1,\x1B\x20";
  491. static BYTE ENDFAX[] = "\x1B\x12?F2,1\x1B\x20";
  492. INT APIENTRY OEMCommandCallback(
  493. PDEVOBJ pdevobj,
  494. DWORD dwCmdCbID,
  495. DWORD dwCount,
  496. PDWORD pdwParams)
  497. {
  498. INT ocmd, iRet;
  499. BYTE Cmd[256];
  500. SHORT nTmp;
  501. LPSTR lpcmd;
  502. WORD fLandscape, fFinisherSR30Active, fDoFormFeed, fPaperX;
  503. // @Apr/02/2002 ->
  504. // POEMUD_EXTRADATA pOEMExtra = MINIPRIVATE_DM(pdevobj); // @Oct/06/98
  505. // POEMPDEV pOEM = MINIDEV_DATA(pdevobj); // @Oct/06/98
  506. POEMUD_EXTRADATA pOEMExtra;
  507. POEMPDEV pOEM;
  508. // @Apr/02/2002 <-
  509. // VERBOSE(("OEMCommandCallback() entry.\n"));
  510. //
  511. // verify pdevobj okay
  512. //
  513. ASSERT(VALID_PDEVOBJ(pdevobj));
  514. // @Apr/02/2002 ->
  515. pOEMExtra = MINIPRIVATE_DM(pdevobj);
  516. pOEM = MINIDEV_DATA(pdevobj);
  517. // @Apr/02/2002 <-
  518. //
  519. // fill in printer commands
  520. //
  521. ocmd = 0;
  522. iRet = 0;
  523. // If TextMode RectangleFill or Move_X,Y are not called now &&
  524. // Move_X,Y command is saved, then flush the command here.
  525. if (dwCmdCbID != CMD_SET_TEXTRECT_W && dwCmdCbID != CMD_SET_TEXTRECT_H &&
  526. dwCmdCbID != CMD_DRAW_TEXTRECT &&
  527. dwCmdCbID != CMD_DRAW_TEXTRECT_REL && // @Dec/11/97
  528. dwCmdCbID != CMD_DRAW_TEXTRECT_WHITE && // @Aug/14/98
  529. dwCmdCbID != CMD_DRAW_TEXTRECT_WHITE_REL && // @Aug/14/98
  530. !(dwCmdCbID >= CMD_XM_ABS && dwCmdCbID <= CMD_YM_RELUP)) // @Aug/28/98
  531. {
  532. if (BITTEST32(pOEM->fGeneral2, TEXTRECT_CONTINUE)) // @Dec/11/97
  533. {
  534. BITCLR32(pOEM->fGeneral2, TEXTRECT_CONTINUE);
  535. // If white-rect has been done before, set raster drawmode to OR. @Jan/20/99
  536. if (!pOEM->TextRectGray)
  537. {
  538. if (BITTEST32(pOEM->fGeneral1, FONT_WHITETEXT_ON))
  539. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_ON, sizeof(ESC_WHITETEXT_ON)-1);
  540. else
  541. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_OFF, sizeof(ESC_WHITETEXT_OFF)-1);
  542. }
  543. }
  544. if (dwCmdCbID == CMD_FF)
  545. {
  546. BITCLR32(pOEM->fGeneral1, YM_ABS_GONNAOUT);
  547. BITCLR32(pOEM->fGeneral1, XM_ABS_GONNAOUT);
  548. }
  549. if (BITTEST32(pOEM->fGeneral1, YM_ABS_GONNAOUT))
  550. {
  551. BITCLR32(pOEM->fGeneral1, YM_ABS_GONNAOUT);
  552. // Output Move_Y command here.
  553. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ESC_YM_ABS, pOEM->TextCurPos.y);
  554. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  555. }
  556. if (BITTEST32(pOEM->fGeneral1, XM_ABS_GONNAOUT))
  557. {
  558. BITCLR32(pOEM->fGeneral1, XM_ABS_GONNAOUT);
  559. // Output Move_X command here.
  560. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ESC_XM_ABS, pOEM->TextCurPos.x);
  561. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  562. }
  563. }
  564. switch (dwCmdCbID) {
  565. case CMD_SET_TEXTRECT_W: // pdwParams:RectXSize
  566. pOEM->TextRect.x = *pdwParams / pOEM->nResoRatio;
  567. break;
  568. case CMD_SET_TEXTRECT_H: // pdwParams:RectYSize
  569. pOEM->TextRect.y = *pdwParams / pOEM->nResoRatio;
  570. break;
  571. case CMD_DRAW_TEXTRECT_WHITE: // @Aug/14/98, pdwParams:DestX,DestY @Aug/28/98
  572. if (pOEM->TextRectGray || !BITTEST32(pOEM->fGeneral2, TEXTRECT_CONTINUE))
  573. {
  574. pOEM->TextRectGray = 0;
  575. WRITESPOOLBUF(pdevobj, SET_TEXTRECT_WHITE, sizeof(SET_TEXTRECT_WHITE)-1);
  576. }
  577. goto _DRAW_RECT;
  578. case CMD_DRAW_TEXTRECT: // pdwParams:DestX,DestY,GrayPercentage
  579. // If white-rect has been done before, set raster drawmode to OR. @Jan/20/99
  580. if (!pOEM->TextRectGray)
  581. {
  582. if (BITTEST32(pOEM->fGeneral1, FONT_WHITETEXT_ON))
  583. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_ON, sizeof(ESC_WHITETEXT_ON)-1);
  584. else
  585. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_OFF, sizeof(ESC_WHITETEXT_OFF)-1);
  586. }
  587. if ((WORD)*(pdwParams+2) >= 1 && (WORD)*(pdwParams+2) <= 100 &&
  588. (WORD)*(pdwParams+2) != pOEM->TextRectGray) // @Jan/08/98, 3rd param @Aug/28/98
  589. {
  590. if ((pOEM->TextRectGray = (WORD)*(pdwParams+2)) == 100) // @Aug/26/98
  591. {
  592. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_TEXTRECT_BLACK);
  593. }
  594. else
  595. {
  596. WORD gray;
  597. if ((gray = pOEM->TextRectGray * RPDLGRAYMAX / 100) < RPDLGRAYMIN)
  598. gray = RPDLGRAYMIN; // use RPDLGRAYMIN @Aug/15/98
  599. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_TEXTRECT_GRAY, gray);
  600. }
  601. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  602. }
  603. _DRAW_RECT: // @Aug/14/98
  604. // @Jan/13/99 ->
  605. if (!BITTEST32(pOEM->fGeneral2, TEXTRECT_CONTINUE))
  606. BITSET32(pOEM->fGeneral2, TEXTRECT_CONTINUE);
  607. // @Jan/13/99 <-
  608. {
  609. LONG x = pOEM->TextCurPos.x;
  610. LONG y = pOEM->TextCurPosRealY; // y without page_length adjustment
  611. LONG w = pOEM->TextRect.x;
  612. LONG h = pOEM->TextRect.y;
  613. LONG dest_x = *pdwParams / pOEM->nResoRatio + pOEM->Offset.x;
  614. // UNIDRV5 SIDE ISSUE
  615. // We can rely on DestX, except when CmdCR is emitted.
  616. // Following bugs are concerned.
  617. // - RPDL117&124: Current x isn't updated by CMD_XM_ABS while device font
  618. // direct(not-substituted) printing. -> DestX is reliable.
  619. // - #236215: DestX doesn't become 0 after CmdCR when current y is 0.
  620. // (SP8 WINPARTy printarea.exe) -> TextCurPos.x is reliable.
  621. // - DestX doesn't become 0 after CmdCR, even though current y isn't 0.
  622. // (NX720N WINPARTy printarea.exe at 1200dpi) -> TextCurPos.x is reliable.
  623. // @Mar/15/2001 ->
  624. // if (!(x != dest_x && x == pOEM->Offset.x && y == pOEM->Offset.y))
  625. if (!(x != dest_x && x == pOEM->Offset.x))
  626. // @Mar/15/2001 <-
  627. pOEM->TextCurPos.x = x = dest_x;
  628. // Convert unit from dot to 1/720inch_unit at OLD models
  629. if (!(TEST_AFTER_SP10(pOEM->fModel) || BITTEST32(pOEM->fModel, GRP_MF150E)))
  630. {
  631. if (pOEM->nResoRatio == MASTERUNIT/240) // 240dpi printer
  632. {
  633. x *= 3; // 3 = 720/240
  634. y *= 3;
  635. w *= 3;
  636. h *= 3;
  637. }
  638. else // MF530,150
  639. {
  640. x *= 18; // 18 = 720/400*10
  641. w = (w * 18 + x % 10) / 10; // Adjust fractional part
  642. x /= 10; // KIRISUTE
  643. y *= 18;
  644. h = (h * 18 + y % 10) / 10;
  645. y /= 10;
  646. }
  647. }
  648. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), DRAW_TEXTRECT, x, y, w, h);
  649. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  650. }
  651. break;
  652. case CMD_DRAW_TEXTRECT_WHITE_REL: // @Aug/14/98, pdwParams:DestX,DestY @Aug/28/98
  653. if (pOEM->TextRectGray || !BITTEST32(pOEM->fGeneral2, TEXTRECT_CONTINUE))
  654. {
  655. pOEM->TextRectGray = 0;
  656. WRITESPOOLBUF(pdevobj, SET_TEXTRECT_WHITE, sizeof(SET_TEXTRECT_WHITE)-1);
  657. }
  658. goto _DRAW_RECT_REL;
  659. // Relative-coordinate rectangle command since NX-510 @Dec/12/97
  660. case CMD_DRAW_TEXTRECT_REL: // pdwParams:DestX,DestY,GrayPercentage
  661. // If white-rect has been done before, set raster drawmode to OR. @Jan/20/99
  662. if (!pOEM->TextRectGray)
  663. {
  664. if (BITTEST32(pOEM->fGeneral1, FONT_WHITETEXT_ON))
  665. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_ON, sizeof(ESC_WHITETEXT_ON)-1);
  666. else
  667. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_OFF, sizeof(ESC_WHITETEXT_OFF)-1);
  668. }
  669. if ((WORD)*(pdwParams+2) >= 1 && (WORD)*(pdwParams+2) <= 100 &&
  670. (WORD)*(pdwParams+2) != pOEM->TextRectGray) // @Jan/08/98, 3rd param @Aug/28/98
  671. {
  672. if ((pOEM->TextRectGray = (WORD)*(pdwParams+2)) == 100) // @Aug/26/98
  673. {
  674. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_TEXTRECT_BLACK);
  675. }
  676. else
  677. {
  678. WORD gray;
  679. if ((gray = pOEM->TextRectGray * RPDLGRAYMAX / 100) < RPDLGRAYMIN)
  680. gray = RPDLGRAYMIN; // use RPDLGRAYMIN @Aug/15/98
  681. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_TEXTRECT_GRAY, gray);
  682. }
  683. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  684. }
  685. _DRAW_RECT_REL: // @Aug/14/98
  686. {
  687. LONG dest_x = *pdwParams / pOEM->nResoRatio + pOEM->Offset.x;
  688. // UNIDRV5 SIDE ISSUE
  689. // @Mar/15/2001 ->
  690. // if (!(pOEM->TextCurPos.x != dest_x && pOEM->TextCurPos.x == pOEM->Offset.x &&
  691. // pOEM->TextCurPosRealY == pOEM->Offset.y))
  692. if (!(pOEM->TextCurPos.x != dest_x && pOEM->TextCurPos.x == pOEM->Offset.x))
  693. // @Mar/15/2001 <-
  694. {
  695. pOEM->TextCurPos.x = dest_x;
  696. }
  697. }
  698. if (!BITTEST32(pOEM->fGeneral2, TEXTRECT_CONTINUE))
  699. {
  700. BITSET32(pOEM->fGeneral2, TEXTRECT_CONTINUE);
  701. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), DRAW_TEXTRECT,
  702. pOEM->TextCurPos.x, pOEM->TextCurPosRealY,
  703. pOEM->TextRect.x, pOEM->TextRect.y);
  704. }
  705. else
  706. {
  707. LONG x = pOEM->TextCurPos.x - pOEM->TextRectPrevPos.x;
  708. LONG y = pOEM->TextCurPosRealY - pOEM->TextRectPrevPos.y;
  709. // If height is 1dot, this parameter can be omitted.
  710. if (pOEM->TextRect.y != 1)
  711. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), DRAW_TEXTRECT_R_P4, x, y,
  712. pOEM->TextRect.x, pOEM->TextRect.y);
  713. else
  714. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), DRAW_TEXTRECT_R_P3, x, y,
  715. pOEM->TextRect.x);
  716. }
  717. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  718. pOEM->TextRectPrevPos.x = pOEM->TextCurPos.x;
  719. pOEM->TextRectPrevPos.y = pOEM->TextCurPosRealY;
  720. break;
  721. case CMD_SET_SRCBMP_H: // @Jun/04/98
  722. pOEM->dwSrcBmpHeight = *pdwParams;
  723. break;
  724. case CMD_SET_SRCBMP_W: // @Jun/04/98
  725. pOEM->dwSrcBmpWidthByte = *pdwParams;
  726. break;
  727. case CMD_OEM_COMPRESS_ON: // @Jun/04/98
  728. // VERBOSE(("** OEM_COMPRESS_ON **\n"));
  729. BITSET32(pOEM->fGeneral2, OEM_COMPRESS_ON);
  730. BITCLR32(pOEM->fGeneral1, RLE_COMPRESS_ON);
  731. break;
  732. case CMD_RLE_COMPRESS_ON:
  733. // VERBOSE(("** RLE_COMPRESS_ON **\n"));
  734. BITSET32(pOEM->fGeneral1, RLE_COMPRESS_ON);
  735. BITCLR32(pOEM->fGeneral2, OEM_COMPRESS_ON); // @Jun/04/98
  736. break;
  737. case CMD_COMPRESS_OFF:
  738. // VERBOSE(("** COMPRESS_OFF **\n"));
  739. BITCLR32(pOEM->fGeneral1, RLE_COMPRESS_ON);
  740. BITCLR32(pOEM->fGeneral2, OEM_COMPRESS_ON); // @Jun/04/98
  741. break;
  742. case CMD_SEND_BLOCK: // pdwParams:NumOfDataBytes,RasterDataH&W
  743. // Do FE-DeltaRow compression @Jun/04/98
  744. if (BITTEST32(pOEM->fGeneral2, OEM_COMPRESS_ON))
  745. {
  746. // VERBOSE(("** OEM_COMPRESS_SEND (%d) **\n", *pdwParams));
  747. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGIN_SEND_BLOCK_DRC,
  748. (WORD)*(pdwParams+2) * 8, // RasterDataWidthInBytes
  749. (WORD)*(pdwParams+1)); // RasterDataHeightInPixels
  750. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  751. }
  752. else
  753. {
  754. // Do FE-RunLength compression
  755. if (BITTEST32(pOEM->fGeneral1, RLE_COMPRESS_ON))
  756. {
  757. // VERBOSE(("** RLE_COMPRESS_SEND (%d) **\n", *pdwParams));
  758. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGIN_SEND_BLOCK_C,
  759. (WORD)*(pdwParams+2) * 8, // RasterDataWidthInBytes
  760. (WORD)*(pdwParams+1), // RasterDataHeightInPixels
  761. (WORD)*pdwParams); // NumOfDataBytes
  762. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  763. }
  764. // No compression
  765. else
  766. {
  767. // VERBOSE(("** NO_COMPRESS_SEND (%d) **\n", *pdwParams));
  768. {
  769. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGIN_SEND_BLOCK_NC,
  770. (WORD)*(pdwParams+2) * 8, // RasterDataWidthInBytes
  771. (WORD)*(pdwParams+1)); // RasterDataHeightInPixels
  772. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  773. }
  774. }
  775. }
  776. break;
  777. case CMD_XM_ABS: // pdwParams:DestX
  778. if (!BITTEST32(pOEM->fGeneral2, BARCODE_DATA_VALID))
  779. {
  780. #ifdef DOWNLOADFONT
  781. pOEM->nCharPosMoveX = 0;
  782. #endif // DOWNLOADFONT
  783. iRet = pOEM->TextCurPos.x = *pdwParams / pOEM->nResoRatio; // @Aug/28/98
  784. pOEM->TextCurPos.x += pOEM->Offset.x;
  785. // Output Move_X command later.
  786. BITSET32(pOEM->fGeneral1, XM_ABS_GONNAOUT);
  787. // VERBOSE(("** CMD_XM_ABS iRet=%d **\n", iRet));
  788. }
  789. break;
  790. case CMD_YM_ABS: // pdwParams:DestY
  791. if (!BITTEST32(pOEM->fGeneral2, BARCODE_DATA_VALID))
  792. {
  793. iRet = pOEM->TextCurPos.y = *pdwParams / pOEM->nResoRatio; // @Aug/28/98
  794. pOEM->TextCurPosRealY = pOEM->TextCurPos.y;
  795. // PRINTER SIDE ISSUE: RPDL
  796. // Because RPDL do formfeed when vertical position is around
  797. // ymax-coordinate, we shift position upper 1mm.
  798. if (pOEM->TextCurPos.y > pOEM->PageMaxMoveY)
  799. pOEM->TextCurPos.y = pOEM->PageMaxMoveY;
  800. pOEM->TextCurPos.y += pOEM->Offset.y;
  801. pOEM->TextCurPosRealY += pOEM->Offset.y;
  802. // Output Move_Y command later.
  803. BITSET32(pOEM->fGeneral1, YM_ABS_GONNAOUT);
  804. // VERBOSE(("** CMD_YM_ABS iRet=%d **\n", iRet));
  805. }
  806. break;
  807. case CMD_XM_REL: // pdwParams:DestXRel
  808. if (!BITTEST32(pOEM->fGeneral2, BARCODE_DATA_VALID))
  809. {
  810. iRet = *pdwParams / pOEM->nResoRatio; // @Aug/28/98
  811. pOEM->TextCurPos.x += iRet;
  812. // Output Move_X command later.
  813. BITSET32(pOEM->fGeneral1, XM_ABS_GONNAOUT);
  814. }
  815. break;
  816. case CMD_XM_RELLEFT: // pdwParams:DestXRel
  817. if (!BITTEST32(pOEM->fGeneral2, BARCODE_DATA_VALID))
  818. {
  819. iRet = *pdwParams / pOEM->nResoRatio; // @Aug/28/98
  820. pOEM->TextCurPos.x -= iRet;
  821. // Output Move_X command later.
  822. BITSET32(pOEM->fGeneral1, XM_ABS_GONNAOUT);
  823. }
  824. break;
  825. case CMD_YM_REL: // pdwParams:DestYRel
  826. if (!BITTEST32(pOEM->fGeneral2, BARCODE_DATA_VALID))
  827. {
  828. iRet = *pdwParams / pOEM->nResoRatio; // @Aug/28/98
  829. pOEM->TextCurPos.y += iRet;
  830. pOEM->TextCurPosRealY = pOEM->TextCurPos.y;
  831. if (pOEM->TextCurPos.y > pOEM->PageMaxMoveY)
  832. pOEM->TextCurPos.y = pOEM->PageMaxMoveY;
  833. // Output Move_Y command later.
  834. BITSET32(pOEM->fGeneral1, YM_ABS_GONNAOUT);
  835. }
  836. break;
  837. case CMD_YM_RELUP: // pdwParams:DestYRel
  838. if (!BITTEST32(pOEM->fGeneral2, BARCODE_DATA_VALID))
  839. {
  840. iRet = *pdwParams / pOEM->nResoRatio; // @Aug/28/98
  841. pOEM->TextCurPos.y -= iRet;
  842. pOEM->TextCurPosRealY = pOEM->TextCurPos.y;
  843. // Output Move_Y command later.
  844. BITSET32(pOEM->fGeneral1, YM_ABS_GONNAOUT);
  845. }
  846. break;
  847. case CMD_CR:
  848. #ifdef DOWNLOADFONT
  849. pOEM->nCharPosMoveX = 0; // @Jan/19/98
  850. #endif // DOWNLOADFONT
  851. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), CR);
  852. if ((pOEM->TextCurPos.x = pOEM->Offset.x) != 0)
  853. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ESC_XM_ABS, pOEM->TextCurPos.x);
  854. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  855. // VERBOSE(("** CMD_CR **\n"));
  856. break;
  857. case CMD_LF:
  858. WRITESPOOLBUF(pdevobj, LF, sizeof(LF)-1);
  859. break;
  860. case CMD_BS:
  861. WRITESPOOLBUF(pdevobj, BS, sizeof(BS)-1);
  862. break;
  863. case CMD_FF:
  864. fDoFormFeed = FALSE;
  865. // If 2in1
  866. if (TEST_2IN1_MODE(pOEM->fGeneral1))
  867. {
  868. // If 2nd page finished
  869. if (pOEM->Nin1RemainPage)
  870. {
  871. pOEM->Nin1RemainPage = 0;
  872. // Initialize offset
  873. pOEM->Offset.x = pOEM->BaseOffset.x;
  874. pOEM->Offset.y = pOEM->BaseOffset.y;
  875. // Output formfeed command later
  876. fDoFormFeed = TRUE;
  877. }
  878. // If not 2nd page, disable formfeed and increase offset.
  879. else
  880. {
  881. WORD PageSpace, wTmp;
  882. pOEM->Nin1RemainPage++;
  883. // space(dot) between 2pages of 2in1.
  884. if (BITTEST32(pOEM->fGeneral2, EDGE2EDGE_PRINT)) // @Nov/27/97
  885. {
  886. wTmp = BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_67)?
  887. PageSpace_2IN1_67E2E[pOEM->DocPaperID] :
  888. PAGESPACE_2IN1_100E2E;
  889. }
  890. else
  891. {
  892. wTmp = BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_67)?
  893. PageSpace_2IN1_67[pOEM->DocPaperID] :
  894. PAGESPACE_2IN1_100;
  895. }
  896. PageSpace = ((WORD)(MASTERUNIT*10)/(WORD)254) * wTmp /
  897. pOEM->nResoRatio;
  898. if (BITTEST32(pOEM->fGeneral1, ORIENT_LANDSCAPE))
  899. pOEM->Offset.y = pOEM->PageMax.y + pOEM->BaseOffset.y + PageSpace;
  900. else
  901. pOEM->Offset.x = pOEM->PageMax.x + pOEM->BaseOffset.x + PageSpace;
  902. } // 'if (Nin1RemainPage) else' end
  903. }
  904. // If 4in1
  905. else if (TEST_4IN1_MODE(pOEM->fGeneral1)) // OLD MF do not support this
  906. {
  907. switch (++pOEM->Nin1RemainPage) // bug fix @Jan/20/99
  908. {
  909. default: // If illegal, treat as 1st page finished.
  910. pOEM->Nin1RemainPage = 1;
  911. pOEM->Offset.y = pOEM->BaseOffset.y;
  912. case 1:
  913. pOEM->Offset.x = pOEM->PageMax.x + pOEM->BaseOffset.x;
  914. break;
  915. case 2:
  916. pOEM->Offset.x = pOEM->BaseOffset.x;
  917. pOEM->Offset.y = pOEM->PageMax.y + pOEM->BaseOffset.y;
  918. break;
  919. case 3:
  920. pOEM->Offset.x = pOEM->PageMax.x + pOEM->BaseOffset.x;
  921. break;
  922. case 4: // 4th page finished
  923. pOEM->Nin1RemainPage = 0;
  924. // Initialize offset
  925. pOEM->Offset.x = pOEM->BaseOffset.x;
  926. pOEM->Offset.y = pOEM->BaseOffset.y;
  927. // Output formfeed command later
  928. fDoFormFeed = TRUE;
  929. break;
  930. }
  931. }
  932. // Usual case (non Nin1 mode)
  933. else
  934. {
  935. // Output formfeed command later
  936. fDoFormFeed = TRUE;
  937. } // 'if (TEST_2IN1_MODE) else if (TEST_4IN1_MODE) else' end
  938. BITCLR32(pOEM->fGeneral1, TEXT_CLIP_VALID);
  939. if (fDoFormFeed)
  940. {
  941. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO)) // @Sep/14/98
  942. DrawTOMBO(pdevobj, DRAW_TOMBO);
  943. WRITESPOOLBUF(pdevobj, FF, sizeof(FF)-1); // moved here @Sep/14/98
  944. // SPEC of RPDL
  945. // Because RPDL's formfeed resets font status(vertical-text, bold, italic,
  946. // white-text and TextMode clipping), we must output these commands again.
  947. if (BITTEST32(pOEM->fGeneral1, FONT_VERTICAL_ON))
  948. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ESC_VERT_ON);
  949. if (BITTEST32(pOEM->fGeneral1, FONT_BOLD_ON))
  950. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ESC_BOLD_ON);
  951. if (BITTEST32(pOEM->fGeneral1, FONT_ITALIC_ON))
  952. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ESC_ITALIC_ON);
  953. if (BITTEST32(pOEM->fGeneral1, FONT_WHITETEXT_ON))
  954. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ESC_WHITETEXT_ON);
  955. } // 'if (fDoFormFeed)' end
  956. // Reset coordinate x&y
  957. pOEM->TextCurPos.x = pOEM->Offset.x;
  958. pOEM->TextCurPos.y = pOEM->Offset.y;
  959. // SPEC of Unidrv5 & RPDL @Aug/14/98
  960. // Unidrv5 doesn't order to set coordinate x,y to 0 after returning iRet=0,
  961. // and RPDL doesn't reset coordinate y of SEND_BLOCK after initializing
  962. // printer.
  963. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ESC_XM_ABS, pOEM->TextCurPos.x);
  964. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ESC_YM_ABS, pOEM->TextCurPos.y);
  965. // reset coordinate y without page_length adjustment, too.
  966. pOEM->TextCurPosRealY = pOEM->TextCurPos.y;
  967. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  968. break;
  969. case CMD_FONT_BOLD_ON:
  970. if (!BITTEST32(pOEM->fGeneral1, FONT_BOLD_ON)) // add @Jan/28/99
  971. {
  972. BITSET32(pOEM->fGeneral1, FONT_BOLD_ON);
  973. WRITESPOOLBUF(pdevobj, ESC_BOLD_ON, sizeof(ESC_BOLD_ON)-1);
  974. }
  975. break;
  976. case CMD_FONT_BOLD_OFF:
  977. if (BITTEST32(pOEM->fGeneral1, FONT_BOLD_ON)) // add @Jan/28/99
  978. {
  979. BITCLR32(pOEM->fGeneral1, FONT_BOLD_ON);
  980. WRITESPOOLBUF(pdevobj, ESC_BOLD_OFF, sizeof(ESC_BOLD_OFF)-1);
  981. }
  982. break;
  983. case CMD_FONT_ITALIC_ON:
  984. if (!BITTEST32(pOEM->fGeneral1, FONT_ITALIC_ON)) // add @Jan/28/99
  985. {
  986. BITSET32(pOEM->fGeneral1, FONT_ITALIC_ON);
  987. WRITESPOOLBUF(pdevobj, ESC_ITALIC_ON, sizeof(ESC_ITALIC_ON)-1);
  988. }
  989. break;
  990. case CMD_FONT_ITALIC_OFF:
  991. if (BITTEST32(pOEM->fGeneral1, FONT_ITALIC_ON)) // add @Jan/28/99
  992. {
  993. BITCLR32(pOEM->fGeneral1, FONT_ITALIC_ON);
  994. WRITESPOOLBUF(pdevobj, ESC_ITALIC_OFF, sizeof(ESC_ITALIC_OFF)-1);
  995. }
  996. break;
  997. case CMD_FONT_WHITETEXT_ON:
  998. BITSET32(pOEM->fGeneral1, FONT_WHITETEXT_ON);
  999. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_ON, sizeof(ESC_WHITETEXT_ON)-1);
  1000. break;
  1001. case CMD_FONT_WHITETEXT_OFF:
  1002. BITCLR32(pOEM->fGeneral1, FONT_WHITETEXT_ON);
  1003. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_OFF, sizeof(ESC_WHITETEXT_OFF)-1);
  1004. break;
  1005. #ifdef DOWNLOADFONT
  1006. case CMD_DL_SET_FONT_ID: // pdwParams:FontHeight
  1007. // OBSOLETE @Nov/20/98 ->
  1008. // pOEM->DLFontH_MU = (WORD)*pdwParams; // @Jun/30/98
  1009. // @Nov/20/98 <-
  1010. break;
  1011. case CMD_DL_SELECT_FONT_ID:
  1012. // OBSOLETE @Jun/30/98 ->
  1013. // pOEM->DLFontCurID = (WORD)*pdwParams; // CurrentFontID
  1014. // @Jun/30/98 <-
  1015. break;
  1016. case CMD_DL_SET_FONT_GLYPH: // pdwParams:NextGlyph
  1017. // VERBOSE(("[DL_SET_FONT_GLYPH] glyph=%d\n", (SHORT)*pdwParams));
  1018. pOEM->DLFontCurGlyph = (WORD)*pdwParams;
  1019. break;
  1020. //
  1021. // Following cases are called at the beginning of a print-job
  1022. //
  1023. case CMD_SET_MEM0KB: // JOB_SETUP.10 @Jan/14/98
  1024. pOEM->DLFontMaxMemKB = 0; // disabled
  1025. pOEM->pDLFontGlyphInfo = NULL; // @Sep/08/98
  1026. break;
  1027. case CMD_SET_MEM128KB:
  1028. pOEM->DLFontMaxMemKB = MEM128KB; // 128Kbytes
  1029. pOEM->DLFontMaxID = DLFONT_ID_4; // 2->4 @Oct/20/98
  1030. goto _SET_MEM_ENABLE;
  1031. case CMD_SET_MEM256KB:
  1032. pOEM->DLFontMaxMemKB = MEM256KB; // 256Kbytes
  1033. pOEM->DLFontMaxID = DLFONT_ID_8; // 4->8 @Oct/20/98
  1034. goto _SET_MEM_ENABLE;
  1035. case CMD_SET_MEM512KB:
  1036. pOEM->DLFontMaxMemKB = MEM512KB; // 512Kbytes
  1037. pOEM->DLFontMaxID = DLFONT_ID_16; // 8->16 @Oct/20/98
  1038. // goto _SET_MEM_ENABLE;
  1039. _SET_MEM_ENABLE: // @Sep/08/98
  1040. pOEM->DLFontMaxGlyph = DLFONT_GLYPH_TOTAL; // 116->70 @Oct/20/98
  1041. // allocate glyph info structure for TrueType download.
  1042. // fix memory leak @Nov/22/2002 ->
  1043. // if already allocated, exit
  1044. if(pOEM->pDLFontGlyphInfo)
  1045. break;
  1046. // @Nov/22/2002 <-
  1047. if(!(pOEM->pDLFontGlyphInfo = (FONTPOS*)MemAllocZ(pOEM->DLFontMaxID *
  1048. pOEM->DLFontMaxGlyph *
  1049. sizeof(FONTPOS))))
  1050. {
  1051. pOEM->DLFontMaxMemKB = 0; // disabled
  1052. }
  1053. break;
  1054. #endif // DOWNLOADFONT
  1055. case CMD_SELECT_STAPLE_NONE: // JOB_SETUP.20 @Dec/02/97
  1056. pOEM->StapleType = 0;
  1057. break;
  1058. case CMD_SELECT_STAPLE_1:
  1059. pOEM->StapleType = 1;
  1060. break;
  1061. case CMD_SELECT_STAPLE_2:
  1062. pOEM->StapleType = 2;
  1063. break;
  1064. case CMD_SELECT_STAPLE_MAX1: // @Mar/18/99
  1065. pOEM->StapleType = 3; // stapling with FinisherSR12(max 1staple)
  1066. break;
  1067. case CMD_SELECT_PUNCH_NONE: // JOB_SETUP.30 @Dec/02/97
  1068. pOEM->PunchType = 0;
  1069. break;
  1070. case CMD_SELECT_PUNCH_1:
  1071. pOEM->PunchType = 1;
  1072. break;
  1073. case CMD_BEGINDOC_SP4II: // SP4mkII,5
  1074. pOEM->fModel = 0;
  1075. BITSET32(pOEM->fModel, GRP_SP4II);
  1076. // Set Emulation:RPDL, Code:SJIS
  1077. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGINDOC1);
  1078. // Set Graphics:KAN-I G, Page-Length:max
  1079. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BEGINDOC2_1);
  1080. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1081. goto _BEGINDOC_FINISH2; // @Sep/09/98;
  1082. case CMD_BEGINDOC_MF530: // MF530
  1083. pOEM->fModel = 0;
  1084. BITSET32(pOEM->fModel, GRP_MF530);
  1085. // Set Emulation:RPDL, Code:SJIS
  1086. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGINDOC1);
  1087. // Set Page-Length:max
  1088. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BEGINDOC2_2);
  1089. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1090. goto _BEGINDOC_FINISH2; // @Sep/09/98;
  1091. case CMD_BEGINDOC_MF150: // MF150
  1092. pOEM->fModel = 0;
  1093. BITSET32(pOEM->fModel, GRP_MF150);
  1094. goto _BEGINDOC_FINISH1;
  1095. case CMD_BEGINDOC_MF150E: // MF150e,160
  1096. pOEM->fModel = 0;
  1097. BITSET32(pOEM->fModel, GRP_MF150E);
  1098. goto _BEGINDOC_FINISH1;
  1099. case CMD_BEGINDOC_SP8: // SP8(7),8(7)mkII,80
  1100. pOEM->fModel = 0;
  1101. BITSET32(pOEM->fModel, GRP_SP8);
  1102. goto _BEGINDOC_FINISH1;
  1103. case CMD_BEGINDOC_MFP250: // MF-P250,355,250(FAX),355(FAX),MF-FD355,MF-P250e,355e
  1104. pOEM->fModel = 0;
  1105. BITSET32(pOEM->fModel, GRP_MFP250);
  1106. goto _BEGINDOC_FINISH1;
  1107. case CMD_BEGINDOC_SP10: // SP10,10mkII
  1108. pOEM->fModel = 0;
  1109. BITSET32(pOEM->fModel, GRP_SP10);
  1110. goto _BEGINDOC_FINISH1;
  1111. case CMD_BEGINDOC_SP9: // SP9,10Pro
  1112. pOEM->fModel = 0;
  1113. BITSET32(pOEM->fModel, GRP_SP9);
  1114. goto _BEGINDOC_FINISH1;
  1115. case CMD_BEGINDOC_SP9II: // SP9II,10ProII,90
  1116. pOEM->fModel = 0;
  1117. BITSET32(pOEM->fModel, GRP_SP9II);
  1118. goto _BEGINDOC_FINISH1;
  1119. case CMD_BEGINDOC_MF200: // MF200,MF-p150,MF2200
  1120. pOEM->fModel = 0; // (separate BEGINDOC_SP9II @Sep/01/98)
  1121. BITSET32(pOEM->fModel, GRP_MF200);
  1122. goto _BEGINDOC_FINISH1;
  1123. case CMD_BEGINDOC_NX100: // NX-100
  1124. pOEM->fModel = 0;
  1125. // not support IBM extended character block
  1126. BITSET32(pOEM->fModel, GRP_NX100);
  1127. goto _BEGINDOC_FINISH1;
  1128. case CMD_BEGINDOC_NX500: // NX-500,1000,110,210,510,1100
  1129. pOEM->fModel = 0;
  1130. // TT font download capable
  1131. BITSET32(pOEM->fModel, GRP_NX500);
  1132. goto _BEGINDOC_FINISH1;
  1133. // OBSOLETE @Apr/15/99
  1134. // case CMD_BEGINDOC_MFP250E: // MF-P250e,355e
  1135. // pOEM->fModel = 0;
  1136. // BITSET32(pOEM->fModel, GRP_MFP250E);
  1137. // goto _BEGINDOC_FINISH1;
  1138. case CMD_BEGINDOC_MF250M: // MF250M
  1139. // staple capable
  1140. pOEM->fModel = 0;
  1141. BITSET32(pOEM->fModel, GRP_MF250M);
  1142. goto _BEGINDOC_FINISH1;
  1143. case CMD_BEGINDOC_MF3550: // MF2700,3500,3550,4550,5550,6550,3530,3570,4570,5550EX,6550EX,1530
  1144. // staple & punch & media type option
  1145. pOEM->fModel = 0;
  1146. BITSET32(pOEM->fModel, GRP_MF3550);
  1147. goto _BEGINDOC_FINISH1;
  1148. case CMD_BEGINDOC_MF3530E: // MF3530e,3570e,4570e,5570,7070,8570,105Pro @Jun/25/2001
  1149. // Job define command is needed for staple
  1150. pOEM->fModel = 0;
  1151. BITSET32(pOEM->fModel, GRP_MF3530E);
  1152. goto _BEGINDOC_FINISH1;
  1153. case CMD_BEGINDOC_MF3300: // MF3300W,3350W,3540W,3580W
  1154. pOEM->fModel = 0;
  1155. // A2 printer
  1156. BITSET32(pOEM->fModel, GRP_MF3300);
  1157. goto _BEGINDOC_FINISH1;
  1158. case CMD_BEGINDOC_IP1: // IP-1
  1159. pOEM->fModel = 0;
  1160. // A1 plotter
  1161. BITSET32(pOEM->fModel, GRP_IP1);
  1162. goto _BEGINDOC_FINISH1;
  1163. case CMD_BEGINDOC_NX70: // NX70,71 @Feb/04/98
  1164. pOEM->fModel = 0;
  1165. // A4 printer, FE-DeltaRow
  1166. BITSET32(pOEM->fModel, GRP_NX70); // BITSET->BITSET32 @Jun/01/98
  1167. goto _BEGINDOC_FINISH1;
  1168. case CMD_BEGINDOC_NX700: // NX700,600,FAX Printer,MF700 @Jun/12/98
  1169. pOEM->fModel = 0;
  1170. // FE-DeltaRow
  1171. BITSET32(pOEM->fModel, GRP_NX700);
  1172. goto _BEGINDOC_FINISH1;
  1173. case CMD_BEGINDOC_NX900: // NX900 @Jan/08/99
  1174. pOEM->fModel = 0;
  1175. // Job define command is needed for shifted collate
  1176. BITSET32(pOEM->fModel, GRP_NX900);
  1177. goto _BEGINDOC_FINISH1;
  1178. case CMD_BEGINDOC_NX800: // NX800,910,810,MF2230,2730 @Mar/03/99, remove MF1530 @Jun/25/2001
  1179. pOEM->fModel = 0;
  1180. // Job define command is needed for staple
  1181. BITSET32(pOEM->fModel, GRP_NX800);
  1182. goto _BEGINDOC_FINISH1;
  1183. case CMD_BEGINDOC_NX710: // NX710,610 @Jun/23/2000
  1184. pOEM->fModel = 0;
  1185. // FE-DeltaRow & media type option (& variable scaling bug)
  1186. BITSET32(pOEM->fModel, GRP_NX710);
  1187. goto _BEGINDOC_FINISH1;
  1188. case CMD_BEGINDOC_NX720: // NX620,620N,720N,Neo350,350D,450,220,270 @Sep/26/2000
  1189. pOEM->fModel = 0;
  1190. // FE-DeltaRow & media type option (GW model)
  1191. BITSET32(pOEM->fModel, GRP_NX720);
  1192. // goto _BEGINDOC_FINISH1;
  1193. _BEGINDOC_FINISH1:
  1194. // Jun/29/2001 ->
  1195. pOEM->FinisherTrayNum = 1;
  1196. // set Emulation:RPDL
  1197. if (TEST_NEED_JOBDEF_CMD(pOEM->fModel))
  1198. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGINDOC_TOP_JOBDEF); // with Job define command
  1199. else
  1200. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGINDOC_TOP); // without Job define command
  1201. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1202. ocmd = 0;
  1203. // Jun/29/2001 <-
  1204. if (BITTEST32(pOEMExtra->fUiOption, FAX_MODEL))
  1205. SendFaxNum(pdevobj);
  1206. // Set Code:SJIS
  1207. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGINDOC1_2); // <-BEGINDOC1 @Jun/25/2001
  1208. // Set Graphics:KAN-I G, Page-Length:max
  1209. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BEGINDOC2_1);
  1210. // Set Duplex:off
  1211. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BEGINDOC3);
  1212. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1213. #ifdef DOWNLOADFONT
  1214. pOEM->dwDLFontUsedMem = 0;
  1215. if (pOEM->DLFontMaxMemKB)
  1216. {
  1217. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), DLFONT_MALLOC, pOEM->DLFontMaxMemKB, DLFONT_MIN_BLOCK_ID);
  1218. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1219. }
  1220. #endif // DOWNLOADFONT
  1221. _BEGINDOC_FINISH2: // @Sep/09/98
  1222. // Allocate heap memory for bOEMOutputCharStr&OEMDownloadCharGlyph.
  1223. // fix memory leak @Nov/22/2002 ->
  1224. // if already allocated, exit
  1225. if(pOEM->pRPDLHeap2K)
  1226. break;
  1227. // @Nov/22/2002 <-
  1228. pOEM->pRPDLHeap2K = (PBYTE)MemAllocZ(HEAPSIZE2K);
  1229. break;
  1230. case CMD_SET_BASEOFFSETX_0: // @May/07/98
  1231. case CMD_SET_BASEOFFSETX_1:
  1232. case CMD_SET_BASEOFFSETX_2:
  1233. case CMD_SET_BASEOFFSETX_3:
  1234. case CMD_SET_BASEOFFSETX_4:
  1235. case CMD_SET_BASEOFFSETX_5:
  1236. pOEM->BaseOffset.x = (LONG)(dwCmdCbID - CMD_SET_BASEOFFSETX_0);
  1237. break;
  1238. case CMD_SET_BASEOFFSETY_0: // @May/07/98
  1239. case CMD_SET_BASEOFFSETY_1:
  1240. case CMD_SET_BASEOFFSETY_2:
  1241. case CMD_SET_BASEOFFSETY_3:
  1242. case CMD_SET_BASEOFFSETY_4:
  1243. case CMD_SET_BASEOFFSETY_5:
  1244. pOEM->BaseOffset.y = (LONG)(dwCmdCbID - CMD_SET_BASEOFFSETY_0);
  1245. break;
  1246. case CMD_RES240:
  1247. pOEM->fGeneral1 = pOEM->fGeneral2 = 0;
  1248. pOEM->nResoRatio = MASTERUNIT/240;
  1249. // Set Options[duplex/2in1:off,reversed_output:on,sort/stack:off]
  1250. if (!BITTEST32(pOEM->fModel, GRP_SP4II))
  1251. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), IMAGE_OPT_OFF);
  1252. // Set Spacing_Unit:1/240inch
  1253. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SELECT_RES240_1);
  1254. if (TEST_AFTER_SP10(pOEM->fModel)) // SP10,9,etc
  1255. // Set Graphics_Unit & Coordinate_Unit:1/240inch,Engine_Resolution:240dpi
  1256. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SELECT_RES240_2);
  1257. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1258. break;
  1259. case CMD_RES400:
  1260. pOEM->fGeneral1 = pOEM->fGeneral2 = 0;
  1261. pOEM->nResoRatio = MASTERUNIT/400;
  1262. // Set Spacing_Unit & Graphics_Unit:1/400inch
  1263. // & Options[duplex/2in1:off,reversed_output:on,sort/stack:off]
  1264. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_RES400_1);
  1265. if (!BITTEST32(pOEM->fModel, GRP_MF530))
  1266. {
  1267. // Set Engine_Resolution:400dpi
  1268. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SELECT_RES400_2);
  1269. if (TEST_AFTER_SP10(pOEM->fModel) ||
  1270. BITTEST32(pOEM->fModel, GRP_MF150E)) // MF150e,160
  1271. {
  1272. // Set Coordinate_Unit:1/400inch
  1273. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SELECT_RES400_3);
  1274. }
  1275. }
  1276. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1277. break;
  1278. case CMD_RES600:
  1279. pOEM->fGeneral1 = pOEM->fGeneral2 = 0;
  1280. pOEM->nResoRatio = MASTERUNIT/600;
  1281. #ifdef DOWNLOADFONT
  1282. // If non-DRC&&600dpi then make it half. @Jun/15/98
  1283. if (!TEST_CAPABLE_DOWNLOADFONT_DRC(pOEM->fModel))
  1284. pOEM->DLFontMaxID /= 2;
  1285. #endif // DOWNLOADFONT
  1286. // Set Spacing_Unit & Graphics_Unit & Coordinate_Unit:1/600inch,
  1287. // Engine_Resolution:600dpi
  1288. // & Options[duplex/2in1:off,reversed_output:on,sort/stack:off]
  1289. WRITESPOOLBUF(pdevobj, SELECT_RES600, sizeof(SELECT_RES600)-1);
  1290. break;
  1291. case CMD_RES1200: // @Mar/02/99
  1292. pOEM->fGeneral1 = pOEM->fGeneral2 = 0;
  1293. pOEM->nResoRatio = MASTERUNIT/1200;
  1294. #ifdef DOWNLOADFONT
  1295. pOEM->DLFontMaxID /= 2;
  1296. #endif // DOWNLOADFONT
  1297. // Set Spacing_Unit & Graphics_Unit & Coordinate_Unit:1/1200inch,
  1298. // Engine_Resolution:1200dpi
  1299. // & Options[duplex/2in1:off,reversed_output:on,sort/stack:off]
  1300. WRITESPOOLBUF(pdevobj, SELECT_RES1200, sizeof(SELECT_RES1200)-1);
  1301. break;
  1302. case CMD_REGION_STANDARD: // @Nov/29/97
  1303. BITCLR32(pOEM->fGeneral2, EDGE2EDGE_PRINT);
  1304. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO)) // @Sep/15/98
  1305. WRITESPOOLBUF(pdevobj, SELECT_REGION_E2E, sizeof(SELECT_REGION_E2E)-1);
  1306. else
  1307. WRITESPOOLBUF(pdevobj, SELECT_REGION_STD, sizeof(SELECT_REGION_STD)-1);
  1308. break;
  1309. case CMD_REGION_EDGE2EDGE: // @Nov/29/97
  1310. BITSET32(pOEM->fGeneral2, EDGE2EDGE_PRINT);
  1311. WRITESPOOLBUF(pdevobj, SELECT_REGION_E2E, sizeof(SELECT_REGION_E2E)-1);
  1312. break;
  1313. case CMD_IMGCTRL_100:
  1314. if (pOEMExtra->UiScale != VAR_SCALING_DEFAULT) // @Feb/06/98
  1315. {
  1316. pOEM->Scale = pOEMExtra->UiScale; // @Mar/18/98
  1317. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), IMAGE_SCALING_VAR, pOEM->Scale);
  1318. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1319. BITSET32(pOEM->fGeneral1, VARIABLE_SCALING_VALID); // @Jan/27/2000
  1320. break;
  1321. }
  1322. pOEM->Scale = 100; // @Mar/18/98
  1323. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_100, sizeof(IMAGE_SCALING_100)-1);
  1324. break;
  1325. case CMD_IMGCTRL_88:
  1326. pOEM->Scale = 88; // @Mar/18/98
  1327. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_88, sizeof(IMAGE_SCALING_88)-1);
  1328. break;
  1329. case CMD_IMGCTRL_80:
  1330. pOEM->Scale = 80; // @Mar/18/98
  1331. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_80, sizeof(IMAGE_SCALING_80)-1);
  1332. break;
  1333. case CMD_IMGCTRL_75:
  1334. pOEM->Scale = 75; // @Mar/18/98
  1335. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_75, sizeof(IMAGE_SCALING_75)-1);
  1336. break;
  1337. case CMD_IMGCTRL_70:
  1338. pOEM->Scale = 70; // @Mar/18/98
  1339. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_70, sizeof(IMAGE_SCALING_70)-1);
  1340. break;
  1341. case CMD_IMGCTRL_67:
  1342. pOEM->Scale = 67; // @Mar/18/98
  1343. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_67, sizeof(IMAGE_SCALING_67)-1);
  1344. break;
  1345. case CMD_IMGCTRL_115:
  1346. pOEM->Scale = 115;
  1347. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_115, sizeof(IMAGE_SCALING_115)-1);
  1348. break;
  1349. case CMD_IMGCTRL_122:
  1350. pOEM->Scale = 122; // @Mar/18/98
  1351. if (TEST_PLOTTERMODEL_SCALING(pOEM->fModel))
  1352. {
  1353. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_122, sizeof(IMAGE_SCALING_122)-1);
  1354. }
  1355. else
  1356. {
  1357. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_122V, sizeof(IMAGE_SCALING_122V)-1);
  1358. BITSET32(pOEM->fGeneral1, VARIABLE_SCALING_VALID); // @Jan/27/2000
  1359. }
  1360. break;
  1361. case CMD_IMGCTRL_141:
  1362. pOEM->Scale = 141; // @Mar/18/98
  1363. if (TEST_PLOTTERMODEL_SCALING(pOEM->fModel))
  1364. {
  1365. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_141, sizeof(IMAGE_SCALING_141)-1);
  1366. }
  1367. else
  1368. {
  1369. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_141V, sizeof(IMAGE_SCALING_141V)-1);
  1370. BITSET32(pOEM->fGeneral1, VARIABLE_SCALING_VALID); // @Jan/27/2000
  1371. }
  1372. break;
  1373. case CMD_IMGCTRL_200:
  1374. pOEM->Scale = 200; // @Mar/18/98
  1375. if (TEST_PLOTTERMODEL_SCALING(pOEM->fModel))
  1376. {
  1377. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_200, sizeof(IMAGE_SCALING_200)-1);
  1378. }
  1379. else
  1380. {
  1381. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_200V, sizeof(IMAGE_SCALING_200V)-1);
  1382. BITSET32(pOEM->fGeneral1, VARIABLE_SCALING_VALID); // @Jan/27/2000
  1383. }
  1384. break;
  1385. case CMD_IMGCTRL_50:
  1386. pOEM->Scale = 50; // @Mar/18/98
  1387. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_50V, sizeof(IMAGE_SCALING_50V)-1);
  1388. BITSET32(pOEM->fGeneral1, VARIABLE_SCALING_VALID); // @Jan/27/2000
  1389. break;
  1390. case CMD_IMGCTRL_AA67: // A->A scaling(67%)
  1391. pOEM->Scale = 67; // @Mar/18/98
  1392. BITSET32(pOEM->fGeneral1, IMGCTRL_AA67);
  1393. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_67, sizeof(IMAGE_SCALING_67)-1);
  1394. break;
  1395. case CMD_IMGCTRL_BA80: // B->A scaling(80%)
  1396. pOEM->Scale = 80; // @Mar/18/98
  1397. BITSET32(pOEM->fGeneral1, IMGCTRL_BA80);
  1398. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_80, sizeof(IMAGE_SCALING_80)-1);
  1399. break;
  1400. case CMD_IMGCTRL_BA115: // B->A scaling(115%)
  1401. pOEM->Scale = 115; // @Mar/18/98
  1402. BITSET32(pOEM->fGeneral1, IMGCTRL_BA115);
  1403. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_115, sizeof(IMAGE_SCALING_115)-1);
  1404. break;
  1405. case CMD_DRV_4IN1_50: // 4in1
  1406. pOEM->Scale = 50; // @Mar/18/98
  1407. BITSET32(pOEM->fGeneral1, IMGCTRL_4IN1_50);
  1408. pOEM->Nin1RemainPage = 0;
  1409. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_50V, sizeof(IMAGE_SCALING_50V)-1);
  1410. BITSET32(pOEM->fGeneral1, VARIABLE_SCALING_VALID); // @Jan/27/2000
  1411. break;
  1412. case CMD_DRV_2IN1_67: // 2in1
  1413. pOEM->Scale = 67; // @Mar/18/98
  1414. BITSET32(pOEM->fGeneral1, IMGCTRL_2IN1_67);
  1415. pOEM->Nin1RemainPage = 0;
  1416. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_67, sizeof(IMAGE_SCALING_67)-1);
  1417. break;
  1418. case CMD_DRV_2IN1_100: // 2in1
  1419. pOEM->Scale = 100; // @Mar/18/98
  1420. BITSET32(pOEM->fGeneral1, IMGCTRL_2IN1_100);
  1421. pOEM->Nin1RemainPage = 0;
  1422. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_100, sizeof(IMAGE_SCALING_100)-1);
  1423. break;
  1424. case CMD_IMGCTRL_AA141: // IP-1,3300W,3350W:A->A scaling(141%)
  1425. pOEM->Scale = 141; // @Mar/18/98
  1426. BITSET32(pOEM->fGeneral1, IMGCTRL_AA141);
  1427. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_141, sizeof(IMAGE_SCALING_141)-1);
  1428. break;
  1429. case CMD_IMGCTRL_AA200: // IP-1:A->A scaling(200%)
  1430. pOEM->Scale = 200; // @Mar/18/98
  1431. BITSET32(pOEM->fGeneral1, IMGCTRL_AA200);
  1432. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_200, sizeof(IMAGE_SCALING_200)-1);
  1433. break;
  1434. case CMD_IMGCTRL_AA283: // IP-1:A->A scaling(283%)
  1435. BITSET32(pOEM->fGeneral1, IMGCTRL_AA283);
  1436. case CMD_IMGCTRL_283: // IP-1
  1437. pOEM->Scale = 283; // @Mar/18/98
  1438. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_283, sizeof(IMAGE_SCALING_283)-1);
  1439. break;
  1440. case CMD_IMGCTRL_A1_400: // IP-1:400% with A1
  1441. BITSET32(pOEM->fGeneral1, IMGCTRL_A1_400);
  1442. case CMD_IMGCTRL_400: // IP-1
  1443. pOEM->Scale = 400; // @Mar/18/98
  1444. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_400, sizeof(IMAGE_SCALING_400)-1);
  1445. break;
  1446. case CMD_SET_LANDSCAPE:
  1447. BITSET32(pOEM->fGeneral1, ORIENT_LANDSCAPE);
  1448. break;
  1449. case CMD_SET_PORTRAIT:
  1450. BITCLR32(pOEM->fGeneral1, ORIENT_LANDSCAPE);
  1451. break;
  1452. // OBSOLETE (actually obsoleted at converting GPC to GPD) @Jan/08/99 ->
  1453. // case CMD_DUPLEX_ON:
  1454. // BITSET32(pOEM->fGeneral1, DUPLEX_VALID);
  1455. // break;
  1456. // @Jan/08/99 <-
  1457. case CMD_DUPLEX_VERT:
  1458. BITSET32(pOEM->fGeneral1, DUPLEX_VALID); // @Jan/08/99
  1459. if (BITTEST32(pOEM->fGeneral1, ORIENT_LANDSCAPE))
  1460. {
  1461. if (!TEST_2IN1_MODE(pOEM->fGeneral1))
  1462. goto _DUP_H;
  1463. }
  1464. else
  1465. {
  1466. if (TEST_2IN1_MODE(pOEM->fGeneral1))
  1467. goto _DUP_H;
  1468. }
  1469. _DUP_V:
  1470. if (pOEMExtra->UiBindMargin)
  1471. {
  1472. BITSET32(pOEM->fGeneral1, DUPLEX_LEFTMARGIN_VALID);
  1473. // Convert mm to 5mm_unit(2=5mm,3=10mm,...,11=50mm)
  1474. nTmp = (pOEMExtra->UiBindMargin + 4) / 5 + 1;
  1475. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_LEFTMARGIN, nTmp);
  1476. // SP9II(except 1st lot),10ProII can set binding margin every 1 mm
  1477. if (TEST_AFTER_SP9II(pOEM->fModel))
  1478. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_LEFTMARGIN_9II, pOEMExtra->UiBindMargin);
  1479. }
  1480. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_BIND_RIGHT))
  1481. {
  1482. pOEM->BindPoint = BIND_RIGHT;
  1483. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DUPLEX_VERT_R);
  1484. }
  1485. else
  1486. {
  1487. pOEM->BindPoint = BIND_LEFT;
  1488. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DUPLEX_VERT);
  1489. }
  1490. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DUPLEX_ON);
  1491. // DCR @Jan/27/2000 ->
  1492. // Emit IMAGE_SCALING_xxxV here, because DUPLEX_VERT resets IMAGE_SCALING_xxxV
  1493. if (BITTEST32(pOEM->fGeneral1, VARIABLE_SCALING_VALID));
  1494. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, IMAGE_SCALING_VAR, pOEM->Scale);
  1495. // @Jan/27/2000 <-
  1496. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1497. break;
  1498. case CMD_DUPLEX_HORZ:
  1499. BITSET32(pOEM->fGeneral1, DUPLEX_VALID); // @Jan/08/99
  1500. if (BITTEST32(pOEM->fGeneral1, ORIENT_LANDSCAPE))
  1501. {
  1502. if (!TEST_2IN1_MODE(pOEM->fGeneral1))
  1503. goto _DUP_V;
  1504. }
  1505. else
  1506. {
  1507. if (TEST_2IN1_MODE(pOEM->fGeneral1))
  1508. goto _DUP_V;
  1509. }
  1510. _DUP_H:
  1511. if (pOEMExtra->UiBindMargin)
  1512. {
  1513. BITSET32(pOEM->fGeneral1, DUPLEX_UPPERMARGIN_VALID);
  1514. nTmp = (pOEMExtra->UiBindMargin + 4) / 5 + 1;
  1515. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_UPPERMARGIN, nTmp);
  1516. if (TEST_AFTER_SP9II(pOEM->fModel))
  1517. {
  1518. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_UPPERMARGIN_9II, pOEMExtra->UiBindMargin);
  1519. }
  1520. }
  1521. pOEM->BindPoint = BIND_UPPER;
  1522. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DUPLEX_HORZ);
  1523. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DUPLEX_ON);
  1524. // DCR @Jan/27/2000 ->
  1525. // Emit IMAGE_SCALING_xxxV here, because DUPLEX_HORZ resets IMAGE_SCALING_xxxV
  1526. if (BITTEST32(pOEM->fGeneral1, VARIABLE_SCALING_VALID));
  1527. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, IMAGE_SCALING_VAR, pOEM->Scale);
  1528. // @Jan/27/2000 <-
  1529. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  1530. break;
  1531. case CMD_MEDIATYPE_STANDARD:
  1532. pOEM->MediaType = MEDIATYPE_STD; // use pOEM->MediaType @Mar/03/99
  1533. break;
  1534. case CMD_MEDIATYPE_OHP:
  1535. pOEM->MediaType = MEDIATYPE_OHP;
  1536. break;
  1537. case CMD_MEDIATYPE_THICK:
  1538. pOEM->MediaType = MEDIATYPE_THICK;
  1539. break;
  1540. case CMD_MEDIATYPE_SPL: // since MF1530 @Mar/03/99
  1541. pOEM->MediaType = MEDIATYPE_SPL;
  1542. break;
  1543. case CMD_MEDIATYPE_TRACE: // since MF5570 @Feb/15/2000
  1544. pOEM->MediaType = MEDIATYPE_TRACE;
  1545. break;
  1546. case CMD_MEDIATYPE_LABEL: // since Neo450 @Oct/12/2000
  1547. pOEM->MediaType = MEDIATYPE_LABEL;
  1548. break;
  1549. case CMD_MEDIATYPE_THIN: // since Neo270 @Feb/05/2001
  1550. pOEM->MediaType = MEDIATYPE_THIN;
  1551. break;
  1552. case CMD_SELECT_PAPER_A2:
  1553. pOEM->DocPaperID = RPDL_A2;
  1554. // If A->A(67%), scale down papersize.
  1555. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67))
  1556. lpcmd = SELECT_PAPER_A3;
  1557. else
  1558. lpcmd = SELECT_PAPER_A2;
  1559. // Store papername to buffer
  1560. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1561. // Because incapable, clear setting
  1562. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1563. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80) ||
  1564. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115) ||
  1565. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141) ||
  1566. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200) ||
  1567. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283) ||
  1568. BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1569. {
  1570. goto _IMGCTRL_OFF1;
  1571. }
  1572. break;
  1573. case CMD_SELECT_PAPER_A3:
  1574. pOEM->DocPaperID = RPDL_A3;
  1575. // If able to select tray with "papername+X" && no staple && no punch
  1576. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1577. !pOEM->PunchType)? TRUE : FALSE;
  1578. // If TOMBO is enabled, scale up papersize. @Sep/14/98
  1579. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO) &&
  1580. TEST_CAPABLE_PAPER_A2(pOEM->fModel))
  1581. {
  1582. lpcmd = SELECT_PAPER_B3;
  1583. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1584. goto _IMGCTRL_OFF1;
  1585. }
  1586. // If A->A(67%), scale down papersize.
  1587. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67))
  1588. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1589. // If A->A(141%), scale up papersize.
  1590. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141))
  1591. lpcmd = SELECT_PAPER_A2;
  1592. // If A->A(200%) || A1(400%), scale up papersize.
  1593. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200) ||
  1594. BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1595. lpcmd = SELECT_PAPER_A1;
  1596. else
  1597. lpcmd = SELECT_PAPER_A3;
  1598. // Store papername to buffer
  1599. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1600. // Because incapable, clear setting
  1601. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100) ||
  1602. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80) ||
  1603. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115) ||
  1604. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283))
  1605. {
  1606. goto _IMGCTRL_OFF1;
  1607. }
  1608. break;
  1609. case CMD_SELECT_PAPER_A4:
  1610. pOEM->DocPaperID = RPDL_A4;
  1611. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1612. !pOEM->PunchType)? TRUE : FALSE;
  1613. // If TOMBO is enabled, scale up papersize. @Sep/14/98
  1614. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  1615. {
  1616. lpcmd = SELECT_PAPER_B4;
  1617. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1618. goto _IMGCTRL_OFF1;
  1619. }
  1620. // If 2in1(100%), scale up papersize.
  1621. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100) ||
  1622. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141))
  1623. lpcmd = SELECT_PAPER_A3;
  1624. // If A->A(67%), scale down papersize.
  1625. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67))
  1626. lpcmd = (fPaperX)? SELECT_PAPER_A5X : SELECT_PAPER_A5W;
  1627. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200))
  1628. lpcmd = SELECT_PAPER_A2;
  1629. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283) ||
  1630. BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1631. lpcmd = SELECT_PAPER_A1;
  1632. else
  1633. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1634. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1635. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80) ||
  1636. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115))
  1637. {
  1638. goto _IMGCTRL_OFF1;
  1639. }
  1640. break;
  1641. case CMD_SELECT_PAPER_A5:
  1642. pOEM->DocPaperID = RPDL_A5;
  1643. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1644. !pOEM->PunchType)? TRUE : FALSE;
  1645. // If TOMBO is enabled, scale up papersize. @Sep/14/98
  1646. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  1647. {
  1648. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1649. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1650. goto _IMGCTRL_OFF1;
  1651. }
  1652. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100) ||
  1653. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141))
  1654. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1655. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67))
  1656. lpcmd = SELECT_PAPER_A6;
  1657. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200))
  1658. lpcmd = SELECT_PAPER_A3;
  1659. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283))
  1660. lpcmd = SELECT_PAPER_A2;
  1661. else
  1662. lpcmd = (fPaperX)? SELECT_PAPER_A5X : SELECT_PAPER_A5W;
  1663. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1664. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80) ||
  1665. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115) ||
  1666. BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1667. {
  1668. goto _IMGCTRL_OFF1;
  1669. }
  1670. break;
  1671. case CMD_SELECT_PAPER_A6:
  1672. pOEM->DocPaperID = RPDL_A6;
  1673. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1674. !pOEM->PunchType)? TRUE : FALSE;
  1675. // If TOMBO is enabled, scale up papersize. @Sep/14/98
  1676. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  1677. {
  1678. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1679. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1680. goto _IMGCTRL_OFF1;
  1681. }
  1682. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100) ||
  1683. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141))
  1684. lpcmd = (fPaperX)? SELECT_PAPER_A5X : SELECT_PAPER_A5W;
  1685. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200))
  1686. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1687. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283))
  1688. lpcmd = SELECT_PAPER_A3;
  1689. else
  1690. lpcmd = SELECT_PAPER_A6;
  1691. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1692. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67) ||
  1693. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80) ||
  1694. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115) ||
  1695. BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1696. {
  1697. goto _IMGCTRL_OFF1;
  1698. }
  1699. break;
  1700. case CMD_SELECT_PAPER_POSTCARD: // since NX700 @Feb/13/98
  1701. pOEM->DocPaperID = RPDL_POSTCARD;
  1702. // If TOMBO is enabled, scale up papersize. @Sep/14/98
  1703. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  1704. {
  1705. lpcmd = SELECT_PAPER_A4X;
  1706. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1707. goto _IMGCTRL_OFF1;
  1708. }
  1709. lpcmd = SELECT_PAPER_PCX;
  1710. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1711. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1712. TEST_SCALING_SEL_TRAY(pOEM->fGeneral1))
  1713. {
  1714. goto _IMGCTRL_OFF1;
  1715. }
  1716. break;
  1717. case CMD_SELECT_PAPER_B3: // @Jan/07/98
  1718. pOEM->DocPaperID = RPDL_B3;
  1719. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80))
  1720. lpcmd = SELECT_PAPER_A3;
  1721. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115))
  1722. lpcmd = SELECT_PAPER_A2;
  1723. else
  1724. lpcmd = SELECT_PAPER_B3;
  1725. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1726. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1727. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67) ||
  1728. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141) ||
  1729. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200) ||
  1730. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283) ||
  1731. BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1732. {
  1733. goto _IMGCTRL_OFF1;
  1734. }
  1735. break;
  1736. case CMD_SELECT_PAPER_B4:
  1737. pOEM->DocPaperID = RPDL_B4;
  1738. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1739. !pOEM->PunchType)? TRUE : FALSE;
  1740. // If TOMBO is enabled, scale up papersize. @Sep/14/98
  1741. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  1742. {
  1743. lpcmd = SELECT_PAPER_A3;
  1744. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1745. goto _IMGCTRL_OFF1;
  1746. }
  1747. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80))
  1748. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1749. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115))
  1750. lpcmd = SELECT_PAPER_A3;
  1751. else
  1752. lpcmd = SELECT_PAPER_B4;
  1753. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1754. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100) ||
  1755. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67) ||
  1756. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141) ||
  1757. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200) ||
  1758. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283) ||
  1759. BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1760. {
  1761. goto _IMGCTRL_OFF1;
  1762. }
  1763. break;
  1764. case CMD_SELECT_PAPER_B5:
  1765. pOEM->DocPaperID = RPDL_B5;
  1766. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1767. !pOEM->PunchType)? TRUE : FALSE;
  1768. // If TOMBO is enabled, scale up papersize. @Sep/14/98
  1769. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  1770. {
  1771. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1772. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1773. goto _IMGCTRL_OFF1;
  1774. }
  1775. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100))
  1776. lpcmd = SELECT_PAPER_B4;
  1777. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80))
  1778. lpcmd = (fPaperX)? SELECT_PAPER_A5X : SELECT_PAPER_A5W;
  1779. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115))
  1780. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1781. else
  1782. lpcmd = (fPaperX)? SELECT_PAPER_B5X : SELECT_PAPER_B5W;
  1783. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1784. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67) ||
  1785. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141) ||
  1786. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200) ||
  1787. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283) ||
  1788. BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1789. {
  1790. goto _IMGCTRL_OFF1;
  1791. }
  1792. break;
  1793. case CMD_SELECT_PAPER_B6:
  1794. pOEM->DocPaperID = RPDL_B6;
  1795. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1796. !pOEM->PunchType)? TRUE : FALSE;
  1797. // If TOMBO is enabled, scale up papersize. @Sep/14/98
  1798. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  1799. {
  1800. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1801. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1802. goto _IMGCTRL_OFF1;
  1803. }
  1804. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100))
  1805. lpcmd = (fPaperX)? SELECT_PAPER_B5X : SELECT_PAPER_B5W;
  1806. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80))
  1807. lpcmd = SELECT_PAPER_A6;
  1808. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115))
  1809. lpcmd = (fPaperX)? SELECT_PAPER_A5X : SELECT_PAPER_A5W;
  1810. else
  1811. lpcmd = SELECT_PAPER_B6;
  1812. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1813. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67) ||
  1814. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141) ||
  1815. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200) ||
  1816. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283) ||
  1817. BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1818. {
  1819. goto _IMGCTRL_OFF1;
  1820. }
  1821. break;
  1822. case CMD_SELECT_PAPER_C:
  1823. pOEM->DocPaperID = RPDL_C;
  1824. lpcmd = SELECT_PAPER_C;
  1825. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1826. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1827. TEST_SCALING_SEL_TRAY(pOEM->fGeneral1))
  1828. {
  1829. goto _IMGCTRL_OFF1;
  1830. }
  1831. break;
  1832. case CMD_SELECT_PAPER_TABLOID:
  1833. pOEM->DocPaperID = RPDL_TABD;
  1834. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1835. lpcmd = SELECT_PAPER_A1;
  1836. else
  1837. lpcmd = SELECT_PAPER_TABD;
  1838. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1839. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100) ||
  1840. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67) ||
  1841. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80) ||
  1842. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115) ||
  1843. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141) ||
  1844. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200) ||
  1845. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283))
  1846. {
  1847. goto _IMGCTRL_OFF1;
  1848. }
  1849. break;
  1850. case CMD_SELECT_PAPER_LEGAL:
  1851. pOEM->DocPaperID = RPDL_LEGL;
  1852. lpcmd = SELECT_PAPER_LEGL;
  1853. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1854. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1855. TEST_SCALING_SEL_TRAY(pOEM->fGeneral1))
  1856. {
  1857. goto _IMGCTRL_OFF1;
  1858. }
  1859. break;
  1860. case CMD_SELECT_PAPER_LETTER:
  1861. pOEM->DocPaperID = RPDL_LETR;
  1862. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1863. !pOEM->PunchType)? TRUE : FALSE;
  1864. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100))
  1865. lpcmd = SELECT_PAPER_TABD;
  1866. else if (BITTEST32(pOEM->fGeneral1, IMGCTRL_A1_400))
  1867. lpcmd = SELECT_PAPER_A1;
  1868. else
  1869. lpcmd = (fPaperX)? SELECT_PAPER_LETRX : SELECT_PAPER_LETRW;
  1870. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1871. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_AA67) ||
  1872. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA80) ||
  1873. BITTEST32(pOEM->fGeneral1, IMGCTRL_BA115) ||
  1874. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA141) ||
  1875. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA200) ||
  1876. BITTEST32(pOEM->fGeneral1, IMGCTRL_AA283))
  1877. {
  1878. goto _IMGCTRL_OFF1;
  1879. }
  1880. break;
  1881. case CMD_SELECT_PAPER_STATEMENT:
  1882. pOEM->DocPaperID = RPDL_STAT;
  1883. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1884. !pOEM->PunchType)? TRUE : FALSE;
  1885. if (BITTEST32(pOEM->fGeneral1, IMGCTRL_2IN1_100))
  1886. lpcmd = (fPaperX)? SELECT_PAPER_LETRX : SELECT_PAPER_LETRW;
  1887. else
  1888. lpcmd = (fPaperX)? SELECT_PAPER_STATX : SELECT_PAPER_STATW;
  1889. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1890. if (TEST_SCALING_SEL_TRAY(pOEM->fGeneral1))
  1891. goto _IMGCTRL_OFF1;
  1892. break;
  1893. case CMD_SELECT_PAPER_A2TOA3:
  1894. pOEM->DocPaperID = RPDL_A2A3;
  1895. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_67, sizeof(IMAGE_SCALING_67)-1);
  1896. // DCR @Jan/27/2000 ->
  1897. // Emit DUPLEX_ON here, because IMAGE_SCALING_xxx resets DUPLEX_ON.
  1898. if (BITTEST32(pOEM->fGeneral1, DUPLEX_VALID))
  1899. WRITESPOOLBUF(pdevobj, DUPLEX_ON, sizeof(DUPLEX_ON)-1);
  1900. // @Jan/27/2000 <-
  1901. lpcmd = SELECT_PAPER_A3;
  1902. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1903. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1904. TEST_SCALING_SEL_TRAY(pOEM->fGeneral1))
  1905. {
  1906. goto _IMGCTRL_OFF2;
  1907. }
  1908. break;
  1909. case CMD_SELECT_PAPER_A3TOA4: // for NX70 @Feb/04/98
  1910. pOEM->DocPaperID = RPDL_A3A4;
  1911. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_67, sizeof(IMAGE_SCALING_67)-1);
  1912. // DCR @Jan/27/2000 ->
  1913. // Emit DUPLEX_ON here, because IMAGE_SCALING_xxx resets DUPLEX_ON.
  1914. if (BITTEST32(pOEM->fGeneral1, DUPLEX_VALID))
  1915. WRITESPOOLBUF(pdevobj, DUPLEX_ON, sizeof(DUPLEX_ON)-1);
  1916. // @Jan/27/2000 <-
  1917. lpcmd = SELECT_PAPER_A4X;
  1918. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1919. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1920. TEST_SCALING_SEL_TRAY(pOEM->fGeneral1))
  1921. {
  1922. goto _IMGCTRL_OFF2;
  1923. }
  1924. break;
  1925. case CMD_SELECT_PAPER_B4TOA4: // for NX70 @Feb/04/98
  1926. pOEM->DocPaperID = RPDL_B4A4;
  1927. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_80, sizeof(IMAGE_SCALING_80)-1);
  1928. // DCR @Jan/27/2000 ->
  1929. // Emit DUPLEX_ON here, because IMAGE_SCALING_xxx resets DUPLEX_ON.
  1930. if (BITTEST32(pOEM->fGeneral1, DUPLEX_VALID))
  1931. WRITESPOOLBUF(pdevobj, DUPLEX_ON, sizeof(DUPLEX_ON)-1);
  1932. // @Jan/27/2000 <-
  1933. lpcmd = SELECT_PAPER_A4X;
  1934. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1935. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1936. TEST_SCALING_SEL_TRAY(pOEM->fGeneral1))
  1937. {
  1938. goto _IMGCTRL_OFF2;
  1939. }
  1940. break;
  1941. case CMD_SELECT_PAPER_11x15TOA4: // @Feb/07/2000
  1942. pOEM->DocPaperID = RPDL_11x15A4;
  1943. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_67, sizeof(IMAGE_SCALING_67)-1);
  1944. if (BITTEST32(pOEM->fGeneral1, DUPLEX_VALID))
  1945. WRITESPOOLBUF(pdevobj, DUPLEX_ON, sizeof(DUPLEX_ON)-1);
  1946. fPaperX = (TEST_CAPABLE_PAPERX(pOEM->fModel) && !pOEM->StapleType &&
  1947. !pOEM->PunchType)? TRUE : FALSE;
  1948. lpcmd = (fPaperX)? SELECT_PAPER_A4X : SELECT_PAPER_A4W;
  1949. pOEM->RPDLHeapCount = (WORD)safe_sprintfA(pOEM->RPDLHeap64, sizeof(pOEM->RPDLHeap64), lpcmd);
  1950. // Emulate NEC MultiWriter 2200
  1951. if (BITTEST32(pOEM->fGeneral1, ORIENT_LANDSCAPE))
  1952. {
  1953. pOEM->BaseOffset.x = 37; // mm
  1954. pOEM->BaseOffset.y = 15;
  1955. }
  1956. else
  1957. {
  1958. pOEM->BaseOffset.x = 15;
  1959. pOEM->BaseOffset.y = 37;
  1960. }
  1961. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1962. TEST_SCALING_SEL_TRAY(pOEM->fGeneral1))
  1963. {
  1964. goto _IMGCTRL_OFF2;
  1965. }
  1966. break;
  1967. case CMD_SELECT_PAPER_DOUBLEPOSTCARD:
  1968. BITSET32(pOEM->fGeneral1, PAPER_DOUBLEPOSTCARD);
  1969. goto _SET_CUSTOMSIZE;
  1970. case CMD_SELECT_PAPER_CUSTOM: // pdwParams:PhysPaperWidth,Length
  1971. pOEM->PhysPaperWidth = (WORD)*pdwParams; // @Dec/26/97
  1972. pOEM->PhysPaperLength = (WORD)*(pdwParams+1);
  1973. BITSET32(pOEM->fGeneral1, PAPER_CUSTOMSIZE);
  1974. _SET_CUSTOMSIZE:
  1975. pOEM->DocPaperID = RPDL_CUSTOMSIZE;
  1976. pOEM->RPDLHeapCount = 0;
  1977. if (TEST_NIN1_MODE(pOEM->fGeneral1) ||
  1978. TEST_SCALING_SEL_TRAY(pOEM->fGeneral1))
  1979. {
  1980. goto _IMGCTRL_OFF1;
  1981. }
  1982. break;
  1983. _IMGCTRL_OFF1:
  1984. // Invalidate image controls
  1985. pOEM->Scale = 100; // @Mar/18/98
  1986. WRITESPOOLBUF(pdevobj, IMAGE_SCALING_100, sizeof(IMAGE_SCALING_100)-1);
  1987. // DCR @Jan/27/2000 ->
  1988. // Emit DUPLEX_ON here, because IMAGE_SCALING_xxx resets DUPLEX_ON.
  1989. if (BITTEST32(pOEM->fGeneral1, DUPLEX_VALID))
  1990. WRITESPOOLBUF(pdevobj, DUPLEX_ON, sizeof(DUPLEX_ON)-1);
  1991. // @Jan/27/2000 <-
  1992. _IMGCTRL_OFF2:
  1993. BITCLR_SCALING_SEL_TRAY(pOEM->fGeneral1);
  1994. BITCLR_NIN1_MODE(pOEM->fGeneral1);
  1995. break;
  1996. case CMD_SET_LONG_EDGE_FEED: // for Multi Tray @May/25/98
  1997. BITSET32(pOEM->fGeneral2, LONG_EDGE_FEED);
  1998. break;
  1999. case CMD_SET_SHORT_EDGE_FEED: // for Multi Tray @May/25/98
  2000. BITCLR32(pOEM->fGeneral2, LONG_EDGE_FEED);
  2001. break;
  2002. case CMD_SELECT_AUTOFEED:
  2003. // Set MediaType (modify @Mar/03/99, @Feb/15/2000, moved top@Sep/27/2000)
  2004. if (TEST_CAPABLE_MEDIATYPE(pOEM->fModel))
  2005. {
  2006. // @Oct/13/2000 ->
  2007. // ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_MEDIATYPE, 'T', '0'+pOEM->MediaType);
  2008. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_MEDIATYPE, 'T', pOEM->MediaType);
  2009. // @Oct/13/2000 <-
  2010. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2011. ocmd = 0;
  2012. }
  2013. if (BITTEST32(pOEM->fGeneral1, PAPER_CUSTOMSIZE) ||
  2014. BITTEST32(pOEM->fGeneral1, PAPER_DOUBLEPOSTCARD))
  2015. {
  2016. // Select ManualFeed
  2017. WRITESPOOLBUF(pdevobj, SELECT_MANUALFEED, sizeof(SELECT_MANUALFEED)-1);
  2018. goto _SELECTPAPER_CUSTOMSIZE;
  2019. }
  2020. // Output Set_Limitless_Paper_Supply_Mode
  2021. WRITESPOOLBUF(pdevobj, SET_LIMITLESS_SUPPLY, sizeof(SET_LIMITLESS_SUPPLY)-1);
  2022. // Output Select_Tray_By_Papersize command.
  2023. // if letter size, select A4 first in case of no letter paper.
  2024. if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_LETRX))
  2025. {
  2026. WRITESPOOLBUF(pdevobj, SEL_TRAY_PAPER_HEAD, sizeof(SEL_TRAY_PAPER_HEAD)-1);
  2027. WRITESPOOLBUF(pdevobj, SELECT_PAPER_A4X, sizeof(SELECT_PAPER_A4X)-1);
  2028. }
  2029. else if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_LETRW))
  2030. {
  2031. WRITESPOOLBUF(pdevobj, SEL_TRAY_PAPER_HEAD, sizeof(SEL_TRAY_PAPER_HEAD)-1);
  2032. WRITESPOOLBUF(pdevobj, SELECT_PAPER_A4W, sizeof(SELECT_PAPER_A4W)-1);
  2033. }
  2034. WRITESPOOLBUF(pdevobj, SEL_TRAY_PAPER_HEAD, sizeof(SEL_TRAY_PAPER_HEAD)-1);
  2035. WRITESPOOLBUF(pdevobj, pOEM->RPDLHeap64, pOEM->RPDLHeapCount);
  2036. break;
  2037. // @Dec/10/99 FK#49, add TRAY1,3,4,5 & reset limitless @Sep/27/2000 ->
  2038. case CMD_SELECT_TRAY1:
  2039. case CMD_SELECT_TRAY2:
  2040. case CMD_SELECT_TRAY3:
  2041. case CMD_SELECT_TRAY4:
  2042. case CMD_SELECT_TRAY5:
  2043. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_TRAY_N, dwCmdCbID - CMD_SELECT_TRAY1 + 2);
  2044. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2045. if (TEST_GWMODEL(pOEM->fModel))
  2046. WRITESPOOLBUF(pdevobj, RESET_LIMITLESS_SUPPLY, sizeof(RESET_LIMITLESS_SUPPLY)-1);
  2047. if (BITTEST32(pOEM->fGeneral1, PAPER_CUSTOMSIZE) ||
  2048. BITTEST32(pOEM->fGeneral1, PAPER_DOUBLEPOSTCARD))
  2049. {
  2050. goto _SELECTPAPER_CUSTOMSIZE;
  2051. }
  2052. break;
  2053. // @Dec/10/99, @Sep/27/2000 <-
  2054. case CMD_SELECT_MANUALFEED:
  2055. case CMD_SELECT_MULTIFEEDER:
  2056. case CMD_SELECT_MULTITRAY: // NXs' MultiTray
  2057. // Moved forward, because NX710(MultiTray) support MediaType @Mar/11/99 ->
  2058. // Set MediaType (modify @Mar/03/99, @Feb/15/2000)
  2059. if (TEST_CAPABLE_MEDIATYPE(pOEM->fModel))
  2060. {
  2061. // @Oct/13/2000 ->
  2062. // ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_MEDIATYPE, 'T', '0'+pOEM->MediaType);
  2063. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_MEDIATYPE, 'T', pOEM->MediaType);
  2064. // @Oct/13/2000 <-
  2065. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2066. ocmd = 0;
  2067. }
  2068. // @Mar/11/99 <-
  2069. // Select Feeder
  2070. if (dwCmdCbID == CMD_SELECT_MANUALFEED)
  2071. {
  2072. // Select ManualFeed
  2073. WRITESPOOLBUF(pdevobj, SELECT_MANUALFEED, sizeof(SELECT_MANUALFEED)-1);
  2074. }
  2075. else
  2076. {
  2077. // Select MultiFeeder/MultTray
  2078. WRITESPOOLBUF(pdevobj, SELECT_MULTIFEEDER, sizeof(SELECT_MULTIFEEDER)-1);
  2079. //@Sep/27/2000 ->
  2080. if (TEST_GWMODEL(pOEM->fModel))
  2081. WRITESPOOLBUF(pdevobj, RESET_LIMITLESS_SUPPLY, sizeof(RESET_LIMITLESS_SUPPLY)-1);
  2082. //@Sep/27/2000 <-
  2083. }
  2084. // If CustomSize, jump.
  2085. if (BITTEST32(pOEM->fGeneral1, PAPER_CUSTOMSIZE) ||
  2086. BITTEST32(pOEM->fGeneral1, PAPER_DOUBLEPOSTCARD))
  2087. {
  2088. goto _SELECTPAPER_CUSTOMSIZE;
  2089. }
  2090. // Set papersize
  2091. // If papersize without transverse (A1,A2,A3,A6,B3,B4,B6,C,Tabloid,Legal)
  2092. if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_A1) ||
  2093. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_A2) ||
  2094. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_A3) ||
  2095. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_A6) ||
  2096. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_B3) || // @Feb/05/98
  2097. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_B4) ||
  2098. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_B6) ||
  2099. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_C) ||
  2100. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_TABD) ||
  2101. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_LEGL))
  2102. {
  2103. // Output Select_Papersize command
  2104. WRITESPOOLBUF(pdevobj, SELECT_PAPER_HEAD, sizeof(SELECT_PAPER_HEAD)-1);
  2105. WRITESPOOLBUF(pdevobj, pOEM->RPDLHeap64, pOEM->RPDLHeapCount);
  2106. }
  2107. else
  2108. {
  2109. if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_A4X) ||
  2110. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_A4W))
  2111. {
  2112. // If long edge feed is enabled, set transverse paper. @May/25/98
  2113. if (dwCmdCbID == CMD_SELECT_MULTITRAY &&
  2114. BITTEST32(pOEM->fGeneral2, LONG_EDGE_FEED))
  2115. {
  2116. lpcmd = SELECT_PAPER_A4;
  2117. }
  2118. else
  2119. {
  2120. lpcmd = SELECT_PAPER_A4R;
  2121. }
  2122. }
  2123. else if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_A5X) ||
  2124. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_A5W))
  2125. {
  2126. if (dwCmdCbID == CMD_SELECT_MULTITRAY &&
  2127. BITTEST32(pOEM->fGeneral2, LONG_EDGE_FEED))
  2128. {
  2129. lpcmd = SELECT_PAPER_A5;
  2130. }
  2131. else
  2132. {
  2133. lpcmd = SELECT_PAPER_A5R;
  2134. }
  2135. }
  2136. else if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_B5X) ||
  2137. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_B5W))
  2138. {
  2139. if (dwCmdCbID == CMD_SELECT_MULTITRAY &&
  2140. BITTEST32(pOEM->fGeneral2, LONG_EDGE_FEED))
  2141. {
  2142. lpcmd = SELECT_PAPER_B5;
  2143. }
  2144. else
  2145. {
  2146. lpcmd = SELECT_PAPER_B5R;
  2147. }
  2148. }
  2149. else if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_LETRX) ||
  2150. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_LETRW))
  2151. {
  2152. if (dwCmdCbID == CMD_SELECT_MULTITRAY &&
  2153. BITTEST32(pOEM->fGeneral2, LONG_EDGE_FEED))
  2154. {
  2155. lpcmd = SELECT_PAPER_LETR;
  2156. }
  2157. else
  2158. {
  2159. lpcmd = SELECT_PAPER_LETRR;
  2160. }
  2161. }
  2162. else if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_STATX) ||
  2163. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_STATW))
  2164. {
  2165. if (dwCmdCbID == CMD_SELECT_MULTITRAY &&
  2166. BITTEST32(pOEM->fGeneral2, LONG_EDGE_FEED))
  2167. {
  2168. lpcmd = SELECT_PAPER_STAT;
  2169. }
  2170. else
  2171. {
  2172. lpcmd = SELECT_PAPER_STATR;
  2173. }
  2174. }
  2175. else if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_PCX)) // @Feb/13/98
  2176. {
  2177. if (dwCmdCbID == CMD_SELECT_MULTITRAY &&
  2178. BITTEST32(pOEM->fGeneral2, LONG_EDGE_FEED))
  2179. {
  2180. lpcmd = SELECT_PAPER_PC;
  2181. }
  2182. else
  2183. {
  2184. lpcmd = SELECT_PAPER_PCR;
  2185. }
  2186. }
  2187. else
  2188. break; // exit
  2189. // Output Select_Papersize command
  2190. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_PAPER_HEAD);
  2191. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, lpcmd);
  2192. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2193. } // 'if (A1,A2,A3,A6,B4,B6,C,TABLOID,LEGAL) else' end
  2194. // Reconfirm ManualFeed/AutoFeed.
  2195. if (dwCmdCbID == CMD_SELECT_MANUALFEED)
  2196. WRITESPOOLBUF(pdevobj, SELECT_MANUALFEED, sizeof(SELECT_MANUALFEED)-1);
  2197. else
  2198. WRITESPOOLBUF(pdevobj, SELECT_MULTIFEEDER, sizeof(SELECT_MULTIFEEDER)-1);
  2199. break;
  2200. _SELECTPAPER_CUSTOMSIZE:
  2201. {
  2202. DWORD dwWidth, dwHeight;
  2203. // If DoublePostcard
  2204. if (BITTEST32(pOEM->fGeneral1, PAPER_DOUBLEPOSTCARD))
  2205. {
  2206. if (BITTEST32(pOEM->fGeneral1, ORIENT_LANDSCAPE))
  2207. {
  2208. dwWidth = 148; // mm
  2209. dwHeight = 200;
  2210. }
  2211. else
  2212. {
  2213. dwWidth = 200;
  2214. dwHeight = 148;
  2215. }
  2216. // Set max pagesize (mm to dot with KIRISUTE)
  2217. pOEM->PageMax.x = (LONG)(dwWidth * (DWORD)(MASTERUNIT*10) /
  2218. (DWORD)254 / (DWORD)pOEM->nResoRatio);
  2219. pOEM->PageMax.y = (LONG)(dwHeight * (DWORD)(MASTERUNIT*10) /
  2220. (DWORD)254 / (DWORD)pOEM->nResoRatio);
  2221. }
  2222. // If CustomSize
  2223. else
  2224. {
  2225. if (BITTEST32(pOEM->fGeneral1, ORIENT_LANDSCAPE))
  2226. {
  2227. dwWidth = pOEM->PhysPaperLength; // masterunit
  2228. dwHeight = pOEM->PhysPaperWidth;
  2229. }
  2230. else
  2231. {
  2232. dwWidth = pOEM->PhysPaperWidth; // masterunit
  2233. dwHeight = pOEM->PhysPaperLength;
  2234. }
  2235. // Set max pagesize
  2236. pOEM->PageMax.x = (LONG)(dwWidth / pOEM->nResoRatio); // dot
  2237. pOEM->PageMax.y = (LONG)(dwHeight / pOEM->nResoRatio);
  2238. // masterunit to mm with SISHAGONYU
  2239. dwWidth = (dwWidth * (DWORD)254 + (DWORD)(MASTERUNIT*10/2)) /
  2240. (DWORD)(MASTERUNIT*10);
  2241. dwHeight = (dwHeight * (DWORD)254 + (DWORD)(MASTERUNIT*10/2)) /
  2242. (DWORD)(MASTERUNIT*10);
  2243. }
  2244. BITCLR32(pOEM->fGeneral1, CUSTOMSIZE_USE_LAND);
  2245. BITCLR32(pOEM->fGeneral1, CUSTOMSIZE_MAKE_LAND_PORT);
  2246. // Because app sometimes sets under-limit in landscape,
  2247. // we need to swap width and height. @Oct/21/98
  2248. if (dwHeight < USRD_H_MIN148) // < 148
  2249. {
  2250. DWORD dwTmp;
  2251. dwTmp = dwWidth;
  2252. dwWidth = dwHeight;
  2253. dwHeight = dwTmp;
  2254. }
  2255. else if (dwWidth >= dwHeight)
  2256. {
  2257. WORD fSwap = FALSE;
  2258. // Because app sometimes sets over-limit width in portrait,
  2259. // we need to swap width and height.
  2260. if (TEST_CAPABLE_PAPER_A2(pOEM->fModel))
  2261. {
  2262. if (dwWidth > USRD_W_A2) // > 432
  2263. fSwap = TRUE;
  2264. }
  2265. else if (TEST_CAPABLE_PAPER_A3_W297(pOEM->fModel))
  2266. {
  2267. if (dwWidth > USRD_W_A3) // > 297
  2268. fSwap = TRUE;
  2269. }
  2270. else if (TEST_CAPABLE_PAPER_A4MAX(pOEM->fModel))
  2271. {
  2272. if (dwWidth > USRD_W_A4) // > 216
  2273. fSwap = TRUE;
  2274. }
  2275. else
  2276. {
  2277. if (dwWidth > USRD_W_A3_OLD) // > 296
  2278. fSwap = TRUE;
  2279. }
  2280. if (fSwap)
  2281. {
  2282. DWORD dwTmp;
  2283. dwTmp = dwWidth;
  2284. dwWidth = dwHeight;
  2285. dwHeight = dwTmp;
  2286. }
  2287. // SPEC of RPDL
  2288. // If width is larger than length, we need to set landscape.
  2289. else
  2290. {
  2291. BITSET32(pOEM->fGeneral1, CUSTOMSIZE_USE_LAND);
  2292. }
  2293. }
  2294. else
  2295. {
  2296. BITSET32(pOEM->fGeneral1, CUSTOMSIZE_MAKE_LAND_PORT);
  2297. }
  2298. // @Dec/10/99 FK#49, add TRAY1-5 & eliminate TRAYA-D @Sep/27/2000 ->
  2299. // ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_PAPER_CUSTOM, (WORD)dwWidth, (WORD)dwHeight);
  2300. // WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2301. if (dwCmdCbID >= CMD_SELECT_TRAY1 && dwCmdCbID <= CMD_SELECT_TRAY5)
  2302. {
  2303. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_PAPER_CUSTOM2, (WORD)dwWidth, (WORD)dwHeight,
  2304. dwCmdCbID - CMD_SELECT_TRAY1 + 2);
  2305. }
  2306. else // manual feed
  2307. {
  2308. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SELECT_PAPER_CUSTOM, (WORD)dwWidth, (WORD)dwHeight);
  2309. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SELECT_MANUALFEED, sizeof(SELECT_MANUALFEED)-1);
  2310. }
  2311. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2312. // @Dec/10/99, @Sep/27/2000 <-
  2313. }
  2314. break;
  2315. case CMD_SELECT_ROLL1: // IP-1
  2316. case CMD_SELECT_ROLL2:
  2317. // Select roll (plotter)
  2318. if (dwCmdCbID == CMD_SELECT_ROLL1)
  2319. WRITESPOOLBUF(pdevobj, SELECT_ROLL1, sizeof(SELECT_ROLL1)-1);
  2320. else
  2321. WRITESPOOLBUF(pdevobj, SELECT_ROLL2, sizeof(SELECT_ROLL2)-1);
  2322. // Output Select_Papersize command ("papername+X" only)
  2323. WRITESPOOLBUF(pdevobj, SELECT_PAPER_HEAD_IP1, sizeof(SELECT_PAPER_HEAD_IP1)-1);
  2324. WRITESPOOLBUF(pdevobj, pOEM->RPDLHeap64, pOEM->RPDLHeapCount);
  2325. break;
  2326. case CMD_SELECT_FINISHER_TRAY2: // @Jun/25/2001
  2327. pOEM->FinisherTrayNum = 2;
  2328. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_PAPERDEST_FINISHER_GW, pOEM->FinisherTrayNum);
  2329. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2330. break;
  2331. case CMD_SET_COLLATE_OFF: // @Jul/31/98
  2332. pOEM->CollateType = COLLATE_OFF; // COLLATE_OFF<-0 @Dec/02/98
  2333. break;
  2334. case CMD_SET_COLLATE_ON: // @Jul/31/98
  2335. pOEM->CollateType = COLLATE_ON; // COLLATE_ON<-1 @Dec/02/98
  2336. break;
  2337. case CMD_SELECT_COLLATE_UNIDIR: // @Aug/10/98
  2338. if (COLLATE_OFF != pOEM->CollateType)
  2339. pOEM->CollateType = COLLATE_UNIDIR; // COLLATE_UNIDIR<-2 @Dec/02/98
  2340. break;
  2341. case CMD_SELECT_COLLATE_ROTATED: // @Aug/10/98
  2342. if (COLLATE_OFF != pOEM->CollateType)
  2343. pOEM->CollateType = COLLATE_ROTATED; // COLLATE_ROTATED<-3 @Dec/02/98
  2344. break;
  2345. case CMD_SELECT_COLLATE_SHIFTED: // @Dec/02/98
  2346. if (COLLATE_OFF != pOEM->CollateType)
  2347. pOEM->CollateType = COLLATE_SHIFTED;
  2348. break;
  2349. // Final command before print
  2350. case CMD_MULTI_COPIES: // pdwParams:NumOfCopies
  2351. // If not CustomSize, set max pagesize.
  2352. if ((nTmp = pOEM->DocPaperID) != RPDL_CUSTOMSIZE)
  2353. {
  2354. if (BITTEST32(pOEM->fGeneral2, EDGE2EDGE_PRINT)) // @Nov/27/97
  2355. {
  2356. pOEM->PageMax.x = RPDLPageSizeE2E[nTmp].x / pOEM->nResoRatio;
  2357. pOEM->PageMax.y = RPDLPageSizeE2E[nTmp].y / pOEM->nResoRatio;
  2358. }
  2359. else
  2360. {
  2361. pOEM->PageMax.x = RPDLPageSize[nTmp].x / pOEM->nResoRatio;
  2362. pOEM->PageMax.y = RPDLPageSize[nTmp].y / pOEM->nResoRatio;
  2363. }
  2364. if (BITTEST32(pOEM->fGeneral1, ORIENT_LANDSCAPE))
  2365. {
  2366. LONG tmp;
  2367. tmp = pOEM->PageMax.x; // swap x-y
  2368. pOEM->PageMax.x = pOEM->PageMax.y;
  2369. pOEM->PageMax.y = tmp;
  2370. }
  2371. }
  2372. if (TEST_BUGFIX_FORMFEED(pOEM->fModel) || // add @Sep/15/98
  2373. BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  2374. {
  2375. pOEM->PageMaxMoveY = pOEM->PageMax.y;
  2376. }
  2377. else
  2378. {
  2379. // PRINTER SIDE ISSUE: RPDL
  2380. // Because RPDL do formfeed when vertical position is around
  2381. // ymax-coordinate, we shift position upper 1mm.
  2382. // Set PageMaxMoveY for checking max vertical position.
  2383. nTmp = BITTEST32(pOEM->fGeneral2, EDGE2EDGE_PRINT)? // @Nov/27/97
  2384. DISABLE_FF_MARGIN_E2E : DISABLE_FF_MARGIN_STD;
  2385. pOEM->PageMaxMoveY = pOEM->PageMax.y - 1 -
  2386. (nTmp + pOEM->nResoRatio - 1) /
  2387. pOEM->nResoRatio; // KIRIAGE
  2388. }
  2389. // If 2in1, switch orientation(portrait<->landscape).
  2390. if (TEST_2IN1_MODE(pOEM->fGeneral1))
  2391. BITSET32(pOEM->fGeneral1, SWITCH_PORT_LAND);
  2392. if (BITTEST32(pOEM->fGeneral1, ORIENT_LANDSCAPE))
  2393. {
  2394. if (BITTEST32(pOEM->fGeneral1, SWITCH_PORT_LAND) ||
  2395. BITTEST32(pOEM->fGeneral1, CUSTOMSIZE_MAKE_LAND_PORT))
  2396. {
  2397. fLandscape = FALSE;
  2398. }
  2399. else
  2400. {
  2401. fLandscape = TRUE;
  2402. }
  2403. }
  2404. else // portrait
  2405. {
  2406. fLandscape = BITTEST32(pOEM->fGeneral1, SWITCH_PORT_LAND)? TRUE : FALSE;
  2407. }
  2408. // Output RPDL orientation command
  2409. if (fLandscape || BITTEST32(pOEM->fGeneral1, CUSTOMSIZE_USE_LAND))
  2410. WRITESPOOLBUF(pdevobj, SET_LANDSCAPE, sizeof(SET_LANDSCAPE)-1);
  2411. else // portrait
  2412. WRITESPOOLBUF(pdevobj, SET_PORTRAIT, sizeof(SET_PORTRAIT)-1);
  2413. // Output copy#
  2414. // Check whether copy# is in the range. @Sep/01/98
  2415. {
  2416. DWORD dwCopy, dwMax;
  2417. dwCopy = *pdwParams; // NumOfCopies
  2418. dwMax = TEST_MAXCOPIES_99(pOEM->fModel)? 99 : 999;
  2419. if(dwCopy > dwMax)
  2420. dwCopy = dwMax;
  2421. else if(dwCopy < 1)
  2422. dwCopy = 1;
  2423. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_MULTI_COPY, (WORD)dwCopy);
  2424. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2425. // @Jan/08/99 ->
  2426. if (1 == dwCopy)
  2427. pOEM->CollateType = COLLATE_OFF;
  2428. // @Jan/08/99 <-
  2429. }
  2430. fFinisherSR30Active = FALSE; // @Mar/19/99
  2431. // staple
  2432. if (pOEM->StapleType)
  2433. {
  2434. ocmd = 0;
  2435. if (BITTEST32(pOEM->fModel, GRP_MF250M)) // model = MF250M (No Punch Unit)
  2436. {
  2437. // sort:on (add duplex param since NX900 @Jan/08/99)
  2438. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_SORT_ON,
  2439. BITTEST32(pOEM->fGeneral1, DUPLEX_VALID)? 1 : 0);
  2440. // paper_destination:outer tray
  2441. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_OUTTRAY);
  2442. // staple:on
  2443. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_STAPLE_CORNER_ON,
  2444. (fLandscape)?
  2445. STAPLE_UPPERRIGHT_CORNER : STAPLE_UPPERLEFT_CORNER);
  2446. }
  2447. else // model = MF2700,3500,3550,4550,5550,6550,NXs
  2448. {
  2449. WORD pnt;
  2450. fFinisherSR30Active = TRUE; // @Mar/19/99
  2451. // sort:on (add duplex param since NX900 @Jan/08/99)
  2452. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_SORT_ON,
  2453. BITTEST32(pOEM->fGeneral1, DUPLEX_VALID)? 1 : 0);
  2454. // paper_destination:finisher shift tray
  2455. // @Jun/25/2001 ->
  2456. // if (!TEST_GWMODEL(pOEM->fModel)) // add if @Oct/10/2000
  2457. // ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_FINISHER);
  2458. if (TEST_GWMODEL(pOEM->fModel))
  2459. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_FINISHER_GW, pOEM->FinisherTrayNum);
  2460. else
  2461. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_FINISHER, pOEM->FinisherTrayNum);
  2462. // @Jun/25/2001 <-
  2463. // Disable rotated collate.
  2464. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, COLLATE_DISABLE_ROT); // @Mar/19/99
  2465. if (pOEM->StapleType == 2) // 2 staples on the paper
  2466. {
  2467. switch (pOEM->BindPoint)
  2468. {
  2469. case BIND_LEFT:
  2470. pnt = STAPLE_LEFT2;
  2471. break;
  2472. case BIND_RIGHT:
  2473. pnt = STAPLE_RIGHT2;
  2474. break;
  2475. case BIND_UPPER:
  2476. pnt = STAPLE_UPPER2;
  2477. break;
  2478. // case BIND_ANY:
  2479. default:
  2480. pnt = (fLandscape)? STAPLE_UPPER2 : STAPLE_LEFT2;
  2481. break;
  2482. }
  2483. // staple:on
  2484. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_STAPLE_ON, pnt);
  2485. }
  2486. // @Mar/18/99 ->
  2487. else if (pOEM->StapleType == 3) // 1 staple with FinisherSR12
  2488. {
  2489. // @Apr/06/99 ->
  2490. // if (BIND_RIGHT == pOEM->BindPoint)
  2491. // pnt = STAPLE_UPPERRIGHT_CORNER;
  2492. // else
  2493. // pnt = (fLandscape)? STAPLE_UPPERRIGHT_CORNER : STAPLE_UPPERLEFT_CORNER;
  2494. switch (pOEM->BindPoint)
  2495. {
  2496. case BIND_LEFT:
  2497. pnt = STAPLE_UPPERLEFT_CORNER;
  2498. break;
  2499. case BIND_RIGHT:
  2500. pnt = STAPLE_UPPERRIGHT_CORNER;
  2501. break;
  2502. default:
  2503. // If papersize without transverse (A3,B4,Tabloid,Legal)
  2504. if (!strcmp(pOEM->RPDLHeap64, SELECT_PAPER_A3) ||
  2505. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_B4) ||
  2506. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_TABD) ||
  2507. !strcmp(pOEM->RPDLHeap64, SELECT_PAPER_LEGL))
  2508. {
  2509. pnt = (fLandscape)? STAPLE_UPPERLEFT_CORNER : STAPLE_UPPERRIGHT_CORNER;
  2510. }
  2511. else
  2512. {
  2513. pnt = (fLandscape)? STAPLE_UPPERRIGHT_CORNER : STAPLE_UPPERLEFT_CORNER;
  2514. }
  2515. break;
  2516. }
  2517. // @Apr/06/99 <-
  2518. // staple:on
  2519. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_STAPLE_CORNER_ON, pnt);
  2520. }
  2521. // @Mar/18/99 <-
  2522. else // 1 staple
  2523. {
  2524. switch (pOEM->BindPoint)
  2525. {
  2526. case BIND_RIGHT:
  2527. pnt = STAPLE_UPPERRIGHT_CORNER;
  2528. break;
  2529. default:
  2530. pnt = STAPLE_UPPERLEFT_CORNER;
  2531. break;
  2532. }
  2533. // staple:on
  2534. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_STAPLE_CORNER_ON, pnt);
  2535. }
  2536. }
  2537. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2538. }
  2539. // punch
  2540. if (pOEM->PunchType)
  2541. {
  2542. WORD pnt;
  2543. ocmd = 0;
  2544. if (!fFinisherSR30Active) // modify @Mar/19/99
  2545. {
  2546. if (COLLATE_OFF != pOEM->CollateType)
  2547. {
  2548. // sort:on (add duplex param since NX900 @Jan/08/99)
  2549. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_SORT_ON,
  2550. BITTEST32(pOEM->fGeneral1, DUPLEX_VALID)? 1 : 0);
  2551. }
  2552. // paper_destination:finisher shift tray
  2553. // @Jun/25/2001 ->
  2554. // if (!TEST_GWMODEL(pOEM->fModel)) // add if @Oct/10/2000
  2555. // ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_FINISHER);
  2556. if (TEST_GWMODEL(pOEM->fModel))
  2557. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_FINISHER_GW, pOEM->FinisherTrayNum);
  2558. else
  2559. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_FINISHER, pOEM->FinisherTrayNum);
  2560. // @Jun/25/2001 <-
  2561. // SPEC of RPDL @May/27/98
  2562. // We must disable rotated collate here.
  2563. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, COLLATE_DISABLE_ROT);
  2564. }
  2565. switch (pOEM->BindPoint)
  2566. {
  2567. case BIND_LEFT:
  2568. pnt = PUNCH_LEFT;
  2569. break;
  2570. case BIND_RIGHT:
  2571. pnt = PUNCH_RIGHT;
  2572. break;
  2573. case BIND_UPPER:
  2574. pnt = PUNCH_UPPER;
  2575. break;
  2576. default:
  2577. pnt = (fLandscape)? PUNCH_UPPER : PUNCH_LEFT;
  2578. break;
  2579. }
  2580. // punch:on
  2581. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PUNCH_ON, pnt);
  2582. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2583. }
  2584. // collate (@Jul/31/98, entirely-modify @Dec/02/98)
  2585. if (!pOEM->StapleType && !pOEM->PunchType)
  2586. {
  2587. // sort:on (add duplex param since NX900 @Jan/08/99)
  2588. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_SORT_ON,
  2589. BITTEST32(pOEM->fGeneral1, DUPLEX_VALID)? 1 : 0);
  2590. switch (pOEM->CollateType)
  2591. {
  2592. case COLLATE_UNIDIR:
  2593. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, COLLATE_DISABLE_ROT);
  2594. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2595. break;
  2596. case COLLATE_ROTATED:
  2597. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, COLLATE_ENABLE_ROT);
  2598. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2599. break;
  2600. // If shifted collate, select finisher shift tray.
  2601. case COLLATE_SHIFTED:
  2602. // @Jun/25/2001 ->
  2603. // if (!TEST_GWMODEL(pOEM->fModel)) // add if @Oct/10/2000
  2604. // ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_FINISHER);
  2605. if (TEST_GWMODEL(pOEM->fModel))
  2606. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_FINISHER_GW, pOEM->FinisherTrayNum);
  2607. else
  2608. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAPERDEST_FINISHER, pOEM->FinisherTrayNum);
  2609. // @Jun/25/2001 <-
  2610. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2611. break;
  2612. // if collate for MF-p150,MF200,250M,2200,NXs
  2613. case COLLATE_ON:
  2614. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2615. break;
  2616. default:
  2617. break;
  2618. }
  2619. }
  2620. ocmd = 0;
  2621. if (TEST_AFTER_SP9II(pOEM->fModel) && !BITTEST32(pOEM->fModel, GRP_NX100))
  2622. {
  2623. //@Jun/23/2000 ->
  2624. // PRINTER SIDE ISSUE: NX610,710,71 RPDL
  2625. // Printer hangs up with variable scaling command. Dummy font select is
  2626. // effective on this problem.
  2627. if (BITTEST32(pOEM->fModel, GRP_NX70) || BITTEST32(pOEM->fModel, GRP_NX710))
  2628. {
  2629. // Emit dummy Mincho font select.
  2630. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_JIS_FONT_SCALE_H_ONLY, 1000L);
  2631. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_JIS_FONT_NAME[0]);
  2632. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2633. ocmd = 0;
  2634. }
  2635. //@Jun/23/2000 <-
  2636. // Set IBM extended character code block, and set region to 'USA'. (latter @Feb/22/99)
  2637. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_IBM_EXT_BLOCK);
  2638. // Disable formfeed when charcter position is around ymax-coordinate
  2639. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_PAGEMAX_VALID);
  2640. }
  2641. // Set color of Textmode RectangleFill black
  2642. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_TEXTRECT_BLACK);
  2643. pOEM->TextRectGray = 100; // @Jan/07/98
  2644. // Set 5mm offset at MF530,150,150e,160.
  2645. // (At these models, CMD_SET_BASEOFFSETs aren't called.)
  2646. if (TEST_GRP_OLDMF(pOEM->fModel) &&
  2647. !BITTEST32(pOEM->fGeneral2, EDGE2EDGE_PRINT) &&
  2648. !BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO)) // add @Sep/15/98
  2649. {
  2650. pOEM->BaseOffset.x = pOEM->BaseOffset.y = 5; // mm
  2651. }
  2652. // Convert mm to dot here ((LONG)<-(DWORD) @Feb/02/99)
  2653. pOEM->BaseOffset.x = pOEM->BaseOffset.x * (LONG)(MASTERUNIT*10) /
  2654. (LONG)254 / (LONG)pOEM->nResoRatio;
  2655. pOEM->BaseOffset.y = pOEM->BaseOffset.y * (LONG)(MASTERUNIT*10) /
  2656. (LONG)254 / (LONG)pOEM->nResoRatio;
  2657. // Think about scaling (@May/18/98, (LONG)<-(DWORD) @Feb/02/99)
  2658. if (pOEM->Scale != 100 && pOEM->Scale != 0)
  2659. {
  2660. pOEM->BaseOffset.x = pOEM->BaseOffset.x * (LONG)100 / (LONG)pOEM->Scale;
  2661. pOEM->BaseOffset.y = pOEM->BaseOffset.y * (LONG)100 / (LONG)pOEM->Scale;
  2662. }
  2663. // Calculate offset for TOMBO.(BaseOffset will be changed.) @Sep/14/98
  2664. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  2665. DrawTOMBO(pdevobj, INIT_TOMBO);
  2666. // Initialize current position
  2667. pOEM->TextCurPos.x = pOEM->Offset.x = pOEM->BaseOffset.x;
  2668. pOEM->TextCurPos.y = pOEM->Offset.y = pOEM->BaseOffset.y;
  2669. pOEM->TextCurPosRealY = pOEM->TextCurPos.y;
  2670. // SPEC of Unidrv5 & RPDL @Aug/14/98
  2671. // Unidrv5 doesn't order to set coordinate x,y to 0 after returning iRet=0,
  2672. // and RPDL doesn't reset coordinate y of SEND_BLOCK after initializing
  2673. // printer.
  2674. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ESC_XM_ABS, pOEM->TextCurPos.x);
  2675. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ESC_YM_ABS, pOEM->TextCurPos.y);
  2676. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2677. break;
  2678. //
  2679. // Following cases are called at the end of a print-job (JOB_FINISH)
  2680. //
  2681. case CMD_ENDDOC_SP4II: // SP4mkII,5
  2682. // If Nin1 && document finished with remaining pages, output FF.
  2683. if (TEST_NIN1_MODE(pOEM->fGeneral1) && pOEM->Nin1RemainPage)
  2684. WRITESPOOLBUF(pdevobj, FF, sizeof(FF)-1);
  2685. // Set Spacing_Unit:(H)1/120,(V)1/48inch, Code:JIS, Scaling:100%
  2686. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ENDDOC1);
  2687. goto _ENDDOC_FINISH;
  2688. case CMD_ENDDOC_SP8: // SP8(7),8(7)mkII,80,10,10mkII
  2689. if (TEST_NIN1_MODE(pOEM->fGeneral1) && pOEM->Nin1RemainPage)
  2690. WRITESPOOLBUF(pdevobj, FF, sizeof(FF)-1);
  2691. // Set Spacing_Unit:(H)1/120,(V)1/48inch, Code:JIS, Scaling:100%
  2692. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ENDDOC1);
  2693. if (TEST_AFTER_SP10(pOEM->fModel)) // SP10,10mkII
  2694. {
  2695. // Set Graphics_Unit:1/240inch,Engine_Resolution:240dpi
  2696. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC2_240DPI);
  2697. // Set Coordinate_Unit:1/720inch
  2698. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC3);
  2699. }
  2700. // Set Options[duplex/2in1:off,reversed_output:off,sort/stack:off]
  2701. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC4);
  2702. goto _ENDDOC_FINISH;
  2703. case CMD_ENDDOC_SP9: // SP9,10Pro,9II,10ProII,90
  2704. if (TEST_NIN1_MODE(pOEM->fGeneral1) && pOEM->Nin1RemainPage)
  2705. WRITESPOOLBUF(pdevobj, FF, sizeof(FF)-1);
  2706. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ENDDOC1);
  2707. // Set Graphics_Unit:1/240inch,Engine_Resolution:400dpi
  2708. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC2_SP9);
  2709. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC3);
  2710. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC4);
  2711. goto _ENDDOC_FINISH;
  2712. case CMD_ENDDOC_400DPI_MODEL: // MF,MF-P,NX,IP-1
  2713. if (TEST_NIN1_MODE(pOEM->fGeneral1) && pOEM->Nin1RemainPage)
  2714. WRITESPOOLBUF(pdevobj, FF, sizeof(FF)-1);
  2715. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ENDDOC1);
  2716. if (TEST_AFTER_SP10(pOEM->fModel) || // MF-P,NX,MF200,250M,MF-p150,MF2200
  2717. BITTEST32(pOEM->fModel, GRP_MF150E)) // MF150e,160
  2718. {
  2719. // Set Graphics_Unit:1/400inch,Engine_Resolution:400dpi
  2720. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC2_400DPI);
  2721. // Set Coordinate_Unit:1/720inch
  2722. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC3);
  2723. }
  2724. // If staple mode, do not change sort/stack of Options.
  2725. if (pOEM->StapleType || pOEM->PunchType)
  2726. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC4_FINISHER);
  2727. else
  2728. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC4);
  2729. // goto _ENDDOC_FINISH;
  2730. _ENDDOC_FINISH:
  2731. // Reset smoothing/tonner_save_mode. (PRINTER SIDE ISSUE: We must not reset SP8.)
  2732. if (TEST_BUGFIX_RESET_SMOOTH(pOEM->fModel))
  2733. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SELECT_SMOOTHING2);
  2734. // Terminate fax at imagio FAX
  2735. if (BITTEST32(pOEMExtra->fUiOption, FAX_MODEL))
  2736. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDFAX);
  2737. // @Jun/29/2001 Add TEST_NEED_JOBDEF_CMD ->
  2738. // PRINTER SIDE ISSUE: RPDL (job define command is needed) GRP_NX900 @Jan/08/99
  2739. // if (BITTEST32(pOEM->fModel, GRP_NX900) &&
  2740. // (COLLATE_OFF != pOEM->CollateType || pOEM->StapleType || pOEM->PunchType))
  2741. if (BITTEST32(pOEM->fModel, GRP_NX900) || TEST_NEED_JOBDEF_CMD(pOEM->fModel))
  2742. // @Jun/29/2001 <-
  2743. {
  2744. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC_JOBDEF_END);
  2745. }
  2746. // Initialize printer
  2747. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, ENDDOC5);
  2748. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2749. ocmd = 0;
  2750. // If binding margin is set,reset it to 0mm.
  2751. if (BITTEST32(pOEM->fGeneral1, DUPLEX_LEFTMARGIN_VALID))
  2752. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_LEFTMARGIN, 1);
  2753. else if (BITTEST32(pOEM->fGeneral1, DUPLEX_UPPERMARGIN_VALID))
  2754. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_UPPERMARGIN, 1);
  2755. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  2756. if(pOEM->pRPDLHeap2K) // @Sep/09/98
  2757. MemFree(pOEM->pRPDLHeap2K); // add ; @Aug/02/2000
  2758. #ifdef DOWNLOADFONT
  2759. if(pOEM->pDLFontGlyphInfo) // @Sep/09/98
  2760. MemFree(pOEM->pDLFontGlyphInfo);
  2761. #endif // DOWNLOADFONT
  2762. break;
  2763. default:
  2764. ERR((("Unknown callback ID = %d.\n"), dwCmdCbID));
  2765. }
  2766. return iRet;
  2767. } //*** OEMCommandCallback
  2768. BOOL APIENTRY bOEMSendFontCmd( // BOOL <- VOID @Mar/27/2002
  2769. PDEVOBJ pdevobj,
  2770. PUNIFONTOBJ pUFObj,
  2771. PFINVOCATION pFInv)
  2772. {
  2773. PGETINFO_STDVAR pSV;
  2774. DWORD adwStdVariable[STDVAR_BUFSIZE(3) / sizeof(DWORD)];
  2775. DWORD dwIn, dwOut;
  2776. PBYTE pubCmd;
  2777. BYTE Cmd[128];
  2778. PIFIMETRICS pIFI;
  2779. POEMPDEV pOEM = MINIDEV_DATA(pdevobj); // @Oct/06/98
  2780. DWORD dwNeeded, dwUFO_FontH, dwUFO_FontW;
  2781. DWORD dwUFO_FontMaxW; // MSKK Jul/23/98
  2782. LONG lTmp;
  2783. VERBOSE(("** bOEMSendFontCmd() entry. **\n"));
  2784. // MSKK 1/24/98 UnSelect ->
  2785. if (0 == pFInv->dwCount)
  2786. {
  2787. // No select command. pProbably some of the
  2788. // un-select case where no invokation command is
  2789. // available. (No explicit un-select.)
  2790. return FALSE; // BOOL <- VOID @Mar/27/2002
  2791. }
  2792. // MSKK 1/24/98 <-
  2793. pubCmd = pFInv->pubCommand;
  2794. pIFI = pUFObj->pIFIMetrics;
  2795. //
  2796. // Get standard variables.
  2797. //
  2798. pSV = (PGETINFO_STDVAR)adwStdVariable;
  2799. pSV->dwSize = STDVAR_BUFSIZE(3);
  2800. pSV->dwNumOfVariable = 3;
  2801. pSV->StdVar[0].dwStdVarID = FNT_INFO_FONTHEIGHT;
  2802. pSV->StdVar[1].dwStdVarID = FNT_INFO_FONTMAXWIDTH;
  2803. pSV->StdVar[2].dwStdVarID = FNT_INFO_FONTWIDTH;
  2804. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_STDVARIABLE, pSV,
  2805. pSV->dwSize, &dwNeeded))
  2806. {
  2807. ERR(("UFO_GETINFO_STDVARIABLE failed.\n"));
  2808. return FALSE; // BOOL <- VOID @Mar/27/2002
  2809. }
  2810. // VERBOSE((("FONTHEIGHT=%d\n"), pSV->StdVar[0].lStdVariable));
  2811. // VERBOSE((("FONTMAXWIDTH=%d\n"), pSV->StdVar[1].lStdVariable));
  2812. // VERBOSE((("FONTWIDTH=%d\n"), pSV->StdVar[2].lStdVariable));
  2813. dwUFO_FontH = (DWORD)pSV->StdVar[0].lStdVariable;
  2814. dwUFO_FontMaxW = (DWORD)pSV->StdVar[1].lStdVariable; // MSKK Jul/23/98
  2815. dwUFO_FontW = (DWORD)pSV->StdVar[2].lStdVariable;
  2816. dwOut = 0;
  2817. BITCLR_BARCODE(pOEM->fGeneral2);
  2818. for (dwIn = 0; dwIn < pFInv->dwCount;)
  2819. {
  2820. if (pubCmd[dwIn] == '#')
  2821. {
  2822. //** set width & height of scalable font for Japanese font **
  2823. if (pubCmd[dwIn+1] == 'A')
  2824. {
  2825. DWORD dwWidth, dwHeight;
  2826. // pOEM->FontH_DOT(unit:dot) for TextMode clipping
  2827. pOEM->FontH_DOT = MASTER_TO_SPACING_UNIT(pOEM, ((WORD)dwUFO_FontH)); // @Jan/30/98
  2828. // dwHeight(unit:cpt) for RPDL command parameter
  2829. dwHeight = dwUFO_FontH * (DWORD)(DEVICE_MASTER_UNIT / DRIVER_MASTER_UNIT);
  2830. if(IS_DBCSCHARSET(pIFI->jWinCharSet))
  2831. // MSKK Jul/23/98 ->
  2832. // dwWidth = dwUFO_FontW * 2;
  2833. dwWidth = dwUFO_FontMaxW;
  2834. // MSKK Jul/23/98 <-
  2835. else
  2836. dwWidth = dwUFO_FontW;
  2837. dwWidth *= DEVICE_MASTER_UNIT / DRIVER_MASTER_UNIT;
  2838. // VERBOSE(("[OEMSCALABLEFONT] w=%d,h=%d(%ddot)\n",
  2839. // (WORD)dwWidth, (WORD)dwHeight, pOEM->FontH_DOT));
  2840. // @Jun/25/98 ->
  2841. // If width is slightly different to height, we suppose they are same.
  2842. if ((lTmp = dwHeight - dwWidth) != 0)
  2843. {
  2844. if (lTmp < 0)
  2845. lTmp = -lTmp;
  2846. if ((DWORD)lTmp < dwHeight / 25) // 1/25 = 4%
  2847. dwWidth = dwHeight;
  2848. }
  2849. // @Jun/25/98 <-
  2850. // Use 10pt-size raster font at SP4mkII,5,8(7),8(7)mkII
  2851. if (TEST_GRP_240DPI(pOEM->fModel) && dwWidth == dwHeight &&
  2852. dwWidth >= NEAR10PT_MIN && dwWidth <= NEAR10PT_MAX)
  2853. {
  2854. dwWidth = dwHeight = 960; // unit:cpt(centi point)
  2855. }
  2856. pOEM->dwFontW_CPT = dwWidth;
  2857. pOEM->dwFontH_CPT = dwHeight;
  2858. // @Jan/29/99 ->
  2859. // If width equals to height, we emit height parameter only.
  2860. // (This is applied to after SP9II because we want to avoid testing
  2861. // at too old models.)
  2862. if (TEST_AFTER_SP9II(pOEM->fModel) && dwWidth == dwHeight)
  2863. dwOut += safe_sprintfA(&Cmd[dwOut], sizeof(Cmd) - dwOut, ",%ld", dwHeight);
  2864. else
  2865. // @Jan/29/99 <-
  2866. dwOut += safe_sprintfA(&Cmd[dwOut], sizeof(Cmd) - dwOut, "%ld,%ld", dwWidth, dwHeight);
  2867. dwIn += 2;
  2868. } // 'if 'A'' end
  2869. //** set width & height of scalable font for IBM ext font **
  2870. else if (pubCmd[dwIn+1] == 'B')
  2871. {
  2872. // @Jan/29/99 ->
  2873. if (TEST_AFTER_SP9II(pOEM->fModel) && pOEM->dwFontW_CPT == pOEM->dwFontH_CPT)
  2874. dwOut += safe_sprintfA(&Cmd[dwOut], sizeof(Cmd) - dwOut, ",%ld", pOEM->dwFontH_CPT);
  2875. else
  2876. // @Jan/29/99 <-
  2877. dwOut += safe_sprintfA(&Cmd[dwOut], sizeof(Cmd) - dwOut, "%ld,%ld",
  2878. pOEM->dwFontW_CPT, pOEM->dwFontH_CPT);
  2879. dwIn += 2;
  2880. } // 'if 'B'' end
  2881. // Set flag for barcode
  2882. else if (pubCmd[dwIn+1] == 'C')
  2883. {
  2884. switch (pubCmd[dwIn+2])
  2885. {
  2886. case '0': // JAN(STANDARD)
  2887. pOEM->nBarMaxLen = 13 + 1; goto _BARCODE_READY;
  2888. case '1': // JAN(SHORT)
  2889. pOEM->nBarMaxLen = 8 + 1; goto _BARCODE_READY;
  2890. // @Dec/07/99 FK#50 ->
  2891. case '7': // CUSTOMER
  2892. pOEM->nBarMaxLen = 20 + 1; goto _BARCODE_READY;
  2893. case '9': // UPC(A)
  2894. pOEM->nBarMaxLen = 12 + 1; goto _BARCODE_READY;
  2895. case 'A': // UPC(A)
  2896. pOEM->nBarMaxLen = 8 + 1; goto _BARCODE_READY;
  2897. case '8': // CODE128
  2898. // @Dec/07/99 FK#50 <-
  2899. case '2': // 2of5(INDUSTRIAL)
  2900. case '3': // 2of5(MATRIX)
  2901. case '4': // 2of5(ITF)
  2902. case '5': // CODE39
  2903. case '6': // NW-7
  2904. pOEM->nBarMaxLen = BARCODE_MAX;
  2905. _BARCODE_READY:
  2906. BITSET32(pOEM->fGeneral2, BARCODE_MODE_IN);
  2907. pOEM->dwBarRatioW = dwUFO_FontH * (DWORD)(DEVICE_MASTER_UNIT / DRIVER_MASTER_UNIT);
  2908. // @Dec/17/99 FK#50 ->
  2909. // pOEM->nBarType = pubCmd[dwIn+2] - '0';
  2910. if (pubCmd[dwIn+2] < 'A')
  2911. pOEM->nBarType = pubCmd[dwIn+2] - '0';
  2912. else
  2913. pOEM->nBarType = pubCmd[dwIn+2] - 'A' + 10;
  2914. // @Dec/17/99 FK#50 <-
  2915. pOEM->RPDLHeapCount = 0;
  2916. VERBOSE(("** BARCODE(1) ratio=%d **\n",pOEM->dwBarRatioW));
  2917. break;
  2918. default:
  2919. break;
  2920. }
  2921. dwIn += 3;
  2922. } // 'if 'C'' end
  2923. //** set width of scalable font **
  2924. else if (pubCmd[dwIn+1] == 'W')
  2925. {
  2926. // MSKK Jul/23/98 ->
  2927. // if (dwUFO_FontW > 0)
  2928. if (dwUFO_FontW > 0 || dwUFO_FontMaxW > 0)
  2929. // MSKK Jul/23/98 <-
  2930. {
  2931. DWORD dwWidth;
  2932. if(IS_DBCSCHARSET(pIFI->jWinCharSet))
  2933. // MSKK Jul/23/98 ->
  2934. // dwWidth = dwUFO_FontW * 2;
  2935. dwWidth = dwUFO_FontMaxW;
  2936. // MSKK Jul/23/98 <-
  2937. else
  2938. dwWidth = dwUFO_FontW;
  2939. pOEM->dwFontW_CPT = dwWidth * (DEVICE_MASTER_UNIT / DRIVER_MASTER_UNIT);
  2940. dwOut += safe_sprintfA(&Cmd[dwOut], sizeof(Cmd) - dwOut, "%ld", pOEM->dwFontW_CPT);
  2941. }
  2942. dwIn += 2;
  2943. } // 'if 'W'' end
  2944. //** set height of scalable font (include Japanese proportional font) **
  2945. else if (pubCmd[dwIn+1] == 'H')
  2946. {
  2947. pOEM->FontH_DOT = MASTER_TO_SPACING_UNIT(pOEM, ((WORD)dwUFO_FontH)); // @Jan/30/98
  2948. pOEM->dwFontH_CPT = dwUFO_FontH * (DWORD)(DEVICE_MASTER_UNIT / DRIVER_MASTER_UNIT);
  2949. dwOut += safe_sprintfA(&Cmd[dwOut], sizeof(Cmd) - dwOut, "%ld", pOEM->dwFontH_CPT);
  2950. dwIn += 2;
  2951. } // 'if 'H'' end
  2952. //** set font pitch (Horizontal-Motion-Index) **
  2953. else if (pubCmd[dwIn+1] == 'P')
  2954. {
  2955. SHORT nTmp1, nTmp2;
  2956. switch (pubCmd[dwIn+2]) // modify(add Arial,Century,etc)
  2957. {
  2958. case 'D': // DBCS (Japanese font ZENKAKU)
  2959. //95/NT4 nTmp1 = lpFont->dfAvgWidth * 2;
  2960. // MSKK 1/25/98 nTmp1 = ((SHORT)dwUFO_FontW + 1) / 2 * 2;
  2961. // MSKK Jul/23/98 nTmp1 = (SHORT)dwUFO_FontW * 2;
  2962. nTmp1 = (SHORT)dwUFO_FontMaxW;
  2963. nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1); // MSKK 1/25/98
  2964. VERBOSE(("** FontMaxW=%d dot **\n", nTmp1));
  2965. // @Aug/10/98 nTmp1 = (nTmp1 / 2 + 1) * 2; // bigger even @Jan/30/98
  2966. break;
  2967. case 'S': // SBCS (Japanese font HANKAKU)
  2968. // RPDL pitch setting command of HANKAKU is EFFECTIVE to SPACE.
  2969. // OBSOLETE @Mar/26/99 ->
  2970. //// @Jan/29/99 ->
  2971. // // RPDL pitch setting command of HANKAKU is not effective, so
  2972. // // do not emit this. (We may not delete this string in UFM.)
  2973. // if (dwOut >= 4 && Cmd[dwOut-4] == '\x1B' && Cmd[dwOut-3] == 'N')
  2974. // {
  2975. // dwIn += 3; // count up input '#PS'
  2976. // dwOut -= 4; // delete previous output '\x1BN\x1B\x1F'
  2977. // continue; // goto for loop-end
  2978. // }
  2979. // else // Maybe none comes here.
  2980. // @Jan/29/99 <-
  2981. // @Mar/26/99 <-
  2982. {
  2983. //95/NT4 nTmp1 = lpFont->dfAvgWidth;
  2984. // NSKK 1/25/98 nTmp1 = ((SHORT)dwUFO_FontW + 1) / 2;
  2985. nTmp1 = (SHORT)dwUFO_FontW;
  2986. nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1); // MSKK 1/25/98
  2987. VERBOSE(("** FontW=%d dot **\n", nTmp1));
  2988. // @Aug/10/98 nTmp1++; // 1dot bigger @Jan/30/98
  2989. }
  2990. break;
  2991. case '1': // SBCS (BoldFacePS)
  2992. case '2': // SBCS (Arial)
  2993. case '3': // SBCS (Century)
  2994. nTmp1 = (SHORT)(dwUFO_FontH * 3L / 10L); // * 0.3
  2995. nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1); // MSKK 1/25/98
  2996. break;
  2997. case '4': // SBCS (TimesNewRoman)
  2998. nTmp1 = (SHORT)(dwUFO_FontH * 27L / 100L); // * 0.27
  2999. nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1); // MSKK 1/25/98
  3000. break;
  3001. case '5': // SBCS (Symbol)
  3002. nTmp1 = (SHORT)dwUFO_FontH / 4; // * 0.25
  3003. nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1); // MSKK 1/25/98
  3004. break;
  3005. case '6': // SBCS (Wingding)
  3006. nTmp1 = (SHORT)dwUFO_FontH; // * 1
  3007. nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1); // MSKK 1/25/98
  3008. break;
  3009. case '7': // DBCS (Japanese proportional font HANKAKU)
  3010. nTmp1 = (SHORT)(dwUFO_FontH * 78L / 256L);
  3011. nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1); // MSKK 1/25/98
  3012. break;
  3013. // OBSOLETE @Mar/26/99 ->
  3014. // case '8': // DBCS (Japanese proportional font ZENKAKU)
  3015. // nTmp1 = (SHORT)(dwUFO_FontH * 170L / 256L);
  3016. // nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1); // MSKK 1/25/98
  3017. // break;
  3018. // @Mar/26/99 <-
  3019. default: // SBCS (Courier,LetterGothic,PrestigeElite)
  3020. //95/NT4 nTmp1 = lpFont->dfPixWidth;
  3021. nTmp1 = (SHORT)dwUFO_FontW;
  3022. nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1); // MSKK 1/25/98
  3023. dwIn --;
  3024. break;
  3025. }
  3026. if (nTmp1 >= 0x7E)
  3027. {
  3028. Cmd[dwOut++] = (BYTE)(((nTmp1 + 2) >> 7) + 0x81);
  3029. // PRINTER SIDE ISSUE: RPDL (We cannot set value of 0x7F & 0x80.)
  3030. if ((nTmp2 = ((nTmp1 + 2) & 0x7F) + 1) > 0x7E)
  3031. nTmp2 = 0x7E;
  3032. Cmd[dwOut++] = (BYTE)nTmp2;
  3033. }
  3034. else
  3035. {
  3036. Cmd[dwOut++] = (BYTE)(nTmp1 + 1);
  3037. }
  3038. dwIn += 3;
  3039. } // 'if 'P'' end
  3040. //** set Vertical-Motion-Index to draw combined font('^'+'A',etc). **
  3041. //** (Courier,LetterGothic,PrestigeElite,BoldFacePS) **
  3042. else if (pubCmd[dwIn+1] == 'V')
  3043. {
  3044. SHORT nTmp1, nTmp2;
  3045. // Set 1/3 height (adequate value to move vertically)
  3046. nTmp1 = (SHORT)dwUFO_FontH / 3;
  3047. nTmp1 = MASTER_TO_SPACING_UNIT(pOEM, nTmp1);
  3048. if (nTmp1 >= 0x7E)
  3049. {
  3050. Cmd[dwOut++] = (BYTE)(((nTmp1 + 2) >> 7) + 0x81);
  3051. // PRINTER SIDE ISSUE: RPDL (We cannot set value of 0x7F & 0x80.)
  3052. if ((nTmp2 = ((nTmp1 + 2) & 0x7F) + 1) > 0x7E)
  3053. nTmp2 = 0x7E;
  3054. Cmd[dwOut++] = (BYTE)nTmp2;
  3055. }
  3056. else
  3057. {
  3058. Cmd[dwOut++] = (BYTE)(nTmp1 + 1);
  3059. }
  3060. dwIn += 2;
  3061. } // 'if 'V'' end
  3062. } // 'if '#'' end
  3063. else
  3064. {
  3065. Cmd[dwOut++] = pubCmd[dwIn++];
  3066. }
  3067. } // 'for (dwIn = 0; dwIn < pFInv->dwCount;)' end
  3068. // VERBOSE(("dwOut = %d\n", dwOut)); // MSKK 1/24/98
  3069. WRITESPOOLBUF(pdevobj, Cmd, dwOut);
  3070. return TRUE; // BOOL <- VOID @Mar/27/2002
  3071. } //*** bOEMSendFontCmd
  3072. static BYTE IsDBCSLeadByteRPDL(BYTE Ch)
  3073. {
  3074. return ShiftJisRPDL[Ch];
  3075. }
  3076. static BYTE IsDifferentPRNFONT(BYTE Ch)
  3077. {
  3078. return VerticalFontCheck[Ch];
  3079. }
  3080. //---------------------------*[LOCAL] DrawTOMBO*-------------------------------
  3081. // Action:
  3082. // (a) INIT_TOMBO: calculate offset in printing. (BaseOffset will be changed)
  3083. // (b) DRAW_TOMBO: drawing TOMBO.
  3084. // Setp/14/98
  3085. //-----------------------------------------------------------------------------
  3086. static VOID DrawTOMBO(
  3087. PDEVOBJ pdevobj,
  3088. SHORT action)
  3089. {
  3090. POEMUD_EXTRADATA pOEMExtra = MINIPRIVATE_DM(pdevobj); // @Oct/06/98
  3091. POEMPDEV pOEM = MINIDEV_DATA(pdevobj); // @Oct/06/98
  3092. POINT P0;
  3093. POINT PaperSizeDoc, PaperSizeUse;
  3094. BYTE Cmd[256]; // build command here
  3095. INT ocmd = 0;
  3096. LONG lLen3, lLen10, lLen13, lWidth0_1, lSav, lTmp;
  3097. SHORT nPaperUse;
  3098. switch (pOEM->DocPaperID)
  3099. {
  3100. case RPDL_A3:
  3101. nPaperUse = RPDL_B3; break;
  3102. case RPDL_B4:
  3103. nPaperUse = RPDL_A3; break;
  3104. case RPDL_A4:
  3105. nPaperUse = RPDL_B4; break;
  3106. case RPDL_A5:
  3107. case RPDL_A6:
  3108. case RPDL_POSTCARD:
  3109. case RPDL_B5:
  3110. case RPDL_B6:
  3111. nPaperUse = RPDL_A4; break;
  3112. default:
  3113. return; // draw nothing
  3114. }
  3115. // Set acutual printed paper size & document paper size
  3116. PaperSizeUse = RPDLPageSizeE2E[nPaperUse];
  3117. PaperSizeDoc = RPDLPageSizeE2E[pOEM->DocPaperID];
  3118. // Orientation?
  3119. if (BITTEST32(pOEM->fGeneral1, ORIENT_LANDSCAPE))
  3120. {
  3121. lTmp = PaperSizeUse.x; // swap x-y
  3122. PaperSizeUse.x = PaperSizeUse.y;
  3123. PaperSizeUse.y = lTmp;
  3124. lTmp = PaperSizeDoc.x;
  3125. PaperSizeDoc.x = PaperSizeDoc.y;
  3126. PaperSizeDoc.y = lTmp;
  3127. }
  3128. // upper-left TOMBO
  3129. P0.x = (PaperSizeUse.x - PaperSizeDoc.x) / 2 / pOEM->nResoRatio;
  3130. P0.y = (PaperSizeUse.y - PaperSizeDoc.y) / 2 / pOEM->nResoRatio;
  3131. // If action is INIT_TOMBO, set BaseOffset and return
  3132. if (INIT_TOMBO == action)
  3133. {
  3134. LONG lUnprintable = BITTEST32(pOEM->fGeneral2, EDGE2EDGE_PRINT)?
  3135. 0 : 240L / pOEM->nResoRatio; // 240masterunit at GPD
  3136. pOEM->BaseOffset.x += P0.x + lUnprintable;
  3137. pOEM->BaseOffset.y += P0.y + lUnprintable;
  3138. return; // exit
  3139. }
  3140. lSav = P0.x; // save left P0.x
  3141. lLen3 = 3L * (LONG)(MASTERUNIT*10) / 254L / pOEM->nResoRatio; // 3mm
  3142. lLen10 = 10L * (LONG)(MASTERUNIT*10) / 254L / pOEM->nResoRatio; // 10mm
  3143. lLen13 = 13L * (LONG)(MASTERUNIT*10) / 254L / pOEM->nResoRatio; // 13mm
  3144. lWidth0_1 = (LONG)MASTERUNIT / 254L / pOEM->nResoRatio; // 0.1mm
  3145. if (lWidth0_1 < 1)
  3146. lWidth0_1 = 1;
  3147. else if (lWidth0_1 >= 2)
  3148. lWidth0_1 = lWidth0_1 / 2 * 2 + 1; // make it odd
  3149. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ENTER_VECTOR); // enter VectorMode
  3150. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, PEN_WIDTH, lWidth0_1);
  3151. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DRAW_TOMBO_POLYLINE, P0.x, P0.y - lLen13,
  3152. 0, lLen10, -lLen13, 0);
  3153. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DRAW_TOMBO_POLYLINE, P0.x - lLen3, P0.y - lLen13,
  3154. 0, lLen13, -lLen10, 0);
  3155. // upper-right TOMBO
  3156. // Add horizontal distance and adjustment (PaperSizeDoc.x:masterunit, AdjX:0.1mm unit)
  3157. P0.x += (PaperSizeDoc.x + (LONG)pOEMExtra->nUiTomboAdjX * (LONG)MASTERUNIT / 254L)
  3158. / pOEM->nResoRatio;
  3159. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DRAW_TOMBO_POLYLINE, P0.x, P0.y - lLen13,
  3160. 0, lLen10, lLen13, 0);
  3161. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DRAW_TOMBO_POLYLINE, P0.x + lLen3, P0.y - lLen13,
  3162. 0, lLen13, lLen10, 0);
  3163. // lower-left TOMBO
  3164. lTmp = P0.x;
  3165. P0.x = lSav; // restore left P0.x
  3166. lSav = lTmp; // save right P0.x
  3167. // Add vertical distance and adjustment (PaperSizeDoc.y:masterunit, AdjY:0.1mm unit)
  3168. P0.y += (PaperSizeDoc.y + (LONG)pOEMExtra->nUiTomboAdjY * (LONG)MASTERUNIT / 254L)
  3169. / pOEM->nResoRatio;
  3170. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DRAW_TOMBO_POLYLINE, P0.x, P0.y + lLen13,
  3171. 0, -lLen10, -lLen13, 0);
  3172. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DRAW_TOMBO_POLYLINE, P0.x - lLen3, P0.y + lLen13,
  3173. 0, -lLen13, -lLen10, 0);
  3174. // lower-right TOMBO
  3175. P0.x = lSav; // restore right P0.x
  3176. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DRAW_TOMBO_POLYLINE, P0.x, P0.y + lLen13,
  3177. 0, -lLen10, lLen13, 0);
  3178. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DRAW_TOMBO_POLYLINE, P0.x + lLen3, P0.y + lLen13,
  3179. 0, -lLen13, lLen10, 0);
  3180. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, EXIT_VECTOR); // exit VectorMode
  3181. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3182. } // *** DrawTOMBO
  3183. //---------------------------*[LOCAL] AssignIBMfont*---------------------------
  3184. // Action:
  3185. // (a) IBMFONT_ENABLE_ALL: assign IBM extended characters to block#1 where
  3186. // JIS1 characters used to be assigned.
  3187. // (b) IBMFONT_RESUME: resume (re-assign IBM extended characters to block#4.
  3188. // block#4 is insufficient for all 388 IBM characters.)
  3189. //-----------------------------------------------------------------------------
  3190. static VOID AssignIBMfont(
  3191. PDEVOBJ pdevobj,
  3192. SHORT rcID,
  3193. SHORT action)
  3194. {
  3195. BYTE Cmd[56]; // build command here
  3196. INT ocmd = 0;
  3197. WORD num;
  3198. WORD fHeightParamOnly; // @Jan/29/99
  3199. DWORD dwWidth, dwHeight;
  3200. POEMPDEV pOEM = MINIDEV_DATA(pdevobj); // @Oct/06/98
  3201. switch (rcID)
  3202. {
  3203. case MINCHO_1: case MINCHO_1+1: // horizontal font: vertical font:
  3204. case MINCHO_B1: case MINCHO_B1+1:
  3205. case MINCHO_E1: case MINCHO_E1+1:
  3206. case GOTHIC_B1: case GOTHIC_B1+1:
  3207. case GOTHIC_M1: case GOTHIC_M1+1:
  3208. case GOTHIC_E1: case GOTHIC_E1+1:
  3209. case MARUGOTHIC_B1: case MARUGOTHIC_B1+1:
  3210. case MARUGOTHIC_M1: case MARUGOTHIC_M1+1:
  3211. case MARUGOTHIC_L1: case MARUGOTHIC_L1+1:
  3212. case GYOSHO_1: case GYOSHO_1+1:
  3213. case KAISHO_1: case KAISHO_1+1:
  3214. case KYOKASHO_1: case KYOKASHO_1+1:
  3215. num = (rcID - MINCHO_1) / 2;
  3216. goto _SET_W_H;
  3217. case MINCHO_3: case MINCHO_3+1: // for NX-100
  3218. num = 0;
  3219. goto _SET_W_H;
  3220. case GOTHIC_B3: case GOTHIC_B3+1:
  3221. num = 3;
  3222. _SET_W_H:
  3223. dwWidth = pOEM->dwFontW_CPT;
  3224. dwHeight = pOEM->dwFontH_CPT;
  3225. break;
  3226. case MINCHO10_RAS: case MINCHO10_RAS+1:
  3227. num = 0; // same to MINCHO_1
  3228. dwWidth = dwHeight = 960; // unit:cpt(centi point)
  3229. break;
  3230. default:
  3231. return; // exit AssignIBMfont()
  3232. }
  3233. // @Jan/29/99 ->
  3234. // If width equals to height, we emit height parameter only.
  3235. // (This is applied to only NX-100 here.)
  3236. if (TEST_AFTER_SP9II(pOEM->fModel) && dwWidth == dwHeight)
  3237. fHeightParamOnly = TRUE;
  3238. else
  3239. fHeightParamOnly = FALSE;
  3240. // @Jan/29/99 <-
  3241. if (IBMFONT_RESUME == action)
  3242. {
  3243. // Resume JIS1 characters block where they used to be. (JIS1 -> block#1)
  3244. // @Jan/29/99 ->
  3245. if (fHeightParamOnly)
  3246. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_JIS_FONT_SCALE_H_ONLY, dwHeight);
  3247. else
  3248. // @Jan/29/99 <-
  3249. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_JIS_FONT_SCALE, dwWidth, dwHeight);
  3250. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_JIS_FONT_NAME[num]);
  3251. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3252. }
  3253. // Assign IBM extended characters to block.
  3254. // @Jan/29/99 ->
  3255. if (fHeightParamOnly)
  3256. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_IBM_FONT_SCALE_H_ONLY, action, dwHeight);
  3257. else
  3258. // @Jan/29/99 <-
  3259. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), SET_IBM_FONT_SCALE, action, dwWidth, dwHeight);
  3260. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, SET_IBM_FONT_NAME[num]);
  3261. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3262. return;
  3263. } //*** AssignIBMfont
  3264. //---------------------------*[LOCAL] SendFaxNum*------------------------------
  3265. // Action: send fax number
  3266. // (Use fax data file @Sep/30/98, Use private devmode @Oct/15/98)
  3267. //-----------------------------------------------------------------------------
  3268. static VOID SendFaxNum( // @Sep/17/98
  3269. PDEVOBJ pdevobj)
  3270. {
  3271. BYTE Cmd[256], PreNumBuf[4+16], NumBuf[32+4];
  3272. SHORT PreNumLen, cnt, SrcLen, NumLen;
  3273. INT ocmd;
  3274. LPSTR lpSrc, lpDst;
  3275. POEMUD_EXTRADATA pOEMExtra = MINIPRIVATE_DM(pdevobj);
  3276. FILEDATA FileData; // <-pFileData (formerly use MemAllocZ) @Mar/17/2000
  3277. FileData.fUiOption = 0;
  3278. // @Mar/01/2002 ->
  3279. // RWFileData(&FileData, pOEMExtra->SharedFileName, GENERIC_READ);
  3280. RWFileData(&FileData, pOEMExtra->SharedFileName, sizeof(pOEMExtra->SharedFileName), GENERIC_READ);
  3281. // @Mar/01/2002 <-
  3282. // If previous fax is finished and hold-options flag isn't valid,
  3283. // do nothing and return.
  3284. // This prevents unexpected fax until user pushes Apply button on the
  3285. // fax property sheet.
  3286. if (BITTEST32(FileData.fUiOption, PRINT_DONE) &&
  3287. !BITTEST32(pOEMExtra->fUiOption, HOLD_OPTIONS))
  3288. {
  3289. VERBOSE(("** SendFaxNum: Exit without doing anything. **\n"));
  3290. return;
  3291. }
  3292. // If not fax option ready, exit.
  3293. if (!BITTEST32(pOEMExtra->fUiOption, FAX_SEND) || pOEMExtra->FaxNumBuf[0] == 0)
  3294. {
  3295. return;
  3296. }
  3297. // Set data_type(1:image, 2:RPDL command), compression (1:MH, 3:MMR),
  3298. // simultaneous print avalilable, etc
  3299. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGINFAX_HEAD,
  3300. BITTEST32(pOEMExtra->fUiOption, FAX_RPDLCMD)? 2 : 1,
  3301. BITTEST32(pOEMExtra->fUiOption, FAX_MH)? 1 : 3,
  3302. BITTEST32(pOEMExtra->fUiOption, FAX_SIMULPRINT)? 2 : 1);
  3303. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3304. // Copy fax channel & extra number to pre_number buffer
  3305. PreNumLen = (SHORT)safe_sprintfA(PreNumBuf, sizeof(PreNumBuf), BEGINFAX_CH, pOEMExtra->FaxCh + 1);
  3306. if (pOEMExtra->FaxExtNumBuf[0] != 0)
  3307. PreNumLen += (SHORT)safe_sprintfA(&PreNumBuf[PreNumLen], sizeof(PreNumBuf) - PreNumLen, BEGINFAX_EXTNUM, pOEMExtra->FaxExtNumBuf);
  3308. // Search each fax number (directly set number & addressbook set number)
  3309. lpSrc = pOEMExtra->FaxNumBuf; // fax number which is set directly
  3310. SrcLen = FAXBUFSIZE256-1; // FaxNumBuf limit = 255
  3311. lpDst = NumBuf;
  3312. NumLen = 0;
  3313. {
  3314. while (SrcLen-- > 0 && *lpSrc != 0)
  3315. {
  3316. // If character is DBCS, skip.
  3317. if (IsDBCSLeadByteRPDL(*lpSrc))
  3318. {
  3319. lpSrc++;
  3320. }
  3321. // If character is valid, input it to NumBuf.
  3322. else if (*lpSrc >= '0' && *lpSrc <= '9' || *lpSrc == '-' || *lpSrc == '#')
  3323. {
  3324. *lpDst++ = *lpSrc;
  3325. if (NumLen++ > 32) // limit of MF-P
  3326. {
  3327. return; // error exit
  3328. }
  3329. }
  3330. // If character is ',' , output fax number.
  3331. else if (*lpSrc == ',')
  3332. {
  3333. *lpDst = 0;
  3334. // Send fax number
  3335. if (NumLen > 0)
  3336. {
  3337. WRITESPOOLBUF(pdevobj, PreNumBuf, PreNumLen);
  3338. WRITESPOOLBUF(pdevobj, NumBuf, NumLen);
  3339. }
  3340. lpDst = NumBuf;
  3341. NumLen = 0;
  3342. }
  3343. lpSrc++;
  3344. } // 'while (SrcLen-- > 0 && *lpSrc != 0)' end
  3345. // Flush last fax number
  3346. if (NumLen > 0)
  3347. {
  3348. WRITESPOOLBUF(pdevobj, PreNumBuf, PreNumLen);
  3349. WRITESPOOLBUF(pdevobj, NumBuf, NumLen);
  3350. }
  3351. } // 'while (cnt-- > 0)' end
  3352. // Get tickcount for ID
  3353. cnt = (SHORT)(GetTickCount() / 1000L);
  3354. cnt = ABS(cnt);
  3355. // Input ID & resolution & send time, etc
  3356. if (BITTEST32(pOEMExtra->fUiOption, FAX_SETTIME) && pOEMExtra->FaxSendTime[0] != 0)
  3357. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGINFAX_TAIL, cnt, pOEMExtra->FaxReso + 1, 2, pOEMExtra->FaxSendTime);
  3358. else
  3359. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), BEGINFAX_TAIL, cnt, pOEMExtra->FaxReso + 1, 1, "");
  3360. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3361. // Set PRINT_DONE flag in the file @Oct/20/98
  3362. FileData.fUiOption = pOEMExtra->fUiOption;
  3363. BITSET32(FileData.fUiOption, PRINT_DONE);
  3364. // @Mar/01/2002 ->
  3365. // RWFileData(&FileData, pOEMExtra->SharedFileName, GENERIC_WRITE);
  3366. RWFileData(&FileData, pOEMExtra->SharedFileName, sizeof(pOEMExtra->SharedFileName), GENERIC_WRITE);
  3367. // @Mar/01/2002 <-
  3368. return;
  3369. } //*** SendFaxNum
  3370. #ifdef JISGTT
  3371. //-----------------------------*[LOCAL] jis2sjis*------------------------------
  3372. // Action: convert JIS code to SJIS code
  3373. //-----------------------------------------------------------------------------
  3374. static VOID jis2sjis( // @Oct/27/98
  3375. BYTE jis[],
  3376. BYTE sjis[])
  3377. {
  3378. BYTE h, l;
  3379. h = jis[0];
  3380. l = jis[1];
  3381. if (h == 0)
  3382. {
  3383. sjis[0] = l;
  3384. sjis[1] = 0;
  3385. return;
  3386. }
  3387. l += 0x1F;
  3388. if (h & 0x01)
  3389. h >>= 1;
  3390. else
  3391. {
  3392. h >>= 1;
  3393. l += 0x5E;
  3394. h--;
  3395. }
  3396. if (l >= 0x7F)
  3397. l++;
  3398. if (h < 0x2F)
  3399. h += 0x71;
  3400. else
  3401. h += 0xB1;
  3402. sjis[0] = h;
  3403. sjis[1] = l;
  3404. } //*** jis2sjis
  3405. #endif // JISGTT
  3406. BOOL APIENTRY bOEMOutputCharStr( // BOOL <- VOID @Mar/27/2002
  3407. PDEVOBJ pdevobj,
  3408. PUNIFONTOBJ pUFObj,
  3409. DWORD dwType,
  3410. DWORD dwCount,
  3411. PVOID pGlyph)
  3412. {
  3413. GETINFO_GLYPHSTRING GStr;
  3414. PBYTE aubBuff; // <-BYTE aubBuff[256] MSKK Aug/13/98
  3415. PTRANSDATA pTrans;
  3416. #ifdef DBG_OUTPUTCHARSTR
  3417. PWORD pwUnicode;
  3418. #endif // DBG_OUTPUTCHARSTR
  3419. DWORD dwI;
  3420. BYTE Cmd[128];
  3421. INT ocmd = 0; // INT<-SHORT @Feb/22/99
  3422. SHORT rcID;
  3423. WORD fVertFont = FALSE, fEuroFont = FALSE, fIBMFontSupport = FALSE;
  3424. WORD fEuroFontFullset = FALSE;
  3425. #ifdef JISGTT
  3426. WORD fJisCode = FALSE; // @Oct/27/98
  3427. #endif // JISGTT
  3428. LPSTR lpChar;
  3429. BYTE CharTmp1, CharTmp2;
  3430. POEMUD_EXTRADATA pOEMExtra = MINIPRIVATE_DM(pdevobj); // @Oct/06/98
  3431. POEMPDEV pOEM = MINIDEV_DATA(pdevobj); // @Oct/06/98
  3432. #ifdef DOWNLOADFONT
  3433. SHORT mov;
  3434. WORD wSerialNum; // short->DWORD @Jun/30/98, DWORD->WORD @Aug/21/98
  3435. LONG lFontID, lGlyphID; // @Aug/21/98
  3436. LPFONTPOS lpDLFont;
  3437. #endif // DOWNLOADFONT
  3438. DWORD dwNeeded;
  3439. WORD fMemAllocated; // @Sep/09/98
  3440. // VERBOSE(("** bOEMOutputCharStr() entry. **\n"));
  3441. if (BITTEST32(pOEM->fGeneral2, TEXTRECT_CONTINUE)) // add @Dec/11/97
  3442. {
  3443. BITCLR32(pOEM->fGeneral2, TEXTRECT_CONTINUE);
  3444. // If white-rect has been done before, set raster drawmode to OR. @Jan/20/99
  3445. if (!pOEM->TextRectGray)
  3446. {
  3447. if (BITTEST32(pOEM->fGeneral1, FONT_WHITETEXT_ON))
  3448. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_ON, sizeof(ESC_WHITETEXT_ON)-1);
  3449. else
  3450. WRITESPOOLBUF(pdevobj, ESC_WHITETEXT_OFF, sizeof(ESC_WHITETEXT_OFF)-1);
  3451. }
  3452. }
  3453. //** flush Move_X,Y command saved at OEMCommandCallback
  3454. if (BITTEST32(pOEM->fGeneral1, YM_ABS_GONNAOUT))
  3455. {
  3456. BITCLR32(pOEM->fGeneral1, YM_ABS_GONNAOUT);
  3457. // Output Move_Y command here.
  3458. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ESC_YM_ABS, pOEM->TextCurPos.y);
  3459. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3460. }
  3461. if (BITTEST32(pOEM->fGeneral1, XM_ABS_GONNAOUT))
  3462. {
  3463. BITCLR32(pOEM->fGeneral1, XM_ABS_GONNAOUT);
  3464. // Output Move_X command here.
  3465. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ESC_XM_ABS, pOEM->TextCurPos.x);
  3466. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3467. }
  3468. // VERBOSE(("dwType = %d\n", dwType)); // MKSKK 1/24/98
  3469. switch (dwType)
  3470. {
  3471. case TYPE_GLYPHHANDLE: // device font
  3472. // #333653: Change I/F for GETINFO_GLYPHSTRING // MSKK 5/17/99 {
  3473. GStr.dwSize = sizeof (GETINFO_GLYPHSTRING);
  3474. GStr.dwCount = dwCount;
  3475. GStr.dwTypeIn = TYPE_GLYPHHANDLE;
  3476. GStr.pGlyphIn = pGlyph;
  3477. GStr.dwTypeOut = TYPE_TRANSDATA;
  3478. GStr.pGlyphOut = NULL;
  3479. GStr.dwGlyphOutSize = 0;
  3480. // Get the size of buffer for pGlyphOut.
  3481. if (pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  3482. GStr.dwSize, &dwNeeded) || !GStr.dwGlyphOutSize)
  3483. {
  3484. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\n"));
  3485. return FALSE; // BOOL <- VOID @Mar/27/2002
  3486. }
  3487. if (pOEM->pRPDLHeap2K && GStr.dwGlyphOutSize <= HEAPSIZE2K)
  3488. {
  3489. aubBuff = pOEM->pRPDLHeap2K;
  3490. fMemAllocated = FALSE;
  3491. }
  3492. else
  3493. {
  3494. if(!(aubBuff = (PBYTE)MemAllocZ(GStr.dwGlyphOutSize)))
  3495. {
  3496. ERR(("aubBuff memory allocation failed.\n"));
  3497. return FALSE; // BOOL <- VOID @Mar/27/2002
  3498. }
  3499. fMemAllocated = TRUE;
  3500. }
  3501. // } MSKK 5/17/99
  3502. #ifdef DBG_OUTPUTCHARSTR
  3503. GStr.dwSize = sizeof(GETINFO_GLYPHSTRING);
  3504. GStr.dwCount = dwCount;
  3505. GStr.dwTypeIn = TYPE_GLYPHHANDLE;
  3506. GStr.pGlyphIn = pGlyph;
  3507. GStr.dwTypeOut = TYPE_UNICODE;
  3508. GStr.pGlyphOut = aubBuff;
  3509. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  3510. GStr.dwSize, &dwNeeded))
  3511. {
  3512. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\n"));
  3513. // fix memory leak by yasuho Nov/20/2002 ->
  3514. if(fMemAllocated)
  3515. MemFree(aubBuff);
  3516. // Nov/20/2002 <-
  3517. return FALSE; // BOOL <- VOID @Mar/27/2002
  3518. }
  3519. pwUnicode = (PWORD)aubBuff;
  3520. for (dwI = 0; dwI < dwCount; dwI ++)
  3521. {
  3522. VERBOSE((("Unicode[%d] = %x\n"), dwI, pwUnicode[dwI]));
  3523. }
  3524. #endif // DBG_OUTPUTCHARSTR
  3525. #ifdef DOWNLOADFONT
  3526. // If moving value of download font remain
  3527. if (pOEM->nCharPosMoveX)
  3528. {
  3529. // Flush moving value of pre-printed download font.
  3530. if (pOEM->nCharPosMoveX > 0)
  3531. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ESC_XM_REL, pOEM->nCharPosMoveX);
  3532. else
  3533. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ESC_XM_RELLEFT, -pOEM->nCharPosMoveX);
  3534. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3535. // Clear moving value
  3536. pOEM->nCharPosMoveX = 0;
  3537. } // 'if (nCharPosMoveX)' end
  3538. #endif // DOWNLOADFONT
  3539. //
  3540. // Call the Unidriver service routine to convert
  3541. // glyph-handles into the character code data.
  3542. //
  3543. GStr.dwSize = sizeof (GETINFO_GLYPHSTRING);
  3544. GStr.dwCount = dwCount;
  3545. GStr.dwTypeIn = TYPE_GLYPHHANDLE;
  3546. GStr.pGlyphIn = pGlyph;
  3547. GStr.dwTypeOut = TYPE_TRANSDATA;
  3548. GStr.pGlyphOut = aubBuff;
  3549. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  3550. GStr.dwSize, &dwNeeded))
  3551. {
  3552. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\n"));
  3553. // fix memory leak by yasuho Nov/20/2002 ->
  3554. if(fMemAllocated)
  3555. MemFree(aubBuff);
  3556. // Nov/20/2002 <-
  3557. return FALSE; // BOOL <- VOID @Mar/27/2002
  3558. }
  3559. pTrans = (PTRANSDATA)aubBuff;
  3560. //** Draw barcode **
  3561. // fix bug with Excel @Nov/24/98
  3562. if (BITTEST32(pOEM->fGeneral2, BARCODE_MODE_IN))
  3563. {
  3564. WORD unit1, unit2, offset_y;
  3565. WORD fCheckdigitCapable, fSetBarWidth, fJANDecrease1Char;
  3566. WORD fCode128; // @Feb/08/2000
  3567. LPSTR lpDst, lpCmd;
  3568. PTRANSDATA pTransTmp; // @Nov/24/98
  3569. WORD wLen, wTmp;
  3570. ocmd = 0;
  3571. // Check start character
  3572. wTmp = wLen = (WORD)dwCount;
  3573. pTransTmp = pTrans;
  3574. while (wTmp-- > 0)
  3575. {
  3576. if (pTransTmp->uCode.ubCode == '[')
  3577. {
  3578. // barcode character is valid from now
  3579. BITSET32(pOEM->fGeneral2, BARCODE_DATA_VALID);
  3580. BITCLR32(pOEM->fGeneral2, BARCODE_CHECKDIGIT_ON);
  3581. BITCLR32(pOEM->fGeneral2, BARCODE_ROT90);
  3582. BITCLR32(pOEM->fGeneral2, BARCODE_ROT270);
  3583. pOEM->RPDLHeapCount = 0;
  3584. wLen = wTmp;
  3585. pTrans = pTransTmp+1;
  3586. #ifdef DEBUG
  3587. for (wTmp = 0; wTmp < BARCODE_MAX; wTmp++)
  3588. pOEM->RPDLHeap64[wTmp] = 0;
  3589. #endif // DEBUG
  3590. break;
  3591. }
  3592. pTransTmp++;
  3593. }
  3594. // Check barcode character length
  3595. VERBOSE(("** BARCODE(2.2) len=%d **\n",wLen));
  3596. fJANDecrease1Char = FALSE;
  3597. if (wLen > (wTmp = pOEM->nBarMaxLen - pOEM->RPDLHeapCount))
  3598. {
  3599. wLen = wTmp;
  3600. BITSET32(pOEM->fGeneral2, BARCODE_FINISH);
  3601. VERBOSE(("** BARCODE(3) limit len=%d(last=%c) **\n", wLen,
  3602. (pTrans+wLen-1)->uCode.ubCode));
  3603. // Decrease RPDLHeapCount later at JAN
  3604. if (pOEM->nBarType == BAR_TYPE_JAN_STD || pOEM->nBarType == BAR_TYPE_JAN_SHORT)
  3605. fJANDecrease1Char = TRUE;
  3606. }
  3607. // Copy barcode characters to RPDLHeap64 (temporary buffer)
  3608. lpDst = &pOEM->RPDLHeap64[pOEM->RPDLHeapCount];
  3609. fCheckdigitCapable = TEST_AFTER_SP8(pOEM->fModel)? TRUE : FALSE;
  3610. while (wLen-- > 0)
  3611. {
  3612. // Check checkdigit-on-flag-character(?) in pTrans->uCode.ubCode
  3613. if (pTrans->uCode.ubCode == '?' && fCheckdigitCapable)
  3614. {
  3615. BITSET32(pOEM->fGeneral2, BARCODE_CHECKDIGIT_ON);
  3616. pTrans++;
  3617. continue;
  3618. }
  3619. // Check end character
  3620. if (pTrans->uCode.ubCode == ']')
  3621. {
  3622. VERBOSE(("** BARCODE(4) terminator **\n"));
  3623. BITSET32(pOEM->fGeneral2, BARCODE_FINISH);
  3624. break;
  3625. }
  3626. *lpDst++ = pTrans->uCode.ubCode;
  3627. pTrans++;
  3628. pOEM->RPDLHeapCount++;
  3629. }
  3630. VERBOSE(("** BARCODE(5) copy-end BarNum=%d **\n", pOEM->RPDLHeapCount));
  3631. VERBOSE((" [%s]\n",pOEM->RPDLHeap64));
  3632. VERBOSE((" CHK = %d\n", BITTEST32(pOEM->fGeneral2, BARCODE_CHECKDIGIT_ON)));
  3633. // Finish
  3634. if (BITTEST32(pOEM->fGeneral2, BARCODE_DATA_VALID) &&
  3635. BITTEST32(pOEM->fGeneral2, BARCODE_FINISH))
  3636. {
  3637. VERBOSE(("** BARCODE(6) finish [%s] **\n", pOEM->RPDLHeap64));
  3638. // 1 barcode has been completed here
  3639. BITCLR32(pOEM->fGeneral2, BARCODE_DATA_VALID);
  3640. BITCLR32(pOEM->fGeneral2, BARCODE_FINISH);
  3641. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ENTER_VECTOR); // enter VectorMode
  3642. // Add checkdigit
  3643. if (BITTEST32(pOEM->fGeneral2, BARCODE_CHECKDIGIT_ON))
  3644. {
  3645. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_CHECKDIGIT);
  3646. }
  3647. // Check barcode-height
  3648. if (pOEMExtra->UiBarHeight == 0)
  3649. {
  3650. pOEMExtra->UiBarHeight = BAR_H_DEFAULT; // default (=10mm)
  3651. }
  3652. else if (pOEMExtra->UiBarHeight != BAR_H_DEFAULT)
  3653. {
  3654. // Set barcode-height (convert unit from mm to dot) (SISHAGONYU)
  3655. unit1 = (WORD)(((DWORD)pOEMExtra->UiBarHeight * (DWORD)(MASTERUNIT*10)
  3656. / (DWORD)pOEM->nResoRatio + (DWORD)(254/2)) / (DWORD)254);
  3657. VERBOSE(("** BARCODE(7) set height %d **\n", unit1));
  3658. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_H_SET, unit1);
  3659. }
  3660. if (BITTEST32(pOEMExtra->fUiOption, DISABLE_BAR_SUBFONT))
  3661. {
  3662. // Disable printing font under barcode
  3663. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_NOFONT[pOEM->nBarType]);
  3664. // Set guard-bar-height of JAN
  3665. if ((pOEM->nBarType == BAR_TYPE_JAN_STD || pOEM->nBarType == BAR_TYPE_JAN_SHORT) &&
  3666. !TEST_AFTER_SP8(pOEM->fModel))
  3667. {
  3668. offset_y = 2;
  3669. }
  3670. else // no guard-bar
  3671. {
  3672. offset_y = 0;
  3673. }
  3674. }
  3675. else
  3676. {
  3677. offset_y = 3; // font-height = 3mm
  3678. }
  3679. // @Dec/8/99 FK#50 ->
  3680. if (pOEM->nBarType == BAR_TYPE_CUSTOMER)
  3681. {
  3682. // calculate vertical offset (barcode-height)
  3683. offset_y = (WORD)(((DWORD)(BAR_H_CUSTOMER) // 36 x 0.1mm
  3684. * (DWORD)MASTERUNIT
  3685. / (DWORD)pOEM->nResoRatio + (DWORD)(254/2)) / (DWORD)254);
  3686. }
  3687. else
  3688. {
  3689. // @Dec/8/99 FK#50 <-
  3690. // Calculate vertical offset (barcode-height + font-height)
  3691. offset_y = (WORD)(((DWORD)(pOEMExtra->UiBarHeight + offset_y)
  3692. * (DWORD)(MASTERUNIT*10)
  3693. / (DWORD)pOEM->nResoRatio + (DWORD)(254/2)) / (DWORD)254);
  3694. // @Dec/8/99 FK#50 ->
  3695. }
  3696. // @Dec/8/99 FK#50 <-
  3697. // Check vertical-flag-character('@') in RPDLHeap64
  3698. VERBOSE(("** BARCODE(7-1) vertical check len=%d(%c..%c) **\n",
  3699. pOEM->RPDLHeapCount, pOEM->RPDLHeap64[0],
  3700. pOEM->RPDLHeap64[pOEM->RPDLHeapCount-1] ));
  3701. // If characters are "@...", vertical(ROT270) barcode
  3702. if (pOEM->RPDLHeap64[0] == '@')
  3703. {
  3704. VERBOSE(("** BARCODE(7-2) vertical(ROT270) **\n"));
  3705. BITSET32(pOEM->fGeneral2, BARCODE_ROT270);
  3706. pOEM->RPDLHeapCount--;
  3707. }
  3708. // If characters are "...@", vertical(ROT90) barcode
  3709. else if (pOEM->RPDLHeap64[pOEM->RPDLHeapCount-1] == '@')
  3710. {
  3711. VERBOSE(("** BARCODE(7-2) vertical(ROT90) **\n"));
  3712. BITSET32(pOEM->fGeneral2, BARCODE_ROT90);
  3713. pOEM->RPDLHeapCount--;
  3714. }
  3715. // 1 charcter margin for '@' at JAN, we decrease here.
  3716. else if (fJANDecrease1Char)
  3717. {
  3718. pOEM->RPDLHeapCount--;
  3719. }
  3720. // Set barcode draw position
  3721. if (BITTEST32(pOEM->fGeneral2, BARCODE_ROT270) &&
  3722. !TEST_NIN1_MODE(pOEM->fGeneral1))
  3723. {
  3724. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_ROT270);
  3725. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, MOVE_ABSOLUTE,
  3726. pOEM->TextCurPos.y,
  3727. pOEM->PageMax.x - pOEM->TextCurPos.x - offset_y);
  3728. }
  3729. else if (BITTEST32(pOEM->fGeneral2, BARCODE_ROT90) &&
  3730. !TEST_4IN1_MODE(pOEM->fGeneral1))
  3731. {
  3732. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_ROT90);
  3733. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, MOVE_ABSOLUTE,
  3734. pOEM->PageMax.y - pOEM->TextCurPos.y,
  3735. pOEM->TextCurPos.x - offset_y);
  3736. }
  3737. else
  3738. {
  3739. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, MOVE_ABSOLUTE,
  3740. pOEM->TextCurPos.x,
  3741. pOEM->TextCurPos.y - offset_y);
  3742. }
  3743. // Check whether setting barcode-width or not.
  3744. // (Scaling is valid when 5pt<=fontsize<9pt or fontsize>11pt)
  3745. if ((pOEM->dwBarRatioW >= BAR_W_MIN_5PT &&
  3746. pOEM->dwBarRatioW < NEAR10PT_MIN) ||
  3747. pOEM->dwBarRatioW > NEAR10PT_MAX)
  3748. {
  3749. fSetBarWidth = TRUE;
  3750. }
  3751. else
  3752. {
  3753. fSetBarWidth = FALSE;
  3754. }
  3755. fCode128 = 0; // @Feb/08/2000
  3756. switch (pOEM->nBarType)
  3757. {
  3758. case BAR_TYPE_JAN_STD: // 0:JAN(STANDARD)
  3759. case BAR_TYPE_JAN_SHORT: // 1:JAN(SHORT)
  3760. case BAR_TYPE_UPC_A: // 9:UPC(A) @Dec/17/99 FK#50
  3761. case BAR_TYPE_UPC_E: // 10:UPC(E) @Dec/17/99 FK#50
  3762. // Set barcode-width
  3763. if (fSetBarWidth)
  3764. {
  3765. // Convert unit from 1/1000mm_unit*1/1000 to dot (SISHAGONYU)
  3766. unit1 = (WORD)(((DWORD)BAR_UNIT_JAN * pOEM->dwBarRatioW
  3767. / (DWORD)pOEM->nResoRatio / (DWORD)100
  3768. * (DWORD)MASTERUNIT / (DWORD)254 + (DWORD)(1000/2))
  3769. / (DWORD)1000);
  3770. VERBOSE(("** BARCODE(8) set unit %d **\n", unit1));
  3771. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_W_SET_JAN, unit1);
  3772. }
  3773. // Output barcode command
  3774. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_TYPE[pOEM->nBarType]);
  3775. break;
  3776. case BAR_TYPE_2OF5IND: // 2:2of5(INDUSTRIAL)
  3777. case BAR_TYPE_2OF5MTX: // 3:2of5(MATRIX)
  3778. case BAR_TYPE_2OF5ITF: // 4:2of5(ITF)
  3779. lpCmd = BAR_W_SET_2OF5;
  3780. goto _BARCODE_CMD_OUT1;
  3781. case BAR_TYPE_CODE39: // 5:CODE39
  3782. lpCmd = BAR_W_SET_C39;
  3783. // @Dec/17/99 FK#50 ->
  3784. goto _BARCODE_CMD_OUT1;
  3785. case BAR_TYPE_CODE128: // 8:CODE128
  3786. lpCmd = BAR_W_SET_C39;
  3787. fCode128 = 1;
  3788. // @Dec/17/99 FK#50 <-
  3789. _BARCODE_CMD_OUT1:
  3790. // Set standard size of module unit (1/1000mm_unit)
  3791. unit1 = BAR_UNIT1_2OF5;
  3792. unit2 = BAR_UNIT2_2OF5;
  3793. goto _BARCODE_CMD_OUT2;
  3794. case BAR_TYPE_NW7: // 6:NW-7
  3795. lpCmd = BAR_W_SET_NW7;
  3796. // Set standard size of module unit
  3797. unit1 = BAR_UNIT1_NW7;
  3798. unit2 = BAR_UNIT2_NW7;
  3799. _BARCODE_CMD_OUT2:
  3800. // Set barcode-width
  3801. if (fSetBarWidth)
  3802. {
  3803. // Convert unit from 1/1000mm_unit*1/1000 to dot (SISHAGONYU)
  3804. unit1 = (WORD)(((DWORD)unit1 * pOEM->dwBarRatioW
  3805. / (DWORD)pOEM->nResoRatio / (DWORD)100
  3806. * (DWORD)MASTERUNIT / (DWORD)254 + (DWORD)(1000/2))
  3807. / (DWORD)1000);
  3808. unit2 = (WORD)(((DWORD)unit2 * pOEM->dwBarRatioW
  3809. / (DWORD)pOEM->nResoRatio / (DWORD)100
  3810. * (DWORD)MASTERUNIT / (DWORD)254 + (DWORD)(1000/2))
  3811. / (DWORD)1000);
  3812. VERBOSE(("** BARCODE(8) set unit %d,%d **\n", unit1,unit2));
  3813. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, lpCmd);
  3814. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_W_PARAMS, unit1, unit1,
  3815. unit2, unit2, unit1);
  3816. }
  3817. // Output barcode command(operand) & character#
  3818. // @Dec/17/99 FK#50 ->
  3819. // ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_TYPE[pOEM->nBarType],
  3820. // pOEM->RPDLHeapCount);
  3821. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_TYPE[pOEM->nBarType],
  3822. pOEM->RPDLHeapCount + fCode128);
  3823. // @Dec/17/99 FK#50 <-
  3824. break;
  3825. // @Dec/07/99 FK#50 ->
  3826. case BAR_TYPE_CUSTOMER: // 7:CUSTOMER
  3827. lpCmd = BAR_W_SET_CUST;
  3828. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, lpCmd);
  3829. unit1 = (WORD)(((pOEM->dwBarRatioW / 10) + 4) / 5) * 5 ;
  3830. if ((unit1 >= 80) && (unit1 <= 115))
  3831. {
  3832. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, "%d", unit1);
  3833. }
  3834. // output barcode command(operand) & character#
  3835. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, BAR_TYPE[pOEM->nBarType],
  3836. pOEM->RPDLHeapCount);
  3837. break;
  3838. // @Dec/07/99 FK#50 <-
  3839. default:
  3840. break;
  3841. }
  3842. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3843. // @Dec/17/99 FK#50 ->
  3844. // Code128 data format ",xx,xx,..."
  3845. if (pOEM->nBarType == BAR_TYPE_CODE128)
  3846. {
  3847. INT len, cnt;
  3848. BYTE Code128Buf[8];
  3849. LPSTR lpTemp;
  3850. lpTemp = pOEM->RPDLHeap64;
  3851. if (BITTEST32(pOEM->fGeneral2, BARCODE_ROT270))
  3852. lpTemp++;
  3853. // send start char
  3854. len = safe_sprintfA(Code128Buf, sizeof(Code128Buf),",%d",(BYTE)BAR_CODE128_START);
  3855. WRITESPOOLBUF(pdevobj, Code128Buf, len);
  3856. for (cnt = 0; cnt < (int)pOEM->RPDLHeapCount; cnt++)
  3857. {
  3858. len = safe_sprintfA(Code128Buf, sizeof(Code128Buf),",%d",(BYTE)(lpTemp[cnt]-32));
  3859. WRITESPOOLBUF(pdevobj, Code128Buf, len);
  3860. }
  3861. }
  3862. else
  3863. {
  3864. // @Dec/17/99 FK#50 <-
  3865. // Output barcode characters
  3866. if (BITTEST32(pOEM->fGeneral2, BARCODE_ROT270)) // @Oct/22/97
  3867. WRITESPOOLBUF(pdevobj, pOEM->RPDLHeap64+1, pOEM->RPDLHeapCount);
  3868. else
  3869. WRITESPOOLBUF(pdevobj, pOEM->RPDLHeap64, pOEM->RPDLHeapCount);
  3870. // @Dec/17/99 FK#50 ->
  3871. }
  3872. // @Dec/17/99 FK#50 <-
  3873. pOEM->RPDLHeapCount = 0;
  3874. // We add ';' for safe finish in case of insufficient character at JAN.
  3875. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), TERMINATOR);
  3876. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, EXIT_VECTOR); // exit VectorMode
  3877. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  3878. } // 'if BARCODE_DATA_VALID && BARCODE_FINISH' end
  3879. if(fMemAllocated)
  3880. MemFree(aubBuff);
  3881. return TRUE; // BOOL <- VOID @Mar/27/2002
  3882. }
  3883. //** Draw barcode END **
  3884. //** Draw device font **
  3885. BITCLR32(pOEM->fGeneral1, FONT_VERTICAL_ON);
  3886. rcID = (SHORT)pUFObj->ulFontID;
  3887. if (rcID >= JPN_FNT_FIRST && rcID <= JPN_FNT_LAST)
  3888. {
  3889. if (TEST_VERTICALFONT(rcID))
  3890. {
  3891. fVertFont = TRUE; // vertical font
  3892. BITSET32(pOEM->fGeneral1, FONT_VERTICAL_ON);
  3893. }
  3894. // IBM ext char(SJIS) supported from SP9II
  3895. if (rcID >= AFTER_SP9II_FNT_FIRST)
  3896. fIBMFontSupport = TRUE;
  3897. // @Oct/27/98 ->
  3898. #ifdef JISGTT
  3899. // Current UFM of PMincho & PGothic declare JIS code set.
  3900. if (rcID >= JPN_MSPFNT_FIRST)
  3901. fJisCode = TRUE;
  3902. #endif // JISGTT
  3903. // @Oct/27/98 <-
  3904. }
  3905. else if (rcID >= EURO_FNT_FIRST && rcID <= EURO_FNT_LAST)
  3906. {
  3907. fEuroFont = TRUE; // European font(Courier,BoldFacePS,etc).
  3908. // Fullset(0x20-0xFF) fonts(Arial,Century,TimesNewRoman,etc) are supported
  3909. // from NX-110
  3910. if (rcID >= EURO_MSFNT_FIRST)
  3911. fEuroFontFullset = TRUE;
  3912. }
  3913. for (dwI = 0; dwI < dwCount; dwI ++, pTrans ++) // increment pTrans MSKK 98/3/16
  3914. {
  3915. switch (pTrans->ubType & MTYPE_FORMAT_MASK)
  3916. {
  3917. case MTYPE_DIRECT: // SBCS (European font & Japanese font HANKAkU)
  3918. // VERBOSE((("TYPE_TRANSDATA:ubCode:0x%x\n"), pTrans->uCode.ubCode));
  3919. lpChar = &pTrans->uCode.ubCode;
  3920. CharTmp1 = *lpChar;
  3921. if (fEuroFont) //** European font **
  3922. {
  3923. // ** print 1st SBCS font(0x20-0x7F) **
  3924. if (CharTmp1 < 0x80)
  3925. {
  3926. // PRINTER SIDE ISSUE: RPDL
  3927. // take care of device font bug
  3928. if (rcID == SYMBOL && CharTmp1 == 0x60) // "radical extention"
  3929. {
  3930. WRITESPOOLBUF(pdevobj, DOUBLE_SPACE, sizeof(DOUBLE_SPACE)-1);
  3931. WRITESPOOLBUF(pdevobj, &CharTmp1, 1);
  3932. WRITESPOOLBUF(pdevobj, DOUBLE_BS, sizeof(DOUBLE_BS)-1);
  3933. }
  3934. else
  3935. {
  3936. WRITESPOOLBUF(pdevobj, &CharTmp1, 1);
  3937. }
  3938. continue; // goto for-loop end
  3939. }
  3940. // ** print 2nd SBCS font(0x80-0xFF) **
  3941. // If full-set(0x20-0xFF) font
  3942. if (fEuroFontFullset)
  3943. {
  3944. // If same to DBCS 1st byte
  3945. if (IsDBCSLeadByteRPDL(CharTmp1))
  3946. WRITESPOOLBUF(pdevobj, ESC_CTRLCODE, sizeof(ESC_CTRLCODE)-1);
  3947. WRITESPOOLBUF(pdevobj, &CharTmp1, 1);
  3948. continue; // goto for-loop end
  3949. }
  3950. // If not full-set font
  3951. switch (CharTmp1)
  3952. {
  3953. case 0x82:
  3954. CharTmp1 = ','; goto _WRITE1BYTE;
  3955. case 0x88:
  3956. CharTmp1 = '^'; goto _WRITE1BYTE;
  3957. case 0x8B:
  3958. CharTmp1 = '<'; goto _WRITE1BYTE;
  3959. case 0x9B:
  3960. CharTmp1 = '>'; goto _WRITE1BYTE;
  3961. case 0x91: // single quatation
  3962. case 0x92:
  3963. CharTmp1 = 0x27; goto _WRITE1BYTE;
  3964. case 0x93: // double quatation
  3965. case 0x94:
  3966. CharTmp1 = 0x22; goto _WRITE1BYTE;
  3967. case 0x96:
  3968. case 0x97:
  3969. CharTmp1 = '-'; goto _WRITE1BYTE;
  3970. case 0x98:
  3971. CharTmp1 = '~'; goto _WRITE1BYTE;
  3972. case 0xA6:
  3973. CharTmp1 = '|'; goto _WRITE1BYTE;
  3974. case 0xAD:
  3975. CharTmp1 = '-'; goto _WRITE1BYTE;
  3976. case 0xB8:
  3977. CharTmp1 = ','; goto _WRITE1BYTE;
  3978. case 0xD7:
  3979. CharTmp1 = 'x'; goto _WRITE1BYTE;
  3980. case 0x83:
  3981. CharTmp1 = 0xBF; goto _WRITE1BYTE;
  3982. case 0x86:
  3983. CharTmp1 = 0xA8; goto _WRITE1BYTE;
  3984. case 0x99:
  3985. CharTmp1 = 0xA9; goto _WRITE1BYTE;
  3986. case 0xE7:
  3987. CharTmp1 = 0xA2; goto _WRITE1BYTE;
  3988. case 0xE8:
  3989. CharTmp1 = 0xBD; goto _WRITE1BYTE;
  3990. case 0xE9:
  3991. CharTmp1 = 0xBB; goto _WRITE1BYTE;
  3992. case 0xF9:
  3993. CharTmp1 = 0xBC; goto _WRITE1BYTE;
  3994. case 0xFC:
  3995. CharTmp1 = 0xFD; goto _WRITE1BYTE;
  3996. case 0xA0:
  3997. case 0xA3:
  3998. case 0xA4:
  3999. goto _WRITE1BYTE;
  4000. case 0xA2:
  4001. CharTmp1 = 0xDE; goto _WRITE1BYTE;
  4002. case 0xA5: //YEN mark
  4003. CharTmp1 = 0xCC; goto _WRITE1BYTE;
  4004. case 0xA7:
  4005. CharTmp1 = 0xC0; goto _WRITE1BYTE;
  4006. case 0xA8:
  4007. CharTmp1 = 0xBE; goto _WRITE1BYTE;
  4008. case 0xA9:
  4009. CharTmp1 = 0xAB; goto _WRITE1BYTE;
  4010. case 0xAE:
  4011. CharTmp1 = 0xAA; goto _WRITE1BYTE;
  4012. case 0xAF:
  4013. CharTmp1 = 0xB0; goto _WRITE1BYTE;
  4014. case 0xB0:
  4015. case 0xBA:
  4016. CharTmp1 = 0xA6; goto _WRITE1BYTE;
  4017. case 0xB4:
  4018. CharTmp1 = 0xA7; goto _WRITE1BYTE;
  4019. case 0xB5:
  4020. CharTmp1 = 0xA5; goto _WRITE1BYTE;
  4021. case 0xB6:
  4022. CharTmp1 = 0xAF; goto _WRITE1BYTE;
  4023. case 0xBC:
  4024. CharTmp1 = 0xAC; goto _WRITE1BYTE;
  4025. case 0xBD:
  4026. CharTmp1 = 0xAE; goto _WRITE1BYTE;
  4027. case 0xBE:
  4028. CharTmp1 = 0xAD; goto _WRITE1BYTE;
  4029. case 0xC4:
  4030. CharTmp1 = 0xDB; goto _WRITE1BYTE;
  4031. case 0xC5:
  4032. CharTmp1 = 0xD6; goto _WRITE1BYTE;
  4033. case 0xC9:
  4034. CharTmp1 = 0xB8; goto _WRITE1BYTE;
  4035. case 0xD6:
  4036. CharTmp1 = 0xDC; goto _WRITE1BYTE;
  4037. case 0xDC:
  4038. CharTmp1 = 0xDD; goto _WRITE1BYTE;
  4039. case 0xDF:
  4040. CharTmp1 = 0xFE; goto _WRITE1BYTE;
  4041. _WRITE1BYTE:
  4042. WRITESPOOLBUF(pdevobj, &CharTmp1, 1);
  4043. break;
  4044. // Combine 2 fonts, because next fonts do not exist in device font
  4045. case 0x87:
  4046. CharTmp1 = '='; CharTmp2 = '|'; goto _COMBINEDFONT;
  4047. case 0xD0: // 'D' with middle bar
  4048. CharTmp1 = 'D'; CharTmp2 = '-'; goto _COMBINEDFONT;
  4049. case 0xD8: // 'O' with slash
  4050. CharTmp1 = 'O'; CharTmp2 = '/'; goto _COMBINEDFONT;
  4051. case 0xE0: // 'a' with right-down dash
  4052. CharTmp1 = 'a'; CharTmp2 = '`'; goto _COMBINEDFONT;
  4053. case 0xE1: // 'a' with left-down dash
  4054. CharTmp1 = 'a'; CharTmp2 = 0xA7; goto _COMBINEDFONT;
  4055. case 0xE2: // 'a' with hat
  4056. CharTmp1 = 'a'; CharTmp2 = '^'; goto _COMBINEDFONT;
  4057. case 0xE3: // 'a' with tilde
  4058. CharTmp1 = 'a'; CharTmp2 = '~'; goto _COMBINEDFONT;
  4059. case 0xE4: // 'a' with umlaut
  4060. CharTmp1 = 'a'; CharTmp2 = 0xBE; goto _COMBINEDFONT;
  4061. case 0xE5: // 'a' with circle
  4062. CharTmp1 = 'a'; CharTmp2 = 0xA6; goto _COMBINEDFONT;
  4063. case 0xEA: // 'e' with hat
  4064. CharTmp1 = 'e'; CharTmp2 = '^'; goto _COMBINEDFONT;
  4065. case 0xEB: // 'e' with umlaut
  4066. CharTmp1 = 'e'; CharTmp2 = 0xBE; goto _COMBINEDFONT;
  4067. case 0xF1: // 'n' with tilde
  4068. CharTmp1 = 'n'; CharTmp2 = '~'; goto _COMBINEDFONT;
  4069. case 0xF2: // 'o' with right-down dash
  4070. CharTmp1 = 'o'; CharTmp2 = '`'; goto _COMBINEDFONT;
  4071. case 0xF3: // 'o' with left-down dash
  4072. CharTmp1 = 'o'; CharTmp2 = 0xA7; goto _COMBINEDFONT;
  4073. case 0xF4: // 'o' with hat
  4074. CharTmp1 = 'o'; CharTmp2 = '^'; goto _COMBINEDFONT;
  4075. case 0xF5: // 'o' with tilde
  4076. CharTmp1 = 'o'; CharTmp2 = '~'; goto _COMBINEDFONT;
  4077. case 0xF6: // 'o' with umlaut
  4078. CharTmp1 = 'o'; CharTmp2 = 0xBE; goto _COMBINEDFONT;
  4079. case 0xF8: // 'o' with slash
  4080. CharTmp1 = 'o'; CharTmp2 = '/'; goto _COMBINEDFONT;
  4081. case 0xFA: // 'u' with left-down dash
  4082. CharTmp1 = 'u'; CharTmp2 = 0xA7; goto _COMBINEDFONT;
  4083. case 0xFB: // 'u' with hat
  4084. CharTmp1 = 'u'; CharTmp2 = '^'; goto _COMBINEDFONT;
  4085. case 0xFD: // 'y' with left-down dash
  4086. CharTmp1 = 'y'; CharTmp2 = 0xA7; goto _COMBINEDFONT;
  4087. case 0xFF: // 'y' with umlaut
  4088. CharTmp1 = 'y'; CharTmp2 = 0xBE; goto _COMBINEDFONT;
  4089. _COMBINEDFONT:
  4090. WRITESPOOLBUF(pdevobj, &CharTmp2, 1);
  4091. WRITESPOOLBUF(pdevobj, BS, sizeof(BS)-1);
  4092. if (rcID == BOLDFACEPS && CharTmp1 != 'D') // BoldFacePS(except 'D'+'-')
  4093. WRITESPOOLBUF(pdevobj, BS, sizeof(BS)-1);
  4094. WRITESPOOLBUF(pdevobj, &CharTmp1, 1);
  4095. break;
  4096. case 0x9F: // 'Y' with umlaut
  4097. CharTmp1 = 'Y'; CharTmp2 = 0xBE; goto _COMBINEDFONT_HALFUP;
  4098. case 0xC0: // 'A' with right-down dash
  4099. CharTmp1 = 'A'; CharTmp2 = '`'; goto _COMBINEDFONT_HALFUP;
  4100. case 0xC1: // 'A' with left-down dash
  4101. CharTmp1 = 'A'; CharTmp2 = 0xA7; goto _COMBINEDFONT_HALFUP;
  4102. case 0xC2: // 'A' with hat
  4103. CharTmp1 = 'A'; CharTmp2 = '^'; goto _COMBINEDFONT_HALFUP;
  4104. case 0xC3: // 'A' with tilde
  4105. CharTmp1 = 'A'; CharTmp2 = '~'; goto _COMBINEDFONT_HALFUP;
  4106. case 0xC8: // 'E' with right-down dash
  4107. CharTmp1 = 'E'; CharTmp2 = '`'; goto _COMBINEDFONT_HALFUP;
  4108. case 0xCA: // 'E' with hat
  4109. CharTmp1 = 'E'; CharTmp2 = '^'; goto _COMBINEDFONT_HALFUP;
  4110. case 0xCB: // 'E' with umlaut
  4111. CharTmp1 = 'E'; CharTmp2 = 0xBE; goto _COMBINEDFONT_HALFUP;
  4112. case 0xCC: // 'I' with right-down dash
  4113. CharTmp1 = 'I'; CharTmp2 = '`'; goto _COMBINEDFONT_HALFUP;
  4114. case 0xCD: // 'I' with left-down dash
  4115. CharTmp1 = 'I'; CharTmp2 = 0xA7; goto _COMBINEDFONT_HALFUP;
  4116. case 0xCE: // 'I' with hat
  4117. CharTmp1 = 'I'; CharTmp2 = '^'; goto _COMBINEDFONT_HALFUP;
  4118. case 0xCF: // 'I' with umlaut
  4119. CharTmp1 = 'I'; CharTmp2 = 0xBE; goto _COMBINEDFONT_HALFUP;
  4120. case 0xD1: // 'N' with tilde
  4121. CharTmp1 = 'N'; CharTmp2 = '~'; goto _COMBINEDFONT_HALFUP;
  4122. case 0xD2: // 'O' with right-down dash
  4123. CharTmp1 = 'O'; CharTmp2 = '`'; goto _COMBINEDFONT_HALFUP;
  4124. case 0xD3: // 'O' with left-down dash
  4125. CharTmp1 = 'O'; CharTmp2 = 0xA7; goto _COMBINEDFONT_HALFUP;
  4126. case 0xD4: // 'O' with hat
  4127. CharTmp1 = 'O'; CharTmp2 = '^'; goto _COMBINEDFONT_HALFUP;
  4128. case 0xD5: // 'O' with tilde
  4129. CharTmp1 = 'O'; CharTmp2 = '~'; goto _COMBINEDFONT_HALFUP;
  4130. case 0xD9: // 'U' with right-down dash
  4131. CharTmp1 = 'U'; CharTmp2 = '`'; goto _COMBINEDFONT_HALFUP;
  4132. case 0xDA: // 'U' with left-down dash
  4133. CharTmp1 = 'U'; CharTmp2 = 0xA7; goto _COMBINEDFONT_HALFUP;
  4134. case 0xDB: // 'U' with hat
  4135. CharTmp1 = 'U'; CharTmp2 = '^'; goto _COMBINEDFONT_HALFUP;
  4136. case 0xDD: // 'Y' with left-down dash
  4137. CharTmp1 = 'Y'; CharTmp2 = 0xA7; goto _COMBINEDFONT_HALFUP;
  4138. _COMBINEDFONT_HALFUP:
  4139. WRITESPOOLBUF(pdevobj, ESC_HALFUP, sizeof(ESC_HALFUP)-1);
  4140. WRITESPOOLBUF(pdevobj, &CharTmp2, 1);
  4141. WRITESPOOLBUF(pdevobj, ESC_HALFDOWN, sizeof(ESC_HALFDOWN)-1);
  4142. WRITESPOOLBUF(pdevobj, BS, sizeof(BS)-1);
  4143. if (rcID == BOLDFACEPS && CharTmp1 != 'I') // BoldFacePS(except 'I')
  4144. WRITESPOOLBUF(pdevobj, BS, sizeof(BS)-1);
  4145. WRITESPOOLBUF(pdevobj, &CharTmp1, 1);
  4146. break;
  4147. case 0x84: // double quatation at bottom
  4148. CharTmp1 = 0x22;
  4149. WRITESPOOLBUF(pdevobj, ESC_DOWN, sizeof(ESC_DOWN)-1);
  4150. WRITESPOOLBUF(pdevobj, &CharTmp1, 1);
  4151. WRITESPOOLBUF(pdevobj, ESC_UP, sizeof(ESC_UP)-1);
  4152. break;
  4153. case 0xB1: // plus-minus
  4154. if (rcID == BOLDFACEPS)
  4155. {
  4156. CharTmp2 = '_'; CharTmp1 = '+';
  4157. WRITESPOOLBUF(pdevobj, &CharTmp2, 1);
  4158. WRITESPOOLBUF(pdevobj, BS, sizeof(BS)-1);
  4159. }
  4160. else
  4161. {
  4162. CharTmp2 = '+'; CharTmp1 = '-';
  4163. WRITESPOOLBUF(pdevobj, &CharTmp2, 1);
  4164. }
  4165. WRITESPOOLBUF(pdevobj, BS, sizeof(BS)-1);
  4166. WRITESPOOLBUF(pdevobj, ESC_DOWN, sizeof(ESC_DOWN)-1);
  4167. WRITESPOOLBUF(pdevobj, &CharTmp1, 1);
  4168. WRITESPOOLBUF(pdevobj, ESC_UP, sizeof(ESC_UP)-1);
  4169. break;
  4170. case 0x95:
  4171. case 0xB7:
  4172. default: // print unprintable font by dot(KATAKANA)
  4173. // Set 2nd SBCS font table(0x80-0xFF) as KATAKANA
  4174. WRITESPOOLBUF(pdevobj, ESC_SHIFT_IN, sizeof(ESC_SHIFT_IN)-1);
  4175. CharTmp1 = 0xA5;
  4176. WRITESPOOLBUF(pdevobj, &CharTmp1, 1);
  4177. // Set 2nd SBCS font table(0x80-0xFF) as 2ndANK
  4178. WRITESPOOLBUF(pdevobj, ESC_SHIFT_OUT, sizeof(ESC_SHIFT_OUT)-1);
  4179. break;
  4180. } // 'switch (CharTmp1)' end
  4181. }
  4182. else //** Japanese font (HANKAKU) **
  4183. {
  4184. if (fVertFont) // vertical font
  4185. {
  4186. // HANKAKU(Alphabetical&Numeric) fonts must not become vertical.
  4187. WRITESPOOLBUF(pdevobj, ESC_VERT_OFF, sizeof(ESC_VERT_OFF)-1);
  4188. WRITESPOOLBUF(pdevobj, lpChar, 1);
  4189. WRITESPOOLBUF(pdevobj, ESC_VERT_ON, sizeof(ESC_VERT_ON)-1);
  4190. }
  4191. else // normal (non vertical) font
  4192. {
  4193. WRITESPOOLBUF(pdevobj, lpChar, 1);
  4194. }
  4195. } // 'if European font else Japanese font(HANKAKU)' end
  4196. break;
  4197. case MTYPE_PAIRED: // DBCS (Japanes font ZENKAKU)
  4198. // VERBOSE((("TYPE_TRANSDATA:ubPairs:0x%x\n"), *(PWORD)(pTrans->uCode.ubPairs)));
  4199. lpChar = pTrans->uCode.ubPairs;
  4200. // For proportional font UFM which has GTT @Oct/27/98 ->
  4201. #ifdef JISGTT
  4202. if (fJisCode)
  4203. {
  4204. BYTE jis[2], sjis[2];
  4205. jis[0] = *lpChar;
  4206. jis[1] = *(lpChar+1);
  4207. jis2sjis(jis, sjis);
  4208. (BYTE)*lpChar = sjis[0];
  4209. (BYTE)*(lpChar+1) = sjis[1];
  4210. }
  4211. #endif // JISGTT
  4212. // @Oct/27/98 <-
  4213. CharTmp1 = *lpChar;
  4214. CharTmp2 = *(lpChar+1);
  4215. // Some vertical device font differ from TrueType font
  4216. if (fVertFont)
  4217. {
  4218. if (CharTmp1 == 0x81)
  4219. {
  4220. // Make vertical device font same to TrueType
  4221. if (IsDifferentPRNFONT(CharTmp2))
  4222. {
  4223. WRITESPOOLBUF(pdevobj, ESC_VERT_OFF, sizeof(ESC_VERT_OFF)-1);
  4224. WRITESPOOLBUF(pdevobj, ESC_ROT90, sizeof(ESC_ROT90)-1);
  4225. WRITESPOOLBUF(pdevobj, lpChar, 2);
  4226. WRITESPOOLBUF(pdevobj, ESC_ROT0, sizeof(ESC_ROT0)-1);
  4227. WRITESPOOLBUF(pdevobj, ESC_VERT_ON, sizeof(ESC_VERT_ON)-1);
  4228. continue; // goto for-loop end
  4229. }
  4230. else if (CharTmp2 >= 0xA8 && CharTmp2 <= 0xAB)
  4231. { //IMAGIO's GOTHIC device font differ from TrueType font
  4232. goto _WITHOUTROTATION;
  4233. }
  4234. }
  4235. if (CharTmp1 == 0x84 &&
  4236. CharTmp2 >= 0x9F && CharTmp2 <= 0xBE)
  4237. {
  4238. _WITHOUTROTATION:
  4239. WRITESPOOLBUF(pdevobj, ESC_VERT_OFF, sizeof(ESC_VERT_OFF)-1);
  4240. WRITESPOOLBUF(pdevobj, lpChar, 2);
  4241. WRITESPOOLBUF(pdevobj, ESC_VERT_ON, sizeof(ESC_VERT_ON)-1);
  4242. continue; // goto for-loop end
  4243. }
  4244. } // 'if(fVertFont)' end
  4245. // Code of HEISEI mark of device font differs from SJIS
  4246. if (CharTmp1 == 0x87 && CharTmp2 == 0x7E)
  4247. {
  4248. (BYTE)*(lpChar+1) = 0x9E;
  4249. WRITESPOOLBUF(pdevobj, lpChar, 2);
  4250. continue; // goto for-loop end
  4251. }
  4252. // If models which support IBM ext char code
  4253. if (fIBMFontSupport)
  4254. {
  4255. WRITESPOOLBUF(pdevobj, lpChar, 2);
  4256. continue; // goto for-loop end
  4257. }
  4258. // Handle IBM ext char code here at models which do not support it
  4259. switch (CharTmp1)
  4260. {
  4261. case 0xFA:
  4262. if (CharTmp2 >= 0x40 && CharTmp2 <= 0xFC)
  4263. (BYTE)*lpChar = 0x0EB;
  4264. goto _WRITE2BYTE;
  4265. case 0xFB:
  4266. if (CharTmp2 >= 0x40 && CharTmp2 <= 0x9E)
  4267. {
  4268. (BYTE)*lpChar = 0xEC;
  4269. goto _WRITE2BYTE;
  4270. }
  4271. if (CharTmp2 >= 0x9F && CharTmp2 <= 0xDD)
  4272. {
  4273. (BYTE)*lpChar = 0x8A;
  4274. (BYTE)*(lpChar+1) -= 0x5F;
  4275. goto _WRITE2BYTE_SWITCHBLOCK;
  4276. }
  4277. if (CharTmp2 >= 0xDE && CharTmp2 <= 0xFC)
  4278. {
  4279. (BYTE)*lpChar = 0x8A;
  4280. (BYTE)*(lpChar+1) -= 0x5E;
  4281. goto _WRITE2BYTE_SWITCHBLOCK;
  4282. }
  4283. goto _WRITE2BYTE;
  4284. case 0xFC:
  4285. if (CharTmp2 >= 0x40 && CharTmp2 <= 0x4B)
  4286. {
  4287. (BYTE)*lpChar = 0x8A;
  4288. (BYTE)*(lpChar+1) += 0x5F;
  4289. goto _WRITE2BYTE_SWITCHBLOCK;
  4290. }
  4291. goto _WRITE2BYTE;
  4292. case 0xED: //IBM extended char selected by NEC
  4293. if (CharTmp2 >= 0x40 && CharTmp2 <= 0x62)
  4294. {
  4295. (BYTE)*lpChar = 0xEB;
  4296. (BYTE)*(lpChar+1) += 0x1C;
  4297. goto _WRITE2BYTE;
  4298. }
  4299. if (CharTmp2 >= 0x63 && CharTmp2 <= 0x7E)
  4300. {
  4301. (BYTE)*lpChar = 0xEB;
  4302. (BYTE)*(lpChar+1) += 0x1D;
  4303. goto _WRITE2BYTE;
  4304. }
  4305. if (CharTmp2 >= 0x80 && CharTmp2 <= 0xE0)
  4306. {
  4307. (BYTE)*lpChar = 0xEB;
  4308. (BYTE)*(lpChar+1) += 0x1C;
  4309. goto _WRITE2BYTE;
  4310. }
  4311. if (CharTmp2 >= 0xE1 && CharTmp2 <= 0xFC)
  4312. {
  4313. (BYTE)*lpChar = 0xEC;
  4314. (BYTE)*(lpChar+1) -= 0xA1;
  4315. goto _WRITE2BYTE;
  4316. }
  4317. goto _WRITE2BYTE;
  4318. case 0xEE: //IBM extended char selected by NEC
  4319. if (CharTmp2 >= 0x40 && CharTmp2 <= 0x62)
  4320. {
  4321. (BYTE)*lpChar = 0xEC;
  4322. (BYTE)*(lpChar+1) += 0x1C;
  4323. goto _WRITE2BYTE;
  4324. }
  4325. if (CharTmp2 >= 0x63 && CharTmp2 <= 0x7E)
  4326. {
  4327. (BYTE)*lpChar = 0xEC;
  4328. (BYTE)*(lpChar+1) += 0x1D;
  4329. goto _WRITE2BYTE;
  4330. }
  4331. if (CharTmp2 >= 0x80 && CharTmp2 <= 0x82)
  4332. {
  4333. (BYTE)*lpChar = 0xEC;
  4334. (BYTE)*(lpChar+1) += 0x1C;
  4335. goto _WRITE2BYTE;
  4336. }
  4337. if (CharTmp2 >= 0x83 && CharTmp2 <= 0xC1)
  4338. {
  4339. (BYTE)*lpChar = 0x8A;
  4340. (BYTE)*(lpChar+1) -= 0x43;
  4341. goto _WRITE2BYTE_SWITCHBLOCK;
  4342. }
  4343. if (CharTmp2 >= 0xC2 && CharTmp2 <= 0xEC)
  4344. {
  4345. (BYTE)*lpChar = 0x8A;
  4346. (BYTE)*(lpChar+1) -= 0x42;
  4347. goto _WRITE2BYTE_SWITCHBLOCK;
  4348. }
  4349. if (CharTmp2 >= 0xEF && CharTmp2 <= 0xF8)
  4350. {
  4351. (BYTE)*lpChar = 0xEB;
  4352. (BYTE)*(lpChar+1) -= 0xAF;
  4353. goto _WRITE2BYTE;
  4354. }
  4355. if (CharTmp2 >= 0xF9 && CharTmp2 <= 0xFC)
  4356. {
  4357. (BYTE)*lpChar = 0xEB;
  4358. (BYTE)*(lpChar+1) -= 0xA5;
  4359. goto _WRITE2BYTE;
  4360. }
  4361. goto _WRITE2BYTE;
  4362. _WRITE2BYTE_SWITCHBLOCK:
  4363. // Assign IBM char to JIS1 block
  4364. AssignIBMfont(pdevobj, rcID, IBMFONT_ENABLE_ALL);
  4365. // Output char code
  4366. WRITESPOOLBUF(pdevobj, lpChar, 2);
  4367. // Resume the block
  4368. AssignIBMfont(pdevobj, rcID, IBMFONT_RESUME);
  4369. break;
  4370. default:
  4371. _WRITE2BYTE:
  4372. WRITESPOOLBUF(pdevobj, lpChar, 2);
  4373. break;
  4374. } // 'switch (CharTmp1)' end
  4375. break;
  4376. } // 'switch (pTrans->ubType & MTYPE_FORMAT_MASK)' end
  4377. } // 'for (dwI = 0; dwI < dwCount; dwI ++, pTrans++)' end
  4378. //** Draw device font END **
  4379. if(fMemAllocated)
  4380. MemFree(aubBuff);
  4381. break;
  4382. case TYPE_GLYPHID: // donwload font
  4383. #ifdef DOWNLOADFONT
  4384. // If negative, do not draw. (lFontID should begin from 0.)
  4385. // VERBOSE((("** ulFontID=%d **\n"), pUFObj->ulFontID));
  4386. if ((lFontID = (LONG)pUFObj->ulFontID - DLFONT_ID_MIN_GPD) < 0)
  4387. break; // exit
  4388. //** Draw download font **
  4389. for (dwI = 0; dwI < dwCount; dwI ++, ((PDWORD)pGlyph)++)
  4390. {
  4391. // If negative, do not draw. (lGlyphID should begin from 0.)
  4392. if ((lGlyphID = (LONG)*(PWORD)pGlyph - DLFONT_GLYPH_MIN_GPD) < 0)
  4393. break; // exit for-loop
  4394. wSerialNum = (WORD)lGlyphID + (WORD)lFontID * DLFONT_GLYPH_TOTAL;
  4395. lpDLFont = &pOEM->pDLFontGlyphInfo[wSerialNum];
  4396. // VERBOSE((("** pGlyph=%d, local glyph_id=%d **\n"), *(PWORD)pGlyph, lGlyphID));
  4397. // If space character
  4398. if (lpDLFont->nPitch < 0)
  4399. {
  4400. // Save moving value for next font print with reseting flag
  4401. pOEM->nCharPosMoveX += -lpDLFont->nPitch;
  4402. }
  4403. else
  4404. {
  4405. // Locate print position.
  4406. if ((mov = pOEM->nCharPosMoveX + lpDLFont->nOffsetX) != 0)
  4407. {
  4408. if (mov > 0)
  4409. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ESC_XM_REL, mov);
  4410. else
  4411. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), ESC_XM_RELLEFT, -mov);
  4412. }
  4413. // Print download font
  4414. ocmd += safe_sprintfA(&Cmd[ocmd], sizeof(Cmd) - ocmd, DLFONT_PRINT, wSerialNum,
  4415. pOEM->TextCurPos.y - lpDLFont->nOffsetY);
  4416. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  4417. ocmd = 0;
  4418. // Save moving value for next font print.
  4419. pOEM->nCharPosMoveX = lpDLFont->nPitch - lpDLFont->nOffsetX;
  4420. } // 'if (pitch < 0) else' end
  4421. } // 'for (dwI = 0; dwI < dwCount; dwI ++, ((PDWORD)pGlyph)++)' end
  4422. #endif // DOWNLOADFONT
  4423. break;
  4424. //** Draw download font END **
  4425. } // 'switch (dwType)' end
  4426. return TRUE; // BOOL <- VOID @Mar/27/2002
  4427. } //*** bOEMOutputCharStr
  4428. DWORD APIENTRY OEMDownloadFontHeader(
  4429. PDEVOBJ pdevobj,
  4430. PUNIFONTOBJ pUFObj)
  4431. {
  4432. #ifndef DOWNLOADFONT
  4433. return 0; // not available
  4434. #else // DOWNLOADFONT
  4435. VERBOSE(("** OEMDownloadFontHeader() entry. **\n"));
  4436. VERBOSE((" FontID=%d\n", pUFObj->ulFontID));
  4437. // OBSOLETE @Apr/02/99 ->
  4438. // SPEC of Unidrv5
  4439. // Unidrv5 doesn't handle 0-return, once OEMTTDownloadMethod returns TTDOWNLOAD_BITMAP.
  4440. // POEMPDEV pOEM = MINIDEV_DATA(pdevobj); // @Oct/06/98
  4441. // LONG lFontID; // @Aug/21/98
  4442. // // If FontID is beyond limit, exit.
  4443. // if ((lFontID = (LONG)pUFObj->ulFontID - DLFONT_ID_MIN_GPD) < 0 ||
  4444. // lFontID >= (LONG)pOEM->DLFontMaxID)
  4445. // {
  4446. // return 0;
  4447. // }
  4448. // @Apr/02/99 <-
  4449. return 1; // available
  4450. #endif // DOWNLOADFONT
  4451. } //*** OEMDownloadFontHeader
  4452. DWORD APIENTRY OEMDownloadCharGlyph(
  4453. PDEVOBJ pdevobj,
  4454. PUNIFONTOBJ pUFObj,
  4455. HGLYPH hGlyph,
  4456. PDWORD pdwWidth)
  4457. {
  4458. #ifndef DOWNLOADFONT
  4459. return 0; // not available
  4460. #else // DOWNLOADFONT
  4461. WORD wSerialNum, wHeight, wWidthByte;
  4462. DWORD dwNeeded, dwSize;
  4463. LPBYTE lpBitmap;
  4464. LPFONTPOS lpDLFont;
  4465. GETINFO_GLYPHBITMAP GBmp;
  4466. POEMPDEV pOEM = MINIDEV_DATA(pdevobj); // @Oct/06/98
  4467. LONG lFontID, lGlyphID;
  4468. VERBOSE(("** OEMDownloadCharGlyph() entry. **\n"));
  4469. // If negative or beyond limit, do not download. (lGlyphID should begin from 0.)
  4470. if ((lGlyphID = (LONG)pOEM->DLFontCurGlyph - DLFONT_GLYPH_MIN_GPD) < 0 ||
  4471. lGlyphID >= pOEM->DLFontMaxGlyph)
  4472. {
  4473. return 0; // exit
  4474. }
  4475. // If beyond limit, do not download. (lFontID should begin from 0.)
  4476. if ((lFontID = (LONG)pUFObj->ulFontID - DLFONT_ID_MIN_GPD) < 0 ||
  4477. lFontID >= (LONG)pOEM->DLFontMaxID)
  4478. {
  4479. return 0; // exit
  4480. }
  4481. VERBOSE((" FontID=%d, GlyphID=%d\n", lFontID, lGlyphID));
  4482. wSerialNum = (WORD)lGlyphID + (WORD)lFontID * DLFONT_GLYPH_TOTAL;
  4483. //
  4484. // GETINFO_GLYPHBITMAP
  4485. //
  4486. GBmp.dwSize = sizeof(GETINFO_GLYPHBITMAP);
  4487. GBmp.hGlyph = hGlyph;
  4488. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHBITMAP, &GBmp,
  4489. GBmp.dwSize, &dwNeeded))
  4490. {
  4491. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHBITMAP failed.\n"));
  4492. return 0; // exit
  4493. }
  4494. wWidthByte = ((WORD)GBmp.pGlyphData->gdf.pgb->sizlBitmap.cx + 7) >> 3; // byte:8bit-boundary
  4495. wHeight = (WORD)GBmp.pGlyphData->gdf.pgb->sizlBitmap.cy;
  4496. lpBitmap = (LPBYTE)GBmp.pGlyphData->gdf.pgb->aj;
  4497. lpDLFont = &pOEM->pDLFontGlyphInfo[wSerialNum];
  4498. lpDLFont->nPitch = (SHORT)(GBmp.pGlyphData->fxD >> 4);
  4499. lpDLFont->nOffsetX = (SHORT)GBmp.pGlyphData->gdf.pgb->ptlOrigin.x;
  4500. lpDLFont->nOffsetY = -(SHORT)GBmp.pGlyphData->gdf.pgb->ptlOrigin.y;
  4501. dwSize = wHeight * wWidthByte;
  4502. // VERBOSE((" width=%dbyte,height=%ddot,bmp[0]=%x\n", wWidthByte, wHeight, *lpBitmap));
  4503. // VERBOSE((" pitch=%d(FIX(28.4):%lxh),offsetx=%d,offsety=%d\n",
  4504. // GBmp.pGlyphData->fxD >> 4, GBmp.pGlyphData->fxD,
  4505. // lpDLFont->nOffsetX, lpDLFont->nOffsetY));
  4506. // VERBOSE((" dwSize(raw)=%ldbyte\n", dwSize));
  4507. // If space character
  4508. if (dwSize == 0 || dwSize == 1 && *lpBitmap == 0)
  4509. {
  4510. // Negate pitch to indicate space character
  4511. lpDLFont->nPitch = -lpDLFont->nPitch;
  4512. return 1; // success return (1<-0 @Jun/15/98)
  4513. }
  4514. else
  4515. {
  4516. BYTE Cmd[64];
  4517. INT ocmd; // INT<-SHORT @Feb/22/99
  4518. WORD fDRC = FALSE;
  4519. DWORD dwSizeRPDL, dwSizeDRC;
  4520. // Do FE-DeltaRow compression (@Jun/15/98, pOEM->pRPDLHeap2K<-OutBuf[1024] @Sep/09/98)
  4521. if (TEST_CAPABLE_DOWNLOADFONT_DRC(pOEM->fModel) && pOEM->pRPDLHeap2K &&
  4522. -1 != (dwSizeDRC = DRCompression(lpBitmap, pOEM->pRPDLHeap2K, dwSize, HEAPSIZE2K,
  4523. (DWORD)wWidthByte, (DWORD)wHeight)))
  4524. {
  4525. fDRC = TRUE;
  4526. dwSize = dwSizeDRC;
  4527. lpBitmap = pOEM->pRPDLHeap2K;
  4528. }
  4529. // Include header size and make it 32byte-boudary.
  4530. dwSizeRPDL = (dwSize + (DLFONT_HEADER_SIZE + DLFONT_MIN_BLOCK - 1))
  4531. / DLFONT_MIN_BLOCK * DLFONT_MIN_BLOCK;
  4532. // Check available memory size
  4533. if((pOEM->dwDLFontUsedMem += dwSizeRPDL) > ((DWORD)pOEM->DLFontMaxMemKB << 10))
  4534. {
  4535. ERR(("DOWNLOAD MEMORY OVERFLOW.\n"));
  4536. return 0; // exit
  4537. }
  4538. VERBOSE((" Consumed Memory=%ldbyte\n", pOEM->dwDLFontUsedMem));
  4539. // Register glyph bitmap image
  4540. if (fDRC) // @Jun/15/98
  4541. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), DLFONT_SEND_BLOCK_DRC, wWidthByte*8, wHeight, wSerialNum, dwSize);
  4542. else
  4543. ocmd = safe_sprintfA(Cmd, sizeof(Cmd), DLFONT_SEND_BLOCK, wWidthByte*8, wHeight, wSerialNum);
  4544. WRITESPOOLBUF(pdevobj, Cmd, ocmd);
  4545. WRITESPOOLBUF(pdevobj, lpBitmap, dwSize);
  4546. return dwSizeRPDL;
  4547. }
  4548. #endif // DOWNLOADFONT
  4549. } //*** OEMDownloadCharGlyph
  4550. DWORD APIENTRY OEMTTDownloadMethod(
  4551. PDEVOBJ pdevobj,
  4552. PUNIFONTOBJ pUFObj)
  4553. {
  4554. #ifndef DOWNLOADFONT
  4555. return TTDOWNLOAD_DONTCARE;
  4556. #else // DOWNLOADFONT
  4557. // @Nov/18/98 ->
  4558. GETINFO_FONTOBJ GFo;
  4559. POEMPDEV pOEM = MINIDEV_DATA(pdevobj);
  4560. DWORD dwNeeded, dwWidth;
  4561. VERBOSE(("** OEMTTDownloadMethod() entry. **\n"));
  4562. // If printer doesn't support or user disabled downloading, do not download.
  4563. if (!pOEM->DLFontMaxMemKB)
  4564. return TTDOWNLOAD_DONTCARE;
  4565. //
  4566. // GETINFO_FONTOBJ
  4567. //
  4568. GFo.dwSize = sizeof(GETINFO_FONTOBJ);
  4569. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_FONTOBJ, &GFo,
  4570. GFo.dwSize, &dwNeeded))
  4571. {
  4572. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_FONTOBJ failed.\n"));
  4573. return TTDOWNLOAD_GRAPHICS; // <-TTDOWNLOAD_DONTCARE @Apr/02/99
  4574. }
  4575. // If bold or italic font, do not download.
  4576. // (SBCS font which has bold or italic glyph (e.g. Arial) doesn't fit this condition.)
  4577. if (GFo.pFontObj->flFontType & (FO_SIM_BOLD | FO_SIM_ITALIC))
  4578. {
  4579. VERBOSE((" UNAVAILABLE: BOLD/ITALIC\n"));
  4580. return TTDOWNLOAD_GRAPHICS; // <-TTDOWNLOAD_DONTCARE @Apr/02/99
  4581. }
  4582. dwWidth = GFo.pFontObj->cxMax * pOEM->nResoRatio; // masterunit
  4583. // VERBOSE((" FontSize=%d\n", GFo.pFontObj->cxMax));
  4584. // If font width is beyond limit, do not download.
  4585. if (IS_DBCSCHARSET(pUFObj->pIFIMetrics->jWinCharSet))
  4586. {
  4587. if (dwWidth > DLFONT_SIZE_DBCS11PT_MU || dwWidth < DLFONT_SIZE_DBCS9PT_MU)
  4588. {
  4589. VERBOSE((" UNAVAILABLE: DBCS FONTSIZE OUT OF RANGE(%ddot,%dcpt)\n",
  4590. GFo.pFontObj->cxMax, dwWidth*7200L/MASTERUNIT));
  4591. return TTDOWNLOAD_GRAPHICS; // <-TTDOWNLOAD_DONTCARE @Apr/02/99
  4592. }
  4593. }
  4594. else
  4595. {
  4596. if (dwWidth > DLFONT_SIZE_SBCS11PT_MU || dwWidth < DLFONT_SIZE_SBCS9PT_MU)
  4597. {
  4598. VERBOSE((" UNAVAILABLE: SBCS FONTSIZE OUT OF RANGE(%ddot,%dcpt)\n",
  4599. GFo.pFontObj->cxMax, dwWidth*7200L/MASTERUNIT));
  4600. return TTDOWNLOAD_GRAPHICS; // <-TTDOWNLOAD_DONTCARE @Apr/02/99
  4601. }
  4602. }
  4603. VERBOSE((" AVAILABLE\n"));
  4604. // @Nov/18/98 <-
  4605. return TTDOWNLOAD_BITMAP;
  4606. #endif // DOWNLOADFONT
  4607. } //*** OEMTTDownloadMethod
  4608. INT APIENTRY OEMCompression( // @Jun/04/98
  4609. PDEVOBJ pdevobj,
  4610. PBYTE pInBuf,
  4611. PBYTE pOutBuf,
  4612. DWORD dwInLen,
  4613. DWORD dwOutLen)
  4614. {
  4615. POEMPDEV pOEM = MINIDEV_DATA(pdevobj); // @Oct/06/98
  4616. // VERBOSE(("OEMCompression() entry.\n"));
  4617. return DRCompression(pInBuf, pOutBuf, dwInLen, dwOutLen,
  4618. pOEM->dwSrcBmpWidthByte, pOEM->dwSrcBmpHeight);
  4619. } //*** OEMCompression
  4620. //---------------------------*[LOCAL] DRCompression*---------------------------
  4621. // Action: Compress data by FE-DeltaRow method
  4622. // Return: number of compressed bytes if successful
  4623. // -1 if unable to compress the data within the specific buffer
  4624. // History:
  4625. // Oct/25/97 Tatsuro Yoshioka(RICOH) Created.
  4626. // Jun/11/98 Masatoshi Kubokura(RICOH) Modified.
  4627. //-----------------------------------------------------------------------------
  4628. static INT DRCompression(
  4629. PBYTE pInBuf, // Pointer to raster data to compress
  4630. PBYTE pOutBuf, // Pointer to output buffer for compressed data
  4631. DWORD dwInLen, // size of input data to compress
  4632. DWORD dwOutLen, // size of output buffer in bytes
  4633. DWORD dwWidthByte, // width of raster data in bytes
  4634. DWORD dwHeight) // height of raster data
  4635. {
  4636. DWORD dwCurRow, dwCurByte, dwSameByteCnt, dwRepeatByteCnt, dwTmp;
  4637. DWORD dwCompLen, dwCnt, dwCnt2;
  4638. BYTE *pTmpPre, *pTmpCur, *pCurRow, *pPreRow;
  4639. BYTE DiffBytes[16], FlagBit;
  4640. // VERBOSE((" dwInLen, dwOutLen=%d, %d\n", dwInLen, dwOutLen));
  4641. // VERBOSE((" Width, Height=%d, %d\n", dwWidthByte, dwHeight));
  4642. if (dwOutLen > dwInLen) // add @Jun/19/98
  4643. dwOutLen = dwInLen;
  4644. // @Apr/07/2000 ->
  4645. // PRINTER SIDE ISSUE: RPDL
  4646. // Bitmap image is destorted when width or height >= 10000dots
  4647. if (dwWidthByte >= (10000L/8L) || dwHeight >= 10000L)
  4648. return -1;
  4649. // @Apr/07/2000 <-
  4650. if (dwHeight <= 3 || dwOutLen <= dwWidthByte * 3)
  4651. return -1;
  4652. pPreRow = pTmpPre = pOutBuf + dwOutLen - dwWidthByte;
  4653. dwCnt = dwWidthByte;
  4654. while (dwCnt--) // fill seed row with 0
  4655. *pTmpPre++ = 0;
  4656. dwCompLen = 0;
  4657. // Loop of each row
  4658. for (dwCurRow = 0, pCurRow = pInBuf; dwCurRow < dwHeight;
  4659. dwCurRow++, pCurRow += dwWidthByte)
  4660. {
  4661. dwCurByte = 0;
  4662. // Loop of each byte-data in row
  4663. while (dwCurByte < dwWidthByte)
  4664. {
  4665. // Search same byte-data between current row and previous row
  4666. dwSameByteCnt = 0;
  4667. dwTmp = dwCurByte;
  4668. pTmpPre = pPreRow + dwTmp;
  4669. pTmpCur = pCurRow + dwTmp;
  4670. while (*pTmpCur++ == *pTmpPre++)
  4671. {
  4672. // bug fix @Nov/19/98 ->
  4673. // if (dwTmp++ >= dwWidthByte)
  4674. // break;
  4675. // dwSameByteCnt++;
  4676. dwSameByteCnt++;
  4677. if (++dwTmp >= dwWidthByte)
  4678. break;
  4679. // @Nov/19/98 <-
  4680. }
  4681. // If we have same byte-data between current row and previous row
  4682. if (dwSameByteCnt)
  4683. {
  4684. if (dwSameByteCnt != dwWidthByte)
  4685. {
  4686. if ((dwCnt = dwSameByteCnt) >= 63)
  4687. {
  4688. dwCnt -= 63;
  4689. if (++dwCompLen > dwOutLen)
  4690. {
  4691. VERBOSE((" OVERSIZE COMPRESSION(1)\n"));
  4692. return -1;
  4693. }
  4694. *pOutBuf++ = 0xBF; // control data (same to previous row)
  4695. while (dwCnt >= 255)
  4696. {
  4697. dwCnt -= 255;
  4698. if (++dwCompLen > dwOutLen)
  4699. {
  4700. VERBOSE((" OVERSIZE COMPRESSION(2)\n"));
  4701. return -1;
  4702. }
  4703. *pOutBuf++ = 0xFF; // repeating count
  4704. }
  4705. }
  4706. else // less than 63
  4707. {
  4708. dwCnt |= 0x80;
  4709. }
  4710. if (++dwCompLen > dwOutLen)
  4711. {
  4712. VERBOSE((" OVERSIZE COMPRESSION(3)\n"));
  4713. return -1;
  4714. }
  4715. // If 63 or more, set the last repeating count, else set control data.
  4716. *pOutBuf++ = (BYTE)dwCnt;
  4717. }
  4718. dwCurByte += dwSameByteCnt;
  4719. }
  4720. // Same byte-data in previous row is none
  4721. else
  4722. {
  4723. BYTE bTmp = *(pCurRow + dwCurByte);
  4724. // How many same byte-data in current row?
  4725. dwRepeatByteCnt = 1;
  4726. dwTmp = dwCurByte + 1;
  4727. pTmpCur = pCurRow + dwTmp;
  4728. while (bTmp == *pTmpCur++)
  4729. {
  4730. // bug fix @Nov/19/98 ->
  4731. // if (dwTmp++ >= dwWidthByte)
  4732. // break;
  4733. // dwRepeatByteCnt++;
  4734. dwRepeatByteCnt++;
  4735. if (++dwTmp >= dwWidthByte)
  4736. break;
  4737. // @Nov/19/98 <-
  4738. }
  4739. // If we have same byte-data in current row
  4740. if (dwRepeatByteCnt > 1)
  4741. {
  4742. if ((dwCnt = dwRepeatByteCnt) >= 63)
  4743. {
  4744. dwCnt -= 63;
  4745. if (++dwCompLen > dwOutLen)
  4746. {
  4747. VERBOSE((" OVERSIZE COMPRESSION(4)\n"));
  4748. return -1;
  4749. }
  4750. *pOutBuf++ = 0xFF; // repeating count
  4751. while (dwCnt >= 255)
  4752. {
  4753. dwCnt -= 255;
  4754. if (++dwCompLen > dwOutLen)
  4755. {
  4756. VERBOSE((" OVERSIZE COMPRESSION(5)\n"));
  4757. return -1;
  4758. }
  4759. *pOutBuf++ = 0xFF; // repeating count
  4760. }
  4761. }
  4762. // Less than 63
  4763. else
  4764. {
  4765. dwCnt |= 0xC0;
  4766. }
  4767. if ((dwCompLen += 2) > dwOutLen)
  4768. {
  4769. VERBOSE((" OVERSIZE COMPRESSION(6)\n"));
  4770. return -1;
  4771. }
  4772. // If 63 or more, set the last repeating count, else set control data.
  4773. *pOutBuf++ = (BYTE)dwCnt;
  4774. *pOutBuf++ = *(pCurRow+dwCurByte); // replacing data
  4775. dwCurByte += dwRepeatByteCnt;
  4776. }
  4777. // Same byte-data in current row is none
  4778. else
  4779. {
  4780. // If next serial 2 byte-data are same
  4781. if (dwWidthByte - dwCurByte > 2 &&
  4782. *(pCurRow+dwCurByte+1) == *(pCurRow+dwCurByte+2))
  4783. {
  4784. if ((dwCompLen += 2) > dwOutLen)
  4785. {
  4786. VERBOSE((" OVERSIZE COMPRESSION(7)\n"));
  4787. return -1;
  4788. }
  4789. *pOutBuf++ = 0xC1; // control data (1 data)
  4790. *pOutBuf++ = *(pCurRow+dwCurByte); // replacing data
  4791. dwCurByte++;
  4792. continue; // continue while(dwCurByte < dwWidthByte)
  4793. }
  4794. // We can pack 8 serial byte-data (may or may not be different to previus row)
  4795. DiffBytes[0] = 0x00;
  4796. DiffBytes[1] = *(pCurRow+dwCurByte);
  4797. dwCnt2 = 2;
  4798. dwTmp = dwCurByte + 1;
  4799. pTmpPre = pPreRow + dwTmp;
  4800. pTmpCur = pCurRow + dwTmp;
  4801. FlagBit = 0x01;
  4802. if ((dwCnt = dwWidthByte - dwTmp) > 7)
  4803. dwCnt = 7;
  4804. while (dwCnt--)
  4805. {
  4806. // If encountered different data
  4807. if (*pTmpCur != *pTmpPre++)
  4808. {
  4809. DiffBytes[0] |= FlagBit; // set different-flag
  4810. DiffBytes[dwCnt2++] = *pTmpCur; // data
  4811. }
  4812. FlagBit <<= 1;
  4813. pTmpCur++;
  4814. }
  4815. if ((dwCompLen += dwCnt2) > dwOutLen)
  4816. {
  4817. VERBOSE((" OVERSIZE COMPRESSION(8)\n"));
  4818. return -1;
  4819. }
  4820. pTmpCur = &DiffBytes[0];
  4821. while (dwCnt2--)
  4822. *pOutBuf++ = *pTmpCur++; // different packed-data
  4823. dwCurByte += 8; // 8 byte-data are packed
  4824. } // 'if (dwRepeatByteCnt > 1) else' end
  4825. } // 'if (dwSameByteCnt) else' end
  4826. } // 'while (dwCurByte < dwWidthByte)' end
  4827. if (++dwCompLen > dwOutLen)
  4828. {
  4829. VERBOSE((" OVERSIZE COMPRESSION(9)\n"));
  4830. return -1;
  4831. }
  4832. *pOutBuf++ = 0x80; // terminator of row
  4833. pPreRow = pCurRow;
  4834. } // 'for (...; dwCurRow < dwHeight; ...)' end
  4835. // VERBOSE((" dwCompLen=%d\n", dwCompLen));
  4836. return dwCompLen;
  4837. } //*** DRCompression