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.

2469 lines
88 KiB

  1. //-----------------------------------------------------------------------------
  2. // This files contains the module name for this mini driver. Each mini driver
  3. // must have a unique module name. The module name is used to obtain the
  4. // module handle of this Mini Driver. The module handle is used by the
  5. // generic library to load in tables from the Mini Driver.
  6. //-----------------------------------------------------------------------------
  7. /*++
  8. Copyright (c) 1996-2000 Microsoft Corporation
  9. Module Name:
  10. Csn5res.c
  11. Abstract:
  12. Implementation of GPD command callback for "Csn5j.gpd":
  13. OEMCommandCallback
  14. Environment:
  15. Windows NT Unidrv driver
  16. Revision History:
  17. 09/10/97
  18. Created it.
  19. --*/
  20. #include "PDEV.H"
  21. #include <stdio.h>
  22. #include "PRNCTL.H"
  23. #include "strsafe.h" // Security-Code 2002.3.6
  24. //
  25. // Misc definitions and declarations.
  26. //
  27. #define BUFFLEN 256
  28. // Replacement of strsafe-api 2002.3.6 >>>
  29. //#ifdef wsprintf
  30. //#undef wsprintf
  31. //#endif // wsprintf
  32. //#define wsprintf sprintf
  33. // Replacement of strsafe-api 2002.3.6 >>>
  34. #define SWAPW(x) \
  35. ((WORD)(((WORD)(x))<<8)|(WORD)(((WORD)(x))>>8))
  36. #define FONT_HEADER_SIZE 0x86 // format type 2
  37. #define SIZE_SYMBOLSET 28
  38. #define FONT_MIN_ID 512
  39. #define FONT_MAX_ID 535
  40. #define SJISCHR 0x2000
  41. #define IsValidDLFontID(x) \
  42. ((x) >= FONT_MIN_ID && (x) <= FONT_MAX_ID)
  43. LONG
  44. LGetPointSize100(
  45. LONG height,
  46. LONG vertRes);
  47. // Replacement of strsafe-api 2002.3.6 >>>
  48. //LONG
  49. //LConvertFontSizeToStr(
  50. // LONG size,
  51. // PSTR pStr);
  52. LONG
  53. LConvertFontSizeToStr(
  54. LONG size,
  55. PSTR pStr,
  56. size_t StrSize);
  57. // Replacement of strsafe-api 2002.3.6 <<<
  58. //
  59. // Command callback ID's
  60. //
  61. #define TEXT_FS_SINGLE_BYTE 21
  62. #define TEXT_FS_DOUBLE_BYTE 22
  63. #define DOWNLOAD_SET_FONT_ID 23
  64. #define DOWNLOAD_SELECT_FONT_ID 24
  65. #define DOWNLOAD_SET_CHAR_CODE 25
  66. #define DOWNLOAD_DELETE_FONT 26
  67. #define FS_BOLD_ON 27
  68. #define FS_BOLD_OFF 28
  69. #define FS_ITALIC_ON 29
  70. #define FS_ITALIC_OFF 30
  71. #define PC_BEGINDOC 82
  72. #define PC_ENDDOC 83
  73. #define PC_DUPLEX_NONE 90
  74. #define PC_DUPLEX_VERT 91
  75. #define PC_DUPLEX_HORZ 92
  76. #define PC_PORTRAIT 93
  77. #define PC_LANDSCAPE 94
  78. #define PSRC_SELECT_CASETTE_1 100
  79. #define PSRC_SELECT_CASETTE_2 101
  80. #define PSRC_SELECT_CASETTE_3 102
  81. #define PSRC_SELECT_CASETTE_4 103
  82. #define PSRC_SELECT_CASETTE_5 104
  83. #define PSRC_SELECT_CASETTE_6 105
  84. #define PSRC_SELECT_MPF 106
  85. #define PSRC_SELECT_AUTO 107
  86. #define TONER_SAVE_NONE 110
  87. #define TONER_SAVE_1 111
  88. #define TONER_SAVE_2 112
  89. #define SMOOTHING_ON 120
  90. #define SMOOTHING_OFF 121
  91. #define JAMRECOVERY_ON 130
  92. #define JAMRECOVERY_OFF 131
  93. #define MEDIATYPE_1 140
  94. #define MEDIATYPE_2 141
  95. #define MEDIATYPE_3 142
  96. #define RECT_FILL_WIDTH 150
  97. #define RECT_FILL_HEIGHT 151
  98. #define RECT_FILL_GRAY 152
  99. #define RECT_FILL_WHITE 153
  100. #define RECT_FILL_BLACK 154
  101. #define START_PAGE 160
  102. #if 0 /* OEM doesn't want to fix minidriver */
  103. /* Below is def. for hack code to fix #412276 */
  104. #define COLOR_SELECT_BLACK 170
  105. #define COLOR_SELECT_RED 171
  106. #define COLOR_SELECT_GREEN 172
  107. #define COLOR_SELECT_BLUE 173
  108. #define COLOR_SELECT_YELLOW 174
  109. #define COLOR_SELECT_MAGENTA 175
  110. #define COLOR_SELECT_CYAN 176
  111. #define COLOR_SELECT_WHITE 177
  112. #define DUMP_RASTER_CYAN 180
  113. #define DUMP_RASTER_MAGENTA 181
  114. #define DUMP_RASTER_YELLOW 182
  115. #define DUMP_RASTER_BLACK 183
  116. /* End of hack code */
  117. #endif /* OEM doesn't want to fix minidriver */
  118. #define OUTBIN_SELECT_EXIT_1 190
  119. #define OUTBIN_SELECT_EXIT_2 191
  120. #define DEFINE_PALETTE_ENTRY 300
  121. #define BEGIN_PALETTE_DEF 301
  122. #define END_PALETTE_DEF 302
  123. #define SELECT_PALETTE_ENTRY 303
  124. #define OPT_DITH_NORMAL "Normal"
  125. #define OPT_DITH_DETAIL "Detail"
  126. #define OPT_DITH_EMPTY "Empty"
  127. #define OPT_DITH_SPREAD "Spread"
  128. #define OPT_DITH_NON "Diz_Off"
  129. #define OPT_COLORMATCH_BRI "ForBright"
  130. #define OPT_COLORMATCH_BRIL "ForBrightL"
  131. #define OPT_COLORMATCH_TINT "ForTint"
  132. #define OPT_COLORMATCH_TINTL "ForTintL"
  133. #define OPT_COLORMATCH_VIV "ForVivid"
  134. #define OPT_COLORMATCH_NONE "Mch_Off"
  135. #define OPT_MONO "Mono"
  136. #define OPT_COLOR "Color"
  137. #define OPT_COLOR_SINGLE "Color_Single"
  138. #define OPT_COLOR_MANY "Color_Many"
  139. #define OPT_COLOR_MANY2 "Color_Many2"
  140. #define OPT_1 "Option1"
  141. #define OPT_2 "Option2"
  142. #define OPT_CMYBLACK_GRYBLK "GrayBlack"
  143. #define OPT_CMYBLACK_BLKTYPE1 "BlackType1"
  144. #define OPT_CMYBLACK_BLKTYPE2 "BlackType2"
  145. #define OPT_CMYBLACK_BLACK "Black"
  146. #define OPT_CMYBLACK_TYPE1 "Type1"
  147. #define OPT_CMYBLACK_TYPE2 "Type2"
  148. #define OPT_CMYBLACK_NONE "Non"
  149. #define OPT_AUTO "Auto"
  150. #define OPT_RASTER "Raster"
  151. #define OPT_PRESSOFF "PressOff"
  152. //
  153. // ---- S T R U C T U R E D E F I N E ----
  154. //
  155. typedef BYTE * LPDIBITS;
  156. typedef struct {
  157. WORD Integer;
  158. WORD Fraction;
  159. } FRAC;
  160. typedef struct {
  161. BYTE bFormat;
  162. BYTE bDataDir;
  163. WORD wCharCode;
  164. WORD wBitmapWidth;
  165. WORD wBitmapHeight;
  166. WORD wLeftOffset;
  167. WORD wAscent;
  168. FRAC CharWidth;
  169. } ESCPAGECHAR;
  170. typedef struct {
  171. WORD wFormatType;
  172. WORD wDataSize;
  173. WORD wSymbolSet;
  174. WORD wCharSpace;
  175. FRAC CharWidth;
  176. FRAC CharHeight;
  177. WORD wFontID;
  178. WORD wWeight;
  179. WORD wEscapement;
  180. WORD wItalic;
  181. WORD wLast;
  182. WORD wFirst;
  183. WORD wUnderline;
  184. WORD wUnderlineWidth;
  185. WORD wOverline;
  186. WORD wOverlineWidth;
  187. WORD wStrikeOut;
  188. WORD wStrikeOutWidth;
  189. WORD wCellWidth;
  190. WORD wCellHeight;
  191. WORD wCellLeftOffset;
  192. WORD wCellAscender;
  193. FRAC FixPitchWidth;
  194. } ESCPAGEHEADER, FAR * LPESCPAGEHEADER;
  195. //
  196. // Static data to be used by this minidriver.
  197. //
  198. BYTE bit_mask[] = {0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe};
  199. BYTE BEGINDOC_EJL_BEGIN[] =
  200. "\x1bz\x00\x80"
  201. "\x1b\x01@EJL \x0a"
  202. "@EJL SET";
  203. BYTE BEGINDOC_EJL_END[] =
  204. " ERRORCODE=ON"
  205. "\x0a"
  206. "@EJL EN LA=ESC/PAGE\x0a";
  207. BYTE BEGINDOC_EPG_END[] =
  208. "\x1DrhE\x1D\x32\x34ifF\x1D\x31\x34isE"
  209. "\x1D\x32iaF\x1D\x31\x30ifF"
  210. "\x1D\x31ipP"
  211. "\x1B\x7A\xD0\x01\x43\x61\x2A\x1B\x7A\x00\x01"
  212. "\x1D\x30pmP";
  213. BYTE ENDDOC_EJL_RESET[] = "\x1drhE"
  214. "\x1b\x01@EJL \x0a"
  215. "\x1b\x01@EJL \x0a"
  216. "\x1bz\xb0\x00";
  217. BYTE CMD_START_PAGE[] =
  218. "\x1Bz\xD0\x01" "Ca*\x1Bz\x00\x01"
  219. "\x1D" "1alfP\x1D" "1affP\x1D"
  220. "0;0;0clfP\x1D" "0X\x1D" "0Y";
  221. BYTE SET_FONT_ID[] = "\x1D%d;%ddh{F";
  222. BYTE DLI_SELECT_FONT_ID[] = "\x1D%ddcF\x1D\x30;-%dcoP";
  223. BYTE DLI_DELETE_FONT[] = "\x1D%dddcF";
  224. BYTE SET_SINGLE_BMP[] = "\x1D%d;%dsc{F";
  225. BYTE SET_DOUBLE_BMP[] = "\x1D%d;%d;%dsc{F";
  226. BYTE SET_WIDTH_TBL[] = "\x1D%d;%dcw{F";
  227. BYTE FS_SINGLE_BYTE[] = "\x1D\x31;0mcF";
  228. BYTE FS_DOUBLE_BYTE[] = "\x1D\x31;1mcF";
  229. BYTE PRN_DIRECTION[] = "\x1D%droF";
  230. BYTE SET_CHAR_OFFSET[] = "\x1D\x30;%dcoP";
  231. BYTE SET_CHAR_OFFSET_XY[] = "\x1D%d;%dcoP";
  232. BYTE VERT_FONT_SET[] = "\x1D%dvpC";
  233. BYTE BOLD_SET[] = "\x1D%dweF";
  234. BYTE ITALIC_SET[] = "\x1D%dslF";
  235. BYTE ORG_MODE_IN[] = "\x1Bz\xD0\x01";
  236. BYTE ORG_MODE_OUT[] = "\x1Bz\x00\x01";
  237. BYTE PALETTE_SELECT[] = "Cd,%d,%d*";
  238. BYTE PALETTE_DEFINE[] = "Cf,%d,%d,%d,%d,%d*";
  239. BYTE RECT_FILL[] =
  240. "\x1D" "1owE"
  241. "\x1D" "1tsE"
  242. "\x1D" "0;0;%dspE"
  243. "\x1D" "1dmG"
  244. "\x1D" "%d;%d;%d;%d;0rG"
  245. // do not turn overwrite mode off since it
  246. // has bad effect over white-on-black texts
  247. // "\x1D" "0owE"
  248. "\x1D" "0tsE";
  249. BYTE OVERWRITE[] =
  250. "\x1D" "1owE"
  251. "\x1D" "1tsE"
  252. "\x1D" "1;0;100spE";
  253. #define PSRC_CASETTE_1 0
  254. #define PSRC_CASETTE_2 1
  255. #define PSRC_CASETTE_3 2
  256. #define PSRC_CASETTE_4 3
  257. #define PSRC_CASETTE_5 4
  258. #define PSRC_CASETTE_6 5
  259. #define PSRC_MPF 6
  260. #define PSRC_AUTO 7
  261. BYTE *EJL_SelectPsrc[] = {
  262. " PU=1", " PU=2", " PU=255", " PU=254", " PU=253", " PU=252", " PU=4", " PU=AU" };
  263. BYTE *EJL_SelectOrient[] = {
  264. " ORIENTATION=PORTRAIT", " ORIENTATION=LANDSCAPE" };
  265. BYTE *EJL_SelectRes[] = {
  266. " ##RZ=OFF", " ##RZ=ON" };
  267. BYTE *EPg_SelectRes[] = {
  268. "\x1D" "0;300;300drE\x1D" "1;300;300drE\x1D" "2;240;240drE",
  269. "\x1D" "0;600;600drE\x1D" "1;600;600drE\x1D" "2;240;240drE" };
  270. BYTE *EJL_SetColorTone[] = {
  271. " ##LE=OFF", " ##LE=ON", " ##LE=16" };
  272. #define DUPLEX_NONE 0
  273. #define DUPLEX_SIDE 1
  274. #define DUPLEX_UP 2
  275. BYTE *EJL_SetDuplex[] = {
  276. " ##DC=OFF", " ##DC=DUPON", " ##DC=DUPUP" };
  277. #define XX_TONER_NORMAL 0
  278. #define XX_TONER_SAVE_1 1
  279. #define XX_TONER_SAVE_2 2
  280. BYTE *EJL_SetTonerSave[] = {
  281. " ##TS=NORMAL", " ##TS=1", " ##TS=2" };
  282. // Modification of Color-mode command 2002.3.28 >>>
  283. //BYTE *EJL_SetColorMode[] = {
  284. // " ##CM=OFF", " ##CM=ON" };
  285. BYTE *EJL_SetColorMode[] = {
  286. " ##CM=OFF", " ##CM=NML", " ##CM=ECO", " ##CM=ECO2" };
  287. // Modification of Color-mode command 2002.3.28 <<<
  288. #define XX_SMOOTHING_OFF 0
  289. #define XX_SMOOTHING_ON 1
  290. BYTE *EJL_SetSmoohing[] = {
  291. " RI=OFF", " RI=ON" };
  292. #define XX_JAMRECOVERY_OFF 0
  293. #define XX_JAMRECOVERY_ON 1
  294. BYTE *EJL_SetJamRecovery[] = {
  295. " ##JC=OFF", " ##JC=ON" };
  296. #define XX_MEDIATYPE_1 1
  297. #define XX_MEDIATYPE_2 2
  298. #define XX_MEDIATYPE_3 3
  299. BYTE *EJL_SetMediaType[] = {
  300. " PK=NM", " PK=OS", " PK=TH" };
  301. #define OUTBIN_EXIT_1 1
  302. #define OUTBIN_EXIT_2 2
  303. BYTE *EJL_SelectOutbin[] = {
  304. " ##ET=1", " ##ET=2" };
  305. #if 0 /* OEM doesn't want to fix minidriver */
  306. /* Below is def. for hack code to fix #412276 */
  307. BYTE *COLOR_SELECT_COMMAND[] = {
  308. "\x1Bz\xD0\x01\x43\x63,0,0,0,255*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Black */
  309. "\x1Bz\xD0\x01\x43\x62,255,0,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Red */
  310. "\x1Bz\xD0\x01\x43\x62,0,255,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Green */
  311. "\x1Bz\xD0\x01\x43\x62,0,0,255*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Blue */
  312. "\x1Bz\xD0\x01\x43\x63,0,0,255,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Yellow */
  313. "\x1Bz\xD0\x01\x43\x63,0,255,0,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Magenta */
  314. "\x1Bz\xD0\x01\x43\x63,255,0,0,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Cyan */
  315. "\x1Bz\xD0\x01\x43\x63,0,0,0,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE" /* White */
  316. };
  317. DWORD COLOR_SELECT_COMMAND_LEN[] = { 42, 39, 39, 39, 42, 42, 42, 39 };
  318. BYTE *DUMP_RASTER_COMMAND[] = {
  319. "\x1Bz\xD0\x01\x43\x63,255,0,0,0*\x1Bz\x00\x01\x1D\x30owE\x1D\x30tsE", /* Cyan */
  320. "\x1Bz\xD0\x01\x43\x63,0,255,0,0*\x1Bz\x00\x01\x1D\x30owE\x1D\x30tsE", /* Magenta */
  321. "\x1Bz\xD0\x01\x43\x63,0,0,255,0*\x1Bz\x00\x01\x1D\x30owE\x1D\x30tsE", /* Yellow */
  322. "\x1Bz\xD0\x01\x43\x63,0,0,0,255*\x1Bz\x00\x01\x1D\x30owE\x1D\x30tsE" /* Black */
  323. };
  324. #define DUMP_RASTER_COMMAND_LEN 31
  325. /* End of hack code */
  326. #endif /* OEM doesn't want to fix minidriver */
  327. #define MasterToDevice(p, i) \
  328. ((i) / ((PMYPDEV)(p))->iUnitFactor)
  329. #define PARAM(p,n) \
  330. (*((p)+(n)))
  331. VOID
  332. VSetSelectDLFont(
  333. PDEVOBJ pdevobj,
  334. DWORD dwFontID)
  335. {
  336. PMYPDEV pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  337. BYTE Cmd[BUFFLEN];
  338. WORD wlen = 0;
  339. LPSTR pDestEnd; // 2002.3.6
  340. size_t szRemLen; // 2002.3.6
  341. // Replacement of strsafe-api 2002.3.6 >>>
  342. // wlen += (WORD)wsprintf(Cmd, DLI_SELECT_FONT_ID,
  343. // (dwFontID - FONT_MIN_ID), 0);
  344. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  345. &pDestEnd, &szRemLen,
  346. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  347. DLI_SELECT_FONT_ID, (dwFontID - FONT_MIN_ID), 0)) {
  348. return;
  349. }
  350. wlen += (WORD)(pDestEnd - Cmd);
  351. // Replacement of strsafe-api 2002.3.6 <<<
  352. // if(pOEM->fGeneral & FG_VERT) {
  353. // wlen += wsprintf(&Cmd[wlen], VERT_FONT_SET, 0);
  354. // pOEM->fGeneral &= ~FG_VERT;
  355. //
  356. // }
  357. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  358. pOEM->dwDLFontID = dwFontID;
  359. DL_VERBOSE(("Set/Select: dwFontID=%x\n", dwFontID));
  360. }
  361. //////////////////////////////////////////////////////////////////////////
  362. // Function: OEMEnablePDEV
  363. //////////////////////////////////////////////////////////////////////////
  364. PDEVOEM APIENTRY
  365. OEMEnablePDEV(
  366. PDEVOBJ pdevobj,
  367. PWSTR pPrinterName,
  368. ULONG cPatterns,
  369. HSURF *phsurfPatterns,
  370. ULONG cjGdiInfo,
  371. GDIINFO *pGdiInfo,
  372. ULONG cjDevInfo,
  373. DEVINFO *pDevInfo,
  374. DRVENABLEDATA *pded)
  375. {
  376. PMYPDEV pOEM;
  377. BYTE byOutput[64];
  378. DWORD dwNeeded;
  379. DWORD dwOptionsReturned;
  380. MY_VERBOSE(("\nOEMEnablePdev ENTRY\n"));
  381. if (!pdevobj->pdevOEM)
  382. {
  383. if (!(pdevobj->pdevOEM = MemAllocZ(sizeof(MYPDEV))))
  384. {
  385. ERR(("Faild to allocate memory. (%d)\n",
  386. GetLastError()));
  387. return NULL;
  388. }
  389. }
  390. pOEM = (PMYPDEV)pdevobj->pdevOEM;
  391. pOEM->fGeneral = 0;
  392. pOEM->iEscapement = 0;
  393. pOEM->sHeightDiv = 0;
  394. pOEM->iDevCharOffset = 0;
  395. pOEM->iPaperSource = 0;
  396. pOEM->iDuplex = 0;
  397. pOEM->iTonerSave = 0;
  398. pOEM->iOrientation = 0;
  399. pOEM->iSmoothing = 0;
  400. pOEM->iJamRecovery = 0;
  401. pOEM->iMediaType = 0;
  402. pOEM->iOutBin = 0; //+N5
  403. pOEM->dwDLFontID = UNKNOWN_DLFONT_ID;
  404. pOEM->dwDLSelectFontID = UNKNOWN_DLFONT_ID;
  405. pOEM->dwDLSetFontID = UNKNOWN_DLFONT_ID;
  406. pOEM->wCharCode = 0;
  407. pOEM->iUnitFactor = 1;
  408. // Get MYPDEV member
  409. // ColorMatching
  410. if (!DRVGETDRIVERSETTING(pdevobj, "ColorMatching", byOutput,
  411. sizeof(BYTE) * 64, &dwNeeded, &dwOptionsReturned)) {
  412. ERR(("DrvGetDriverSetting(ColorMatching) Failed\n"));
  413. pOEM->Printer = PRN_N5;
  414. pOEM->iColorMatching = XX_COLORMATCH_NONE;
  415. } else {
  416. MY_VERBOSE((" ColorMatching:[%s]\n", byOutput));
  417. if (!strcmp(byOutput, OPT_COLORMATCH_BRI)) {
  418. pOEM->Printer = PRN_N5;
  419. pOEM->iColorMatching = XX_COLORMATCH_BRI;
  420. } else if (!strcmp(byOutput, OPT_COLORMATCH_TINT)) {
  421. pOEM->Printer = PRN_N5;
  422. pOEM->iColorMatching = XX_COLORMATCH_TINT;
  423. } else if (!strcmp(byOutput, OPT_COLORMATCH_VIV)) {
  424. pOEM->Printer = PRN_N5;
  425. pOEM->iColorMatching = XX_COLORMATCH_VIV;
  426. } else if (!strcmp(byOutput, OPT_COLORMATCH_NONE)) {
  427. pOEM->Printer = PRN_N5;
  428. pOEM->iColorMatching = XX_COLORMATCH_NONE;
  429. } else {
  430. pOEM->Printer = PRN_N5;
  431. pOEM->iColorMatching = XX_COLORMATCH_NONE;
  432. }
  433. }
  434. MY_VERBOSE((" pOEM->Printer:[%d]\n", pOEM->Printer));
  435. MY_VERBOSE((" pOEM->iColorMatching:[%d]\n", pOEM->iColorMatching));
  436. // Resolution
  437. if (!DRVGETDRIVERSETTING(pdevobj, "Resolution", byOutput,
  438. sizeof(BYTE) * 64, &dwNeeded, &dwOptionsReturned)) {
  439. ERR(("DrvGetDriverSetting(Resolution) Failed\n"));
  440. pOEM->iResolution = XX_RES_300DPI;
  441. } else {
  442. MY_VERBOSE((" Resolution:[%s]\n", byOutput));
  443. if (!strcmp(byOutput, OPT_1)) {
  444. pOEM->iResolution = XX_RES_300DPI;
  445. pOEM->iUnitFactor = 4;
  446. pOEM->sHeightDiv = 1;
  447. } else if (!strcmp(byOutput, OPT_2)) {
  448. pOEM->iResolution = XX_RES_600DPI;
  449. pOEM->iUnitFactor = 2;
  450. pOEM->sHeightDiv = 4;
  451. }
  452. }
  453. MY_VERBOSE((" pOEM->iResolution:[%d]\n", pOEM->iResolution));
  454. MY_VERBOSE((" pOEM->iUnitFactor:[%d]\n", pOEM->iUnitFactor));
  455. MY_VERBOSE((" pOEM->sHeightDiv:[%d]\n", pOEM->sHeightDiv));
  456. // Dithering
  457. if (!DRVGETDRIVERSETTING(pdevobj, "Dithering", byOutput,
  458. sizeof(BYTE) * 64, &dwNeeded, &dwOptionsReturned)) {
  459. ERR(("DrvGetDriverSetting(Dithering) Failed\n"));
  460. pOEM->iDithering = XX_DITH_NON;
  461. } else {
  462. MY_VERBOSE((" Dithering:[%s]\n", byOutput));
  463. if (!strcmp(byOutput, OPT_DITH_NORMAL)) {
  464. pOEM->iDithering = XX_DITH_NORMAL;
  465. } else if (!strcmp(byOutput, OPT_DITH_DETAIL)) {
  466. pOEM->iDithering = XX_DITH_DETAIL;
  467. } else if (!strcmp(byOutput, OPT_DITH_EMPTY)) {
  468. pOEM->iDithering = XX_DITH_EMPTY;
  469. } else if (!strcmp(byOutput, OPT_DITH_SPREAD)) {
  470. pOEM->iDithering = XX_DITH_SPREAD;
  471. } else {
  472. pOEM->iDithering = XX_DITH_NON;
  473. }
  474. }
  475. MY_VERBOSE((" pOEM->iDithering:[%d]\n", pOEM->iDithering));
  476. // BitFont
  477. if (!DRVGETDRIVERSETTING(pdevobj, "BitFont", byOutput,
  478. sizeof(BYTE) * 64, &dwNeeded, &dwOptionsReturned)) {
  479. ERR(("DrvGetDriverSetting(BitFont) Failed\n"));
  480. pOEM->iBitFont = XX_BITFONT_OFF;
  481. } else {
  482. MY_VERBOSE((" BitFont:[%s]\n", byOutput));
  483. if (!strcmp(byOutput, OPT_2)) {
  484. pOEM->iBitFont = XX_BITFONT_OFF;
  485. } else if (!strcmp(byOutput, OPT_1)) {
  486. pOEM->iBitFont = XX_BITFONT_ON;
  487. } else {
  488. pOEM->iBitFont = XX_BITFONT_OFF;
  489. }
  490. }
  491. MY_VERBOSE((" pOEM->iBitFont:[%d]\n", pOEM->iBitFont));
  492. // CmyBlack
  493. if (!DRVGETDRIVERSETTING(pdevobj, "CmyBlack", byOutput,
  494. sizeof(BYTE) * 64, &dwNeeded, &dwOptionsReturned)) {
  495. ERR(("DrvGetDriverSetting(CmyBlack) Failed\n"));
  496. pOEM->iCmyBlack = XX_CMYBLACK_NONE;
  497. } else {
  498. MY_VERBOSE((" CmyBlack:[%s]\n", byOutput));
  499. // CASIO 2001/02/15 ->
  500. if (pOEM->iDithering == XX_DITH_NON) {
  501. pOEM->iCmyBlack = XX_CMYBLACK_NONE;
  502. // if (!strcmp(byOutput, OPT_CMYBLACK_GRYBLK)) {
  503. } else if (!strcmp(byOutput, OPT_CMYBLACK_GRYBLK)) {
  504. // CASIO 2001/02/15 <-
  505. pOEM->iCmyBlack = XX_CMYBLACK_GRYBLK;
  506. } else if (!strcmp(byOutput, OPT_CMYBLACK_BLKTYPE1)) {
  507. pOEM->iCmyBlack = XX_CMYBLACK_BLKTYPE1;
  508. } else if (!strcmp(byOutput, OPT_CMYBLACK_BLKTYPE2)) {
  509. pOEM->iCmyBlack = XX_CMYBLACK_BLKTYPE2;
  510. } else if (!strcmp(byOutput, OPT_CMYBLACK_BLACK)) {
  511. pOEM->iCmyBlack = XX_CMYBLACK_BLACK;
  512. } else if (!strcmp(byOutput, OPT_CMYBLACK_TYPE1)) {
  513. pOEM->iCmyBlack = XX_CMYBLACK_TYPE1;
  514. } else if (!strcmp(byOutput, OPT_CMYBLACK_TYPE2)) {
  515. pOEM->iCmyBlack = XX_CMYBLACK_TYPE2;
  516. } else {
  517. pOEM->iCmyBlack = XX_CMYBLACK_NONE;
  518. }
  519. }
  520. MY_VERBOSE((" pOEM->iCmyBlack:[%d]\n", pOEM->iCmyBlack));
  521. // ColorMode
  522. if (!DRVGETDRIVERSETTING(pdevobj, "ColorMode", byOutput,
  523. sizeof(BYTE) * 64, &dwNeeded, &dwOptionsReturned)) {
  524. ERR(("DrvGetDriverSetting(ColorMode) Failed\n"));
  525. pOEM->iColor = XX_COLOR;
  526. } else {
  527. MY_VERBOSE((" ColorMode:[%s]\n", byOutput));
  528. if (!strcmp(byOutput, OPT_COLOR_SINGLE)) {
  529. pOEM->iColor = XX_COLOR_SINGLE;
  530. } else if (!strcmp(byOutput, OPT_COLOR_MANY)) {
  531. pOEM->iColor = XX_COLOR_MANY;
  532. } else if (!strcmp(byOutput, OPT_COLOR_MANY2)) {
  533. pOEM->iColor = XX_COLOR_MANY2;
  534. } else if (!strcmp(byOutput, OPT_COLOR)) {
  535. pOEM->iColor = XX_COLOR;
  536. } else if (!strcmp(byOutput, OPT_MONO)) {
  537. pOEM->iColor = XX_MONO;
  538. }
  539. }
  540. MY_VERBOSE((" pOEM->iColor:[%d]\n", pOEM->iColor));
  541. // Compress
  542. if (!DRVGETDRIVERSETTING(pdevobj, "Compress", byOutput,
  543. sizeof(BYTE) * 64, &dwNeeded, &dwOptionsReturned)) {
  544. ERR(("DrvGetDriverSetting(Compress) Failed\n"));
  545. pOEM->iCompress = XX_COMPRESS_OFF;
  546. } else {
  547. MY_VERBOSE((" Compress:[%s]\n", byOutput));
  548. if (!strcmp(byOutput, OPT_AUTO)) {
  549. pOEM->iCompress = XX_COMPRESS_AUTO;
  550. } else if (!strcmp(byOutput, OPT_RASTER)) {
  551. pOEM->iCompress = XX_COMPRESS_RASTER;
  552. } else {
  553. pOEM->iCompress = XX_COMPRESS_OFF;
  554. }
  555. }
  556. MY_VERBOSE((" pOEM->iCompress:[%d]\n", pOEM->iCompress));
  557. MY_VERBOSE((" pdevobj->pPublicDM->dmICMMethod:[%d]\n", pdevobj->pPublicDM->dmICMMethod));
  558. if (pdevobj->pPublicDM->dmICMMethod == 1) {
  559. pOEM->iIcmMode = XX_ICM_NON;
  560. } else {
  561. pOEM->iIcmMode = XX_ICM_USE;
  562. }
  563. MY_VERBOSE((" pOEM->iICMMethod:[%d]\n", pOEM->iIcmMode));
  564. if (pOEM->iColor == XX_COLOR_SINGLE
  565. || pOEM->iColor == XX_COLOR_MANY
  566. || pOEM->iColor == XX_COLOR_MANY2) { //+N5
  567. if (ColMatchInit(pdevobj) == FALSE) {
  568. return NULL;
  569. }
  570. }
  571. MY_VERBOSE(("OEMEnablePdev END\n"));
  572. return pdevobj->pdevOEM;
  573. }
  574. //////////////////////////////////////////////////////////////////////////
  575. // Function: OEMImageProcessing
  576. //////////////////////////////////////////////////////////////////////////
  577. PBYTE APIENTRY
  578. OEMImageProcessing(
  579. PDEVOBJ pdevobj,
  580. PBYTE pSrcBitmap,
  581. PBITMAPINFOHEADER pBitmapInfoHeader,
  582. PBYTE pColorTable,
  583. DWORD dwCallbackID,
  584. PIPPARAMS pIPParams)
  585. {
  586. BOOL bret;
  587. if (pIPParams->bBlankBand) {
  588. MY_VERBOSE(("BB=TRUE\n"));
  589. bret = TRUE; // Not spool to printer
  590. }
  591. else {
  592. MY_VERBOSE(("BB=FALSE\n"));
  593. // DIB spool to printer
  594. bret = (DIBtoPrn(pdevobj, pSrcBitmap, pBitmapInfoHeader, pColorTable, pIPParams)) ? TRUE : FALSE;
  595. }
  596. return (PBYTE)IntToPtr(bret);
  597. }
  598. //////////////////////////////////////////////////////////////////////////
  599. // Function: OEMDisablePDEV
  600. //////////////////////////////////////////////////////////////////////////
  601. VOID APIENTRY
  602. OEMDisablePDEV(
  603. PDEVOBJ pdevobj)
  604. {
  605. PMYPDEV pOEM = (PMYPDEV)pdevobj->pdevOEM;
  606. if (pdevobj->pdevOEM)
  607. {
  608. if (pOEM->iColor == XX_COLOR_SINGLE
  609. || pOEM->iColor == XX_COLOR_MANY
  610. || pOEM->iColor == XX_COLOR_MANY2) { //+N5
  611. ColMatchDisable(pdevobj);
  612. }
  613. MemFree(pdevobj->pdevOEM);
  614. pdevobj->pdevOEM = NULL;
  615. }
  616. return;
  617. }
  618. BOOL APIENTRY OEMResetPDEV(
  619. PDEVOBJ pdevobjOld,
  620. PDEVOBJ pdevobjNew)
  621. {
  622. PMYPDEV pOEMOld, pOEMNew;
  623. UINT num001;
  624. MY_VERBOSE(("OEMResetPDEV() Start\n"));
  625. pOEMOld = (PMYPDEV)pdevobjOld->pdevOEM;
  626. pOEMNew = (PMYPDEV)pdevobjNew->pdevOEM;
  627. if (pOEMOld != NULL && pOEMNew != NULL) {
  628. // *pOEMNew = *pOEMOld;
  629. pOEMNew->fGeneral = pOEMOld->fGeneral;
  630. pOEMNew->iEscapement = pOEMOld->iEscapement;
  631. pOEMNew->sHeightDiv = pOEMOld->sHeightDiv;
  632. pOEMNew->iDevCharOffset = pOEMOld->iDevCharOffset;
  633. pOEMNew->iPaperSource = pOEMOld->iPaperSource;
  634. pOEMNew->iDuplex = pOEMOld->iDuplex;
  635. pOEMNew->iTonerSave = pOEMOld->iTonerSave;
  636. pOEMNew->iOrientation = pOEMOld->iOrientation;
  637. pOEMNew->iResolution = pOEMOld->iResolution;
  638. pOEMNew->iColor = pOEMOld->iColor;
  639. pOEMNew->iSmoothing = pOEMOld->iSmoothing;
  640. pOEMNew->iJamRecovery = pOEMOld->iJamRecovery;
  641. pOEMNew->iMediaType = pOEMOld->iMediaType;
  642. pOEMNew->iOutBin = pOEMOld->iOutBin;
  643. pOEMNew->iIcmMode = pOEMOld->iIcmMode;
  644. pOEMNew->iUnitFactor = pOEMOld->iUnitFactor;
  645. pOEMNew->iDithering = pOEMOld->iDithering;
  646. pOEMNew->iColorMatching = pOEMOld->iColorMatching;
  647. pOEMNew->iBitFont = pOEMOld->iBitFont;
  648. pOEMNew->iCmyBlack = pOEMOld->iCmyBlack;
  649. pOEMNew->iTone = pOEMOld->iTone;
  650. pOEMNew->iPaperSize = pOEMOld->iPaperSize;
  651. pOEMNew->iCompress = pOEMOld->iCompress;
  652. pOEMNew->Printer = pOEMOld->Printer;
  653. pOEMNew->wRectWidth = pOEMOld->wRectWidth;
  654. pOEMNew->wRectHeight = pOEMOld->wRectHeight;
  655. pOEMNew->dwDLFontID = pOEMOld->dwDLFontID;
  656. pOEMNew->dwDLSelectFontID = pOEMOld->dwDLSelectFontID;
  657. pOEMNew->dwDLSetFontID = pOEMOld->dwDLSetFontID;
  658. pOEMNew->wCharCode = pOEMOld->wCharCode;
  659. pOEMNew->Col.wReso = pOEMOld->Col.wReso;
  660. pOEMNew->Col.ColMon = pOEMOld->Col.ColMon;
  661. pOEMNew->Col.DatBit = pOEMOld->Col.DatBit;
  662. pOEMNew->Col.BytDot = pOEMOld->Col.BytDot;
  663. pOEMNew->Col.Mch.Mode = pOEMOld->Col.Mch.Mode;
  664. pOEMNew->Col.Mch.GryKToner= pOEMOld->Col.Mch.GryKToner;
  665. pOEMNew->Col.Mch.Viv = pOEMOld->Col.Mch.Viv;
  666. pOEMNew->Col.Mch.LutNum = pOEMOld->Col.Mch.LutNum;
  667. pOEMNew->Col.Mch.Diz = pOEMOld->Col.Mch.Diz;
  668. pOEMNew->Col.Mch.Tnr = pOEMOld->Col.Mch.Tnr;
  669. pOEMNew->Col.Mch.CmyBlk = pOEMOld->Col.Mch.CmyBlk;
  670. pOEMNew->Col.Mch.Speed = pOEMOld->Col.Mch.Speed;
  671. pOEMNew->Col.Mch.Gos32 = pOEMOld->Col.Mch.Gos32;
  672. pOEMNew->Col.Mch.PColor = pOEMOld->Col.Mch.PColor;
  673. pOEMNew->Col.Mch.Ucr = pOEMOld->Col.Mch.Ucr;
  674. pOEMNew->Col.Mch.SubDef = pOEMOld->Col.Mch.SubDef;
  675. pOEMNew->Col.Mch.Bright = pOEMOld->Col.Mch.Bright;
  676. pOEMNew->Col.Mch.Contrast = pOEMOld->Col.Mch.Contrast;
  677. pOEMNew->Col.Mch.GamRed = pOEMOld->Col.Mch.GamRed;
  678. pOEMNew->Col.Mch.GamGreen = pOEMOld->Col.Mch.GamGreen;
  679. pOEMNew->Col.Mch.GamBlue = pOEMOld->Col.Mch.GamBlue;
  680. pOEMNew->Col.Mch.CchMch = pOEMOld->Col.Mch.CchMch;
  681. pOEMNew->Col.Mch.CchCnv = pOEMOld->Col.Mch.CchCnv;
  682. pOEMNew->Col.Mch.CchRGB = pOEMOld->Col.Mch.CchRGB;
  683. pOEMNew->Col.Mch.CchCMYK = pOEMOld->Col.Mch.CchCMYK;
  684. pOEMNew->Col.Mch.LutMakGlb= pOEMOld->Col.Mch.LutMakGlb;
  685. pOEMNew->Col.Mch.KToner = pOEMOld->Col.Mch.KToner;
  686. pOEMNew->Col.Dot = pOEMOld->Col.Dot;
  687. if (NULL != pOEMNew->Col.lpColIF) { MemFree(pOEMNew->Col.lpColIF); }
  688. pOEMNew->Col.lpColIF = pOEMOld->Col.lpColIF;
  689. pOEMOld->Col.lpColIF = NULL;
  690. pOEMNew->Col.Mch.lpRGBInf = pOEMOld->Col.Mch.lpRGBInf;
  691. pOEMNew->Col.Mch.lpCMYKInf = pOEMOld->Col.Mch.lpCMYKInf;
  692. pOEMNew->Col.Mch.lpColMch = pOEMOld->Col.Mch.lpColMch;
  693. pOEMNew->Col.Mch.lpDizInf = pOEMOld->Col.Mch.lpDizInf;
  694. pOEMOld->Col.Mch.lpRGBInf = NULL;
  695. pOEMOld->Col.Mch.lpCMYKInf = NULL;
  696. pOEMOld->Col.Mch.lpColMch = NULL;
  697. pOEMOld->Col.Mch.lpDizInf = NULL;
  698. if (NULL != pOEMNew->Col.LutTbl) { MemFree(pOEMNew->Col.LutTbl); }
  699. pOEMNew->Col.LutTbl = pOEMOld->Col.LutTbl;
  700. pOEMOld->Col.LutTbl = NULL;
  701. if (NULL != pOEMNew->Col.CchRGB) { MemFree(pOEMNew->Col.CchRGB); }
  702. pOEMNew->Col.CchRGB = pOEMOld->Col.CchRGB;
  703. pOEMOld->Col.CchRGB = NULL;
  704. if (NULL != pOEMNew->Col.CchCMYK) { MemFree(pOEMNew->Col.CchCMYK); }
  705. pOEMNew->Col.CchCMYK = pOEMOld->Col.CchCMYK;
  706. pOEMOld->Col.CchCMYK = NULL;
  707. for (num001 = 0; num001 < 4; num001++) {
  708. if (NULL != pOEMNew->Col.DizTbl[num001]) { MemFree(pOEMNew->Col.DizTbl[num001]); }
  709. pOEMNew->Col.DizTbl[num001] = pOEMOld->Col.DizTbl[num001];
  710. pOEMOld->Col.DizTbl[num001] = NULL;
  711. }
  712. if (NULL != pOEMNew->Col.lpTmpRGB) { MemFree(pOEMNew->Col.lpTmpRGB); }
  713. pOEMNew->Col.lpTmpRGB = pOEMOld->Col.lpTmpRGB;
  714. pOEMOld->Col.lpTmpRGB = NULL;
  715. if (NULL != pOEMNew->Col.lpTmpCMYK) { MemFree(pOEMNew->Col.lpTmpCMYK); }
  716. pOEMNew->Col.lpTmpCMYK = pOEMOld->Col.lpTmpCMYK;
  717. pOEMOld->Col.lpTmpCMYK = NULL;
  718. if (NULL != pOEMNew->Col.lpDrwInf) { MemFree(pOEMNew->Col.lpDrwInf); }
  719. pOEMNew->Col.lpDrwInf = pOEMOld->Col.lpDrwInf;
  720. pOEMOld->Col.lpDrwInf = NULL;
  721. if (NULL != pOEMNew->Col.lpLut032) { MemFree(pOEMNew->Col.lpLut032); }
  722. pOEMNew->Col.lpLut032 = pOEMOld->Col.lpLut032;
  723. pOEMOld->Col.lpLut032 = NULL;
  724. if (NULL != pOEMNew->Col.lpUcr) { MemFree(pOEMNew->Col.lpUcr); }
  725. pOEMNew->Col.lpUcr = pOEMOld->Col.lpUcr;
  726. pOEMOld->Col.lpUcr = NULL;
  727. if (NULL != pOEMNew->Col.lpLutMakGlb) { MemFree(pOEMNew->Col.lpLutMakGlb); }
  728. pOEMNew->Col.lpLutMakGlb = pOEMOld->Col.lpLutMakGlb;
  729. pOEMOld->Col.lpLutMakGlb = NULL;
  730. if (NULL != pOEMNew->Col.lpGryTbl) { MemFree(pOEMNew->Col.lpGryTbl); }
  731. pOEMNew->Col.lpGryTbl = pOEMOld->Col.lpGryTbl;
  732. pOEMOld->Col.lpGryTbl = NULL;
  733. }
  734. return TRUE;
  735. }
  736. //////////////////////////////////////////////////////////////////////////
  737. // Function: OEMCommandCallback
  738. //////////////////////////////////////////////////////////////////////////
  739. INT
  740. APIENTRY
  741. OEMCommandCallback(
  742. PDEVOBJ pdevobj,
  743. DWORD dwCmdCbID,
  744. DWORD dwCount,
  745. PDWORD pdwParams
  746. )
  747. {
  748. INT iRet = 0;
  749. BYTE Cmd[BUFFLEN];
  750. PMYPDEV pOEM;
  751. WORD wlen;
  752. WORD wGray;
  753. DWORD dwTempX, dwTempY;
  754. CMYK TmpCmyk;
  755. RGBS TmpRgb;
  756. // MSKK 99/6/24
  757. WORD wPalID;
  758. LPSTR pDestEnd; // 2002.3.6
  759. size_t szRemLen; // 2002.3.6
  760. size_t pcb; // 2002.3.6
  761. MY_VERBOSE(("OEMCommandCallback() entry.\n"));
  762. //
  763. // verify pdevobj okay
  764. //
  765. ASSERT(VALID_PDEVOBJ(pdevobj));
  766. //
  767. // fill in printer commands
  768. //
  769. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  770. switch (dwCmdCbID) {
  771. case FS_BOLD_ON:
  772. case FS_BOLD_OFF:
  773. if(pdwParams[0])
  774. pOEM->fGeneral |= FG_BOLD;
  775. else
  776. pOEM->fGeneral &= ~FG_BOLD;
  777. // Replacement of strsafe-api 2002.3.6 >>>
  778. // wlen = (WORD)wsprintf(Cmd,BOLD_SET, (pOEM->fGeneral & FG_BOLD)?15:0);
  779. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  780. &pDestEnd, &szRemLen,
  781. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  782. BOLD_SET, (pOEM->fGeneral & FG_BOLD)?15:0)) {
  783. break;
  784. }
  785. wlen = (WORD)(pDestEnd - Cmd);
  786. // Replacement of strsafe-api 2002.3.6 <<<
  787. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  788. break;
  789. case FS_ITALIC_ON:
  790. case FS_ITALIC_OFF:
  791. if(pdwParams[0])
  792. pOEM->fGeneral |= FG_ITALIC;
  793. else
  794. pOEM->fGeneral &= ~FG_ITALIC;
  795. // Replacement of strsafe-api 2002.3.6 >>>
  796. // wlen = (WORD)wsprintf(Cmd,ITALIC_SET, (pOEM->fGeneral & FG_ITALIC)?346:0);
  797. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  798. &pDestEnd, &szRemLen,
  799. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  800. ITALIC_SET, (pOEM->fGeneral & FG_ITALIC)?346:0)) {
  801. break;
  802. }
  803. wlen = (WORD)(pDestEnd - Cmd);
  804. // Replacement of strsafe-api 2002.3.6 <<<
  805. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  806. break;
  807. case TEXT_FS_SINGLE_BYTE:
  808. // Replacement of strsafe-api 2002.3.6 >>>
  809. // strcpy(Cmd,FS_SINGLE_BYTE);
  810. // wlen = (WORD)strlen( Cmd );
  811. // wlen += (WORD)wsprintf(&Cmd[wlen],PRN_DIRECTION,pOEM->iEscapement);
  812. if (S_OK != StringCbCopyExA(Cmd, sizeof(Cmd), FS_SINGLE_BYTE,
  813. &pDestEnd, &szRemLen,
  814. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  815. break;
  816. }
  817. wlen = (WORD)(pDestEnd - Cmd);
  818. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  819. &pDestEnd, &szRemLen,
  820. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  821. PRN_DIRECTION, pOEM->iEscapement)) {
  822. break;
  823. }
  824. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  825. // Replacement of strsafe-api 2002.3.6 <<<
  826. if (pOEM->fGeneral & FG_VERT)
  827. {
  828. // Replacement of strsafe-api 2002.3.6 >>>
  829. // wlen += (WORD)wsprintf(&Cmd[wlen], VERT_FONT_SET, 0);
  830. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  831. &pDestEnd, &szRemLen,
  832. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  833. VERT_FONT_SET, 0)) {
  834. break;
  835. }
  836. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  837. // Replacement of strsafe-api 2002.3.6 <<<
  838. }
  839. pOEM->fGeneral &= ~FG_DOUBLE;
  840. // Replacement of strsafe-api 2002.3.6 >>>
  841. // wlen += (WORD)wsprintf(&Cmd[wlen],BOLD_SET,
  842. // (pOEM->fGeneral & FG_BOLD)?15:0);
  843. // wlen += (WORD)wsprintf(&Cmd[wlen],ITALIC_SET,
  844. // (pOEM->fGeneral & FG_ITALIC)?346:0);
  845. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  846. &pDestEnd, &szRemLen,
  847. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  848. BOLD_SET, (pOEM->fGeneral & FG_BOLD)?15:0)) {
  849. break;
  850. }
  851. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  852. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  853. &pDestEnd, &szRemLen,
  854. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  855. ITALIC_SET, (pOEM->fGeneral & FG_ITALIC)?346:0)) {
  856. break;
  857. }
  858. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  859. // Replacement of strsafe-api 2002.3.6 <<<
  860. WRITESPOOLBUF(pdevobj, Cmd, wlen);
  861. break;
  862. case TEXT_FS_DOUBLE_BYTE:
  863. // Replacement of strsafe-api 2002.3.6 >>>
  864. // strcpy(Cmd,FS_DOUBLE_BYTE);
  865. // wlen = (WORD)strlen( Cmd );
  866. // wlen += (WORD)wsprintf(&Cmd[wlen],PRN_DIRECTION,pOEM->iEscapement);
  867. if (S_OK != StringCbCopyExA(Cmd, sizeof(Cmd), FS_DOUBLE_BYTE,
  868. &pDestEnd, &szRemLen,
  869. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  870. break;
  871. }
  872. wlen = (WORD)(pDestEnd - Cmd);
  873. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  874. &pDestEnd, &szRemLen,
  875. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  876. PRN_DIRECTION, pOEM->iEscapement)) {
  877. break;
  878. }
  879. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  880. // Replacement of strsafe-api 2002.3.6 <<<
  881. if (pOEM->fGeneral & FG_VERT)
  882. {
  883. // Replacement of strsafe-api 2002.3.6 >>>
  884. // wlen += (WORD)wsprintf(&Cmd[wlen], VERT_FONT_SET, 1);
  885. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  886. &pDestEnd, &szRemLen,
  887. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  888. VERT_FONT_SET, 1)) {
  889. break;
  890. }
  891. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  892. // Replacement of strsafe-api 2002.3.6 <<<
  893. }
  894. pOEM->fGeneral |= FG_DOUBLE;
  895. // Replacement of strsafe-api 2002.3.6 >>>
  896. // wlen += (WORD)wsprintf(&Cmd[wlen],BOLD_SET,
  897. // (pOEM->fGeneral & FG_BOLD)?15:0);
  898. // wlen += (WORD)wsprintf(&Cmd[wlen],ITALIC_SET,
  899. // (pOEM->fGeneral & FG_ITALIC)?346:0);
  900. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  901. &pDestEnd, &szRemLen,
  902. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  903. BOLD_SET, (pOEM->fGeneral & FG_BOLD)?15:0)) {
  904. break;
  905. }
  906. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  907. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  908. &pDestEnd, &szRemLen,
  909. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  910. ITALIC_SET, (pOEM->fGeneral & FG_ITALIC)?346:0)) {
  911. break;
  912. }
  913. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  914. // Replacement of strsafe-api 2002.3.6 <<<
  915. WRITESPOOLBUF(pdevobj, Cmd, wlen);
  916. break;
  917. case PC_PORTRAIT:
  918. pOEM->iOrientation = 0;
  919. break;
  920. case PC_LANDSCAPE:
  921. pOEM->iOrientation = 1;
  922. break;
  923. case PC_DUPLEX_NONE:
  924. pOEM->iDuplex = (DUPLEX_NONE + 1);
  925. break;
  926. case PC_DUPLEX_VERT:
  927. pOEM->iDuplex =
  928. (pOEM->iOrientation ?
  929. (DUPLEX_UP + 1) : (DUPLEX_SIDE + 1));
  930. break;
  931. case PC_DUPLEX_HORZ:
  932. pOEM->iDuplex =
  933. (pOEM->iOrientation ?
  934. (DUPLEX_SIDE + 1) : (DUPLEX_UP + 1));
  935. break;
  936. case PSRC_SELECT_MPF:
  937. pOEM->iPaperSource = PSRC_MPF;
  938. break;
  939. case PSRC_SELECT_CASETTE_1:
  940. pOEM->iPaperSource = PSRC_CASETTE_1;
  941. break;
  942. case PSRC_SELECT_CASETTE_2:
  943. pOEM->iPaperSource = PSRC_CASETTE_2;
  944. break;
  945. case PSRC_SELECT_CASETTE_3:
  946. pOEM->iPaperSource = PSRC_CASETTE_3;
  947. break;
  948. case PSRC_SELECT_CASETTE_4:
  949. pOEM->iPaperSource = PSRC_CASETTE_4;
  950. break;
  951. case PSRC_SELECT_CASETTE_5:
  952. pOEM->iPaperSource = PSRC_CASETTE_5;
  953. break;
  954. case PSRC_SELECT_CASETTE_6:
  955. pOEM->iPaperSource = PSRC_CASETTE_6;
  956. break;
  957. case PSRC_SELECT_AUTO:
  958. pOEM->iPaperSource = PSRC_AUTO;
  959. break;
  960. case PC_BEGINDOC:
  961. // EJL commands
  962. WRITESPOOLBUF(pdevobj,
  963. BEGINDOC_EJL_BEGIN,
  964. BYTE_LENGTH(BEGINDOC_EJL_BEGIN));
  965. wlen = 0;
  966. // Replacement of strsafe-api 2002.3.6 >>>
  967. // strcpy( &Cmd[wlen], EJL_SelectPsrc[pOEM->iPaperSource] );
  968. // wlen += (WORD)strlen( &Cmd[wlen] );
  969. // strcpy( &Cmd[wlen], EJL_SelectOrient[pOEM->iOrientation] );
  970. // wlen += (WORD)strlen( &Cmd[wlen] );
  971. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SelectPsrc[pOEM->iPaperSource],
  972. &pDestEnd, &szRemLen,
  973. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  974. break;
  975. }
  976. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  977. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SelectOrient[pOEM->iOrientation],
  978. &pDestEnd, &szRemLen,
  979. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  980. break;
  981. }
  982. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  983. // Replacement of strsafe-api 2002.3.6 <<<
  984. // CASIO extention
  985. // Replacement of strsafe-api 2002.3.6 >>>
  986. // strcpy( &Cmd[wlen], EJL_SelectRes[pOEM->iResolution] );
  987. // wlen += (WORD)strlen( &Cmd[wlen] );
  988. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SelectRes[pOEM->iResolution],
  989. &pDestEnd, &szRemLen,
  990. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  991. break;
  992. }
  993. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  994. // Replacement of strsafe-api 2002.3.6 <<<
  995. // Modification of Color-mode command 2002.3.28 >>>
  996. #if 0
  997. if (pOEM->iColor > 0) {
  998. // Replacement of strsafe-api 2002.3.6 >>>
  999. // strcpy( &Cmd[wlen], EJL_SetColorMode[1] );
  1000. // wlen += (WORD)strlen( &Cmd[wlen] );
  1001. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetColorMode[1],
  1002. &pDestEnd, &szRemLen,
  1003. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1004. break;
  1005. }
  1006. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1007. // Replacement of strsafe-api 2002.3.6 <<<
  1008. }
  1009. #else
  1010. if (pOEM->iColor > 0) {
  1011. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetColorMode[1],
  1012. &pDestEnd, &szRemLen,
  1013. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1014. break;
  1015. }
  1016. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1017. } else {
  1018. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetColorMode[0],
  1019. &pDestEnd, &szRemLen,
  1020. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1021. break;
  1022. }
  1023. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1024. }
  1025. #endif
  1026. // Modification of Color-mode command 2002.3.28 <<<
  1027. if (pOEM->iDuplex > 0) {
  1028. // Replacement of strsafe-api 2002.3.6 >>>
  1029. // strcpy( &Cmd[wlen], EJL_SetDuplex[pOEM->iDuplex - 1] );
  1030. // wlen += (WORD)strlen( &Cmd[wlen] );
  1031. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetDuplex[pOEM->iDuplex - 1],
  1032. &pDestEnd, &szRemLen,
  1033. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1034. break;
  1035. }
  1036. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1037. // Replacement of strsafe-api 2002.3.6 <<<
  1038. }
  1039. if (pOEM->iColor == XX_COLOR_MANY) {
  1040. // Replacement of strsafe-api 2002.3.6 >>>
  1041. // strcpy( &Cmd[wlen], EJL_SetColorTone[1] );
  1042. if (S_OK != StringCbCopyA(&Cmd[wlen],sizeof(Cmd)-wlen,EJL_SetColorTone[1]))
  1043. break;
  1044. // Replacement of strsafe-api 2002.3.6 <<<
  1045. } else if (pOEM->iColor == XX_COLOR_MANY2) {
  1046. // Replacement of strsafe-api 2002.3.6 >>>
  1047. // strcpy( &Cmd[wlen], EJL_SetColorTone[2] );
  1048. if (S_OK != StringCbCopyA(&Cmd[wlen],sizeof(Cmd)-wlen,EJL_SetColorTone[2]))
  1049. break;
  1050. // Replacement of strsafe-api 2002.3.6 <<<
  1051. } else {
  1052. // Replacement of strsafe-api 2002.3.6 >>>
  1053. // strcpy( &Cmd[wlen], EJL_SetColorTone[0] );
  1054. if (S_OK != StringCbCopyA(&Cmd[wlen],sizeof(Cmd)-wlen,EJL_SetColorTone[0]))
  1055. break;
  1056. // Replacement of strsafe-api 2002.3.6 <<<
  1057. }
  1058. // Replacement of strsafe-api 2002.3.6 >>>
  1059. // wlen += (WORD)strlen( &Cmd[wlen] );
  1060. if (S_OK != StringCbLengthA(&Cmd[wlen], sizeof(Cmd)-wlen, &pcb))
  1061. break;
  1062. wlen += (WORD)pcb;
  1063. // Replacement of strsafe-api 2002.3.6 <<<
  1064. // Replacement of strsafe-api 2002.3.6 >>>
  1065. // strcpy( &Cmd[wlen], EJL_SetTonerSave[pOEM->iTonerSave] );
  1066. // wlen += (WORD)strlen( &Cmd[wlen] );
  1067. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetTonerSave[pOEM->iTonerSave],
  1068. &pDestEnd, &szRemLen,
  1069. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1070. break;
  1071. }
  1072. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1073. // Replacement of strsafe-api 2002.3.6 <<<
  1074. // Replacement of strsafe-api 2002.3.6 >>>
  1075. // strcpy( &Cmd[wlen], EJL_SetSmoohing[pOEM->iSmoothing] );
  1076. // wlen += (WORD)strlen( &Cmd[wlen] );
  1077. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetSmoohing[pOEM->iSmoothing],
  1078. &pDestEnd, &szRemLen,
  1079. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1080. break;
  1081. }
  1082. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1083. // Replacement of strsafe-api 2002.3.6 <<<
  1084. // Replacement of strsafe-api 2002.3.6 >>>
  1085. // strcpy( &Cmd[wlen], EJL_SetJamRecovery[pOEM->iJamRecovery] );
  1086. // wlen += (WORD)strlen( &Cmd[wlen] );
  1087. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetJamRecovery[pOEM->iJamRecovery],
  1088. &pDestEnd, &szRemLen,
  1089. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1090. break;
  1091. }
  1092. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1093. // Replacement of strsafe-api 2002.3.6 <<<
  1094. // Replacement of strsafe-api 2002.3.6 >>>
  1095. // strcpy( &Cmd[wlen], " ##SN=ON");
  1096. // wlen += (WORD)strlen( &Cmd[wlen] );
  1097. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, " ##SN=ON",
  1098. &pDestEnd, &szRemLen,
  1099. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1100. break;
  1101. }
  1102. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1103. // Replacement of strsafe-api 2002.3.6 <<<
  1104. if (pOEM->iMediaType > 0) {
  1105. // Replacement of strsafe-api 2002.3.6 >>>
  1106. // strcpy( &Cmd[wlen], EJL_SetMediaType[pOEM->iMediaType - 1] );
  1107. // wlen += (WORD)strlen( &Cmd[wlen] );
  1108. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetMediaType[pOEM->iMediaType - 1],
  1109. &pDestEnd, &szRemLen,
  1110. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1111. break;
  1112. }
  1113. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1114. // Replacement of strsafe-api 2002.3.6 <<<
  1115. }
  1116. //+N5 Begin
  1117. if (pOEM->iOutBin > 0) {
  1118. // Replacement of strsafe-api 2002.3.6 >>>
  1119. // strcpy( &Cmd[wlen], EJL_SelectOutbin[pOEM->iOutBin -1] );
  1120. // wlen += (WORD)strlen( &Cmd[wlen] );
  1121. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SelectOutbin[pOEM->iOutBin -1],
  1122. &pDestEnd, &szRemLen,
  1123. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1124. break;
  1125. }
  1126. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1127. // Replacement of strsafe-api 2002.3.6 <<<
  1128. }
  1129. //+N5 End
  1130. WRITESPOOLBUF(pdevobj, Cmd, wlen );
  1131. WRITESPOOLBUF(pdevobj,
  1132. BEGINDOC_EJL_END,
  1133. BYTE_LENGTH(BEGINDOC_EJL_END));
  1134. WRITESPOOLBUF(pdevobj,
  1135. BEGINDOC_EPG_END,
  1136. BYTE_LENGTH(BEGINDOC_EPG_END));
  1137. if(pOEM->iResolution == XX_RES_300DPI)
  1138. WRITESPOOLBUF(pdevobj, "\x1D\x30;0.24muE", 10);
  1139. else
  1140. WRITESPOOLBUF(pdevobj, "\x1D\x30;0.12muE", 10);
  1141. // ESC/Page commands
  1142. wlen = 0;
  1143. // Replacement of strsafe-api 2002.3.6 >>>
  1144. // strcpy( &Cmd[wlen], EPg_SelectRes[pOEM->iResolution] );
  1145. // wlen += (WORD)strlen( &Cmd[wlen] );
  1146. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EPg_SelectRes[pOEM->iResolution],
  1147. &pDestEnd, &szRemLen,
  1148. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1149. break;
  1150. }
  1151. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1152. // Replacement of strsafe-api 2002.3.6 <<<
  1153. WRITESPOOLBUF(pdevobj, Cmd, wlen );
  1154. // Clear dwDLFontID
  1155. // (There are data that contains a plural pages and
  1156. // also each page has different color mode.
  1157. // When page is changed, STARTDOC commands are spooled.
  1158. // It means that new DL font is set.
  1159. // That is why dwDLFontID got to be claer.)
  1160. pOEM->dwDLFontID = UNKNOWN_DLFONT_ID;
  1161. break;
  1162. case PC_ENDDOC:
  1163. WRITESPOOLBUF(pdevobj,
  1164. ENDDOC_EJL_RESET,
  1165. BYTE_LENGTH(ENDDOC_EJL_RESET));
  1166. break;
  1167. case TONER_SAVE_NONE:
  1168. pOEM->iTonerSave = XX_TONER_NORMAL;
  1169. break;
  1170. case TONER_SAVE_1:
  1171. pOEM->iTonerSave = XX_TONER_SAVE_1;
  1172. break;
  1173. case TONER_SAVE_2:
  1174. pOEM->iTonerSave = XX_TONER_SAVE_2;
  1175. break;
  1176. case SMOOTHING_ON:
  1177. pOEM->iSmoothing = XX_SMOOTHING_ON;
  1178. break;
  1179. case SMOOTHING_OFF:
  1180. pOEM->iSmoothing = XX_SMOOTHING_OFF;
  1181. break;
  1182. case JAMRECOVERY_ON:
  1183. pOEM->iJamRecovery = XX_JAMRECOVERY_ON;
  1184. break;
  1185. case JAMRECOVERY_OFF:
  1186. pOEM->iJamRecovery = XX_JAMRECOVERY_OFF;
  1187. break;
  1188. case MEDIATYPE_1:
  1189. pOEM->iMediaType = XX_MEDIATYPE_1;
  1190. break;
  1191. case MEDIATYPE_2:
  1192. pOEM->iMediaType = XX_MEDIATYPE_2;
  1193. break;
  1194. case MEDIATYPE_3:
  1195. pOEM->iMediaType = XX_MEDIATYPE_3;
  1196. break;
  1197. case OUTBIN_SELECT_EXIT_1:
  1198. pOEM->iOutBin = OUTBIN_EXIT_1;
  1199. break;
  1200. case OUTBIN_SELECT_EXIT_2:
  1201. pOEM->iOutBin = OUTBIN_EXIT_2;
  1202. break;
  1203. case DEFINE_PALETTE_ENTRY:
  1204. //RGB -> CMYK
  1205. TmpRgb.Red = (BYTE)(PARAM(pdwParams, 1));
  1206. TmpRgb.Grn = (BYTE)(PARAM(pdwParams, 2));
  1207. TmpRgb.Blu = (BYTE)(PARAM(pdwParams, 3));
  1208. memset(&TmpCmyk, 0x00, sizeof(TmpCmyk));
  1209. ColMatching(pdevobj, No, No, &TmpRgb, (WORD)1, &TmpCmyk);
  1210. wPalID = (WORD)(PARAM(pdwParams, 0));
  1211. WRITESPOOLBUF(pdevobj, ORG_MODE_IN, BYTE_LENGTH(ORG_MODE_IN));
  1212. // Replacement of strsafe-api 2002.3.6 >>>
  1213. // wlen = (WORD)wsprintf(Cmd, PALETTE_DEFINE, wPalID, TmpCmyk.Cyn,
  1214. // TmpCmyk.Mgt, TmpCmyk.Yel, TmpCmyk.Bla);
  1215. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  1216. &pDestEnd, &szRemLen,
  1217. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1218. PALETTE_DEFINE, wPalID,
  1219. TmpCmyk.Cyn, TmpCmyk.Mgt, TmpCmyk.Yel, TmpCmyk.Bla)) {
  1220. break;
  1221. }
  1222. wlen = (WORD)(pDestEnd - Cmd);
  1223. // Replacement of strsafe-api 2002.3.6 <<<
  1224. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  1225. WRITESPOOLBUF(pdevobj, ORG_MODE_OUT, BYTE_LENGTH(ORG_MODE_OUT));
  1226. MY_VERBOSE(("DEFINE_PALETTE_ENTRY No %d\n",
  1227. (INT)(PARAM(pdwParams, wPalID))));
  1228. break;
  1229. case BEGIN_PALETTE_DEF:
  1230. MY_VERBOSE(("CmdBeginPaletteDef\n"));
  1231. break;
  1232. case END_PALETTE_DEF:
  1233. MY_VERBOSE(("CmdEndPaletteDef\n"));
  1234. break;
  1235. case SELECT_PALETTE_ENTRY:
  1236. MY_VERBOSE(("SELECT_PALETTE_ENTRY "));
  1237. wPalID = (WORD)(PARAM(pdwParams, 0));
  1238. WRITESPOOLBUF(pdevobj, ORG_MODE_IN, BYTE_LENGTH(ORG_MODE_IN));
  1239. // Replacement of strsafe-api 2002.3.6 >>>
  1240. // wlen = (WORD)wsprintf(Cmd, PALETTE_SELECT, 0, wPalID);
  1241. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  1242. &pDestEnd, &szRemLen,
  1243. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1244. PALETTE_SELECT, 0, wPalID)) {
  1245. break;
  1246. }
  1247. wlen = (WORD)(pDestEnd - Cmd);
  1248. // Replacement of strsafe-api 2002.3.6 <<<
  1249. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  1250. WRITESPOOLBUF(pdevobj, ORG_MODE_OUT, BYTE_LENGTH(ORG_MODE_OUT));
  1251. WRITESPOOLBUF(pdevobj, OVERWRITE, BYTE_LENGTH(OVERWRITE));
  1252. break;
  1253. case START_PAGE:
  1254. MY_VERBOSE(("OEMCommandCallback() START_PAGE Start\n"));
  1255. WRITESPOOLBUF(pdevobj, CMD_START_PAGE, BYTE_LENGTH(CMD_START_PAGE));
  1256. if (pOEM->iColor == XX_COLOR_MANY
  1257. || pOEM->iColor == XX_COLOR_MANY2 //+N5
  1258. || pOEM->iColor == XX_COLOR_SINGLE) {
  1259. //Initialize palette state (Spools pure black color command)
  1260. wlen = 0;
  1261. TmpRgb.Red = TmpRgb.Grn = TmpRgb.Blu = 0;
  1262. MY_VERBOSE(("OEMCommandCallback() ColMatching()\n"));
  1263. ColMatching(pdevobj, No, No, &TmpRgb, (WORD)1, &TmpCmyk);
  1264. // Replacement of strsafe-api 2002.3.6 >>>
  1265. // strcpy( &Cmd[wlen], ORG_MODE_IN );
  1266. // wlen += (WORD)strlen( &Cmd[wlen] );
  1267. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, ORG_MODE_IN,
  1268. &pDestEnd, &szRemLen,
  1269. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  1270. break;
  1271. }
  1272. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1273. // Replacement of strsafe-api 2002.3.6 <<<
  1274. // Replacement of strsafe-api 2002.3.6 >>>
  1275. // wlen += (WORD)wsprintf(&Cmd[wlen], PALETTE_DEFINE,
  1276. // DEFAULT_PALETTE_INDEX,
  1277. // TmpCmyk.Cyn, TmpCmyk.Mgt, TmpCmyk.Yel, TmpCmyk.Bla);
  1278. // wlen += (WORD)wsprintf(&Cmd[wlen], PALETTE_SELECT,
  1279. // 0, DEFAULT_PALETTE_INDEX);
  1280. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  1281. &pDestEnd, &szRemLen,
  1282. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1283. PALETTE_DEFINE,
  1284. DEFAULT_PALETTE_INDEX,
  1285. TmpCmyk.Cyn, TmpCmyk.Mgt, TmpCmyk.Yel, TmpCmyk.Bla)) {
  1286. break;
  1287. }
  1288. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1289. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  1290. &pDestEnd, &szRemLen,
  1291. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1292. PALETTE_SELECT,
  1293. 0, DEFAULT_PALETTE_INDEX)) {
  1294. break;
  1295. }
  1296. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1297. // Replacement of strsafe-api 2002.3.6 <<<
  1298. WRITESPOOLBUF(pdevobj, Cmd, wlen);
  1299. WRITESPOOLBUF(pdevobj, ORG_MODE_OUT, BYTE_LENGTH(ORG_MODE_OUT));
  1300. }
  1301. MY_VERBOSE(("OEMCommandCallback() START_PAGE End\n"));
  1302. break;
  1303. case DOWNLOAD_SET_FONT_ID:
  1304. if (!IsValidDLFontID(pdwParams[0])) {
  1305. // Must not happen!!
  1306. ERR(("DLSetFontID: Soft font ID %x invalid.\n",
  1307. pdwParams[0]));
  1308. break;
  1309. }
  1310. // Actual printer command is sent
  1311. // within DownloadCharGlyph.
  1312. pOEM->dwDLSetFontID = pdwParams[0];
  1313. DL_VERBOSE(("SetFontID: dwDLSetFontID=%x\n",
  1314. pOEM->dwDLSetFontID));
  1315. break;
  1316. case DOWNLOAD_SELECT_FONT_ID:
  1317. if (!IsValidDLFontID(pdwParams[0])) {
  1318. // Must not happen!!
  1319. ERR(("DLSelectFontID: Soft font ID %x invalid.\n",
  1320. pdwParams[0]));
  1321. break;
  1322. }
  1323. pOEM->dwDLSelectFontID = pdwParams[0];
  1324. DL_VERBOSE(("SelectFontID: dwDLSelectFontID=%x\n",
  1325. pOEM->dwDLSelectFontID));
  1326. if (pOEM->dwDLFontID != pOEM->dwDLSelectFontID)
  1327. VSetSelectDLFont(pdevobj, pOEM->dwDLSelectFontID);
  1328. break;
  1329. case DOWNLOAD_SET_CHAR_CODE:
  1330. pOEM->wCharCode=(WORD)pdwParams[0];
  1331. break;
  1332. case DOWNLOAD_DELETE_FONT:
  1333. DL_VERBOSE(("DLDeleteFont: dwDLFontID=%x, %x\n",
  1334. pOEM->dwDLFontID, pdwParams[0]));
  1335. // Replacement of strsafe-api 2002.3.6 >>>
  1336. // wlen = (WORD)wsprintf(Cmd, DLI_DELETE_FONT, (WORD)pdwParams[0]-FONT_MIN_ID);
  1337. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  1338. &pDestEnd, &szRemLen,
  1339. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1340. DLI_DELETE_FONT, (WORD)pdwParams[0]-FONT_MIN_ID)) {
  1341. break;
  1342. }
  1343. wlen = (WORD)(pDestEnd - Cmd);
  1344. // Replacement of strsafe-api 2002.3.6 <<<
  1345. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  1346. pOEM->dwDLFontID = UNKNOWN_DLFONT_ID;
  1347. break;
  1348. case RECT_FILL_WIDTH:
  1349. pOEM->wRectWidth =
  1350. (WORD)MasterToDevice(pOEM, pdwParams[0]);
  1351. break;
  1352. case RECT_FILL_HEIGHT:
  1353. pOEM->wRectHeight =
  1354. (WORD)MasterToDevice(pOEM, pdwParams[0]);
  1355. break;
  1356. case RECT_FILL_GRAY:
  1357. case RECT_FILL_WHITE:
  1358. case RECT_FILL_BLACK:
  1359. if (RECT_FILL_GRAY == dwCmdCbID)
  1360. wGray = (WORD)pdwParams[2];
  1361. else if (RECT_FILL_WHITE == dwCmdCbID)
  1362. wGray = 0;
  1363. else
  1364. wGray = 100;
  1365. dwTempX = MasterToDevice(pOEM, pdwParams[0]);
  1366. dwTempY = MasterToDevice(pOEM, pdwParams[1]);
  1367. MY_VERBOSE(("RectFill:%d,x=%d,y=%d,w=%d,h=%d\n",
  1368. wGray,
  1369. (WORD)dwTempX,
  1370. (WORD)dwTempY,
  1371. pOEM->wRectWidth,
  1372. pOEM->wRectHeight));
  1373. // Replacement of strsafe-api 2002.3.6 >>>
  1374. // wlen = (WORD)wsprintf(Cmd, RECT_FILL,
  1375. // wGray,
  1376. // (WORD)dwTempX,
  1377. // (WORD)dwTempY,
  1378. // (WORD)(dwTempX + pOEM->wRectWidth - 1),
  1379. // (WORD)(dwTempY + pOEM->wRectHeight - 1));
  1380. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  1381. &pDestEnd, &szRemLen,
  1382. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1383. RECT_FILL,
  1384. wGray,
  1385. (WORD)dwTempX,
  1386. (WORD)dwTempY,
  1387. (WORD)(dwTempX + pOEM->wRectWidth - 1),
  1388. (WORD)(dwTempY + pOEM->wRectHeight - 1))) {
  1389. break;
  1390. }
  1391. wlen = (WORD)(pDestEnd - Cmd);
  1392. // Replacement of strsafe-api 2002.3.6 >>>
  1393. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  1394. break;
  1395. #if 0 /* OEM doesn't want to fix minidriver */
  1396. /* Below is hack code to fix #412276 */
  1397. case COLOR_SELECT_BLACK:
  1398. case COLOR_SELECT_RED:
  1399. case COLOR_SELECT_GREEN:
  1400. case COLOR_SELECT_BLUE:
  1401. case COLOR_SELECT_YELLOW:
  1402. case COLOR_SELECT_MAGENTA:
  1403. case COLOR_SELECT_CYAN:
  1404. case COLOR_SELECT_WHITE:
  1405. /* Remember what color is select */
  1406. pOEM->dwSelectedColor = dwCmdCbID;
  1407. pOEM->iColorMayChange = 0; /* Reset flag */
  1408. /* Output Color Select Command */
  1409. /* The logic supposes COLOR_SELECT_xxx starts with COLOR_SELECT_BLACK */
  1410. /* and increases one by one */
  1411. WRITESPOOLBUF(pdevobj, (LPSTR)COLOR_SELECT_COMMAND[dwCmdCbID - COLOR_SELECT_BLACK],
  1412. COLOR_SELECT_COMMAND_LEN[dwCmdCbID - COLOR_SELECT_BLACK] );
  1413. break;
  1414. case DUMP_RASTER_CYAN:
  1415. case DUMP_RASTER_MAGENTA:
  1416. case DUMP_RASTER_YELLOW:
  1417. case DUMP_RASTER_BLACK:
  1418. /* Remember what color may change */
  1419. pOEM->iColorMayChange = 1; /* Set flag */
  1420. /* Output Dump Raster Command */
  1421. /* The logic supposes DUMP_RASTER_xxx starts with DUMP_RASTER_CYAN */
  1422. /* and increases one by one */
  1423. WRITESPOOLBUF(pdevobj, (LPSTR)DUMP_RASTER_COMMAND[dwCmdCbID - DUMP_RASTER_CYAN],
  1424. DUMP_RASTER_COMMAND_LEN );
  1425. break;
  1426. /* End of hack code */
  1427. #endif /* OEM doesn't want to fix minidriver */
  1428. default:
  1429. ERR(("Unknown callback ID = %d.\n", dwCmdCbID));
  1430. }
  1431. return iRet;
  1432. }
  1433. //////////////////////////////////////////////////////////////////////////
  1434. // Function: OEMSendFontCmdk
  1435. //////////////////////////////////////////////////////////////////////////
  1436. VOID
  1437. APIENTRY
  1438. OEMSendFontCmd(
  1439. PDEVOBJ pdevobj,
  1440. PUNIFONTOBJ pUFObj,
  1441. PFINVOCATION pFInv)
  1442. {
  1443. PGETINFO_STDVAR pSV;
  1444. DWORD adwStdVariable[2+2*4];
  1445. DWORD dwIn, dwOut;
  1446. PBYTE pubCmd;
  1447. BYTE aubCmd[128];
  1448. PIFIMETRICS pIFI;
  1449. DWORD height, width;
  1450. PMYPDEV pOEM;
  1451. BYTE Cmd[128];
  1452. WORD wlen;
  1453. DWORD dwNeeded;
  1454. DWORD dwTemp;
  1455. LPSTR pDestEnd; // 2002.3.6
  1456. size_t szRemLen; // 2002.3.6
  1457. SC_VERBOSE(("OEMSendFontCmd() entry.\n"));
  1458. pubCmd = pFInv->pubCommand;
  1459. pIFI = pUFObj->pIFIMetrics;
  1460. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  1461. //
  1462. // Get standard variables.
  1463. //
  1464. pSV = (PGETINFO_STDVAR)adwStdVariable;
  1465. pSV->dwSize = sizeof(GETINFO_STDVAR) + 2 * sizeof(DWORD) * (4 - 1);
  1466. pSV->dwNumOfVariable = 4;
  1467. pSV->StdVar[0].dwStdVarID = FNT_INFO_FONTHEIGHT;
  1468. pSV->StdVar[1].dwStdVarID = FNT_INFO_FONTWIDTH;
  1469. pSV->StdVar[2].dwStdVarID = FNT_INFO_TEXTYRES;
  1470. pSV->StdVar[3].dwStdVarID = FNT_INFO_TEXTXRES;
  1471. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_STDVARIABLE, pSV, pSV->dwSize, &dwNeeded)) {
  1472. ERR(("UFO_GETINFO_STDVARIABLE failed.\n"));
  1473. return;
  1474. }
  1475. SC_VERBOSE(("ulFontID=%x\n", pUFObj->ulFontID));
  1476. SC_VERBOSE(("FONTHEIGHT=%d\n", pSV->StdVar[0].lStdVariable));
  1477. SC_VERBOSE(("FONTWIDTH=%d\n", pSV->StdVar[1].lStdVariable));
  1478. // Initialize pOEM
  1479. if (pIFI->jWinCharSet == 0x80)
  1480. pOEM->fGeneral |= FG_DOUBLE;
  1481. else
  1482. pOEM->fGeneral &= ~FG_DOUBLE;
  1483. pOEM->fGeneral &= ~FG_BOLD;
  1484. pOEM->fGeneral &= ~FG_ITALIC;
  1485. if('@' == *((LPSTR)pIFI+pIFI->dpwszFaceName))
  1486. pOEM->fGeneral |= FG_VERT;
  1487. else
  1488. pOEM->fGeneral &= ~FG_VERT;
  1489. if (pIFI->jWinPitchAndFamily & 0x01)
  1490. pOEM->fGeneral &= ~FG_PROP;
  1491. else
  1492. pOEM->fGeneral |= FG_PROP;
  1493. dwOut = 0;
  1494. pOEM->fGeneral &= ~FG_DBCS;
  1495. for( dwIn = 0; dwIn < pFInv->dwCount;) {
  1496. if (pubCmd[dwIn] == '#' && pubCmd[dwIn+1] == 'V') {
  1497. // Specify font height in device unit (current
  1498. // output resolution). Note Unidrv gives us
  1499. // font-height in master units
  1500. height = pSV->StdVar[0].lStdVariable * 100;
  1501. height = MasterToDevice(pOEM, height);
  1502. SC_VERBOSE(("Height=%d\n", height));
  1503. // Replacement of strsafe-api 2002.3.6 >>>
  1504. // dwOut += LConvertFontSizeToStr(height, &aubCmd[dwOut]);
  1505. dwOut += LConvertFontSizeToStr(height, &aubCmd[dwOut], sizeof(aubCmd)-dwOut);
  1506. // Replacement of strsafe-api 2002.3.6 >>>
  1507. dwIn += 2;
  1508. } else if (pubCmd[dwIn] == '#' && pubCmd[dwIn+1] == 'H') {
  1509. if (pubCmd[dwIn+2] == 'S') {
  1510. SC_VERBOSE(("HS: "));
  1511. width = pSV->StdVar[1].lStdVariable;
  1512. dwIn += 3;
  1513. pOEM->fGeneral |= FG_DBCS;
  1514. } else if (pubCmd[dwIn+2] == 'D') {
  1515. SC_VERBOSE(("HD: "));
  1516. width = pSV->StdVar[1].lStdVariable * 2;
  1517. dwIn += 3;
  1518. pOEM->fGeneral |= FG_DBCS;
  1519. } else {
  1520. SC_VERBOSE(("H: "));
  1521. if (pSV->StdVar[1].lStdVariable)
  1522. width = pSV->StdVar[1].lStdVariable;
  1523. else
  1524. width = pIFI->fwdAveCharWidth;
  1525. dwIn += 2;
  1526. }
  1527. // Specify font width in CPI.
  1528. // Check of zero divide 2002.3.23 >>>
  1529. if (width == 0) {
  1530. ERR(("OEMSendFontCmd() 0Div-Check [width=0] \n"));
  1531. return;
  1532. }
  1533. // Check of zero divide 2002.3.23 <<<
  1534. width = (MASTER_UNIT * 100L) / width;
  1535. SC_VERBOSE(("Width=%d\n", width));
  1536. // Replacement of strsafe-api 2002.3.6 >>>
  1537. // dwOut += LConvertFontSizeToStr(width, &aubCmd[dwOut]);
  1538. dwOut += LConvertFontSizeToStr(width, &aubCmd[dwOut], sizeof(aubCmd)-dwOut);
  1539. // Replacement of strsafe-api 2002.3.6 <<<
  1540. } else {
  1541. aubCmd[dwOut++] = pubCmd[dwIn++];
  1542. }
  1543. }
  1544. WRITESPOOLBUF(pdevobj, aubCmd, dwOut);
  1545. #if 0 //MSKK 98/12/22
  1546. pOEM->iDevCharOffset = (pIFI->fwdWinDescender * pSV->StdVar[0].lStdVariable * 72)
  1547. / (pIFI->fwdUnitsPerEm * pSV->StdVar[2].lStdVariable / pOEM->sHeightDiv);
  1548. #else
  1549. // Unidrv gives us raw IFIMETRICS block so we need to
  1550. // translate its members into meaningful values. n.b.
  1551. // we assume font height passed from Unidrv = em value.
  1552. // Check of zero divide 2002.3.23 >>>
  1553. if (pIFI->fwdUnitsPerEm == 0) {
  1554. ERR(("OEMSendFontCmd() 0Div-Check [pIFI->fwdUnitsPerEm=0] \n"));
  1555. return;
  1556. }
  1557. // Check of zero divide 2002.3.23 <<<
  1558. dwTemp = MasterToDevice(pOEM, pSV->StdVar[0].lStdVariable)
  1559. * pIFI->fwdWinDescender;
  1560. dwTemp /= pIFI->fwdUnitsPerEm;
  1561. pOEM->iDevCharOffset = (short)dwTemp;
  1562. #endif
  1563. MY_VERBOSE(("Descender=%d\n", pOEM->iDevCharOffset));
  1564. // Replacement of strsafe-api 2002.3.6 >>>
  1565. // wlen = (WORD)wsprintf(Cmd, SET_CHAR_OFFSET,
  1566. // (pOEM->fGeneral & FG_DBCS)?pOEM->iDevCharOffset:0);
  1567. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  1568. &pDestEnd, &szRemLen,
  1569. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1570. SET_CHAR_OFFSET,
  1571. (pOEM->fGeneral & FG_DBCS)?pOEM->iDevCharOffset:0)) {
  1572. return;
  1573. }
  1574. wlen = (WORD)(pDestEnd - Cmd);
  1575. // Replacement of strsafe-api 2002.3.6 <<<
  1576. if (pOEM->fGeneral & FG_VERT)
  1577. {
  1578. // Replacement of strsafe-api 2002.3.6 >>>
  1579. // wlen += (WORD)wsprintf(&Cmd[wlen], VERT_FONT_SET, 1);
  1580. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  1581. &pDestEnd, &szRemLen,
  1582. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1583. VERT_FONT_SET, 1)) {
  1584. return;
  1585. }
  1586. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1587. // Replacement of strsafe-api 2002.3.6 >>>
  1588. }
  1589. WRITESPOOLBUF(pdevobj, Cmd, wlen);
  1590. // DL font will be unselectd
  1591. pOEM->dwDLFontID = UNKNOWN_DLFONT_ID;
  1592. }
  1593. LONG
  1594. LGetPointSize100(
  1595. LONG height,
  1596. LONG vertRes)
  1597. {
  1598. LONG tmp = ((LONG)height * (LONG)7200) / (LONG)vertRes;
  1599. //
  1600. // round to the nearest quarter point.
  1601. //
  1602. return 25 * ((tmp + 12) / (LONG)25);
  1603. }
  1604. // Replacement of strsafe-api 2002.3.6 >>>
  1605. //LONG
  1606. //LConvertFontSizeToStr(
  1607. // LONG size,
  1608. // PSTR pStr)
  1609. //{
  1610. // register long count;
  1611. //
  1612. // count = strlen(_ltoa(size / 100, pStr, 10));
  1613. // pStr[count++] = '.';
  1614. // count += strlen(_ltoa(size % 100, &pStr[count], 10));
  1615. //
  1616. // return count;
  1617. //}
  1618. LONG
  1619. LConvertFontSizeToStr(
  1620. LONG size,
  1621. PSTR pStr,
  1622. size_t StrSize)
  1623. {
  1624. register long count;
  1625. size_t pcb;
  1626. if (S_OK != StringCbLengthA(_ltoa(size / 100, pStr, 10), StrSize, &pcb))
  1627. return 0;
  1628. count = (WORD)pcb;
  1629. pStr[count++] = '.';
  1630. if (S_OK != StringCbLengthA(_ltoa(size % 100, &pStr[count], 10), StrSize-count, &pcb))
  1631. return 0;
  1632. count += (WORD)pcb;
  1633. return count;
  1634. }
  1635. // Replacement of strsafe-api 2002.3.6 <<<
  1636. //////////////////////////////////////////////////////////////////////////
  1637. // Function: OEMOutputCharStr
  1638. //////////////////////////////////////////////////////////////////////////
  1639. VOID APIENTRY
  1640. OEMOutputCharStr(
  1641. PDEVOBJ pdevobj,
  1642. PUNIFONTOBJ pUFObj,
  1643. DWORD dwType,
  1644. DWORD dwCount,
  1645. PVOID pGlyph)
  1646. {
  1647. GETINFO_GLYPHSTRING GStr;
  1648. PTRANSDATA pTrans;
  1649. PTRANSDATA pTransOrg;
  1650. WORD id;
  1651. DWORD dwI;
  1652. DWORD dwNeeded;
  1653. PMYPDEV pOEM;
  1654. PIFIMETRICS pIFI;
  1655. WORD wLen;
  1656. BYTE *pTemp;
  1657. BOOL bRet;
  1658. pIFI = pUFObj->pIFIMetrics;
  1659. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  1660. pTrans = NULL;
  1661. pTransOrg = NULL;
  1662. MY_VERBOSE(("OEMOutputCharStr() entry.\n"));
  1663. #if 0 /* OEM doesn't want to fix minidriver */
  1664. /* Below is hack code to fix #412276 */
  1665. if ( pOEM->iColorMayChange == 1 )
  1666. {
  1667. /* Output Color Select Command */
  1668. /* The logic supposes COLOR_SELECT_xxx starts with COLOR_SELECT_BLACK */
  1669. /* and increases one by one */
  1670. WRITESPOOLBUF(pdevobj, (LPSTR)COLOR_SELECT_COMMAND[pOEM->dwSelectedColor - COLOR_SELECT_BLACK],
  1671. COLOR_SELECT_COMMAND_LEN[pOEM->dwSelectedColor - COLOR_SELECT_BLACK] );
  1672. /* Reset flag, for ensuring color */
  1673. pOEM->iColorMayChange = 0;
  1674. }
  1675. /* End of hack code */
  1676. #endif /* OEM doesn't want to fix minidriver */
  1677. switch (dwType)
  1678. {
  1679. case TYPE_GLYPHHANDLE:
  1680. GStr.dwSize = sizeof (GETINFO_GLYPHSTRING);
  1681. GStr.dwCount = dwCount;
  1682. GStr.dwTypeIn = TYPE_GLYPHHANDLE;
  1683. GStr.pGlyphIn = pGlyph;
  1684. GStr.dwTypeOut = TYPE_TRANSDATA;
  1685. GStr.pGlyphOut = NULL;
  1686. GStr.dwGlyphOutSize = 0;
  1687. if ((FALSE != (bRet = pUFObj->pfnGetInfo(pUFObj,
  1688. UFO_GETINFO_GLYPHSTRING, &GStr, 0, NULL)))
  1689. || 0 == GStr.dwGlyphOutSize)
  1690. {
  1691. ERR(("UFO_GETINFO_GRYPHSTRING faild - %d, %d.\n",
  1692. bRet, GStr.dwGlyphOutSize));
  1693. return;
  1694. }
  1695. pTrans = (TRANSDATA *)MemAlloc(GStr.dwGlyphOutSize);
  1696. if (NULL == pTrans)
  1697. {
  1698. ERR(("MemAlloc faild.\n"));
  1699. return;
  1700. }
  1701. pTransOrg = pTrans;
  1702. GStr.pGlyphOut = pTrans;
  1703. // convert glyph string to TRANSDATA
  1704. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr, 0, NULL))
  1705. {
  1706. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\r\n"));
  1707. /* pTransOrg isn't NULL because the function have already ended if pTransOrg is NULL. */
  1708. /* So, we need not check whether it is NULL. */
  1709. MemFree(pTransOrg);
  1710. return;
  1711. }
  1712. for (dwI = 0; dwI < dwCount; dwI ++, pTrans++)
  1713. {
  1714. MY_VERBOSE(("TYPE_TRANSDATA:ubCodePageID:0x%x\n",
  1715. pTrans->ubCodePageID));
  1716. MY_VERBOSE(("TYPE_TRANSDATA:ubType:0x%x\n",
  1717. pTrans->ubType));
  1718. switch (pTrans->ubType & MTYPE_DOUBLEBYTECHAR_MASK)
  1719. {
  1720. case MTYPE_SINGLE:
  1721. if(pOEM->fGeneral & FG_DOUBLE){
  1722. OEMCommandCallback(pdevobj, TEXT_FS_SINGLE_BYTE, 0, NULL );
  1723. }
  1724. break;
  1725. case MTYPE_DOUBLE:
  1726. if(!(pOEM->fGeneral & FG_DOUBLE)){
  1727. OEMCommandCallback(pdevobj, TEXT_FS_DOUBLE_BYTE, 0, NULL );
  1728. }
  1729. break;
  1730. }
  1731. switch (pTrans->ubType & MTYPE_FORMAT_MASK)
  1732. {
  1733. case MTYPE_DIRECT:
  1734. MY_VERBOSE(("TYPE_TRANSDATA:ubCode:0x%x\n",
  1735. pTrans->uCode.ubCode));
  1736. pTemp = (BYTE *)&pTrans->uCode.ubCode;
  1737. wLen = 1;
  1738. break;
  1739. case MTYPE_PAIRED:
  1740. MY_VERBOSE(("TYPE_TRANSDATA:ubPairs:0x%x\n",
  1741. *(PWORD)(pTrans->uCode.ubPairs)));
  1742. pTemp = (BYTE *)&(pTrans->uCode.ubPairs);
  1743. wLen = 2;
  1744. break;
  1745. case MTYPE_COMPOSE:
  1746. // ntbug9#398026: garbage print out when chars are high ansi.
  1747. pTemp = (BYTE *)(pTransOrg) + pTrans->uCode.sCode;
  1748. // first two bytes are the length of the string
  1749. wLen = *pTemp + (*(pTemp + 1) << 8);
  1750. pTemp += 2;
  1751. break;
  1752. default:
  1753. WARNING(("Unsupported MTYPE %d ignored\n",
  1754. (pTrans->ubType & MTYPE_FORMAT_MASK)));
  1755. wLen = 0;
  1756. break;
  1757. }
  1758. if (wLen > 0)
  1759. {
  1760. WRITESPOOLBUF(pdevobj, pTemp, wLen);
  1761. }
  1762. }
  1763. break;
  1764. case TYPE_GLYPHID:
  1765. DL_VERBOSE(("CharStr: dwDLFontID=%x, dwDLSelectFontID=%x\n",
  1766. pOEM->dwDLFontID, pOEM->dwDLSelectFontID));
  1767. // Make sure correct soft font is chosen
  1768. if (pOEM->dwDLFontID != pOEM->dwDLSelectFontID)
  1769. VSetSelectDLFont(pdevobj, pOEM->dwDLSelectFontID);
  1770. for (dwI = 0; dwI < dwCount; dwI ++, ((PDWORD)pGlyph)++)
  1771. {
  1772. DL_VERBOSE(("Glyph: %x\n", (*(PDWORD)pGlyph)));
  1773. MY_VERBOSE(("TYPE_GLYPHID:0x%x\n", *(PDWORD)pGlyph));
  1774. // CASIO 98/11/24 ->
  1775. // if( pIFI->jWinCharSet == SHIFTJIS_CHARSET ){
  1776. // id = SWAPW( *(PDWORD)pGlyph + SJISCHR);
  1777. // WRITESPOOLBUF(pdevobj, &id, 2);
  1778. // }else{
  1779. WRITESPOOLBUF(pdevobj, (PBYTE)pGlyph, 1);
  1780. // }
  1781. // CASIO 98/11/24 <-
  1782. }
  1783. break;
  1784. }
  1785. /* pTransOrg isn't NULL because the function have already ended if pTransOrg is NULL. */
  1786. /* So, we need not check whether it is NULL. */
  1787. MemFree(pTransOrg);
  1788. }
  1789. //////////////////////////////////////////////////////////////////////////
  1790. // Function: OEMDownloadFontHeader
  1791. //////////////////////////////////////////////////////////////////////////
  1792. DWORD APIENTRY
  1793. OEMDownloadFontHeader(
  1794. PDEVOBJ pdevobj,
  1795. PUNIFONTOBJ pUFObj
  1796. )
  1797. {
  1798. PGETINFO_STDVAR pSV;
  1799. DWORD adwStdVariable[2+4*2];
  1800. PMYPDEV pOEM;
  1801. PIFIMETRICS pIFI;
  1802. ESCPAGEHEADER FontHeader;
  1803. // BYTE sFontName[54]; // 2002.3.6 Buffer size insufficient
  1804. BYTE sFontName[64]; // 2002.3.6
  1805. BYTE Buff[32];
  1806. int iSizeOfBuf,iSizeFontName;
  1807. WORD id;
  1808. DWORD dwNeeded;
  1809. INT iCellLeftOffset, iTemp;
  1810. WORD wCellHeight, wCellWidth;
  1811. WORD wFontPitch;
  1812. LPSTR pDestEnd; // 2002.3.6
  1813. size_t szRemLen; // 2002.3.6
  1814. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  1815. pIFI = pUFObj->pIFIMetrics;
  1816. DL_VERBOSE(("OEMDownloadFontHeader() entry.\n"));
  1817. DL_VERBOSE(("TT Font:\n"));
  1818. DL_VERBOSE(("flInfo=%08x\n", pIFI->flInfo));
  1819. DL_VERBOSE(("fwdMaxCharInc=%d\n", pIFI->fwdMaxCharInc));
  1820. DL_VERBOSE(("fwdAveCharWidth=%d\n", pIFI->fwdAveCharWidth));
  1821. DL_VERBOSE(("jWinCharSet=%d\n", pIFI->jWinCharSet));
  1822. DL_VERBOSE(("rclFontBox=%d,%d,%d,%d\n",
  1823. pIFI->rclFontBox.left, pIFI->rclFontBox.top,
  1824. pIFI->rclFontBox.right, pIFI->rclFontBox.bottom));
  1825. // if(pIFI->jWinPitchAndFamily & 0x01)
  1826. if(pIFI->flInfo & FM_INFO_CONSTANT_WIDTH)
  1827. pOEM->fGeneral &= ~FG_PROP;
  1828. else
  1829. pOEM->fGeneral |= FG_PROP;
  1830. // id = (WORD)pUFObj->ulFontID;
  1831. id = (WORD)pOEM->dwDLSetFontID;
  1832. if(id > FONT_MAX_ID) return 0;
  1833. if (pOEM->iResolution) return 0;
  1834. //
  1835. // Get standard variables.
  1836. //
  1837. pSV = (PGETINFO_STDVAR)adwStdVariable;
  1838. pSV->dwSize = sizeof(GETINFO_STDVAR) + 2 * sizeof(DWORD) * (4 - 1);
  1839. pSV->dwNumOfVariable = 4;
  1840. pSV->StdVar[0].dwStdVarID = FNT_INFO_FONTHEIGHT;
  1841. pSV->StdVar[1].dwStdVarID = FNT_INFO_FONTWIDTH;
  1842. pSV->StdVar[2].dwStdVarID = FNT_INFO_TEXTYRES;
  1843. pSV->StdVar[3].dwStdVarID = FNT_INFO_TEXTXRES;
  1844. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_STDVARIABLE,
  1845. pSV, pSV->dwSize, &dwNeeded)) {
  1846. ERR(("UFO_GETINFO_STDVARIABLE failed.\n"));
  1847. return 0;
  1848. }
  1849. DL_VERBOSE(("FONTHEIGHT=%d\n", pSV->StdVar[0].lStdVariable));
  1850. DL_VERBOSE(("FONTWIDTH=%d\n", pSV->StdVar[1].lStdVariable));
  1851. DL_VERBOSE(("TEXTXRES=%d\n", pSV->StdVar[2].lStdVariable));
  1852. DL_VERBOSE(("TEXTYRES=%d\n", pSV->StdVar[3].lStdVariable));
  1853. wCellHeight = (WORD)pSV->StdVar[0].lStdVariable;
  1854. wCellWidth = (WORD)pSV->StdVar[1].lStdVariable;
  1855. // CASIO 98/11/20 ->
  1856. if ( MasterToDevice(pOEM,wCellHeight) > 64 )
  1857. {
  1858. DL_VERBOSE(("Abort OEMDownloadFontHeader: pt=%d\n",
  1859. MasterToDevice(pOEM, wCellHeight)));
  1860. return 0;
  1861. }
  1862. // CASIO 98/11/20 <-
  1863. //
  1864. // rclFontBox.left may not be 0
  1865. //
  1866. iTemp = max(pIFI->rclFontBox.right -
  1867. pIFI->rclFontBox.left + 1,
  1868. pIFI->fwdAveCharWidth);
  1869. // Check of zero divide 2002.3.23 >>>
  1870. if (iTemp == 0) {
  1871. ERR(("OEMDownloadFontHeader() 0Div-Check [iTemp=0] \n"));
  1872. return 0;
  1873. }
  1874. // Check of zero divide 2002.3.23 <<<
  1875. iCellLeftOffset = (-pIFI->rclFontBox.left)
  1876. * wCellWidth / iTemp;
  1877. wFontPitch = pIFI->fwdAveCharWidth
  1878. * wCellWidth / iTemp;
  1879. FontHeader.wFormatType = SWAPW(0x0002);
  1880. FontHeader.wDataSize = SWAPW(0x0086);
  1881. // CASIO 98/11/24 ->
  1882. // if( pIFI->jWinCharSet == SHIFTJIS_CHARSET ){
  1883. // FontHeader.wSymbolSet = SWAPW(id-FONT_MIN_ID+0x4000+0x8000); //id-FONT_MIN_ID + 4000h + 8000h
  1884. // FontHeader.wLast = (WORD)SWAPW (0x23ff);
  1885. // FontHeader.wFirst = (WORD)SWAPW (0x2020);
  1886. // }else{
  1887. FontHeader.wSymbolSet = SWAPW(id-FONT_MIN_ID+0x4000); //id-FONT_MIN_ID + 4000h
  1888. FontHeader.wLast = SWAPW (0xff);
  1889. FontHeader.wFirst = SWAPW (0x20);
  1890. // }
  1891. // CASIO 98/11/24 <-
  1892. if (pOEM->fGeneral & FG_PROP)
  1893. {
  1894. FontHeader.wCharSpace = SWAPW(1);
  1895. FontHeader.CharWidth.Integer = (WORD)SWAPW(0x0100);
  1896. FontHeader.CharWidth.Fraction = 0;
  1897. }
  1898. else
  1899. {
  1900. FontHeader.wCharSpace = 0;
  1901. FontHeader.CharWidth.Integer
  1902. = SWAPW(MasterToDevice(pOEM, wCellWidth));
  1903. FontHeader.CharWidth.Fraction = 0;
  1904. }
  1905. FontHeader.CharHeight.Integer
  1906. = SWAPW(MasterToDevice(pOEM, wCellHeight));
  1907. FontHeader.CharHeight.Fraction = 0;
  1908. // in the range 128 - 255
  1909. FontHeader.wFontID = SWAPW( id - FONT_MIN_ID + ( id < 0x80 ? 0x80 : 0x00));
  1910. FontHeader.wWeight = 0;
  1911. FontHeader.wEscapement = 0;
  1912. FontHeader.wItalic = 0;
  1913. FontHeader.wUnderline = 0;
  1914. FontHeader.wUnderlineWidth = SWAPW(10);
  1915. FontHeader.wOverline = 0;
  1916. FontHeader.wOverlineWidth = 0;
  1917. FontHeader.wStrikeOut = 0;
  1918. FontHeader.wStrikeOutWidth = 0;
  1919. FontHeader.wCellWidth
  1920. = SWAPW(MasterToDevice(pOEM, wCellWidth));
  1921. FontHeader.wCellHeight
  1922. = SWAPW(MasterToDevice(pOEM, wCellHeight));
  1923. FontHeader.wCellLeftOffset = SWAPW(iCellLeftOffset);
  1924. FontHeader.wCellAscender
  1925. = SWAPW((pIFI->fwdWinAscender
  1926. * MasterToDevice(pOEM, wCellHeight)));
  1927. FontHeader.FixPitchWidth.Integer
  1928. = SWAPW(MasterToDevice(pOEM, wFontPitch));
  1929. FontHeader.FixPitchWidth.Fraction = 0;
  1930. // Replacement of strsafe-api 2002.3.6 >>>
  1931. // iSizeFontName = wsprintf(sFontName,
  1932. // "________________________EPSON_ESC_PAGE_DOWNLOAD_FONT%02d",id-FONT_MIN_ID);
  1933. if (S_OK != StringCbPrintfExA(sFontName, sizeof(sFontName),
  1934. &pDestEnd, &szRemLen,
  1935. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1936. "________________________EPSON_ESC_PAGE_DOWNLOAD_FONT%02d",id-FONT_MIN_ID)) {
  1937. return 0;
  1938. }
  1939. iSizeFontName = (WORD)(pDestEnd - sFontName);
  1940. // iSizeOfBuf = wsprintf(Buff,SET_FONT_ID,FONT_HEADER_SIZE,id-FONT_MIN_ID);
  1941. if (S_OK != StringCbPrintfExA(Buff, sizeof(Buff),
  1942. &pDestEnd, &szRemLen,
  1943. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1944. SET_FONT_ID,FONT_HEADER_SIZE,id-FONT_MIN_ID)) {
  1945. return 0;
  1946. }
  1947. iSizeOfBuf = (WORD)(pDestEnd - Buff);
  1948. // Replacement of strsafe-api 2002.3.6 <<<<
  1949. WRITESPOOLBUF(pdevobj, Buff, iSizeOfBuf);
  1950. WRITESPOOLBUF(pdevobj, (LPSTR)&FontHeader,sizeof(ESCPAGEHEADER));
  1951. WRITESPOOLBUF(pdevobj, sFontName,iSizeFontName);
  1952. WRITESPOOLBUF(pdevobj, "EPC_PAGE_DOWNLOAD_FONT_INDEX", SIZE_SYMBOLSET);
  1953. // iSizeOfBuf = wsprintf(Buff,DLI_SELECT_FONT_ID,id-FONT_MIN_ID,0);
  1954. // WRITESPOOLBUF(pdevobj, Buff, iSizeOfBuf);
  1955. //
  1956. DL_VERBOSE(("DLFontHeader: ulFontID=%x, dwDLSetFontID=%x\n",
  1957. pUFObj->ulFontID, pOEM->dwDLSetFontID));
  1958. DL_VERBOSE(("FontHeader:\n"));
  1959. DL_VERBOSE(("wFormatType=%d\n", SWAPW(FontHeader.wFormatType)));
  1960. DL_VERBOSE(("wDataSize=%d\n", SWAPW(FontHeader.wDataSize)));
  1961. DL_VERBOSE(("wSymbolSet=%d\n", SWAPW(FontHeader.wSymbolSet)));
  1962. DL_VERBOSE(("wCharSpace=%d\n", SWAPW(FontHeader.wCharSpace)));
  1963. DL_VERBOSE(("CharWidth=%d.%d\n",
  1964. SWAPW(FontHeader.CharWidth.Integer),
  1965. FontHeader.CharWidth.Fraction));
  1966. DL_VERBOSE(("CharHeight=%d.%d\n",
  1967. SWAPW(FontHeader.CharHeight.Integer),
  1968. FontHeader.CharHeight.Fraction));
  1969. DL_VERBOSE(("wFontID=%d\n", SWAPW(FontHeader.wFontID)));
  1970. DL_VERBOSE(("wWeight=%d\n", SWAPW(FontHeader.wWeight)));
  1971. DL_VERBOSE(("wEscapement=%d\n", SWAPW(FontHeader.wEscapement)));
  1972. DL_VERBOSE(("wItalic=%d\n", SWAPW(FontHeader.wItalic)));
  1973. DL_VERBOSE(("wLast=%d\n", SWAPW(FontHeader.wLast)));
  1974. DL_VERBOSE(("wFirst=%d\n", SWAPW(FontHeader.wFirst)));
  1975. DL_VERBOSE(("wUnderline=%d\n", SWAPW(FontHeader.wUnderline)));
  1976. DL_VERBOSE(("wUnderlineWidth=%d\n", SWAPW(FontHeader.wUnderlineWidth)));
  1977. DL_VERBOSE(("wOverline=%d\n", SWAPW(FontHeader.wOverline)));
  1978. DL_VERBOSE(("wOverlineWidth=%d\n", SWAPW(FontHeader.wOverlineWidth)));
  1979. DL_VERBOSE(("wStrikeOut=%d\n", SWAPW(FontHeader.wStrikeOut)));
  1980. DL_VERBOSE(("wStrikeOutWidth=%d\n", SWAPW(FontHeader.wStrikeOutWidth)));
  1981. DL_VERBOSE(("wCellWidth=%d\n", SWAPW(FontHeader.wCellWidth)));
  1982. DL_VERBOSE(("wCellHeight=%d\n", SWAPW(FontHeader.wCellHeight)));
  1983. DL_VERBOSE(("wCellLeftOffset=%d\n", SWAPW(FontHeader.wCellLeftOffset)));
  1984. DL_VERBOSE(("wCellAscender=%d\n", SWAPW(FontHeader.wCellAscender)));
  1985. DL_VERBOSE(("FixPitchWidth=%d.%d\n",
  1986. SWAPW(FontHeader.FixPitchWidth.Integer),
  1987. FontHeader.FixPitchWidth.Fraction));
  1988. DL_VERBOSE(("FontName=%s\n", sFontName));
  1989. return FONT_HEADER_SIZE;
  1990. }
  1991. //////////////////////////////////////////////////////////////////////////
  1992. // Function: OEMDownloadCharGlyph
  1993. //////////////////////////////////////////////////////////////////////////
  1994. DWORD APIENTRY
  1995. OEMDownloadCharGlyph(
  1996. PDEVOBJ pdevobj,
  1997. PUNIFONTOBJ pUFObj,
  1998. HGLYPH hGlyph,
  1999. PDWORD pdwWidth
  2000. )
  2001. {
  2002. GETINFO_GLYPHBITMAP GBmp;
  2003. GLYPHDATA *pGdata;
  2004. GLYPHBITS *pbit;
  2005. DWORD dwNeeded;
  2006. WORD cp;
  2007. ESCPAGECHAR ESCPageChar;
  2008. WORD wWidth, Width, Hight;
  2009. LPDIBITS lpSrc;
  2010. BYTE mask;
  2011. int iSizeOfBuf, i;
  2012. DWORD dwSize, dwCellSize, dwAirSize;
  2013. BYTE Buff[32];
  2014. PMYPDEV pOEM;
  2015. PIFIMETRICS pIFI;
  2016. LPSTR pDestEnd; // 2002.3.6
  2017. size_t szRemLen; // 2002.3.6
  2018. pIFI = pUFObj->pIFIMetrics;
  2019. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  2020. MY_VERBOSE(("OEMDownloadCharGlyph() entry.\n"));
  2021. cp = (WORD)pOEM->wCharCode;
  2022. GBmp.dwSize = sizeof (GETINFO_GLYPHBITMAP);
  2023. GBmp.hGlyph = hGlyph;
  2024. GBmp.pGlyphData = NULL;
  2025. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHBITMAP, &GBmp, GBmp.dwSize, &dwNeeded))
  2026. {
  2027. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHBITMAP failed.\n"));
  2028. return 0;
  2029. }
  2030. pGdata = GBmp.pGlyphData;
  2031. pbit = pGdata->gdf.pgb;
  2032. DL_VERBOSE(("DLCharGlyph: dwDLFont=%x, dwDLSetFont=%x, wCharCode=%x\n",
  2033. pOEM->dwDLFontID, pOEM->dwDLSetFontID, pOEM->wCharCode));
  2034. // Set font id if not already
  2035. if (pOEM->dwDLFontID != pOEM->dwDLSetFontID)
  2036. VSetSelectDLFont(pdevobj, pOEM->dwDLSetFontID);
  2037. // fill in the charcter header information.
  2038. ESCPageChar.bFormat = 0x01;
  2039. ESCPageChar.bDataDir = 0x10;
  2040. // CASIO 98/11/24 ->
  2041. // if( pIFI->jWinCharSet == SHIFTJIS_CHARSET ){
  2042. // cp += SJISCHR;
  2043. // ESCPageChar.wCharCode = SWAPW(cp);
  2044. // }else{
  2045. ESCPageChar.wCharCode = LOBYTE(cp);
  2046. // }
  2047. // CASIO 98/11/24 <-
  2048. ESCPageChar.wBitmapWidth = SWAPW(pbit->sizlBitmap.cx);
  2049. ESCPageChar.wBitmapHeight = SWAPW(pbit->sizlBitmap.cy);
  2050. // MSKK 98/04/06 ->
  2051. // ESCPageChar.wLeftOffset = SWAPW(pbit->ptlOrigin.x);
  2052. // ESCPageChar.wAscent = SWAPW(pbit->ptlOrigin.y * -1);
  2053. ESCPageChar.wLeftOffset = (pbit->ptlOrigin.x > 0 ?
  2054. SWAPW(pbit->ptlOrigin.x) : 0);
  2055. ESCPageChar.wAscent = (pbit->ptlOrigin.y < 0 ?
  2056. SWAPW(pbit->ptlOrigin.y * -1) : 0);
  2057. // MSKK 98/04/06 <-
  2058. ESCPageChar.CharWidth.Integer = SWAPW(pGdata->fxD / 16);
  2059. ESCPageChar.CharWidth.Fraction = 0;
  2060. *pdwWidth = ESCPageChar.CharWidth.Integer;
  2061. Width = LOWORD(pbit->sizlBitmap.cx);
  2062. wWidth = (LOWORD(pbit->sizlBitmap.cx) + 7) >> 3;
  2063. Hight = LOWORD(pbit->sizlBitmap.cy);
  2064. // not multiple of 8, need to mask out unused last byte
  2065. // This is done so that we do not advance beyond segment bound
  2066. // which can happen if lpBitmap is just under 64K and adding
  2067. // width to it will cause invalid segment register to be loaded.
  2068. if (mask = bit_mask[LOWORD(Width) & 0x7])
  2069. {
  2070. lpSrc = pbit->aj + wWidth - 1;
  2071. i = LOWORD(Hight);
  2072. while (TRUE)
  2073. {
  2074. (*lpSrc) &= mask;
  2075. i--;
  2076. if (i > 0)
  2077. lpSrc += wWidth;
  2078. else
  2079. break;
  2080. }
  2081. }
  2082. dwCellSize = (DWORD)pbit->sizlBitmap.cy * wWidth;
  2083. dwSize = (DWORD)(LOWORD(Hight)) * wWidth;
  2084. // Replacement of strsafe-api 2002.3.6 >>>
  2085. //// CASIO 98/11/24 ->
  2086. //// if( pIFI->jWinCharSet == SHIFTJIS_CHARSET ){
  2087. //// iSizeOfBuf = wsprintf(Buff,SET_DOUBLE_BMP,dwCellSize + sizeof(ESCPAGECHAR),HIBYTE(cp),LOBYTE(cp));
  2088. //// }else{
  2089. // iSizeOfBuf = wsprintf(Buff,SET_SINGLE_BMP,dwCellSize + sizeof(ESCPAGECHAR),LOBYTE(cp));
  2090. //// }
  2091. //// CASIO 98/11/24 <-
  2092. if (S_OK != StringCbPrintfExA(Buff, sizeof(Buff),
  2093. &pDestEnd, &szRemLen,
  2094. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  2095. SET_SINGLE_BMP,dwCellSize + sizeof(ESCPAGECHAR),LOBYTE(cp))) {
  2096. return 0;
  2097. }
  2098. iSizeOfBuf = (WORD)(pDestEnd - Buff);
  2099. // Replacement of strsafe-api 2002.3.6 <<<
  2100. WRITESPOOLBUF(pdevobj, Buff, iSizeOfBuf);
  2101. WRITESPOOLBUF(pdevobj, (LPSTR)&ESCPageChar, sizeof(ESCPAGECHAR));
  2102. for (lpSrc = pbit->aj; dwSize; lpSrc += wWidth)
  2103. {
  2104. if ( dwSize > 0x4000 )
  2105. wWidth = 0x4000;
  2106. else
  2107. wWidth = LOWORD(dwSize);
  2108. dwSize -= wWidth;
  2109. WRITESPOOLBUF(pdevobj, (LPSTR)lpSrc, (WORD)wWidth);
  2110. }
  2111. MY_VERBOSE(("ESCPageChar:\n"));
  2112. MY_VERBOSE(("bFormat=%d\n", ESCPageChar.bFormat));
  2113. MY_VERBOSE(("bDataDir=%d\n", ESCPageChar.bDataDir));
  2114. MY_VERBOSE(("wCharCode=%d\n", SWAPW(ESCPageChar.wCharCode)));
  2115. MY_VERBOSE(("wBitmapWidth=%d\n", SWAPW(ESCPageChar.wBitmapWidth)));
  2116. MY_VERBOSE(("wBitmapHeight=%d\n", SWAPW(ESCPageChar.wBitmapHeight)));
  2117. MY_VERBOSE(("wLeftOffset=%d\n", SWAPW(ESCPageChar.wLeftOffset)));
  2118. MY_VERBOSE(("wAscent=%d\n", SWAPW(ESCPageChar.wAscent)));
  2119. MY_VERBOSE(("CharWidth=%d.%d\n", SWAPW(ESCPageChar.CharWidth.Integer),
  2120. ESCPageChar.CharWidth.Fraction));
  2121. return sizeof(ESCPAGECHAR) + dwCellSize;
  2122. }
  2123. //////////////////////////////////////////////////////////////////////////
  2124. // Function: OEMTTDownloadMethod
  2125. //////////////////////////////////////////////////////////////////////////
  2126. DWORD APIENTRY
  2127. OEMTTDownloadMethod(
  2128. PDEVOBJ pdevobj,
  2129. PUNIFONTOBJ pUFObj
  2130. )
  2131. {
  2132. DWORD dwRet;
  2133. // Default is to download.
  2134. dwRet = TTDOWNLOAD_BITMAP;
  2135. DL_VERBOSE(("TTDLMethod: dwRet=%d\n", dwRet));
  2136. return dwRet;
  2137. }
  2138. VOID APIENTRY
  2139. OEMMemoryUsage(
  2140. PDEVOBJ pdevobj,
  2141. POEMMEMORYUSAGE pMemoryUsage
  2142. )
  2143. {
  2144. PMYPDEV pOEM = (PMYPDEV)pdevobj->pdevOEM;
  2145. if (pOEM->iColor == XX_COLOR_SINGLE
  2146. || pOEM->iColor == XX_COLOR_MANY
  2147. || pOEM->iColor == XX_COLOR_MANY2) {
  2148. pMemoryUsage->dwFixedMemoryUsage =
  2149. LUTSIZ016 + LUTSIZ032 + LUTSIZRGB + LUTSIZCMY +
  2150. CCHRGBSIZ + CCHCMYSIZ +
  2151. LUTGLBWRK + LUT032WRK + DIZINFWRK +
  2152. LUTFILESIZ + DIZFILESIZ + LUT032SIZ +
  2153. UCRTBLSIZ + UCRWRKSIZ + sRGBLUTFILESIZ + LUTMAKGLBSIZ;
  2154. pMemoryUsage->dwPercentMemoryUsage = 100 * (pOEM->Col.DatBit * 4 + 24 + 32) / 32;
  2155. MY_VERBOSE(("OEMMemoryUsage() dwFixedMemoryUsage:[%d]\n", pMemoryUsage->dwFixedMemoryUsage));
  2156. MY_VERBOSE((" dwPercentMemoryUsage:[%d]\n", pMemoryUsage->dwPercentMemoryUsage));
  2157. MY_VERBOSE((" pOEM->Col.DatBit:[%d]\n", pOEM->Col.DatBit));
  2158. MY_VERBOSE(("OEMMemOryUsage pOEM->Col.DatBit = %d\n",pOEM->Col.DatBit));
  2159. }
  2160. return;
  2161. }
  2162. // End of File