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.

556 lines
16 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. // 08/08/94 Wrote it. by Hayakawa, Task.
  8. //
  9. #define _FUPRJRES_C
  10. #include "pdev.h"
  11. DWORD gdwDrvMemPoolTag = 'meoD'; // lib.h requires this global var, for debugging
  12. /***************************************************************************
  13. Function Name : SheetFeed
  14. Parameters : LPDV lpdv Private Device Structure
  15. Note : Make this. 09/13/94 Task
  16. ***************************************************************************/
  17. void SheetFeed(
  18. PDEVOBJ pdevobj
  19. ){
  20. USHORT bFirstPage;
  21. DEVICE_DATA *pOEM;
  22. DWORD dwResult;
  23. //
  24. // verify pdevobj okay
  25. //
  26. if( !VALID_PDEVOBJ(pdevobj) ) return;
  27. pOEM = (DEVICE_DATA *)MINIDEV_DATA(pdevobj);
  28. bFirstPage = (USHORT)pOEM->bFirstPage;
  29. if ((pOEM->wPaperSource == DMBIN_180BIN1) ||
  30. (pOEM->wPaperSource == DMBIN_180BIN2) ||
  31. (pOEM->wPaperSource == DMBIN_360BIN1) ||
  32. (pOEM->wPaperSource == DMBIN_360BIN2) ||
  33. (pOEM->wPaperSource == DMBIN_SUIHEI_BIN1) ||
  34. (pOEM->wPaperSource == DMBIN_TAMOKUTEKI_BIN1) ||
  35. (pOEM->wPaperSource == DMBIN_FI_FRONT)) {
  36. WRITESPOOLBUF(pdevobj, ecCSFBPAGE.pEscStr, ecCSFBPAGE.cbSize, &dwResult);
  37. } else if ((pOEM->wPaperSource == DMBIN_TRACTOR) ||
  38. (pOEM->wPaperSource == DMBIN_FI_TRACTOR)) {
  39. WRITESPOOLBUF(pdevobj, ecTRCTBPAGE.pEscStr, ecTRCTBPAGE.cbSize, &dwResult);
  40. } else if ((pOEM->wPaperSource == DMBIN_MANUAL) &&
  41. (!bFirstPage)) {
  42. WRITESPOOLBUF(pdevobj, ecManual2P.pEscStr, ecManual2P.cbSize, &dwResult);
  43. pOEM->bFirstPage = FALSE;
  44. }
  45. WRITESPOOLBUF(pdevobj,"\x0D", 1, &dwResult);
  46. if (bFirstPage) pOEM->bFirstPage = FALSE;
  47. }
  48. /***************************************************************************
  49. Function Name : OEMSendFontCmd
  50. Note : Make this. 09/26/97
  51. ***************************************************************************/
  52. VOID APIENTRY OEMSendFontCmd(
  53. PDEVOBJ pdevobj,
  54. PUNIFONTOBJ pUFObj,
  55. PFINVOCATION pFInv)
  56. {
  57. DWORD dwResult;
  58. WRITESPOOLBUF(pdevobj,pFInv->pubCommand, pFInv->dwCount, &dwResult);
  59. }
  60. /***************************************************************************
  61. Function Name : OEMCommandCallback
  62. Note : Make this. 09/26/97
  63. ***************************************************************************/
  64. INT APIENTRY OEMCommandCallback(
  65. PDEVOBJ pdevobj,
  66. DWORD dwCmdCbID,
  67. DWORD dwCount,
  68. PDWORD pdwParams
  69. ){
  70. USHORT bFirstPage;
  71. DEVICE_DATA *pOEM;
  72. DWORD dwResult;
  73. //
  74. // verify pdevobj okay
  75. //
  76. //ASSERT(VALID_PDEVOBJ(pdevobj));
  77. if( !VALID_PDEVOBJ(pdevobj) ) return 0;
  78. pOEM = (DEVICE_DATA *)MINIDEV_DATA(pdevobj);
  79. bFirstPage = (USHORT)pOEM->bFirstPage;
  80. switch (dwCmdCbID) {
  81. case CMDID_ENDDOC :
  82. WRITESPOOLBUF(pdevobj,ecFMEnddoc.pEscStr,ecFMEnddoc.cbSize, &dwResult);
  83. break;
  84. case CMDID_BEGINDOC :
  85. pOEM->bFirstPage = 1;
  86. pOEM->wPaperSource = 0;
  87. // NTRAID#NTBUG9-588420-2002/04/09-yasuho-: Device "Mincho" can not print out.
  88. pOEM->jColor = TEXT_COLOR_BANDW;
  89. break;
  90. case CMDID_MAN180 :
  91. case CMDID_MAN360 :
  92. pOEM->wPaperSource = DMBIN_MANUAL;
  93. SheetFeed(pdevobj);
  94. break;
  95. case CMDID_TRA180 :
  96. pOEM->wPaperSource = DMBIN_TRACTOR;
  97. SheetFeed(pdevobj);
  98. break;
  99. case CMDID_180BIN1 :
  100. if (pOEM->wPaperSource != DMBIN_180BIN1) {
  101. pOEM->wPaperSource = DMBIN_180BIN1;
  102. WRITESPOOLBUF(pdevobj, ecSelectBIN1.pEscStr, ecSelectBIN1.cbSize, &dwResult);
  103. }
  104. SheetFeed(pdevobj);
  105. break;
  106. case CMDID_180BIN2 :
  107. if (pOEM->wPaperSource != DMBIN_180BIN2) {
  108. pOEM->wPaperSource = DMBIN_180BIN2;
  109. WRITESPOOLBUF(pdevobj, ecSelectBIN2.pEscStr, ecSelectBIN2.cbSize, &dwResult);
  110. }
  111. SheetFeed(pdevobj);
  112. break;
  113. case CMDID_360BIN1 :
  114. if (pOEM->wPaperSource != DMBIN_360BIN1) {
  115. pOEM->wPaperSource = DMBIN_360BIN1;
  116. WRITESPOOLBUF(pdevobj, ecSelectBIN1.pEscStr, ecSelectBIN1.cbSize, &dwResult);
  117. }
  118. SheetFeed(pdevobj);
  119. break;
  120. case CMDID_360BIN2 :
  121. if (pOEM->wPaperSource != DMBIN_360BIN2) {
  122. pOEM->wPaperSource = DMBIN_360BIN2;
  123. WRITESPOOLBUF(pdevobj, ecSelectBIN2.pEscStr, ecSelectBIN2.cbSize, &dwResult);
  124. }
  125. SheetFeed(pdevobj);
  126. break;
  127. case CMDID_FI_TRACTOR :
  128. if (pOEM->wPaperSource != DMBIN_FI_TRACTOR) {
  129. pOEM->wPaperSource = DMBIN_FI_TRACTOR;
  130. WRITESPOOLBUF(pdevobj, ecSelectFTRCT.pEscStr, ecSelectFTRCT.cbSize, &dwResult);
  131. }
  132. SheetFeed(pdevobj);
  133. break;
  134. case CMDID_FI_FRONT :
  135. if (pOEM->wPaperSource != DMBIN_FI_FRONT) {
  136. pOEM->wPaperSource = DMBIN_FI_FRONT;
  137. WRITESPOOLBUF(pdevobj, ecSelectFFRNT.pEscStr, ecSelectFFRNT.cbSize, &dwResult);
  138. }
  139. SheetFeed(pdevobj);
  140. break;
  141. case CMDID_SUIHEI_BIN1 :
  142. if (pOEM->wPaperSource != DMBIN_SUIHEI_BIN1) {
  143. pOEM->wPaperSource = DMBIN_SUIHEI_BIN1;
  144. WRITESPOOLBUF(pdevobj, ecSelectBIN1.pEscStr, ecSelectBIN1.cbSize, &dwResult);
  145. }
  146. SheetFeed(pdevobj);
  147. break;
  148. case CMDID_TAMOKUTEKI_BIN1 :
  149. if (pOEM->wPaperSource != DMBIN_TAMOKUTEKI_BIN1) {
  150. pOEM->wPaperSource = DMBIN_TAMOKUTEKI_BIN1;
  151. WRITESPOOLBUF(pdevobj, ecSelectBIN1.pEscStr, ecSelectBIN1.cbSize, &dwResult);
  152. }
  153. SheetFeed(pdevobj);
  154. break;
  155. case CMDID_BEGINPAGE :
  156. // Assume it is not safe to think color settings
  157. // are carried over pages.
  158. SetRibbonColor(pdevobj, TEXT_COLOR_UNKNOWN);
  159. break;
  160. case CMDID_ENDPAGE :
  161. if ((pOEM->wPaperSource == DMBIN_180BIN1) ||
  162. (pOEM->wPaperSource == DMBIN_180BIN2) ||
  163. (pOEM->wPaperSource == DMBIN_360BIN1) ||
  164. (pOEM->wPaperSource == DMBIN_360BIN2) ||
  165. (pOEM->wPaperSource == DMBIN_SUIHEI_BIN1) ||
  166. (pOEM->wPaperSource == DMBIN_TAMOKUTEKI_BIN1) ||
  167. (pOEM->wPaperSource == DMBIN_FI_FRONT)) {
  168. WRITESPOOLBUF(pdevobj, ecCSFEPAGE.pEscStr, ecCSFEPAGE.cbSize, &dwResult);
  169. }
  170. break;
  171. case CMDID_SELECT_BLACK_COLOR:
  172. pOEM->jColor = TEXT_COLOR_BLACK;
  173. break;
  174. case CMDID_SELECT_BLUE_COLOR:
  175. pOEM->jColor = TEXT_COLOR_BLUE;
  176. break;
  177. case CMDID_SELECT_CYAN_COLOR:
  178. pOEM->jColor = TEXT_COLOR_CYAN;
  179. break;
  180. case CMDID_SELECT_GREEN_COLOR:
  181. pOEM->jColor = TEXT_COLOR_GREEN;
  182. break;
  183. case CMDID_SELECT_MAGENTA_COLOR:
  184. pOEM->jColor = TEXT_COLOR_MAGENTA;
  185. break;
  186. case CMDID_SELECT_RED_COLOR:
  187. pOEM->jColor = TEXT_COLOR_RED;
  188. break;
  189. case CMDID_SELECT_WHITE_COLOR:
  190. // Should not happen
  191. pOEM->jColor = TEXT_COLOR_UNKNOWN;
  192. break;
  193. case CMDID_SELECT_YELLOW_COLOR:
  194. pOEM->jColor = TEXT_COLOR_YELLOW;
  195. break;
  196. case CMDID_SEND_BLACK_COLOR:
  197. SetRibbonColor(pdevobj, TEXT_COLOR_BLACK);
  198. break;
  199. case CMDID_SEND_CYAN_COLOR:
  200. SetRibbonColor(pdevobj, TEXT_COLOR_CYAN);
  201. break;
  202. case CMDID_SEND_MAGENTA_COLOR:
  203. SetRibbonColor(pdevobj, TEXT_COLOR_MAGENTA);
  204. break;
  205. case CMDID_SEND_YELLOW_COLOR:
  206. SetRibbonColor(pdevobj, TEXT_COLOR_YELLOW);
  207. break;
  208. } /* end switch */
  209. return 0;
  210. }
  211. PDEVOEM APIENTRY
  212. OEMEnablePDEV(
  213. PDEVOBJ pdevobj,
  214. PWSTR pPrinterName,
  215. ULONG cPatterns,
  216. HSURF *phsurfPatterns,
  217. ULONG cjGdiInfo,
  218. GDIINFO* pGdiInfo,
  219. ULONG cjDevInfo,
  220. DEVINFO* pDevInfo,
  221. DRVENABLEDATA *pded)
  222. {
  223. DEVICE_DATA *pTemp;
  224. VERBOSE((DLLTEXT("OEMEnablePDEV() entry.\n")));
  225. if(!pdevobj) return NULL;
  226. // Set minidriver PDEV address.
  227. pTemp = (DEVICE_DATA *)MemAllocZ(sizeof(DEVICE_DATA));
  228. if (NULL == pTemp) {
  229. ERR(("Memory allocation failure.\n"));
  230. return NULL;
  231. }
  232. pTemp->bFirstPage = TRUE;
  233. pdevobj->pdevOEM = (MINIDEV *)MemAllocZ(sizeof(MINIDEV));
  234. if (NULL == pdevobj->pdevOEM) {
  235. ERR(("Memory allocation failure.\n"));
  236. MemFree(pTemp);
  237. return NULL;
  238. }
  239. MINIDEV_DATA(pdevobj) = (PDEVOEM)pTemp;
  240. return pdevobj->pdevOEM;
  241. }
  242. VOID APIENTRY
  243. OEMDisablePDEV(
  244. PDEVOBJ pdevobj)
  245. {
  246. VERBOSE((DLLTEXT("OEMDisablePDEV() entry.\n")));
  247. if ( NULL != pdevobj->pdevOEM ) {
  248. if (MINIDEV_DATA(pdevobj)) {
  249. MemFree(MINIDEV_DATA(pdevobj));
  250. }
  251. MemFree( pdevobj->pdevOEM );
  252. pdevobj->pdevOEM = NULL;
  253. }
  254. }
  255. BOOL APIENTRY OEMResetPDEV(
  256. PDEVOBJ pdevobjOld,
  257. PDEVOBJ pdevobjNew)
  258. {
  259. DEVICE_DATA *pOEMOld, *pOEMNew;
  260. pOEMOld = (DEVICE_DATA *)MINIDEV_DATA(pdevobjOld);
  261. pOEMNew = (DEVICE_DATA *)MINIDEV_DATA(pdevobjNew);
  262. if (pOEMOld != NULL && pOEMNew != NULL)
  263. *pOEMNew = *pOEMOld;
  264. return TRUE;
  265. }
  266. BOOL
  267. myOEMOutputCharStr(
  268. PDEVOBJ pdevobj,
  269. PUNIFONTOBJ pUFObj,
  270. DWORD dwType,
  271. DWORD dwCount,
  272. PVOID pGlyph )
  273. {
  274. GETINFO_GLYPHSTRING GStr;
  275. PBYTE aubBuff;
  276. PTRANSDATA pTrans;
  277. DWORD dwI;
  278. DEVICE_DATA *pOEM;
  279. DWORD dwResult;
  280. INT i;
  281. BYTE jColor;
  282. BOOL bBackTab;
  283. VERBOSE(("OEMOutputCharStr() entry.\n"));
  284. if( !VALID_PDEVOBJ(pdevobj) ) return FALSE;
  285. if(!pdevobj || !pUFObj || !pGlyph)
  286. {
  287. ERR(("OEMOutputCharStr: Invalid parameter.\n"));
  288. return FALSE;
  289. }
  290. pOEM = (DEVICE_DATA *)MINIDEV_DATA(pdevobj);
  291. switch (dwType)
  292. {
  293. case TYPE_GLYPHHANDLE:
  294. GStr.dwSize = sizeof (GETINFO_GLYPHSTRING);
  295. GStr.dwCount = dwCount;
  296. GStr.dwTypeIn = TYPE_GLYPHHANDLE;
  297. GStr.pGlyphIn = pGlyph;
  298. GStr.dwTypeOut = TYPE_TRANSDATA;
  299. //NTRAID#NTBUG9-333653-2002/03/25-hiroi-: Change I/F for GETINFO_GLYPHSTRING
  300. GStr.pGlyphOut = NULL;
  301. GStr.dwGlyphOutSize = 0;
  302. if (pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr, 0, NULL) || !GStr.dwGlyphOutSize)
  303. {
  304. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\n"));
  305. return FALSE;
  306. }
  307. if(!(aubBuff = (PBYTE)MemAllocZ(GStr.dwGlyphOutSize)) )
  308. {
  309. ERR(("MemAlloc failed.\n"));
  310. return FALSE;
  311. }
  312. GStr.pGlyphOut = aubBuff;
  313. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr, 0, NULL))
  314. {
  315. ERR(("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\n"));
  316. goto out;
  317. }
  318. jColor = pOEM->jColor;
  319. VERBOSE(("jColor=%d\n", jColor));
  320. // NTRAID#NTBUG9-588420-2002/04/09-yasuho-: Device "Mincho" can not print out.
  321. if (jColor == TEXT_COLOR_BANDW) { // monochrome case.
  322. pTrans = (PTRANSDATA)aubBuff;
  323. // Send out text
  324. for (dwI = 0; dwI < dwCount; dwI ++, pTrans++)
  325. {
  326. switch (pTrans->ubType & MTYPE_FORMAT_MASK)
  327. {
  328. case MTYPE_DIRECT:
  329. WRITESPOOLBUF(pdevobj,
  330. &pTrans->uCode.ubCode, 1,
  331. &dwResult);
  332. break;
  333. case MTYPE_PAIRED:
  334. WRITESPOOLBUF(pdevobj,
  335. &pTrans->uCode.ubPairs[0], 1,
  336. &dwResult);
  337. WRITESPOOLBUF(pdevobj,
  338. &pTrans->uCode.ubPairs[1], 1,
  339. &dwResult);
  340. break;
  341. }
  342. }
  343. goto out;
  344. }
  345. // If old color can be used as it is,
  346. // use it first.
  347. jColor <<= 1;
  348. if (0 != (pOEM->jColor & pOEM->jOldColor)) {
  349. jColor &= ~(pOEM->jOldColor << 1);
  350. jColor |= 1;
  351. }
  352. for (i = 0; i < 5 && jColor > 0;
  353. i++, (jColor >>= 1)) {
  354. pTrans = (PTRANSDATA)aubBuff;
  355. // Check if we need to print this plane.
  356. if (!(jColor & 1))
  357. continue;
  358. // Check if we need to do back-tab
  359. bBackTab = (jColor > 1);
  360. if (bBackTab)
  361. {
  362. WRITESPOOLBUF(pdevobj,
  363. "\x1BH", 2, &dwResult);
  364. }
  365. // Send out color select command
  366. switch (i)
  367. {
  368. case 0:
  369. // Same as before
  370. break;
  371. case 1:
  372. // Y
  373. SetRibbonColor(pdevobj, TEXT_COLOR_YELLOW);
  374. break;
  375. case 2:
  376. // M
  377. SetRibbonColor(pdevobj, TEXT_COLOR_MAGENTA);
  378. break;
  379. case 3:
  380. // C
  381. SetRibbonColor(pdevobj, TEXT_COLOR_CYAN);
  382. break;
  383. case 4:
  384. // K
  385. SetRibbonColor(pdevobj, TEXT_COLOR_BLACK);
  386. break;
  387. }
  388. // Send out text
  389. for (dwI = 0; dwI < dwCount; dwI ++, pTrans++)
  390. {
  391. switch (pTrans->ubType & MTYPE_FORMAT_MASK)
  392. {
  393. case MTYPE_DIRECT:
  394. WRITESPOOLBUF(pdevobj,
  395. &pTrans->uCode.ubCode, 1,
  396. &dwResult);
  397. break;
  398. case MTYPE_PAIRED:
  399. WRITESPOOLBUF(pdevobj,
  400. &pTrans->uCode.ubPairs[0], 1,
  401. &dwResult);
  402. WRITESPOOLBUF(pdevobj,
  403. &pTrans->uCode.ubPairs[1], 1,
  404. &dwResult);
  405. break;
  406. }
  407. }
  408. // Do back-tab for next plane
  409. if (bBackTab)
  410. {
  411. WRITESPOOLBUF(pdevobj,
  412. "\x1C" "D\x1B[3g", 6,
  413. &dwResult);
  414. }
  415. }
  416. out:
  417. MemFree(aubBuff);
  418. break;
  419. }
  420. return TRUE;
  421. }
  422. VOID APIENTRY
  423. OEMOutputCharStr(
  424. PDEVOBJ pdevobj,
  425. PUNIFONTOBJ pUFObj,
  426. DWORD dwType,
  427. DWORD dwCount,
  428. PVOID pGlyph )
  429. {
  430. myOEMOutputCharStr(pdevobj,pUFObj,dwType,dwCount,pGlyph);
  431. }
  432. VOID
  433. SetRibbonColor(
  434. PDEVOBJ pdevobj,
  435. BYTE jColor)
  436. {
  437. DEVICE_DATA *pOEM;
  438. DWORD dwResult;
  439. pOEM = (DEVICE_DATA *)MINIDEV_DATA(pdevobj);
  440. switch (jColor)
  441. {
  442. case TEXT_COLOR_YELLOW:
  443. if (TEXT_COLOR_YELLOW != pOEM->jOldColor)
  444. {
  445. WRITESPOOLBUF(pdevobj,
  446. "\x1C*!s", 4, &dwResult);
  447. pOEM->jOldColor = TEXT_COLOR_YELLOW;
  448. }
  449. break;
  450. case TEXT_COLOR_MAGENTA:
  451. if (TEXT_COLOR_MAGENTA != pOEM->jOldColor)
  452. {
  453. WRITESPOOLBUF(pdevobj,
  454. "\x1C*!u", 4, &dwResult);
  455. pOEM->jOldColor = TEXT_COLOR_MAGENTA;
  456. }
  457. break;
  458. case TEXT_COLOR_CYAN:
  459. if (TEXT_COLOR_CYAN != pOEM->jOldColor)
  460. {
  461. WRITESPOOLBUF(pdevobj,
  462. "\x1C*!v", 4, &dwResult);
  463. pOEM->jOldColor = TEXT_COLOR_CYAN;
  464. }
  465. break;
  466. case TEXT_COLOR_BLACK:
  467. if (TEXT_COLOR_BLACK != pOEM->jOldColor)
  468. {
  469. WRITESPOOLBUF(pdevobj,
  470. "\x1C*!p", 4, &dwResult);
  471. pOEM->jOldColor = TEXT_COLOR_BLACK;
  472. }
  473. break;
  474. case TEXT_COLOR_UNKNOWN:
  475. pOEM->jOldColor = TEXT_COLOR_UNKNOWN;
  476. break;
  477. }
  478. }