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.

2352 lines
82 KiB

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