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.

2006 lines
66 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. casn4res.c
  11. Abstract:
  12. Implementation of GPD command callback for "csn4j.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 "strsafe.h" // Security-Code 2002.3.6
  23. //
  24. // For debugging.
  25. //
  26. //#define DL_VERBOSE WARNING
  27. #define DL_VERBOSE VERBOSE
  28. //#define SC_VERBOSE WARNING
  29. #define SC_VERBOSE VERBOSE
  30. //
  31. // Misc definitions and declarations.
  32. //
  33. #define BUFFLEN 256
  34. // Replacement of strsafe-api 2002.3.6 >>>
  35. //#ifdef wsprintf
  36. //#undef wsprintf
  37. //#endif // wsprintf
  38. //#define wsprintf sprintf
  39. // Replacement of strsafe-api 2002.3.6 <<<
  40. #define SWAPW(x) \
  41. ((WORD)(((WORD)(x))<<8)|(WORD)(((WORD)(x))>>8))
  42. #define FONT_HEADER_SIZE 0x86 // format type 2
  43. #define SIZE_SYMBOLSET 28
  44. #define FONT_MIN_ID 512
  45. #define FONT_MAX_ID 535
  46. #define SJISCHR 0x2000
  47. #define IsValidDLFontID(x) \
  48. ((x) >= FONT_MIN_ID && (x) <= FONT_MAX_ID)
  49. LONG
  50. LGetPointSize100(
  51. LONG height,
  52. LONG vertRes);
  53. // Replacement of strsafe-api 2002.3.6 >>>
  54. //LONG
  55. //LConvertFontSizeToStr(
  56. // LONG size,
  57. // PSTR pStr);
  58. LONG
  59. LConvertFontSizeToStr(
  60. LONG size,
  61. PSTR pStr,
  62. size_t StrSize);
  63. // Replacement of strsafe-api 2002.3.6 <<<
  64. //
  65. // Command callback ID's
  66. //
  67. #define TEXT_FS_SINGLE_BYTE 21
  68. #define TEXT_FS_DOUBLE_BYTE 22
  69. #define DOWNLOAD_SET_FONT_ID 23
  70. #define DOWNLOAD_SELECT_FONT_ID 24
  71. #define DOWNLOAD_SET_CHAR_CODE 25
  72. #define DOWNLOAD_DELETE_FONT 26
  73. #define FS_BOLD_ON 27
  74. #define FS_BOLD_OFF 28
  75. #define FS_ITALIC_ON 29
  76. #define FS_ITALIC_OFF 30
  77. #define RES_SELECTRES_300 70
  78. #define RES_SELECTRES_600 71
  79. #define RES_SELECTRES_300_COLOR 72
  80. #define PC_BEGINDOC 82
  81. #define PC_ENDDOC 83
  82. #define PC_DUPLEX_NONE 90
  83. #define PC_DUPLEX_VERT 91
  84. #define PC_DUPLEX_HORZ 92
  85. #define PC_PORTRAIT 93
  86. #define PC_LANDSCAPE 94
  87. #define PSRC_SELECT_CASETTE_1 100
  88. #define PSRC_SELECT_CASETTE_2 101
  89. #define PSRC_SELECT_CASETTE_3 102
  90. #define PSRC_SELECT_MPF 103
  91. #define PSRC_SELECT_AUTO 104
  92. #define XXXX_TONER_SAVE_NONE 110
  93. #define XXXX_TONER_SAVE_1 111
  94. #define XXXX_TONER_SAVE_2 112
  95. #define XXXX_TONER_SAVE_3 113
  96. #define SMOOTHING_ON 120
  97. #define SMOOTHING_OFF 121
  98. #define JAMRECOVERY_ON 130
  99. #define JAMRECOVERY_OFF 131
  100. #define MediaType_1 140
  101. #define MediaType_2 141
  102. #define MediaType_3 142 //+CP-E8000
  103. #define RECT_FILL_WIDTH 150
  104. #define RECT_FILL_HEIGHT 151
  105. #define RECT_FILL_GRAY 152
  106. #define RECT_FILL_WHITE 153
  107. #define RECT_FILL_BLACK 154
  108. #if 0 /* OEM doesn't want to fix minidriver */
  109. /* Below is def. for hack code to fix #412276 */
  110. #define COLOR_SELECT_BLACK 160
  111. #define COLOR_SELECT_RED 161
  112. #define COLOR_SELECT_GREEN 162
  113. #define COLOR_SELECT_BLUE 163
  114. #define COLOR_SELECT_YELLOW 164
  115. #define COLOR_SELECT_MAGENTA 165
  116. #define COLOR_SELECT_CYAN 166
  117. #define COLOR_SELECT_WHITE 167
  118. #define DUMP_RASTER_CYAN 170
  119. #define DUMP_RASTER_MAGENTA 171
  120. #define DUMP_RASTER_YELLOW 172
  121. #define DUMP_RASTER_BLACK 173
  122. /* End of hack code */
  123. #endif /* OEM doesn't want to fix minidriver */
  124. //+CP-E8000 Begin
  125. #define OUTBIN_SELECT_EXIT_1 190
  126. #define OUTBIN_SELECT_EXIT_2 191
  127. #define OUTBIN_SELECT_EXIT_3 192
  128. #define OUTBIN_SELECT_EXIT_4 193
  129. #define OUTBIN_SELECT_EXIT_5 194
  130. #define OUTBIN_SELECT_EXIT_6 195
  131. //+CP-E8000 End
  132. // Modification of Color-mode command 2002.3.28 >>>
  133. #define OPT_MONO "Mono"
  134. #define OPT_COLOR "Color"
  135. // Modification of Color-mode command 2002.3.28 <<<
  136. //
  137. // ---- S T R U C T U R E D E F I N E ----
  138. //
  139. typedef BYTE * LPDIBITS;
  140. typedef struct {
  141. WORD Integer;
  142. WORD Fraction;
  143. } FRAC;
  144. typedef struct {
  145. BYTE bFormat;
  146. BYTE bDataDir;
  147. WORD wCharCode;
  148. WORD wBitmapWidth;
  149. WORD wBitmapHeight;
  150. WORD wLeftOffset;
  151. WORD wAscent;
  152. FRAC CharWidth;
  153. } ESCPAGECHAR;
  154. typedef struct {
  155. WORD wFormatType;
  156. WORD wDataSize;
  157. WORD wSymbolSet;
  158. WORD wCharSpace;
  159. FRAC CharWidth;
  160. FRAC CharHeight;
  161. WORD wFontID;
  162. WORD wWeight;
  163. WORD wEscapement;
  164. WORD wItalic;
  165. WORD wLast;
  166. WORD wFirst;
  167. WORD wUnderline;
  168. WORD wUnderlineWidth;
  169. WORD wOverline;
  170. WORD wOverlineWidth;
  171. WORD wStrikeOut;
  172. WORD wStrikeOutWidth;
  173. WORD wCellWidth;
  174. WORD wCellHeight;
  175. WORD wCellLeftOffset;
  176. WORD wCellAscender;
  177. FRAC FixPitchWidth;
  178. } ESCPAGEHEADER, FAR * LPESCPAGEHEADER;
  179. //
  180. // Static data to be used by this minidriver.
  181. //
  182. BYTE bit_mask[] = {0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe};
  183. #define BYTE_LENGTH(s) (sizeof (s) - 1)
  184. BYTE BEGINDOC_EJL_BEGIN[] =
  185. "\x1bz\x00\x80"
  186. "\x1b\x01@EJL \x0a"
  187. "@EJL SET";
  188. BYTE BEGINDOC_EJL_END[] =
  189. " ERRORCODE=ON"
  190. "\x0a"
  191. "@EJL EN LA=ESC/PAGE\x0a";
  192. BYTE BEGINDOC_EPG_END[] =
  193. "\x1DrhE\x1D\x32\x34ifF\x1D\x31\x34isE"
  194. "\x1D\x32iaF\x1D\x31\x30ifF"
  195. "\x1D\x31ipP"
  196. "\x1B\x7A\xD0\x01\x43\x61\x2A\x1B\x7A\x00\x01"
  197. "\x1D\x30pmP";
  198. // CASIO 00/09/16 ->
  199. //BYTE ENDDOC_EJL_RESET[] = "\x1d\rhE"
  200. BYTE ENDDOC_EJL_RESET[] = "\x1drhE"
  201. // CASIO 00/09/16 <-
  202. "\x1b\x01@EJL \x0a"
  203. "\x1b\x01@EJL \x0a"
  204. "\x1bz\xb0\x00";
  205. char SET_FONT_ID[] = "\x1D%d;%ddh{F";
  206. char DLI_SELECT_FONT_ID[] = "\x1D%ddcF\x1D\x30;-%dcoP";
  207. char DLI_DELETE_FONT[] = "\x1D%dddcF";
  208. char SET_SINGLE_BMP[] = "\x1D%d;%dsc{F";
  209. char SET_DOUBLE_BMP[] = "\x1D%d;%d;%dsc{F";
  210. char SET_WIDTH_TBL[] = "\x1D%d;%dcw{F";
  211. char FS_SINGLE_BYTE[] = "\x1D\x31;0mcF";
  212. char FS_DOUBLE_BYTE[] = "\x1D\x31;1mcF";
  213. char PRN_DIRECTION[] = "\x1D%droF";
  214. char SET_CHAR_OFFSET[] = "\x1D\x30;%dcoP";
  215. char SET_CHAR_OFFSET_XY[] = "\x1D%d;%dcoP";
  216. char VERT_FONT_SET[] = "\x1D%dvpC";
  217. char BOLD_SET[] = "\x1D%dweF";
  218. char ITALIC_SET[] = "\x1D%dslF";
  219. BYTE RECT_FILL[] =
  220. "\x1D" "1owE"
  221. "\x1D" "1tsE"
  222. "\x1D" "0;0;%dspE"
  223. "\x1D" "1dmG"
  224. "\x1D" "%d;%d;%d;%d;0rG"
  225. // do not turn overwrite mode off since it
  226. // has bad effect over white-on-black texts
  227. // "\x1D" "0owE"
  228. "\x1D" "0tsE";
  229. #define PSRC_CASETTE_1 0
  230. #define PSRC_CASETTE_2 1
  231. #define PSRC_CASETTE_3 2
  232. #define PSRC_MPF 3
  233. #define PSRC_AUTO 4
  234. // CASIO 00/09/13 ->
  235. BYTE *EJL_SelectPsrc[] = {
  236. // " PU=1", " PU=2", " PU=3", " PU=4", " PU=AU" };
  237. " PU=1", " PU=2", " PU=255", " PU=4", " PU=AU" };
  238. // CASIO 00/09/13 <-
  239. BYTE *EJL_SelectOrient[] = {
  240. " ORIENTATION=PORTRAIT", " ORIENTATION=LANDSCAPE" };
  241. #define RES_300DPI 0
  242. #define RES_600DPI 1
  243. BYTE *EJL_SelectRes[] = {
  244. " ##RZ=OFF", " ##RZ=ON" };
  245. BYTE *EPg_SelectRes[] = {
  246. "\x1D" "0;300;300drE\x1D" "1;300;300drE\x1D" "2;240;240drE",
  247. "\x1D" "0;600;600drE\x1D" "1;600;600drE\x1D" "2;240;240drE" };
  248. #define DUPLEX_NONE 0
  249. #define DUPLEX_SIDE 1
  250. #define DUPLEX_UP 2
  251. BYTE *EJL_SetDuplex[] = {
  252. " ##DC=OFF", " ##DC=DUPON", " ##DC=DUPUP" };
  253. #define XX_TONER_NORMAL 0
  254. #define XX_TONER_SAVE_1 1
  255. #define XX_TONER_SAVE_2 2
  256. #define XX_TONER_SAVE_3 3
  257. BYTE *EJL_SetTonerSave[] = {
  258. " ##TS=NORMAL", " ##TS=1", " ##TS=2", " ##TS=3" };
  259. // Modification of Color-mode command 2002.3.28 >>>
  260. //BYTE *EJL_SetColorMode[] = {
  261. // " ##CM=OFF", " ##CM=ON" };
  262. BYTE *EJL_SetColorMode[] = {
  263. " ##CM=OFF", " ##CM=NML", " ##CM=ECO", " ##CM=ECO2" };
  264. // Modification of Color-mode command 2002.3.28 >>>
  265. #define XX_SMOOTHING_OFF 0
  266. #define XX_SMOOTHING_ON 1
  267. BYTE *EJL_SetSmoohing[] = {
  268. " RI=OFF", " RI=ON" };
  269. #define XX_JAMRECOVERY_OFF 0
  270. #define XX_JAMRECOVERY_ON 1
  271. BYTE *EJL_SetJamRecovery[] = {
  272. " ##JC=OFF", " ##JC=ON" };
  273. #define XX_MediaType_1 1
  274. #define XX_MediaType_2 2
  275. //+CP-E8000 Begin
  276. #define XX_MediaType_3 3
  277. BYTE *EJL_SetMediaType[] = {
  278. " PK=NM", " PK=OS", " PK=TH" };
  279. //+CP-E8000 End
  280. //+CP-E8000 Begin
  281. #define OUTBIN_EXIT_1 1
  282. #define OUTBIN_EXIT_2 2
  283. #define OUTBIN_EXIT_3 3
  284. #define OUTBIN_EXIT_4 4
  285. #define OUTBIN_EXIT_5 5
  286. #define OUTBIN_EXIT_6 6
  287. BYTE *EJL_SelectOutbin[] = {
  288. " ##ET=1", " ##ET=3", " ##ET=4", " ##ET=5", " ##ET=6", " ##ET=7" };
  289. #define JOBSHIFT_OFF 0
  290. #define JOBSHIFT_ON 1
  291. BYTE *EJL_JobShift[] = {
  292. " ##JO=OFF", " ##JO=ON" };
  293. //+CP-E8000 End
  294. #if 0 /* OEM doesn't want to fix minidriver */
  295. /* Below is def. for hack code to fix #412276 */
  296. BYTE *COLOR_SELECT_COMMAND[] = {
  297. "\x1Bz\xD0\x01\x43\x63,0,0,0,255*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Black */
  298. "\x1Bz\xD0\x01\x43\x62,255,0,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Red */
  299. "\x1Bz\xD0\x01\x43\x62,0,255,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Green */
  300. "\x1Bz\xD0\x01\x43\x62,0,0,255*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Blue */
  301. "\x1Bz\xD0\x01\x43\x63,0,0,255,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Yellow */
  302. "\x1Bz\xD0\x01\x43\x63,0,255,0,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Magenta */
  303. "\x1Bz\xD0\x01\x43\x63,255,0,0,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE", /* Cyan */
  304. "\x1Bz\xD0\x01\x43\x63,0,0,0,0*\x1Bz\x00\x01\x1D\x31owE\x1D\x31tsE\x1D\x31;0;100spE" /* White */
  305. };
  306. DWORD COLOR_SELECT_COMMAND_LEN[] = { 42, 39, 39, 39, 42, 42, 42, 39 };
  307. BYTE *DUMP_RASTER_COMMAND[] = {
  308. "\x1Bz\xD0\x01\x43\x63,255,0,0,0*\x1Bz\x00\x01\x1D\x30owE\x1D\x30tsE", /* Cyan */
  309. "\x1Bz\xD0\x01\x43\x63,0,255,0,0*\x1Bz\x00\x01\x1D\x30owE\x1D\x30tsE", /* Magenta */
  310. "\x1Bz\xD0\x01\x43\x63,0,0,255,0*\x1Bz\x00\x01\x1D\x30owE\x1D\x30tsE", /* Yellow */
  311. "\x1Bz\xD0\x01\x43\x63,0,0,0,255*\x1Bz\x00\x01\x1D\x30owE\x1D\x30tsE" /* Black */
  312. };
  313. #define DUMP_RASTER_COMMAND_LEN 31
  314. /* End of hack code */
  315. #endif /* OEM doesn't want to fix minidriver */
  316. #define MasterToDevice(p, i) \
  317. ((i) / ((PMYPDEV)(p))->iUnitFactor)
  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. PDEVOEM APIENTRY
  349. OEMEnablePDEV(
  350. PDEVOBJ pdevobj,
  351. PWSTR pPrinterName,
  352. ULONG cPatterns,
  353. HSURF *phsurfPatterns,
  354. ULONG cjGdiInfo,
  355. GDIINFO *pGdiInfo,
  356. ULONG cjDevInfo,
  357. DEVINFO *pDevInfo,
  358. DRVENABLEDATA *pded)
  359. {
  360. PMYPDEV pOEM;
  361. // Modification of Color-mode command 2002.3.28 >>>
  362. BYTE byOutput[64];
  363. DWORD dwNeeded;
  364. DWORD dwOptionsReturned;
  365. // Modification of Color-mode command 2002.3.28 <<<
  366. if(!pdevobj->pdevOEM)
  367. {
  368. if(!(pdevobj->pdevOEM = MemAllocZ(sizeof(MYPDEV))))
  369. {
  370. ERR(("Faild to allocate memory. (%d)\n",
  371. GetLastError()));
  372. return NULL;
  373. }
  374. }
  375. pOEM = (PMYPDEV)pdevobj->pdevOEM;
  376. pOEM->fGeneral = 0;
  377. pOEM->iEscapement = 0;
  378. pOEM->iDevCharOffset = 0;
  379. pOEM->iPaperSource = 0;
  380. pOEM->iDuplex = 0;
  381. pOEM->iTonerSave = 0;
  382. pOEM->iOrientation = 0;
  383. pOEM->iResolution = 0;
  384. pOEM->iColor = 0;
  385. pOEM->iSmoothing = 0;
  386. pOEM->iJamRecovery = 0;
  387. pOEM->iMediaType = 0;
  388. //+CP-E8000 Begin
  389. pOEM->iOutBin = 0;
  390. //+CP-E8000 End
  391. // Modification of Color-mode command 2002.3.28 >>>
  392. // ColorMode
  393. if (!DRVGETDRIVERSETTING(pdevobj, "ColorMode", byOutput,
  394. sizeof(BYTE) * 64, &dwNeeded, &dwOptionsReturned)) {
  395. ERR(("DrvGetDriverSetting(ColorMode) Failed\n"));
  396. pOEM->iColor = 0;
  397. } else {
  398. if (!strcmp(byOutput, OPT_COLOR)) {
  399. pOEM->iColor = 2;
  400. } else if (!strcmp(byOutput, OPT_MONO)) {
  401. pOEM->iColor = 0;
  402. }
  403. }
  404. // Modification of Color-mode command 2002.3.28 <<<
  405. pOEM->dwDLFontID = UNKNOWN_DLFONT_ID;
  406. pOEM->dwDLSelectFontID = UNKNOWN_DLFONT_ID;
  407. pOEM->dwDLSetFontID = UNKNOWN_DLFONT_ID;
  408. pOEM->wCharCode = 0;
  409. pOEM->iUnitFactor = 1;
  410. return pdevobj->pdevOEM;
  411. }
  412. VOID APIENTRY
  413. OEMDisablePDEV(
  414. PDEVOBJ pdevobj)
  415. {
  416. if(pdevobj->pdevOEM)
  417. {
  418. MemFree(pdevobj->pdevOEM);
  419. pdevobj->pdevOEM = NULL;
  420. }
  421. return;
  422. }
  423. BOOL APIENTRY OEMResetPDEV(
  424. PDEVOBJ pdevobjOld,
  425. PDEVOBJ pdevobjNew)
  426. {
  427. PMYPDEV pOEMOld, pOEMNew;
  428. pOEMOld = (PMYPDEV)pdevobjOld->pdevOEM;
  429. pOEMNew = (PMYPDEV)pdevobjNew->pdevOEM;
  430. if (pOEMOld != NULL && pOEMNew != NULL)
  431. *pOEMNew = *pOEMOld;
  432. return TRUE;
  433. }
  434. //////////////////////////////////////////////////////////////////////////
  435. // Function: OEMCommandCallback
  436. //////////////////////////////////////////////////////////////////////////
  437. INT
  438. APIENTRY
  439. OEMCommandCallback(
  440. PDEVOBJ pdevobj,
  441. DWORD dwCmdCbID,
  442. DWORD dwCount,
  443. PDWORD pdwParams
  444. )
  445. {
  446. INT iRet = 0;
  447. BYTE *bp;
  448. BYTE Cmd[BUFFLEN];
  449. PMYPDEV pOEM;
  450. WORD wlen;
  451. WORD wGray;
  452. DWORD dwTempX, dwTempY;
  453. LPSTR pDestEnd; // 2002.3.6
  454. size_t szRemLen; // 2002.3.6
  455. VERBOSE(("OEMCommandCallback() entry.\n"));
  456. //
  457. // verify pdevobj okay
  458. //
  459. ASSERT(VALID_PDEVOBJ(pdevobj));
  460. //
  461. // fill in printer commands
  462. //
  463. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  464. switch (dwCmdCbID) {
  465. case FS_BOLD_ON:
  466. case FS_BOLD_OFF:
  467. if(pdwParams[0])
  468. pOEM->fGeneral |= FG_BOLD;
  469. else
  470. pOEM->fGeneral &= ~FG_BOLD;
  471. // Replacement of strsafe-api 2002.3.6 >>>
  472. // wlen = (WORD)wsprintf(Cmd,BOLD_SET, (pOEM->fGeneral & FG_BOLD)?15:0);
  473. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  474. &pDestEnd, &szRemLen,
  475. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  476. BOLD_SET, (pOEM->fGeneral & FG_BOLD)?15:0)) {
  477. break;
  478. }
  479. wlen = (WORD)(pDestEnd - Cmd);
  480. // Replacement of strsafe-api 2002.3.6 <<<
  481. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  482. break;
  483. case FS_ITALIC_ON:
  484. case FS_ITALIC_OFF:
  485. if(pdwParams[0])
  486. pOEM->fGeneral |= FG_ITALIC;
  487. else
  488. pOEM->fGeneral &= ~FG_ITALIC;
  489. // Replacement of strsafe-api 2002.3.6 >>>
  490. // wlen = (WORD)wsprintf(Cmd,ITALIC_SET, (pOEM->fGeneral & FG_ITALIC)?346:0);
  491. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  492. &pDestEnd, &szRemLen,
  493. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  494. ITALIC_SET, (pOEM->fGeneral & FG_ITALIC)?346:0)) {
  495. break;
  496. }
  497. wlen = (WORD)(pDestEnd - Cmd);
  498. // Replacement of strsafe-api 2002.3.6 <<<
  499. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  500. break;
  501. case TEXT_FS_SINGLE_BYTE:
  502. // Replacement of strsafe-api 2002.3.6 >>>
  503. // strcpy(Cmd,FS_SINGLE_BYTE);
  504. // wlen = (WORD)strlen( Cmd );
  505. // wlen += (WORD)wsprintf(&Cmd[wlen],PRN_DIRECTION,pOEM->iEscapement);
  506. if (S_OK != StringCbCopyExA(Cmd, sizeof(Cmd), FS_SINGLE_BYTE,
  507. &pDestEnd, &szRemLen,
  508. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  509. break;
  510. }
  511. wlen = (WORD)(pDestEnd - Cmd);
  512. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  513. &pDestEnd, &szRemLen,
  514. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  515. PRN_DIRECTION, pOEM->iEscapement)) {
  516. break;
  517. }
  518. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  519. // Replacement of strsafe-api 2002.3.6 <<<
  520. if (pOEM->fGeneral & FG_VERT)
  521. {
  522. // Replacement of strsafe-api 2002.3.6 >>>
  523. // wlen += (WORD)wsprintf(&Cmd[wlen], VERT_FONT_SET, 0);
  524. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  525. &pDestEnd, &szRemLen,
  526. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  527. VERT_FONT_SET, 0)) {
  528. break;
  529. }
  530. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  531. // Replacement of strsafe-api 2002.3.6 <<<
  532. }
  533. pOEM->fGeneral &= ~FG_DOUBLE;
  534. // Replacement of strsafe-api 2002.3.6 >>>
  535. // wlen += (WORD)wsprintf(&Cmd[wlen],BOLD_SET,
  536. // (pOEM->fGeneral & FG_BOLD)?15:0);
  537. // wlen += (WORD)wsprintf(&Cmd[wlen],ITALIC_SET,
  538. // (pOEM->fGeneral & FG_ITALIC)?346:0);
  539. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  540. &pDestEnd, &szRemLen,
  541. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  542. BOLD_SET, (pOEM->fGeneral & FG_BOLD)?15:0)) {
  543. break;
  544. }
  545. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  546. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  547. &pDestEnd, &szRemLen,
  548. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  549. ITALIC_SET, (pOEM->fGeneral & FG_ITALIC)?346:0)) {
  550. break;
  551. }
  552. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  553. // Replacement of strsafe-api 2002.3.6 <<<
  554. WRITESPOOLBUF(pdevobj, Cmd, wlen);
  555. break;
  556. case TEXT_FS_DOUBLE_BYTE:
  557. // Replacement of strsafe-api 2002.3.6 >>>
  558. // strcpy(Cmd,FS_DOUBLE_BYTE);
  559. // wlen = (WORD)strlen( Cmd );
  560. // wlen += (WORD)wsprintf(&Cmd[wlen],PRN_DIRECTION,pOEM->iEscapement);
  561. if (S_OK != StringCbCopyExA(Cmd, sizeof(Cmd), FS_DOUBLE_BYTE,
  562. &pDestEnd, &szRemLen,
  563. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  564. break;
  565. }
  566. wlen = (WORD)(pDestEnd - Cmd);
  567. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  568. &pDestEnd, &szRemLen,
  569. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  570. PRN_DIRECTION, pOEM->iEscapement)) {
  571. break;
  572. }
  573. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  574. // Replacement of strsafe-api 2002.3.6 <<<
  575. if (pOEM->fGeneral & FG_VERT)
  576. {
  577. // Replacement of strsafe-api 2002.3.6 >>>
  578. // wlen += (WORD)wsprintf(&Cmd[wlen], VERT_FONT_SET, 1);
  579. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  580. &pDestEnd, &szRemLen,
  581. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  582. VERT_FONT_SET,1)) {
  583. break;
  584. }
  585. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  586. // Replacement of strsafe-api 2002.3.6 <<<
  587. }
  588. pOEM->fGeneral |= FG_DOUBLE;
  589. // Replacement of strsafe-api 2002.3.6 >>>
  590. // wlen += (WORD)wsprintf(&Cmd[wlen],BOLD_SET,
  591. // (pOEM->fGeneral & FG_BOLD)?15:0);
  592. // wlen += (WORD)wsprintf(&Cmd[wlen],ITALIC_SET,
  593. // (pOEM->fGeneral & FG_ITALIC)?346:0);
  594. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  595. &pDestEnd, &szRemLen,
  596. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  597. BOLD_SET, (pOEM->fGeneral & FG_BOLD)?15:0)) {
  598. break;
  599. }
  600. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  601. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  602. &pDestEnd, &szRemLen,
  603. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  604. ITALIC_SET, (pOEM->fGeneral & FG_ITALIC)?346:0)) {
  605. break;
  606. }
  607. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  608. // Replacement of strsafe-api 2002.3.6 <<<
  609. WRITESPOOLBUF(pdevobj, Cmd, wlen);
  610. break;
  611. case RES_SELECTRES_300:
  612. pOEM->iResolution = RES_300DPI;
  613. // Modification of Color-mode command 2002.3.28 >>>
  614. // pOEM->iColor = 0;
  615. // Modification of Color-mode command 2002.3.28 <<<
  616. pOEM->iUnitFactor = MASTER_UNIT / 300;
  617. break;
  618. case RES_SELECTRES_600:
  619. pOEM->iResolution = RES_600DPI;
  620. // Modification of Color-mode command 2002.3.28 >>>
  621. // pOEM->iColor = 0;
  622. // Modification of Color-mode command 2002.3.28 <<<
  623. pOEM->iUnitFactor = MASTER_UNIT / 600;
  624. break;
  625. case RES_SELECTRES_300_COLOR:
  626. pOEM->iResolution = RES_300DPI;
  627. // Modification of Color-mode command 2002.3.28 >>>
  628. // pOEM->iColor = 2;
  629. // Modification of Color-mode command 2002.3.28 <<<
  630. pOEM->iUnitFactor = MASTER_UNIT / 300;
  631. break;
  632. case PC_PORTRAIT:
  633. pOEM->iOrientation = 0;
  634. break;
  635. case PC_LANDSCAPE:
  636. pOEM->iOrientation = 1;
  637. break;
  638. case PC_DUPLEX_NONE:
  639. pOEM->iDuplex = (DUPLEX_NONE + 1);
  640. break;
  641. case PC_DUPLEX_VERT:
  642. pOEM->iDuplex =
  643. (pOEM->iOrientation ?
  644. (DUPLEX_UP + 1) : (DUPLEX_SIDE + 1));
  645. break;
  646. case PC_DUPLEX_HORZ:
  647. pOEM->iDuplex =
  648. (pOEM->iOrientation ?
  649. (DUPLEX_SIDE + 1) : (DUPLEX_UP + 1));
  650. break;
  651. case PSRC_SELECT_MPF:
  652. pOEM->iPaperSource = PSRC_MPF;
  653. break;
  654. case PSRC_SELECT_CASETTE_1:
  655. pOEM->iPaperSource = PSRC_CASETTE_1;
  656. break;
  657. case PSRC_SELECT_CASETTE_2:
  658. pOEM->iPaperSource = PSRC_CASETTE_2;
  659. break;
  660. case PSRC_SELECT_CASETTE_3:
  661. pOEM->iPaperSource = PSRC_CASETTE_3;
  662. break;
  663. case PSRC_SELECT_AUTO:
  664. pOEM->iPaperSource = PSRC_AUTO;
  665. break;
  666. case PC_BEGINDOC:
  667. // EJL commands
  668. WRITESPOOLBUF(pdevobj,
  669. BEGINDOC_EJL_BEGIN,
  670. BYTE_LENGTH(BEGINDOC_EJL_BEGIN));
  671. wlen = 0;
  672. // Replacement of strsafe-api 2002.3.6 >>>
  673. // strcpy( &Cmd[wlen], EJL_SelectPsrc[pOEM->iPaperSource] );
  674. // wlen += (WORD)strlen( &Cmd[wlen] );
  675. // strcpy( &Cmd[wlen], EJL_SelectOrient[pOEM->iOrientation] );
  676. // wlen += (WORD)strlen( &Cmd[wlen] );
  677. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SelectPsrc[pOEM->iPaperSource],
  678. &pDestEnd, &szRemLen,
  679. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  680. break;
  681. }
  682. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  683. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SelectOrient[pOEM->iOrientation],
  684. &pDestEnd, &szRemLen,
  685. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  686. break;
  687. }
  688. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  689. // Replacement of strsafe-api 2002.3.6 <<<
  690. // CASIO extention
  691. // Replacement of strsafe-api 2002.3.6 >>>
  692. // strcpy( &Cmd[wlen], EJL_SelectRes[pOEM->iResolution] );
  693. // wlen += (WORD)strlen( &Cmd[wlen] );
  694. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SelectRes[pOEM->iResolution],
  695. &pDestEnd, &szRemLen,
  696. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  697. break;
  698. }
  699. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  700. // Replacement of strsafe-api 2002.3.6 <<<
  701. // Modification of Color-mode command 2002.3.28 >>>
  702. #if 0
  703. if (pOEM->iColor > 0) {
  704. // Replacement of strsafe-api 2002.3.6 >>>
  705. // strcpy( &Cmd[wlen], EJL_SetColorMode[pOEM->iColor - 1] );
  706. // wlen += (WORD)strlen( &Cmd[wlen] );
  707. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetColorMode[pOEM->iColor - 1],
  708. &pDestEnd, &szRemLen,
  709. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  710. break;
  711. }
  712. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  713. // Replacement of strsafe-api 2002.3.6 <<<
  714. }
  715. #else
  716. if (pOEM->iColor > 0) {
  717. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetColorMode[2],
  718. &pDestEnd, &szRemLen,
  719. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  720. break;
  721. }
  722. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  723. } else {
  724. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetColorMode[0],
  725. &pDestEnd, &szRemLen,
  726. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  727. break;
  728. }
  729. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  730. }
  731. #endif
  732. // Modification of Color-mode command 2002.3.28 <<<
  733. if (pOEM->iDuplex > 0) {
  734. // Replacement of strsafe-api 2002.3.6 >>>
  735. // strcpy( &Cmd[wlen], EJL_SetDuplex[pOEM->iDuplex - 1] );
  736. // wlen += (WORD)strlen( &Cmd[wlen] );
  737. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetDuplex[pOEM->iDuplex - 1],
  738. &pDestEnd, &szRemLen,
  739. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  740. break;
  741. }
  742. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  743. // Replacement of strsafe-api 2002.3.6 <<<
  744. }
  745. // Replacement of strsafe-api 2002.3.6 >>>
  746. // strcpy( &Cmd[wlen], EJL_SetTonerSave[pOEM->iTonerSave] );
  747. // wlen += (WORD)strlen( &Cmd[wlen] );
  748. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetTonerSave[pOEM->iTonerSave],
  749. &pDestEnd, &szRemLen,
  750. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  751. break;
  752. }
  753. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  754. // Replacement of strsafe-api 2002.3.6 <<<
  755. // Replacement of strsafe-api 2002.3.6 >>>
  756. // strcpy( &Cmd[wlen], EJL_SetSmoohing[pOEM->iSmoothing] );
  757. // wlen += (WORD)strlen( &Cmd[wlen] );
  758. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetSmoohing[pOEM->iSmoothing],
  759. &pDestEnd, &szRemLen,
  760. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  761. break;
  762. }
  763. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  764. // Replacement of strsafe-api 2002.3.6 <<<
  765. // Replacement of strsafe-api 2002.3.6 >>>
  766. // strcpy( &Cmd[wlen], EJL_SetJamRecovery[pOEM->iJamRecovery] );
  767. // wlen += (WORD)strlen( &Cmd[wlen] );
  768. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetJamRecovery[pOEM->iJamRecovery],
  769. &pDestEnd, &szRemLen,
  770. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  771. break;
  772. }
  773. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  774. // Replacement of strsafe-api 2002.3.6 <<<
  775. if (pOEM->iMediaType > 0) {
  776. // Replacement of strsafe-api 2002.3.6 >>>
  777. // strcpy( &Cmd[wlen], EJL_SetMediaType[pOEM->iMediaType - 1] );
  778. // wlen += (WORD)strlen( &Cmd[wlen] );
  779. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SetMediaType[pOEM->iMediaType - 1],
  780. &pDestEnd, &szRemLen,
  781. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  782. break;
  783. }
  784. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  785. // Replacement of strsafe-api 2002.3.6 <<<
  786. }
  787. //+CP-E8000 Begin
  788. if (pOEM->iOutBin > 0) {
  789. // Replacement of strsafe-api 2002.3.6 >>>
  790. // strcpy( &Cmd[wlen], EJL_SelectOutbin[pOEM->iOutBin - 1] );
  791. // wlen += (WORD)strlen( &Cmd[wlen] );
  792. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_SelectOutbin[pOEM->iOutBin - 1],
  793. &pDestEnd, &szRemLen,
  794. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  795. break;
  796. }
  797. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  798. // Replacement of strsafe-api 2002.3.6 <<<
  799. if (pOEM->iOutBin == OUTBIN_EXIT_2) {
  800. // Replacement of strsafe-api 2002.3.6 >>>
  801. // strcpy( &Cmd[wlen], EJL_JobShift[JOBSHIFT_ON] );
  802. // wlen += (WORD)strlen( &Cmd[wlen] );
  803. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EJL_JobShift[JOBSHIFT_ON],
  804. &pDestEnd, &szRemLen,
  805. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  806. break;
  807. }
  808. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  809. // Replacement of strsafe-api 2002.3.6 <<<
  810. }
  811. }
  812. //+CP-E8000 End
  813. WRITESPOOLBUF(pdevobj, Cmd, wlen );
  814. WRITESPOOLBUF(pdevobj,
  815. BEGINDOC_EJL_END,
  816. BYTE_LENGTH(BEGINDOC_EJL_END));
  817. WRITESPOOLBUF(pdevobj,
  818. BEGINDOC_EPG_END,
  819. BYTE_LENGTH(BEGINDOC_EPG_END));
  820. if(pOEM->iResolution == RES_300DPI)
  821. WRITESPOOLBUF(pdevobj, "\x1D\x30;0.24muE", 10);
  822. else
  823. WRITESPOOLBUF(pdevobj, "\x1D\x30;0.12muE", 10);
  824. // ESC/Page commands
  825. wlen = 0;
  826. // Replacement of strsafe-api 2002.3.6 >>>
  827. // strcpy( &Cmd[wlen], EPg_SelectRes[pOEM->iResolution] );
  828. // wlen += (WORD)strlen( &Cmd[wlen] );
  829. if (S_OK != StringCbCopyExA(&Cmd[wlen], sizeof(Cmd)-wlen, EPg_SelectRes[pOEM->iResolution],
  830. &pDestEnd, &szRemLen,
  831. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE)) {
  832. break;
  833. }
  834. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  835. // Replacement of strsafe-api 2002.3.6 <<<
  836. WRITESPOOLBUF(pdevobj, Cmd, wlen );
  837. // 99/09/28 ->
  838. // break;
  839. // 99/09/28 <-
  840. // Clear dwDLFontID
  841. // (There are data that contains a plural pages and
  842. // also each page has different color mode.
  843. // When page is changed, STARTDOC commands are spooled.
  844. // It means that new DL font is set.
  845. // That is why dwDLFontID got to be claer.)
  846. pOEM->dwDLFontID = UNKNOWN_DLFONT_ID;
  847. break;
  848. case PC_ENDDOC:
  849. WRITESPOOLBUF(pdevobj,
  850. ENDDOC_EJL_RESET,
  851. BYTE_LENGTH(ENDDOC_EJL_RESET));
  852. break;
  853. case XXXX_TONER_SAVE_NONE:
  854. pOEM->iTonerSave = XX_TONER_NORMAL;
  855. break;
  856. case XXXX_TONER_SAVE_1:
  857. pOEM->iTonerSave = XX_TONER_SAVE_1;
  858. break;
  859. case XXXX_TONER_SAVE_2:
  860. pOEM->iTonerSave = XX_TONER_SAVE_2;
  861. break;
  862. case XXXX_TONER_SAVE_3:
  863. pOEM->iTonerSave = XX_TONER_SAVE_3;
  864. break;
  865. case SMOOTHING_ON:
  866. pOEM->iSmoothing = XX_SMOOTHING_ON;
  867. break;
  868. case SMOOTHING_OFF:
  869. pOEM->iSmoothing = XX_SMOOTHING_OFF;
  870. break;
  871. case JAMRECOVERY_ON:
  872. pOEM->iJamRecovery = XX_JAMRECOVERY_ON;
  873. break;
  874. case JAMRECOVERY_OFF:
  875. pOEM->iJamRecovery = XX_JAMRECOVERY_OFF;
  876. break;
  877. case MediaType_1:
  878. pOEM->iMediaType = XX_MediaType_1;
  879. break;
  880. case MediaType_2:
  881. pOEM->iMediaType = XX_MediaType_2;
  882. break;
  883. //+CP-E8000 Begin
  884. case MediaType_3:
  885. pOEM->iMediaType = XX_MediaType_3;
  886. break;
  887. case OUTBIN_SELECT_EXIT_1:
  888. pOEM->iOutBin = OUTBIN_EXIT_1;
  889. break;
  890. case OUTBIN_SELECT_EXIT_2:
  891. pOEM->iOutBin = OUTBIN_EXIT_2;
  892. break;
  893. case OUTBIN_SELECT_EXIT_3:
  894. pOEM->iOutBin = OUTBIN_EXIT_3;
  895. break;
  896. case OUTBIN_SELECT_EXIT_4:
  897. pOEM->iOutBin = OUTBIN_EXIT_4;
  898. break;
  899. case OUTBIN_SELECT_EXIT_5:
  900. pOEM->iOutBin = OUTBIN_EXIT_5;
  901. break;
  902. case OUTBIN_SELECT_EXIT_6:
  903. pOEM->iOutBin = OUTBIN_EXIT_6;
  904. break;
  905. //+CP-E8000 End
  906. case DOWNLOAD_SET_FONT_ID:
  907. if (!IsValidDLFontID(pdwParams[0])) {
  908. // Must not happen!!
  909. ERR(("DLSetFontID: Soft font ID %x invalid.\n",
  910. pdwParams[0]));
  911. break;
  912. }
  913. // Actual printer command is sent
  914. // within DownloadCharGlyph.
  915. pOEM->dwDLSetFontID = pdwParams[0];
  916. DL_VERBOSE(("SetFontID: dwDLSetFontID=%x\n",
  917. pOEM->dwDLSetFontID));
  918. break;
  919. case DOWNLOAD_SELECT_FONT_ID:
  920. if (!IsValidDLFontID(pdwParams[0])) {
  921. // Must not happen!!
  922. ERR(("DLSelectFontID: Soft font ID %x invalid.\n",
  923. pdwParams[0]));
  924. break;
  925. }
  926. pOEM->dwDLSelectFontID = pdwParams[0];
  927. DL_VERBOSE(("SelectFontID: dwDLSelectFontID=%x\n",
  928. pOEM->dwDLSelectFontID));
  929. if (pOEM->dwDLFontID != pOEM->dwDLSelectFontID)
  930. VSetSelectDLFont(pdevobj, pOEM->dwDLSelectFontID);
  931. break;
  932. case DOWNLOAD_SET_CHAR_CODE:
  933. pOEM->wCharCode=(WORD)pdwParams[0];
  934. break;
  935. case DOWNLOAD_DELETE_FONT:
  936. DL_VERBOSE(("DLDeleteFont: dwDLFontID=%x, %x\n",
  937. pOEM->dwDLFontID, pdwParams[0]));
  938. // Replacement of strsafe-api 2002.3.6 >>>
  939. // wlen = (WORD)wsprintf(Cmd, DLI_DELETE_FONT, (WORD)pdwParams[0]-FONT_MIN_ID);
  940. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  941. &pDestEnd, &szRemLen,
  942. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  943. DLI_DELETE_FONT, (WORD)pdwParams[0]-FONT_MIN_ID)) {
  944. break;
  945. }
  946. wlen = (WORD)(pDestEnd - Cmd);
  947. // Replacement of strsafe-api 2002.3.6 <<<
  948. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  949. pOEM->dwDLFontID = UNKNOWN_DLFONT_ID;
  950. break;
  951. case RECT_FILL_WIDTH:
  952. pOEM->wRectWidth =
  953. (WORD)MasterToDevice(pOEM, pdwParams[0]);
  954. break;
  955. case RECT_FILL_HEIGHT:
  956. pOEM->wRectHeight =
  957. (WORD)MasterToDevice(pOEM, pdwParams[0]);
  958. break;
  959. case RECT_FILL_GRAY:
  960. case RECT_FILL_WHITE:
  961. case RECT_FILL_BLACK:
  962. if (RECT_FILL_GRAY == dwCmdCbID)
  963. wGray = (WORD)pdwParams[2];
  964. else if (RECT_FILL_WHITE == dwCmdCbID)
  965. wGray = 0;
  966. else
  967. wGray = 100;
  968. dwTempX = MasterToDevice(pOEM, pdwParams[0]);
  969. dwTempY = MasterToDevice(pOEM, pdwParams[1]);
  970. VERBOSE(("RectFill:%d,x=%d,y=%d,w=%d,h=%d\n",
  971. wGray,
  972. (WORD)dwTempX,
  973. (WORD)dwTempY,
  974. pOEM->wRectWidth,
  975. pOEM->wRectHeight));
  976. // Replacement of strsafe-api 2002.3.6 >>>
  977. // wlen = (WORD)wsprintf(Cmd, RECT_FILL,
  978. // wGray,
  979. // (WORD)dwTempX,
  980. // (WORD)dwTempY,
  981. // (WORD)(dwTempX + pOEM->wRectWidth - 1),
  982. // (WORD)(dwTempY + pOEM->wRectHeight - 1));
  983. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  984. &pDestEnd, &szRemLen,
  985. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  986. RECT_FILL,
  987. wGray,
  988. (WORD)dwTempX,
  989. (WORD)dwTempY,
  990. (WORD)(dwTempX + pOEM->wRectWidth - 1),
  991. (WORD)(dwTempY + pOEM->wRectHeight - 1))) {
  992. break;
  993. }
  994. wlen = (WORD)(pDestEnd - Cmd);
  995. // Replacement of strsafe-api 2002.3.6 <<<
  996. WRITESPOOLBUF(pdevobj, (LPSTR)Cmd, wlen);
  997. break;
  998. #if 0 /* OEM doesn't want to fix minidriver */
  999. /* Below is hack code to fix #412276 */
  1000. case COLOR_SELECT_BLACK:
  1001. case COLOR_SELECT_RED:
  1002. case COLOR_SELECT_GREEN:
  1003. case COLOR_SELECT_BLUE:
  1004. case COLOR_SELECT_YELLOW:
  1005. case COLOR_SELECT_MAGENTA:
  1006. case COLOR_SELECT_CYAN:
  1007. case COLOR_SELECT_WHITE:
  1008. /* Remember what color is select */
  1009. pOEM->dwSelectedColor = dwCmdCbID;
  1010. pOEM->iColorMayChange = 0; /* Reset flag */
  1011. /* Output Color Select Command */
  1012. /* The logic supposes COLOR_SELECT_xxx starts with COLOR_SELECT_BLACK */
  1013. /* and increases one by one */
  1014. WRITESPOOLBUF(pdevobj, (LPSTR)COLOR_SELECT_COMMAND[dwCmdCbID - COLOR_SELECT_BLACK],
  1015. COLOR_SELECT_COMMAND_LEN[dwCmdCbID - COLOR_SELECT_BLACK] );
  1016. break;
  1017. case DUMP_RASTER_CYAN:
  1018. case DUMP_RASTER_MAGENTA:
  1019. case DUMP_RASTER_YELLOW:
  1020. case DUMP_RASTER_BLACK:
  1021. /* Remember what color may change */
  1022. pOEM->iColorMayChange = 1; /* Set flag */
  1023. /* Output Dump Raster Command */
  1024. /* The logic supposes DUMP_RASTER_xxx starts with DUMP_RASTER_CYAN */
  1025. /* and increases one by one */
  1026. WRITESPOOLBUF(pdevobj, (LPSTR)DUMP_RASTER_COMMAND[dwCmdCbID - DUMP_RASTER_CYAN],
  1027. DUMP_RASTER_COMMAND_LEN );
  1028. break;
  1029. /* End of hack code */
  1030. #endif /* OEM doesn't want to fix minidriver */
  1031. default:
  1032. ERR(("Unknown callback ID = %d.\n", dwCmdCbID));
  1033. }
  1034. return iRet;
  1035. }
  1036. //////////////////////////////////////////////////////////////////////////
  1037. // Function: OEMSendFontCmdk
  1038. //////////////////////////////////////////////////////////////////////////
  1039. VOID
  1040. APIENTRY
  1041. OEMSendFontCmd(
  1042. PDEVOBJ pdevobj,
  1043. PUNIFONTOBJ pUFObj,
  1044. PFINVOCATION pFInv)
  1045. {
  1046. PGETINFO_STDVAR pSV;
  1047. DWORD adwStdVariable[2+2*4];
  1048. DWORD dwIn, dwOut;
  1049. PBYTE pubCmd;
  1050. BYTE aubCmd[128];
  1051. PIFIMETRICS pIFI;
  1052. DWORD height, width, charoff;
  1053. PMYPDEV pOEM;
  1054. BYTE Cmd[128];
  1055. WORD wlen;
  1056. DWORD dwNeeded;
  1057. DWORD dwTemp;
  1058. LPSTR pDestEnd; // 2002.3.6
  1059. size_t szRemLen; // 2002.3.6
  1060. SC_VERBOSE(("OEMSendFontCmd() entry.\n"));
  1061. pubCmd = pFInv->pubCommand;
  1062. pIFI = pUFObj->pIFIMetrics;
  1063. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  1064. //
  1065. // Get standard variables.
  1066. //
  1067. pSV = (PGETINFO_STDVAR)adwStdVariable;
  1068. pSV->dwSize = sizeof(GETINFO_STDVAR) + 2 * sizeof(DWORD) * (4 - 1);
  1069. pSV->dwNumOfVariable = 4;
  1070. pSV->StdVar[0].dwStdVarID = FNT_INFO_FONTHEIGHT;
  1071. pSV->StdVar[1].dwStdVarID = FNT_INFO_FONTWIDTH;
  1072. pSV->StdVar[2].dwStdVarID = FNT_INFO_TEXTYRES;
  1073. pSV->StdVar[3].dwStdVarID = FNT_INFO_TEXTXRES;
  1074. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_STDVARIABLE, pSV, pSV->dwSize, &dwNeeded)) {
  1075. ERR(("UFO_GETINFO_STDVARIABLE failed.\n"));
  1076. return;
  1077. }
  1078. SC_VERBOSE(("ulFontID=%x\n", pUFObj->ulFontID));
  1079. SC_VERBOSE(("FONTHEIGHT=%d\n", pSV->StdVar[0].lStdVariable));
  1080. SC_VERBOSE(("FONTWIDTH=%d\n", pSV->StdVar[1].lStdVariable));
  1081. // Initialize pOEM
  1082. if (pIFI->jWinCharSet == 0x80)
  1083. pOEM->fGeneral |= FG_DOUBLE;
  1084. else
  1085. pOEM->fGeneral &= ~FG_DOUBLE;
  1086. pOEM->fGeneral &= ~FG_BOLD;
  1087. pOEM->fGeneral &= ~FG_ITALIC;
  1088. if('@' == *((LPSTR)pIFI+pIFI->dpwszFaceName))
  1089. pOEM->fGeneral |= FG_VERT;
  1090. else
  1091. pOEM->fGeneral &= ~FG_VERT;
  1092. if (pIFI->jWinPitchAndFamily & 0x01)
  1093. pOEM->fGeneral &= ~FG_PROP;
  1094. else
  1095. pOEM->fGeneral |= FG_PROP;
  1096. dwOut = 0;
  1097. pOEM->fGeneral &= ~FG_DBCS;
  1098. for( dwIn = 0; dwIn < pFInv->dwCount;) {
  1099. if (pubCmd[dwIn] == '#' && pubCmd[dwIn+1] == 'V') {
  1100. // Specify font height in device unit (current
  1101. // output resolution). Note Unidrv gives us
  1102. // font-height in master units
  1103. height = pSV->StdVar[0].lStdVariable * 100;
  1104. height = MasterToDevice(pOEM, height);
  1105. SC_VERBOSE(("Height=%d\n", height));
  1106. // Replacement of strsafe-api 2002.3.6 >>>
  1107. // dwOut += LConvertFontSizeToStr(height, &aubCmd[dwOut]);
  1108. dwOut += LConvertFontSizeToStr(height, &aubCmd[dwOut], sizeof(aubCmd)-dwOut);
  1109. // Replacement of strsafe-api 2002.3.6 <<<
  1110. dwIn += 2;
  1111. } else if (pubCmd[dwIn] == '#' && pubCmd[dwIn+1] == 'H') {
  1112. if (pubCmd[dwIn+2] == 'S') {
  1113. SC_VERBOSE(("HS: "));
  1114. width = pSV->StdVar[1].lStdVariable;
  1115. dwIn += 3;
  1116. pOEM->fGeneral |= FG_DBCS;
  1117. } else if (pubCmd[dwIn+2] == 'D') {
  1118. SC_VERBOSE(("HD: "));
  1119. width = pSV->StdVar[1].lStdVariable * 2;
  1120. dwIn += 3;
  1121. pOEM->fGeneral |= FG_DBCS;
  1122. } else {
  1123. SC_VERBOSE(("H: "));
  1124. if (pSV->StdVar[1].lStdVariable)
  1125. width = pSV->StdVar[1].lStdVariable;
  1126. else
  1127. width = pIFI->fwdAveCharWidth;
  1128. dwIn += 2;
  1129. }
  1130. // Specify font width in CPI.
  1131. // Check of zero divide 2002.3.23 >>>
  1132. if (width == 0) {
  1133. ERR(("OEMSendFontCmd() 0Div-Check [width=0] \n"));
  1134. return;
  1135. }
  1136. // Check of zero divide 2002.3.23 <<<
  1137. width = (MASTER_UNIT * 100L) / width;
  1138. SC_VERBOSE(("Width=%d\n", width));
  1139. // Replacement of strsafe-api 2002.3.6 >>>
  1140. // dwOut += LConvertFontSizeToStr(width, &aubCmd[dwOut]);
  1141. dwOut += LConvertFontSizeToStr(width, &aubCmd[dwOut], sizeof(aubCmd)-dwOut);
  1142. // Replacement of strsafe-api 2002.3.6 <<<
  1143. } else {
  1144. aubCmd[dwOut++] = pubCmd[dwIn++];
  1145. }
  1146. }
  1147. WRITESPOOLBUF(pdevobj, aubCmd, dwOut);
  1148. #if 0 //MSKK 98/12/22
  1149. pOEM->iDevCharOffset = (pIFI->fwdWinDescender * pSV->StdVar[0].lStdVariable * 72)
  1150. / (pIFI->fwdUnitsPerEm * pSV->StdVar[2].lStdVariable / pOEM->sHeightDiv);
  1151. #else
  1152. // Unidrv gives us raw IFIMETRICS block so we need to
  1153. // translate its members into meaningful values. n.b.
  1154. // we assume font height passed from Unidrv = em value.
  1155. // Check of zero divide 2002.3.23 >>>
  1156. if (pIFI->fwdUnitsPerEm == 0) {
  1157. ERR(("OEMSendFontCmd() 0Div-Check [pIFI->fwdUnitsPerEm=0] \n"));
  1158. return;
  1159. }
  1160. // Check of zero divide 2002.3.23 <<<
  1161. dwTemp = MasterToDevice(pOEM, pSV->StdVar[0].lStdVariable)
  1162. * pIFI->fwdWinDescender;
  1163. dwTemp /= pIFI->fwdUnitsPerEm;
  1164. pOEM->iDevCharOffset = (short)dwTemp;
  1165. #endif
  1166. VERBOSE(("Descender=%d\n", pOEM->iDevCharOffset));
  1167. // Replacement of strsafe-api 2002.3.6 >>>
  1168. // wlen = (WORD)wsprintf(Cmd, SET_CHAR_OFFSET,
  1169. // (pOEM->fGeneral & FG_DBCS)?pOEM->iDevCharOffset:0);
  1170. if (S_OK != StringCbPrintfExA(Cmd, sizeof(Cmd),
  1171. &pDestEnd, &szRemLen,
  1172. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1173. SET_CHAR_OFFSET, (pOEM->fGeneral & FG_DBCS)?pOEM->iDevCharOffset:0)) {
  1174. return;
  1175. }
  1176. wlen = (WORD)(pDestEnd - Cmd);
  1177. // Replacement of strsafe-api 2002.3.6 <<<<
  1178. if (pOEM->fGeneral & FG_VERT)
  1179. {
  1180. // Replacement of strsafe-api 2002.3.6 >>>
  1181. // wlen += (WORD)wsprintf(&Cmd[wlen], VERT_FONT_SET, 1);
  1182. if (S_OK != StringCbPrintfExA(&Cmd[wlen], sizeof(Cmd)-wlen,
  1183. &pDestEnd, &szRemLen,
  1184. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1185. VERT_FONT_SET, 1)) {
  1186. return;
  1187. }
  1188. wlen += (WORD)(pDestEnd - &Cmd[wlen]);
  1189. // Replacement of strsafe-api 2002.3.6 <<<
  1190. }
  1191. WRITESPOOLBUF(pdevobj, Cmd, wlen);
  1192. // DL font will be unselectd
  1193. pOEM->dwDLFontID = UNKNOWN_DLFONT_ID;
  1194. }
  1195. LONG
  1196. LGetPointSize100(
  1197. LONG height,
  1198. LONG vertRes)
  1199. {
  1200. // Check of zero divide 2002.3.23 >>>
  1201. // LONG tmp = ((LONG)height * (LONG)7200) / (LONG)vertRes;
  1202. LONG tmp;
  1203. if (vertRes == 0) {
  1204. ERR(("LGetPointSize100() 0Div-Check [vertRes=0] \n"));
  1205. return 0;
  1206. }
  1207. tmp = ((LONG)height * (LONG)7200) / (LONG)vertRes;
  1208. // Check of zero divide 2002.3.23 <<<
  1209. //
  1210. // round to the nearest quarter point.
  1211. //
  1212. return 25 * ((tmp + 12) / (LONG)25);
  1213. }
  1214. // Replacement of strsafe-api 2002.3.6 >>>
  1215. //LONG
  1216. //LConvertFontSizeToStr(
  1217. // LONG size,
  1218. // PSTR pStr)
  1219. //{
  1220. // register long count;
  1221. //
  1222. // count = (long)strlen(_ltoa(size / 100, pStr, 10));
  1223. // pStr[count++] = '.';
  1224. // count += (long)strlen(_ltoa(size % 100, &pStr[count], 10));
  1225. //
  1226. // return count;
  1227. //}
  1228. LONG
  1229. LConvertFontSizeToStr(
  1230. LONG size,
  1231. PSTR pStr,
  1232. size_t StrSize)
  1233. {
  1234. register long count;
  1235. size_t pcb;
  1236. if (S_OK != StringCbLengthA(_ltoa(size / 100, pStr, 10), StrSize, &pcb))
  1237. return 0;
  1238. count = (WORD)pcb;
  1239. pStr[count++] = '.';
  1240. if (S_OK != StringCbLengthA(_ltoa(size % 100, &pStr[count], 10), StrSize-count, &pcb))
  1241. return 0;
  1242. count += (WORD)pcb;
  1243. return count;
  1244. }
  1245. // Replacement of strsafe-api 2002.3.6 <<<
  1246. //////////////////////////////////////////////////////////////////////////
  1247. // Function: OEMOutputCharStr
  1248. //////////////////////////////////////////////////////////////////////////
  1249. VOID APIENTRY
  1250. OEMOutputCharStr(
  1251. PDEVOBJ pdevobj,
  1252. PUNIFONTOBJ pUFObj,
  1253. DWORD dwType,
  1254. DWORD dwCount,
  1255. PVOID pGlyph)
  1256. {
  1257. GETINFO_GLYPHSTRING GStr;
  1258. PTRANSDATA pTrans;
  1259. PTRANSDATA pTransOrg;
  1260. WORD id;
  1261. DWORD dwI;
  1262. DWORD dwNeeded;
  1263. PMYPDEV pOEM;
  1264. PIFIMETRICS pIFI;
  1265. WORD wLen;
  1266. BYTE *pTemp;
  1267. BOOL bRet;
  1268. LPSTR pDestEnd; // 2002.3.6
  1269. size_t szRemLen; // 2002.3.6
  1270. pIFI = pUFObj->pIFIMetrics;
  1271. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  1272. pTrans = NULL;
  1273. pTransOrg = NULL;
  1274. VERBOSE(("OEMOutputCharStr() entry.\n"));
  1275. #if 0 /* OEM doesn't want to fix minidriver */
  1276. /* Below is hack code to fix #412276 */
  1277. if ( pOEM->iColorMayChange == 1 )
  1278. {
  1279. /* Output Color Select Command */
  1280. /* The logic supposes COLOR_SELECT_xxx starts with COLOR_SELECT_BLACK */
  1281. /* and increases one by one */
  1282. WRITESPOOLBUF(pdevobj, (LPSTR)COLOR_SELECT_COMMAND[pOEM->dwSelectedColor - COLOR_SELECT_BLACK],
  1283. COLOR_SELECT_COMMAND_LEN[pOEM->dwSelectedColor - COLOR_SELECT_BLACK] );
  1284. /* Reset flag, for ensuring color */
  1285. pOEM->iColorMayChange = 0;
  1286. }
  1287. /* End of hack code */
  1288. #endif /* OEM doesn't want to fix minidriver */
  1289. switch (dwType)
  1290. {
  1291. case TYPE_GLYPHHANDLE:
  1292. GStr.dwSize = sizeof (GETINFO_GLYPHSTRING);
  1293. GStr.dwCount = dwCount;
  1294. GStr.dwTypeIn = TYPE_GLYPHHANDLE;
  1295. GStr.pGlyphIn = pGlyph;
  1296. GStr.dwTypeOut = TYPE_TRANSDATA;
  1297. GStr.pGlyphOut = NULL;
  1298. GStr.dwGlyphOutSize = 0;
  1299. if ((FALSE != (bRet = pUFObj->pfnGetInfo(pUFObj,
  1300. UFO_GETINFO_GLYPHSTRING, &GStr, 0, NULL)))
  1301. || 0 == GStr.dwGlyphOutSize)
  1302. {
  1303. ERR(("UFO_GETINFO_GRYPHSTRING faild - %d, %d.\n",
  1304. bRet, GStr.dwGlyphOutSize));
  1305. return;
  1306. }
  1307. pTrans = (TRANSDATA *)MemAlloc(GStr.dwGlyphOutSize);
  1308. if (NULL == pTrans)
  1309. {
  1310. ERR(("MemAlloc faild.\n"));
  1311. return;
  1312. }
  1313. pTransOrg = pTrans;
  1314. GStr.pGlyphOut = pTrans;
  1315. // convert glyph string to TRANSDATA
  1316. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr, 0, NULL))
  1317. {
  1318. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\r\n"));
  1319. return;
  1320. }
  1321. for (dwI = 0; dwI < dwCount; dwI ++, pTrans++)
  1322. {
  1323. VERBOSE(("TYPE_TRANSDATA:ubCodePageID:0x%x\n",
  1324. pTrans->ubCodePageID));
  1325. VERBOSE(("TYPE_TRANSDATA:ubType:0x%x\n",
  1326. pTrans->ubType));
  1327. switch (pTrans->ubType & MTYPE_DOUBLEBYTECHAR_MASK)
  1328. {
  1329. case MTYPE_SINGLE:
  1330. if(pOEM->fGeneral & FG_DOUBLE){
  1331. OEMCommandCallback(pdevobj, TEXT_FS_SINGLE_BYTE, 0, NULL );
  1332. }
  1333. break;
  1334. case MTYPE_DOUBLE:
  1335. if(!(pOEM->fGeneral & FG_DOUBLE)){
  1336. OEMCommandCallback(pdevobj, TEXT_FS_DOUBLE_BYTE, 0, NULL );
  1337. }
  1338. break;
  1339. }
  1340. switch (pTrans->ubType & MTYPE_FORMAT_MASK)
  1341. {
  1342. case MTYPE_DIRECT:
  1343. VERBOSE(("TYPE_TRANSDATA:ubCode:0x%x\n",
  1344. pTrans->uCode.ubCode));
  1345. pTemp = (BYTE *)&pTrans->uCode.ubCode;
  1346. wLen = 1;
  1347. break;
  1348. case MTYPE_PAIRED:
  1349. VERBOSE(("TYPE_TRANSDATA:ubPairs:0x%x\n",
  1350. *(PWORD)(pTrans->uCode.ubPairs)));
  1351. pTemp = (BYTE *)&(pTrans->uCode.ubPairs);
  1352. wLen = 2;
  1353. break;
  1354. case MTYPE_COMPOSE:
  1355. // ntbug9#398026: garbage print out when chars are high ansi.
  1356. pTemp = (BYTE *)(pTransOrg) + pTrans->uCode.sCode;
  1357. // first two bytes are the length of the string
  1358. wLen = *pTemp + (*(pTemp + 1) << 8);
  1359. pTemp += 2;
  1360. break;
  1361. default:
  1362. WARNING(("Unsupported MTYPE %d ignored\n",
  1363. (pTrans->ubType & MTYPE_FORMAT_MASK)));
  1364. wLen = 0; // 392057: PREFIX
  1365. }
  1366. if (wLen > 0)
  1367. {
  1368. WRITESPOOLBUF(pdevobj, pTemp, wLen);
  1369. }
  1370. }
  1371. break;
  1372. case TYPE_GLYPHID:
  1373. DL_VERBOSE(("CharStr: dwDLFontID=%x, dwDLSelectFontID=%x\n",
  1374. pOEM->dwDLFontID, pOEM->dwDLSelectFontID));
  1375. // Make sure correct soft font is chosen
  1376. if (pOEM->dwDLFontID != pOEM->dwDLSelectFontID)
  1377. VSetSelectDLFont(pdevobj, pOEM->dwDLSelectFontID);
  1378. for (dwI = 0; dwI < dwCount; dwI ++, ((PDWORD)pGlyph)++)
  1379. {
  1380. DL_VERBOSE(("Glyph: %x\n", (*(PDWORD)pGlyph)));
  1381. VERBOSE(("TYPE_GLYPHID:0x%x\n", *(PDWORD)pGlyph));
  1382. // CASIO 98/11/24 ->
  1383. // if( pIFI->jWinCharSet == SHIFTJIS_CHARSET ){
  1384. // id = SWAPW( *(PDWORD)pGlyph + SJISCHR);
  1385. // WRITESPOOLBUF(pdevobj, &id, 2);
  1386. // }else{
  1387. WRITESPOOLBUF(pdevobj, (PBYTE)pGlyph, 1);
  1388. // }
  1389. // CASIO 98/11/24 <-
  1390. }
  1391. break;
  1392. }
  1393. if (NULL != pTransOrg)
  1394. {
  1395. MemFree(pTransOrg);
  1396. }
  1397. }
  1398. //////////////////////////////////////////////////////////////////////////
  1399. // Function: OEMDownloadFontHeader
  1400. //////////////////////////////////////////////////////////////////////////
  1401. DWORD APIENTRY
  1402. OEMDownloadFontHeader(
  1403. PDEVOBJ pdevobj,
  1404. PUNIFONTOBJ pUFObj
  1405. )
  1406. {
  1407. PGETINFO_STDVAR pSV;
  1408. DWORD adwStdVariable[2+4*2];
  1409. PMYPDEV pOEM;
  1410. PIFIMETRICS pIFI;
  1411. ESCPAGEHEADER FontHeader;
  1412. // BYTE sFontName[54]; // 2002.3.6 Buffer size insufficient
  1413. BYTE sFontName[64]; // 2002.3.6
  1414. BYTE Buff[32];
  1415. int iSizeOfBuf,iSizeFontName;
  1416. WORD id;
  1417. DWORD dwNeeded;
  1418. INT iCellLeftOffset, iTemp;
  1419. WORD wCellHeight, wCellWidth;
  1420. WORD wFontPitch;
  1421. LPSTR pDestEnd; // 2002.3.6
  1422. size_t szRemLen; // 2002.3.6
  1423. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  1424. pIFI = pUFObj->pIFIMetrics;
  1425. VERBOSE(("OEMDownloadFontHeader() entry.\n"));
  1426. VERBOSE(("TT Font:\n"));
  1427. VERBOSE(("flInfo=%08x\n", pIFI->flInfo));
  1428. VERBOSE(("fwdMaxCharInc=%d\n", pIFI->fwdMaxCharInc));
  1429. VERBOSE(("fwdAveCharWidth=%d\n", pIFI->fwdAveCharWidth));
  1430. VERBOSE(("jWinCharSet=%d\n", pIFI->jWinCharSet));
  1431. VERBOSE(("rclFontBox=%d,%d,%d,%d\n",
  1432. pIFI->rclFontBox.left, pIFI->rclFontBox.top,
  1433. pIFI->rclFontBox.right, pIFI->rclFontBox.bottom));
  1434. // if(pIFI->jWinPitchAndFamily & 0x01)
  1435. if(pIFI->flInfo & FM_INFO_CONSTANT_WIDTH)
  1436. pOEM->fGeneral &= ~FG_PROP;
  1437. else
  1438. pOEM->fGeneral |= FG_PROP;
  1439. // id = (WORD)pUFObj->ulFontID;
  1440. id = (WORD)pOEM->dwDLSetFontID;
  1441. if(id > FONT_MAX_ID) return 0;
  1442. if(pOEM->iResolution) return 0;
  1443. //
  1444. // Get standard variables.
  1445. //
  1446. pSV = (PGETINFO_STDVAR)adwStdVariable;
  1447. pSV->dwSize = sizeof(GETINFO_STDVAR) + 2 * sizeof(DWORD) * (4 - 1);
  1448. pSV->dwNumOfVariable = 4;
  1449. pSV->StdVar[0].dwStdVarID = FNT_INFO_FONTHEIGHT;
  1450. pSV->StdVar[1].dwStdVarID = FNT_INFO_FONTWIDTH;
  1451. pSV->StdVar[2].dwStdVarID = FNT_INFO_TEXTYRES;
  1452. pSV->StdVar[3].dwStdVarID = FNT_INFO_TEXTXRES;
  1453. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_STDVARIABLE,
  1454. pSV, pSV->dwSize, &dwNeeded)) {
  1455. ERR(("UFO_GETINFO_STDVARIABLE failed.\n"));
  1456. return 0;
  1457. }
  1458. VERBOSE(("FONTHEIGHT=%d\n", pSV->StdVar[0].lStdVariable));
  1459. VERBOSE(("FONTWIDTH=%d\n", pSV->StdVar[1].lStdVariable));
  1460. VERBOSE(("TEXTXRES=%d\n", pSV->StdVar[2].lStdVariable));
  1461. VERBOSE(("TEXTYRES=%d\n", pSV->StdVar[3].lStdVariable));
  1462. wCellHeight = (WORD)pSV->StdVar[0].lStdVariable;
  1463. wCellWidth = (WORD)pSV->StdVar[1].lStdVariable;
  1464. // CASIO 98/11/20 ->
  1465. if( MasterToDevice(pOEM,wCellHeight) > 64 ) return 0;
  1466. // CASIO 98/11/20 <-
  1467. //
  1468. // rclFontBox.left may not be 0
  1469. //
  1470. iTemp = max(pIFI->rclFontBox.right -
  1471. pIFI->rclFontBox.left + 1,
  1472. pIFI->fwdAveCharWidth);
  1473. // Check of zero divide 2002.3.23 >>>
  1474. if (iTemp == 0) {
  1475. ERR(("OEMDownloadFontHeader() 0Div-Check [iTemp=0] \n"));
  1476. return 0;
  1477. }
  1478. // Check of zero divide 2002.3.23 <<<
  1479. iCellLeftOffset = (-pIFI->rclFontBox.left)
  1480. * wCellWidth / iTemp;
  1481. wFontPitch = pIFI->fwdAveCharWidth
  1482. * wCellWidth / iTemp;
  1483. FontHeader.wFormatType = SWAPW(0x0002);
  1484. FontHeader.wDataSize = SWAPW(0x0086);
  1485. // CASIO 98/11/24 ->
  1486. // if( pIFI->jWinCharSet == SHIFTJIS_CHARSET ){
  1487. // FontHeader.wSymbolSet = SWAPW(id-FONT_MIN_ID+0x4000+0x8000); //id-FONT_MIN_ID + 4000h + 8000h
  1488. // FontHeader.wLast = (WORD)SWAPW (0x23ff);
  1489. // FontHeader.wFirst = (WORD)SWAPW (0x2020);
  1490. // }else{
  1491. FontHeader.wSymbolSet = SWAPW(id-FONT_MIN_ID+0x4000); //id-FONT_MIN_ID + 4000h
  1492. FontHeader.wLast = SWAPW (0xff);
  1493. FontHeader.wFirst = SWAPW (0x20);
  1494. // }
  1495. // CASIO 98/11/24 <-
  1496. if (pOEM->fGeneral & FG_PROP)
  1497. {
  1498. FontHeader.wCharSpace = SWAPW(1);
  1499. FontHeader.CharWidth.Integer = (WORD)SWAPW(0x0100);
  1500. FontHeader.CharWidth.Fraction = 0;
  1501. }
  1502. else
  1503. {
  1504. FontHeader.wCharSpace = 0;
  1505. FontHeader.CharWidth.Integer
  1506. = SWAPW(MasterToDevice(pOEM, wCellWidth));
  1507. FontHeader.CharWidth.Fraction = 0;
  1508. }
  1509. FontHeader.CharHeight.Integer
  1510. = SWAPW(MasterToDevice(pOEM, wCellHeight));
  1511. FontHeader.CharHeight.Fraction = 0;
  1512. // in the range 128 - 255
  1513. FontHeader.wFontID = SWAPW( id - FONT_MIN_ID + ( id < 0x80 ? 0x80 : 0x00));
  1514. FontHeader.wWeight = 0;
  1515. FontHeader.wEscapement = 0;
  1516. FontHeader.wItalic = 0;
  1517. FontHeader.wUnderline = 0;
  1518. FontHeader.wUnderlineWidth = SWAPW(10);
  1519. FontHeader.wOverline = 0;
  1520. FontHeader.wOverlineWidth = 0;
  1521. FontHeader.wStrikeOut = 0;
  1522. FontHeader.wStrikeOutWidth = 0;
  1523. FontHeader.wCellWidth
  1524. = SWAPW(MasterToDevice(pOEM, wCellWidth));
  1525. FontHeader.wCellHeight
  1526. = SWAPW(MasterToDevice(pOEM, wCellHeight));
  1527. FontHeader.wCellLeftOffset = SWAPW(iCellLeftOffset);
  1528. FontHeader.wCellAscender
  1529. = SWAPW((pIFI->fwdWinAscender
  1530. * MasterToDevice(pOEM, wCellHeight)));
  1531. FontHeader.FixPitchWidth.Integer
  1532. = SWAPW(MasterToDevice(pOEM, wFontPitch));
  1533. FontHeader.FixPitchWidth.Fraction = 0;
  1534. // Replacement of strsafe-api 2002.3.6 >>>
  1535. // iSizeFontName = wsprintf(sFontName,
  1536. // "________________________EPSON_ESC_PAGE_DOWNLOAD_FONT%02d",id-FONT_MIN_ID);
  1537. // iSizeOfBuf = wsprintf(Buff,SET_FONT_ID,FONT_HEADER_SIZE,id-FONT_MIN_ID);
  1538. if (S_OK != StringCbPrintfExA(sFontName, sizeof(sFontName),
  1539. &pDestEnd, &szRemLen,
  1540. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1541. "________________________EPSON_ESC_PAGE_DOWNLOAD_FONT%02d",id-FONT_MIN_ID)) {
  1542. return 0;
  1543. }
  1544. iSizeFontName = (WORD)(pDestEnd - sFontName);
  1545. if (S_OK != StringCbPrintfExA(Buff, sizeof(Buff),
  1546. &pDestEnd, &szRemLen,
  1547. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1548. SET_FONT_ID,FONT_HEADER_SIZE,id-FONT_MIN_ID)) {
  1549. return 0;
  1550. }
  1551. iSizeOfBuf = (WORD)(pDestEnd - Buff);
  1552. // Replacement of strsafe-api 2002.3.6 <<<
  1553. WRITESPOOLBUF(pdevobj, Buff, iSizeOfBuf);
  1554. WRITESPOOLBUF(pdevobj, (LPSTR)&FontHeader,sizeof(ESCPAGEHEADER));
  1555. WRITESPOOLBUF(pdevobj, sFontName,iSizeFontName);
  1556. WRITESPOOLBUF(pdevobj, "EPC_PAGE_DOWNLOAD_FONT_INDEX", SIZE_SYMBOLSET);
  1557. // iSizeOfBuf = wsprintf(Buff,DLI_SELECT_FONT_ID,id-FONT_MIN_ID,0);
  1558. // WRITESPOOLBUF(pdevobj, Buff, iSizeOfBuf);
  1559. //
  1560. DL_VERBOSE(("DLFontHeader: ulFontID=%x, dwDLSetFontID=%x\n",
  1561. pUFObj->ulFontID, pOEM->dwDLSetFontID));
  1562. VERBOSE(("FontHeader:\n"));
  1563. VERBOSE(("wFormatType=%d\n", SWAPW(FontHeader.wFormatType)));
  1564. VERBOSE(("wDataSize=%d\n", SWAPW(FontHeader.wDataSize)));
  1565. VERBOSE(("wSymbolSet=%d\n", SWAPW(FontHeader.wSymbolSet)));
  1566. VERBOSE(("wCharSpace=%d\n", SWAPW(FontHeader.wCharSpace)));
  1567. VERBOSE(("CharWidth=%d.%d\n",
  1568. SWAPW(FontHeader.CharWidth.Integer),
  1569. FontHeader.CharWidth.Fraction));
  1570. VERBOSE(("CharHeight=%d.%d\n",
  1571. SWAPW(FontHeader.CharHeight.Integer),
  1572. FontHeader.CharHeight.Fraction));
  1573. VERBOSE(("wFontID=%d\n", SWAPW(FontHeader.wFontID)));
  1574. VERBOSE(("wWeight=%d\n", SWAPW(FontHeader.wWeight)));
  1575. VERBOSE(("wEscapement=%d\n", SWAPW(FontHeader.wEscapement)));
  1576. VERBOSE(("wItalic=%d\n", SWAPW(FontHeader.wItalic)));
  1577. VERBOSE(("wLast=%d\n", SWAPW(FontHeader.wLast)));
  1578. VERBOSE(("wFirst=%d\n", SWAPW(FontHeader.wFirst)));
  1579. VERBOSE(("wUnderline=%d\n", SWAPW(FontHeader.wUnderline)));
  1580. VERBOSE(("wUnderlineWidth=%d\n", SWAPW(FontHeader.wUnderlineWidth)));
  1581. VERBOSE(("wOverline=%d\n", SWAPW(FontHeader.wOverline)));
  1582. VERBOSE(("wOverlineWidth=%d\n", SWAPW(FontHeader.wOverlineWidth)));
  1583. VERBOSE(("wStrikeOut=%d\n", SWAPW(FontHeader.wStrikeOut)));
  1584. VERBOSE(("wStrikeOutWidth=%d\n", SWAPW(FontHeader.wStrikeOutWidth)));
  1585. VERBOSE(("wCellWidth=%d\n", SWAPW(FontHeader.wCellWidth)));
  1586. VERBOSE(("wCellHeight=%d\n", SWAPW(FontHeader.wCellHeight)));
  1587. VERBOSE(("wCellLeftOffset=%d\n", SWAPW(FontHeader.wCellLeftOffset)));
  1588. VERBOSE(("wCellAscender=%d\n", SWAPW(FontHeader.wCellAscender)));
  1589. VERBOSE(("FixPitchWidth=%d.%d\n",
  1590. SWAPW(FontHeader.FixPitchWidth.Integer),
  1591. FontHeader.FixPitchWidth.Fraction));
  1592. VERBOSE(("FontName=%s\n", sFontName));
  1593. return FONT_HEADER_SIZE;
  1594. }
  1595. //////////////////////////////////////////////////////////////////////////
  1596. // Function: OEMDownloadCharGlyph
  1597. //////////////////////////////////////////////////////////////////////////
  1598. DWORD APIENTRY
  1599. OEMDownloadCharGlyph(
  1600. PDEVOBJ pdevobj,
  1601. PUNIFONTOBJ pUFObj,
  1602. HGLYPH hGlyph,
  1603. PDWORD pdwWidth
  1604. )
  1605. {
  1606. GETINFO_GLYPHBITMAP GBmp;
  1607. GLYPHDATA *pGdata;
  1608. GLYPHBITS *pbit;
  1609. DWORD dwNeeded;
  1610. WORD cp;
  1611. ESCPAGECHAR ESCPageChar;
  1612. WORD wWidth, Width, Hight;
  1613. LPDIBITS lpSrc;
  1614. BYTE mask;
  1615. int iSizeOfBuf, i;
  1616. DWORD dwSize, dwCellSize, dwAirSize;
  1617. BYTE Buff[32];
  1618. PMYPDEV pOEM;
  1619. PIFIMETRICS pIFI;
  1620. LPSTR pDestEnd; // 2002.3.6
  1621. size_t szRemLen; // 2002.3.6
  1622. pIFI = pUFObj->pIFIMetrics;
  1623. pOEM = (PMYPDEV)MINIPDEV_DATA(pdevobj);
  1624. VERBOSE(("OEMDownloadCharGlyph() entry.\n"));
  1625. cp = (WORD)pOEM->wCharCode;
  1626. GBmp.dwSize = sizeof (GETINFO_GLYPHBITMAP);
  1627. GBmp.hGlyph = hGlyph;
  1628. GBmp.pGlyphData = NULL;
  1629. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHBITMAP, &GBmp, GBmp.dwSize, &dwNeeded))
  1630. {
  1631. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHBITMAP failed.\n"));
  1632. return 0;
  1633. }
  1634. pGdata = GBmp.pGlyphData;
  1635. pbit = pGdata->gdf.pgb;
  1636. DL_VERBOSE(("DLCharGlyph: dwDLFont=%x, dwDLSetFont=%x, wCharCode=%x\n",
  1637. pOEM->dwDLFontID, pOEM->dwDLSetFontID, pOEM->wCharCode));
  1638. // Set font id if not already
  1639. if (pOEM->dwDLFontID != pOEM->dwDLSetFontID)
  1640. VSetSelectDLFont(pdevobj, pOEM->dwDLSetFontID);
  1641. // fill in the charcter header information.
  1642. ESCPageChar.bFormat = 0x01;
  1643. ESCPageChar.bDataDir = 0x10;
  1644. // CASIO 98/11/24 ->
  1645. // if( pIFI->jWinCharSet == SHIFTJIS_CHARSET ){
  1646. // cp += SJISCHR;
  1647. // ESCPageChar.wCharCode = SWAPW(cp);
  1648. // }else{
  1649. ESCPageChar.wCharCode = LOBYTE(cp);
  1650. // }
  1651. // CASIO 98/11/24 <-
  1652. ESCPageChar.wBitmapWidth = SWAPW(pbit->sizlBitmap.cx);
  1653. ESCPageChar.wBitmapHeight = SWAPW(pbit->sizlBitmap.cy);
  1654. // MSKK 98/04/06 ->
  1655. // ESCPageChar.wLeftOffset = SWAPW(pbit->ptlOrigin.x);
  1656. // ESCPageChar.wAscent = SWAPW(pbit->ptlOrigin.y * -1);
  1657. ESCPageChar.wLeftOffset = (pbit->ptlOrigin.x > 0 ?
  1658. SWAPW(pbit->ptlOrigin.x) : 0);
  1659. ESCPageChar.wAscent = (pbit->ptlOrigin.y < 0 ?
  1660. SWAPW(pbit->ptlOrigin.y * -1) : 0);
  1661. // MSKK 98/04/06 <-
  1662. ESCPageChar.CharWidth.Integer = SWAPW(pGdata->fxD / 16);
  1663. ESCPageChar.CharWidth.Fraction = 0;
  1664. *pdwWidth = ESCPageChar.CharWidth.Integer;
  1665. Width = LOWORD(pbit->sizlBitmap.cx);
  1666. wWidth = (LOWORD(pbit->sizlBitmap.cx) + 7) >> 3;
  1667. Hight = LOWORD(pbit->sizlBitmap.cy);
  1668. // not multiple of 8, need to mask out unused last byte
  1669. // This is done so that we do not advance beyond segment bound
  1670. // which can happen if lpBitmap is just under 64K and adding
  1671. // width to it will cause invalid segment register to be loaded.
  1672. if (mask = bit_mask[LOWORD(Width) & 0x7])
  1673. {
  1674. lpSrc = pbit->aj + wWidth - 1;
  1675. i = LOWORD(Hight);
  1676. while (TRUE)
  1677. {
  1678. (*lpSrc) &= mask;
  1679. i--;
  1680. if (i > 0)
  1681. lpSrc += wWidth;
  1682. else
  1683. break;
  1684. }
  1685. }
  1686. dwCellSize = (DWORD)pbit->sizlBitmap.cy * wWidth;
  1687. dwSize = (DWORD)(LOWORD(Hight)) * wWidth;
  1688. // Replacement of strsafe-api 2002.3.6 >>>
  1689. //// CASIO 98/11/24 ->
  1690. //// if( pIFI->jWinCharSet == SHIFTJIS_CHARSET ){
  1691. //// iSizeOfBuf = wsprintf(Buff,SET_DOUBLE_BMP,dwCellSize + sizeof(ESCPAGECHAR),HIBYTE(cp),LOBYTE(cp));
  1692. //// }else{
  1693. // iSizeOfBuf = wsprintf(Buff,SET_SINGLE_BMP,dwCellSize + sizeof(ESCPAGECHAR),LOBYTE(cp));
  1694. //// }
  1695. //// CASIO 98/11/24 <-
  1696. if (S_OK != StringCbPrintfExA(Buff, sizeof(Buff),
  1697. &pDestEnd, &szRemLen,
  1698. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE,
  1699. SET_SINGLE_BMP,dwCellSize + sizeof(ESCPAGECHAR),LOBYTE(cp))) {
  1700. return 0;
  1701. }
  1702. iSizeOfBuf = (WORD)(pDestEnd - Buff);
  1703. // Replacement of strsafe-api 2002.3.6 <<<
  1704. WRITESPOOLBUF(pdevobj, Buff, iSizeOfBuf);
  1705. WRITESPOOLBUF(pdevobj, (LPSTR)&ESCPageChar, sizeof(ESCPAGECHAR));
  1706. for (lpSrc = pbit->aj; dwSize; lpSrc += wWidth)
  1707. {
  1708. if ( dwSize > 0x4000 )
  1709. wWidth = 0x4000;
  1710. else
  1711. wWidth = LOWORD(dwSize);
  1712. dwSize -= wWidth;
  1713. WRITESPOOLBUF(pdevobj, (LPSTR)lpSrc, (WORD)wWidth);
  1714. }
  1715. VERBOSE(("ESCPageChar:\n"));
  1716. VERBOSE(("bFormat=%d\n", ESCPageChar.bFormat));
  1717. VERBOSE(("bDataDir=%d\n", ESCPageChar.bDataDir));
  1718. VERBOSE(("wCharCode=%d\n", SWAPW(ESCPageChar.wCharCode)));
  1719. VERBOSE(("wBitmapWidth=%d\n", SWAPW(ESCPageChar.wBitmapWidth)));
  1720. VERBOSE(("wBitmapHeight=%d\n", SWAPW(ESCPageChar.wBitmapHeight)));
  1721. VERBOSE(("wLeftOffset=%d\n", SWAPW(ESCPageChar.wLeftOffset)));
  1722. VERBOSE(("wAscent=%d\n", SWAPW(ESCPageChar.wAscent)));
  1723. VERBOSE(("CharWidth=%d.%d\n", SWAPW(ESCPageChar.CharWidth.Integer),
  1724. ESCPageChar.CharWidth.Fraction));
  1725. return sizeof(ESCPAGECHAR) + dwCellSize;
  1726. }
  1727. //////////////////////////////////////////////////////////////////////////
  1728. // Function: OEMTTDownloadMethod
  1729. //////////////////////////////////////////////////////////////////////////
  1730. DWORD APIENTRY
  1731. OEMTTDownloadMethod(
  1732. PDEVOBJ pdevobj,
  1733. PUNIFONTOBJ pUFObj
  1734. )
  1735. {
  1736. DWORD dwRet;
  1737. // Default is to download.
  1738. dwRet = TTDOWNLOAD_BITMAP;
  1739. VERBOSE(("TTDLMethod: dwRet=%d\n", dwRet));
  1740. return dwRet;
  1741. }