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.

448 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. xlenable.cpp
  5. Abstract:
  6. Implementation of enable/disable function for PCLXL
  7. Environment:
  8. Windows Whistler
  9. Revision History:
  10. 08/23/99
  11. Created it.
  12. --*/
  13. #include "xlpdev.h"
  14. #include "xldebug.h"
  15. #include <assert.h>
  16. #include "pclxle.h"
  17. #include "pclxlcmd.h"
  18. #include "xlgstate.h"
  19. #include "xloutput.h"
  20. #include "xlbmpcvt.h"
  21. #include "pclxlcmn.h"
  22. #include "xltt.h"
  23. ////////////////////////////////////////////////////////////////////////////////
  24. //
  25. // Local function prototypes
  26. //
  27. inline BOOL BIsColor(
  28. IN PDEVOBJ pDevObj);
  29. ////////////////////////////////////////////////////////////////////////////////
  30. //
  31. // Functions
  32. //
  33. extern "C" VOID APIENTRY
  34. PCLXLDisableDriver(VOID)
  35. /*++
  36. Routine Description:
  37. IPrintOemUni DisableDriver interface
  38. Free all resources, and get prepared to be unloaded.
  39. Arguments:
  40. Return Value:
  41. Note:
  42. --*/
  43. {
  44. VERBOSE(("PCLXLDisaleDriver() entry.\r\n"));
  45. }
  46. extern "C" PDEVOEM APIENTRY
  47. PCLXLEnablePDEV(
  48. PDEVOBJ pdevobj,
  49. PWSTR pPrinterName,
  50. ULONG cPatterns,
  51. HSURF *phsurfPatterns,
  52. ULONG cjGdiInfo,
  53. GDIINFO *pGdiInfo,
  54. ULONG cjDevInfo,
  55. DEVINFO *pDevInfo,
  56. DRVENABLEDATA *pded)
  57. /*++
  58. Routine Description:
  59. IPrintOemUni EnablePDEV interface
  60. Construct its own PDEV. At this time, the driver also passes a function
  61. table which contains its own implementation of DDI entrypoints
  62. Arguments:
  63. pdevobj - pointer to a DEVOBJ structure. pdevobj->pdevOEM is undefined.
  64. pPrinterName - name of the current printer.
  65. Cpatterns -
  66. phsurfPatterns -
  67. cjGdiInfo - size of GDIINFO
  68. pGdiInfo - a pointer to GDIINFO
  69. cjDevInfo - size of DEVINFO
  70. pDevInfo - These parameters are identical to what39s passed into DrvEnablePDEV.
  71. pded: points to a function table which contains the system driver39s
  72. implementation of DDI entrypoints.
  73. Return Value:
  74. --*/
  75. {
  76. PXLPDEV pxlpdev;
  77. VERBOSE(("PCLXLEnablePDEV() entry.\r\n"));
  78. //
  79. // Allocate the XLPDEV
  80. //
  81. if (!(pxlpdev = (PXLPDEV)MemAllocZ(sizeof(XLPDEV))))
  82. return NULL;
  83. pxlpdev->dwSig = XLPDEV_SIG;
  84. //
  85. // Save UNIDRV PDEV
  86. //
  87. pxlpdev->pPDev = (PPDEV)pdevobj;
  88. //
  89. // HS_HORIZONTAL: 0
  90. // HS_VERTICAL: 1
  91. // HS_BDIAGONAL: 2
  92. // HS_FDIAGONAL: 3
  93. // HS_CROSS: 4
  94. // HS_DIAGCROSS: 5
  95. //
  96. pxlpdev->dwLastBrushID = 10; // Raster pattern ID starts from 10.
  97. //
  98. // Initialize buffers
  99. //
  100. // Text string data
  101. //
  102. pxlpdev->pTransOrg = (PTRANSDATA)NULL;
  103. pxlpdev->dwcbTransSize = 0;
  104. pxlpdev->plWidth = (PLONG)NULL;
  105. pxlpdev->dwcbWidthSize = 0;
  106. //
  107. // Initialize buffers
  108. //
  109. // String cache
  110. //
  111. pxlpdev->pptlCharAdvance = (PPOINTL)NULL;
  112. pxlpdev->pawChar = (PWORD)NULL;
  113. pxlpdev->dwCharCount =
  114. pxlpdev->dwMaxCharCount = 0;
  115. //
  116. // Initalize XOutput
  117. //
  118. pxlpdev->pOutput = new XLOutput;
  119. if (NULL == pxlpdev->pOutput)
  120. {
  121. MemFree(pxlpdev);
  122. return NULL;
  123. }
  124. pxlpdev->pOutput->SetResolutionForBrush(((PPDEV)pdevobj)->ptGrxRes.x);
  125. ColorDepth CD;
  126. if (BIsColor(pdevobj))
  127. {
  128. CD = e24Bit;
  129. }
  130. else
  131. {
  132. CD = e8Bit;
  133. }
  134. pxlpdev->pOutput->SetDeviceColorDepth(CD);
  135. #if DBG
  136. pxlpdev->pOutput->SetOutputDbgLevel(OUTPUTDBG);
  137. pxlpdev->pOutput->SetGStateDbgLevel(GSTATEDBG);
  138. #endif
  139. //
  140. // Initialize device font name buffer
  141. //
  142. if (!SUCCEEDED(StringCchCopyA(pxlpdev->ubFontName, CCHOF(pxlpdev->ubFontName),"MS PCLXLFont ")))
  143. {
  144. delete pxlpdev->pOutput;
  145. MemFree(pxlpdev);
  146. return NULL;
  147. }
  148. //
  149. // Initialize
  150. // Fixed pitch TT
  151. // Number of downloaded TrueType font
  152. //
  153. pxlpdev->dwFixedTTWidth = 0;
  154. pxlpdev->dwNumOfTTFont = 0;
  155. //
  156. // TrueType file object
  157. //
  158. pxlpdev->pTTFile = new XLTrueType;
  159. if (NULL == pxlpdev->pTTFile)
  160. {
  161. delete pxlpdev->pOutput;
  162. MemFree(pxlpdev);
  163. return NULL;
  164. }
  165. //
  166. // Text resolution and Font Height
  167. //
  168. pxlpdev->dwFontHeight =
  169. pxlpdev->dwTextRes = 0;
  170. //
  171. // Text Angle
  172. //
  173. pxlpdev->dwTextAngle = 0;
  174. //
  175. // JPEG support
  176. //
  177. //pDevInfo->flGraphicsCaps2 |= GCAPS2_JPEGSRC;
  178. pDevInfo->flGraphicsCaps |= GCAPS_BEZIERS |
  179. GCAPS_BEZIERS |
  180. //GCAPS_GEOMETRICWIDE |
  181. GCAPS_ALTERNATEFILL |
  182. GCAPS_WINDINGFILL |
  183. GCAPS_NUP |
  184. GCAPS_OPAQUERECT |
  185. GCAPS_COLOR_DITHER |
  186. GCAPS_HORIZSTRIKE |
  187. GCAPS_VERTSTRIKE |
  188. GCAPS_OPAQUERECT;
  189. //
  190. // PCL-XL always expects GDI to give the driver full color information.
  191. // Even if PCLXL may be printing monochrome, it still wants full color info.
  192. //
  193. pDevInfo->cxDither = pDevInfo->cyDither = 0;
  194. pDevInfo->iDitherFormat = BMF_24BPP;
  195. //
  196. // Set cursor offset.
  197. //
  198. pxlpdev->pOutput->SetCursorOffset(((PPDEV)pdevobj)->sf.ptPrintOffsetM.x,
  199. ((PPDEV)pdevobj)->sf.ptPrintOffsetM.y);
  200. //
  201. // Return the result
  202. //
  203. return (PDEVOEM)pxlpdev;
  204. }
  205. extern "C" BOOL APIENTRY
  206. PCLXLResetPDEV(
  207. PDEVOBJ pdevobjOld,
  208. PDEVOBJ pdevobjNew)
  209. /*++
  210. Routine Description:
  211. IPrintOemUni ResetPDEV interface
  212. OEMResetPDEV transfers the state of the driver from the old PDEVOBJ to the
  213. new PDEVOBJ when an application calls ResetDC.
  214. Arguments:
  215. pdevobjOld - pdevobj containing Old PDEV
  216. pdevobjNew - pdevobj containing New PDEV
  217. Return Value:
  218. Note:
  219. --*/
  220. {
  221. VERBOSE(("PCLXLResetPDEV entry.\r\n"));
  222. PXLPDEV pxlpdevOld = (PXLPDEV)pdevobjOld->pdevOEM;
  223. PXLPDEV pxlpdevNew = (PXLPDEV)pdevobjNew->pdevOEM;
  224. if (!(pxlpdevOld->dwFlags & XLPDEV_FLAGS_FIRSTPAGE))
  225. {
  226. RemoveAllFonts(pdevobjOld);
  227. }
  228. pxlpdevNew->dwFlags |= XLPDEV_FLAGS_RESETPDEV_CALLED;
  229. return TRUE;
  230. }
  231. extern "C" VOID APIENTRY
  232. PCLXLDisablePDEV(
  233. PDEVOBJ pdevobj)
  234. /*++
  235. Routine Description:
  236. IPrintOemUni DisablePDEV interface
  237. Free resources allocated for the PDEV.
  238. Arguments:
  239. pdevobj -
  240. Return Value:
  241. Note:
  242. --*/
  243. {
  244. PXLPDEV pxlpdev;
  245. VERBOSE(("PCLXLDisablePDEV() entry.\r\n"));
  246. //
  247. // Error check
  248. //
  249. if (!pdevobj)
  250. {
  251. ERR(("PCLXLDisablePDEV(): invalid pdevobj.\r\n"));
  252. return;
  253. }
  254. //
  255. // free memory for XLPDEV and any memory block that hangs off XLPDEV.
  256. //
  257. pxlpdev = (PXLPDEV)pdevobj->pdevOEM;
  258. if (pxlpdev)
  259. {
  260. //
  261. // *Trans data buffer
  262. // *Width data buffer
  263. // *String cache(string and width) buffer
  264. //
  265. if (pxlpdev->pTransOrg)
  266. MemFree(pxlpdev->pTransOrg);
  267. if (pxlpdev->plWidth)
  268. MemFree(pxlpdev->plWidth);
  269. if (pxlpdev->pptlCharAdvance)
  270. MemFree(pxlpdev->pptlCharAdvance);
  271. if (pxlpdev->pawChar)
  272. MemFree(pxlpdev->pawChar);
  273. //
  274. // Delete XLTrueType
  275. //
  276. delete pxlpdev->pTTFile;
  277. //
  278. // Delete XLOutput
  279. //
  280. delete pxlpdev->pOutput;
  281. //
  282. // Delete XLFont
  283. //
  284. delete pxlpdev->pXLFont;
  285. //
  286. // Free XLPDEV
  287. //
  288. MemFree(pxlpdev);
  289. }
  290. }
  291. extern "C"
  292. BOOL
  293. PCLXLDriverDMS(
  294. PVOID pDevObj,
  295. PVOID pBuffer,
  296. DWORD cbSize,
  297. PDWORD pcbNeeded)
  298. /*++
  299. Routine Description:
  300. IPrintOemUni DriverDMS interface
  301. Arguments:
  302. Return Value:
  303. Note:
  304. --*/
  305. {
  306. VERBOSE(("PCLXLDriverDMS() entry.\r\n"));
  307. if (cbSize >= sizeof(DWORD))
  308. {
  309. *(PDWORD)pBuffer =
  310. HOOK_TEXTOUT |
  311. HOOK_LINETO |
  312. HOOK_COPYBITS |
  313. HOOK_BITBLT |
  314. HOOK_STRETCHBLT |
  315. HOOK_PAINT |
  316. HOOK_PLGBLT |
  317. HOOK_STRETCHBLTROP |
  318. HOOK_TRANSPARENTBLT |
  319. HOOK_ALPHABLEND |
  320. HOOK_GRADIENTFILL |
  321. HOOK_STROKEPATH |
  322. HOOK_FILLPATH |
  323. HOOK_STROKEANDFILLPATH;
  324. }
  325. return TRUE;
  326. }
  327. inline BOOL BIsColor(
  328. IN PDEVOBJ pdevobj)
  329. {
  330. //
  331. // If no ColorModeEx is present or if its bColor attribute
  332. // is not set, then its not color.
  333. //
  334. if ( NULL == ((PPDEV)pdevobj)->pColorModeEx ||
  335. FALSE == ((PPDEV)pdevobj)->pColorModeEx->bColor)
  336. {
  337. return FALSE;
  338. }
  339. else
  340. {
  341. return TRUE;
  342. }
  343. }