Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1 | /* |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2 | * PostScript driver initialization functions |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright 1998 Huw D M Davies |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 5 | * Copyright 2001 Marcus Meissner |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 6 | * |
| 7 | */ |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 8 | |
Jeff Garzik | c3e1f72 | 1999-02-19 15:42:11 +0000 | [diff] [blame] | 9 | #include <string.h> |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 10 | #include <unistd.h> |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 11 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 12 | #include "gdi.h" |
| 13 | #include "psdrv.h" |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 14 | #include "debugtools.h" |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 15 | #include "heap.h" |
| 16 | #include "winreg.h" |
Alexandre Julliard | 5954560 | 1999-02-10 06:52:57 +0000 | [diff] [blame] | 17 | #include "winspool.h" |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 18 | #include "winerror.h" |
Huw D M Davies | 91547cb | 1999-07-24 10:11:05 +0000 | [diff] [blame] | 19 | #include "options.h" |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 20 | |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 21 | #ifdef HAVE_CUPS |
| 22 | # include <cups/cups.h> |
| 23 | #endif |
| 24 | |
Dimitrie O. Paun | 529da54 | 2000-11-27 23:54:25 +0000 | [diff] [blame] | 25 | DEFAULT_DEBUG_CHANNEL(psdrv); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 26 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 27 | static BOOL PSDRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device, |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 28 | LPCSTR output, const DEVMODEA* initData ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 29 | static BOOL PSDRV_DeleteDC( DC *dc ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 30 | |
| 31 | static const DC_FUNCTIONS PSDRV_Funcs = |
| 32 | { |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 33 | NULL, /* pAbortDoc */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 34 | NULL, /* pAbortPath */ |
| 35 | NULL, /* pAngleArc */ |
Huw D M Davies | 14c99d0 | 1998-10-24 10:44:05 +0000 | [diff] [blame] | 36 | PSDRV_Arc, /* pArc */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 37 | NULL, /* pArcTo */ |
| 38 | NULL, /* pBeginPath */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 39 | NULL, /* pBitBlt */ |
Huw D M Davies | 87f87bf | 1998-10-28 09:53:53 +0000 | [diff] [blame] | 40 | NULL, /* pBitmapBits */ |
Lionel Ulmer | bedf40b | 2000-05-12 20:18:14 +0000 | [diff] [blame] | 41 | NULL, /* pChoosePixelFormat */ |
Huw D M Davies | 14c99d0 | 1998-10-24 10:44:05 +0000 | [diff] [blame] | 42 | PSDRV_Chord, /* pChord */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 43 | NULL, /* pCloseFigure */ |
Huw D M Davies | 87f87bf | 1998-10-28 09:53:53 +0000 | [diff] [blame] | 44 | NULL, /* pCreateBitmap */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 45 | PSDRV_CreateDC, /* pCreateDC */ |
Patrik Stridvall | b87fe2e | 1999-04-01 08:16:08 +0000 | [diff] [blame] | 46 | NULL, /* pCreateDIBSection */ |
| 47 | NULL, /* pCreateDIBSection16 */ |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 48 | PSDRV_DeleteDC, /* pDeleteDC */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 49 | NULL, /* pDeleteObject */ |
Lionel Ulmer | bedf40b | 2000-05-12 20:18:14 +0000 | [diff] [blame] | 50 | NULL, /* pDescribePixelFormat */ |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 51 | PSDRV_DeviceCapabilities, /* pDeviceCapabilities */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 52 | PSDRV_Ellipse, /* pEllipse */ |
Huw D M Davies | 8156150 | 1999-07-25 11:25:59 +0000 | [diff] [blame] | 53 | PSDRV_EndDoc, /* pEndDoc */ |
| 54 | PSDRV_EndPage, /* pEndPage */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 55 | NULL, /* pEndPath */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 56 | PSDRV_EnumDeviceFonts, /* pEnumDeviceFonts */ |
| 57 | PSDRV_Escape, /* pEscape */ |
| 58 | NULL, /* pExcludeClipRect */ |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 59 | PSDRV_ExtDeviceMode, /* pExtDeviceMode */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 60 | NULL, /* pExtFloodFill */ |
| 61 | PSDRV_ExtTextOut, /* pExtTextOut */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 62 | NULL, /* pFillPath */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 63 | NULL, /* pFillRgn */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 64 | NULL, /* pFlattenPath */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 65 | NULL, /* pFrameRgn */ |
Huw D M Davies | 14c99d0 | 1998-10-24 10:44:05 +0000 | [diff] [blame] | 66 | PSDRV_GetCharWidth, /* pGetCharWidth */ |
Alexandre Julliard | 07e4213 | 2000-03-19 21:19:21 +0000 | [diff] [blame] | 67 | NULL, /* pGetDCOrgEx */ |
Ove Kaaven | 27398d4 | 2001-03-20 01:55:18 +0000 | [diff] [blame] | 68 | NULL, /* pGetDeviceGammaRamp */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 69 | NULL, /* pGetPixel */ |
Lionel Ulmer | bedf40b | 2000-05-12 20:18:14 +0000 | [diff] [blame] | 70 | NULL, /* pGetPixelFormat */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 71 | PSDRV_GetTextExtentPoint, /* pGetTextExtentPoint */ |
| 72 | PSDRV_GetTextMetrics, /* pGetTextMetrics */ |
| 73 | NULL, /* pIntersectClipRect */ |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 74 | NULL, /* pInvertRgn */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 75 | PSDRV_LineTo, /* pLineTo */ |
Patrik Stridvall | d3534c3 | 2000-11-05 03:28:18 +0000 | [diff] [blame] | 76 | NULL, /* pMoveTo */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 77 | NULL, /* pOffsetClipRgn */ |
| 78 | NULL, /* pOffsetViewportOrg (optional) */ |
| 79 | NULL, /* pOffsetWindowOrg (optional) */ |
| 80 | NULL, /* pPaintRgn */ |
Huw D M Davies | e28224f | 1999-07-10 10:21:03 +0000 | [diff] [blame] | 81 | PSDRV_PatBlt, /* pPatBlt */ |
Huw D M Davies | 14c99d0 | 1998-10-24 10:44:05 +0000 | [diff] [blame] | 82 | PSDRV_Pie, /* pPie */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 83 | NULL, /* pPolyBezier */ |
| 84 | NULL, /* pPolyBezierTo */ |
| 85 | NULL, /* pPolyDraw */ |
Huw D M Davies | 14c99d0 | 1998-10-24 10:44:05 +0000 | [diff] [blame] | 86 | PSDRV_PolyPolygon, /* pPolyPolygon */ |
| 87 | PSDRV_PolyPolyline, /* pPolyPolyline */ |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 88 | PSDRV_Polygon, /* pPolygon */ |
| 89 | PSDRV_Polyline, /* pPolyline */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 90 | NULL, /* pPolylineTo */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 91 | NULL, /* pRealizePalette */ |
| 92 | PSDRV_Rectangle, /* pRectangle */ |
| 93 | NULL, /* pRestoreDC */ |
Huw D M Davies | 14c99d0 | 1998-10-24 10:44:05 +0000 | [diff] [blame] | 94 | PSDRV_RoundRect, /* pRoundRect */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 95 | NULL, /* pSaveDC */ |
| 96 | NULL, /* pScaleViewportExt (optional) */ |
| 97 | NULL, /* pScaleWindowExt (optional) */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 98 | NULL, /* pSelectClipPath */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 99 | NULL, /* pSelectClipRgn */ |
| 100 | PSDRV_SelectObject, /* pSelectObject */ |
| 101 | NULL, /* pSelectPalette */ |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 102 | PSDRV_SetBkColor, /* pSetBkColor */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 103 | NULL, /* pSetBkMode */ |
Stephane Lussier | 62efee2 | 1999-10-13 13:58:45 +0000 | [diff] [blame] | 104 | PSDRV_SetDeviceClipping, /* pSetDeviceClipping */ |
Ove Kaaven | 27398d4 | 2001-03-20 01:55:18 +0000 | [diff] [blame] | 105 | NULL, /* pSetDeviceGammaRamp */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 106 | NULL, /* pSetDIBitsToDevice */ |
| 107 | NULL, /* pSetMapMode (optional) */ |
| 108 | NULL, /* pSetMapperFlags */ |
Huw D M Davies | 14c99d0 | 1998-10-24 10:44:05 +0000 | [diff] [blame] | 109 | PSDRV_SetPixel, /* pSetPixel */ |
Lionel Ulmer | bedf40b | 2000-05-12 20:18:14 +0000 | [diff] [blame] | 110 | NULL, /* pSetPixelFormat */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 111 | NULL, /* pSetPolyFillMode */ |
| 112 | NULL, /* pSetROP2 */ |
| 113 | NULL, /* pSetRelAbs */ |
| 114 | NULL, /* pSetStretchBltMode */ |
| 115 | NULL, /* pSetTextAlign */ |
| 116 | NULL, /* pSetTextCharacterExtra */ |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 117 | PSDRV_SetTextColor, /* pSetTextColor */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 118 | NULL, /* pSetTextJustification */ |
| 119 | NULL, /* pSetViewportExt (optional) */ |
| 120 | NULL, /* pSetViewportOrg (optional) */ |
| 121 | NULL, /* pSetWindowExt (optional) */ |
| 122 | NULL, /* pSetWindowOrg (optional) */ |
Huw D M Davies | 8156150 | 1999-07-25 11:25:59 +0000 | [diff] [blame] | 123 | PSDRV_StartDoc, /* pStartDoc */ |
| 124 | PSDRV_StartPage, /* pStartPage */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 125 | NULL, /* pStretchBlt */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 126 | PSDRV_StretchDIBits, /* pStretchDIBits */ |
| 127 | NULL, /* pStrokeAndFillPath */ |
| 128 | NULL, /* pStrokePath */ |
Lionel Ulmer | bedf40b | 2000-05-12 20:18:14 +0000 | [diff] [blame] | 129 | NULL, /* pSwapBuffers */ |
Huw D M Davies | f0f8da5 | 1999-12-05 23:54:02 +0000 | [diff] [blame] | 130 | NULL /* pWidenPath */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | |
| 134 | /* Default entries for devcaps */ |
| 135 | |
| 136 | static DeviceCaps PSDRV_DevCaps = { |
| 137 | /* version */ 0, |
| 138 | /* technology */ DT_RASPRINTER, |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 139 | /* horzSize */ 210, |
| 140 | /* vertSize */ 297, |
| 141 | /* horzRes */ 4961, |
| 142 | /* vertRes */ 7016, |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 143 | /* bitsPixel */ 1, |
| 144 | /* planes */ 1, |
| 145 | /* numBrushes */ -1, |
| 146 | /* numPens */ 10, |
| 147 | /* numMarkers */ 0, |
| 148 | /* numFonts */ 39, |
| 149 | /* numColors */ 2, |
| 150 | /* pdeviceSize */ 0, |
| 151 | /* curveCaps */ CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | |
| 152 | CC_WIDE | CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | |
| 153 | CC_ROUNDRECT, |
| 154 | /* lineCaps */ LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE | |
| 155 | LC_STYLED | LC_WIDESTYLED | LC_INTERIORS, |
| 156 | /* polygoalnCaps */ PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | |
| 157 | PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | |
| 158 | PC_INTERIORS, |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 159 | /* textCaps */ TC_CR_ANY, /* psdrv 0x59f7 */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 160 | /* clipCaps */ CP_RECTANGLE, |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 161 | /* rasterCaps */ RC_BITBLT | RC_BITMAP64 | RC_GDI20_OUTPUT | |
| 162 | RC_DIBTODEV | RC_STRETCHBLT | |
| 163 | RC_STRETCHDIB, /* psdrv 0x6e99 */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 164 | /* aspectX */ 600, |
| 165 | /* aspectY */ 600, |
| 166 | /* aspectXY */ 848, |
| 167 | /* pad1 */ { 0 }, |
| 168 | /* logPixelsX */ 600, |
| 169 | /* logPixelsY */ 600, |
| 170 | /* pad2 */ { 0 }, |
| 171 | /* palette size */ 0, |
| 172 | /* ..etc */ 0, 0 }; |
| 173 | |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 174 | static PSDRV_DEVMODEA DefaultDevmode = |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 175 | { |
| 176 | { /* dmPublic */ |
| 177 | /* dmDeviceName */ "Wine PostScript Driver", |
| 178 | /* dmSpecVersion */ 0x30a, |
| 179 | /* dmDriverVersion */ 0x001, |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 180 | /* dmSize */ sizeof(DEVMODEA), |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 181 | /* dmDriverExtra */ 0, |
Luc Tourangeau | effc55e | 1999-07-18 18:34:45 +0000 | [diff] [blame] | 182 | /* dmFields */ DM_ORIENTATION | DM_PAPERSIZE | DM_SCALE | |
| 183 | DM_COPIES | DM_DEFAULTSOURCE | DM_COLOR | |
| 184 | DM_DUPLEX | DM_YRESOLUTION | DM_TTOPTION, |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 185 | { /* u1 */ |
| 186 | { /* s1 */ |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 187 | /* dmOrientation */ DMORIENT_PORTRAIT, |
| 188 | /* dmPaperSize */ DMPAPER_A4, |
| 189 | /* dmPaperLength */ 2969, |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 190 | /* dmPaperWidth */ 2101 |
| 191 | } |
| 192 | }, |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 193 | /* dmScale */ 100, /* ?? */ |
| 194 | /* dmCopies */ 1, |
| 195 | /* dmDefaultSource */ DMBIN_AUTO, |
| 196 | /* dmPrintQuality */ 0, |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 197 | /* dmColor */ DMCOLOR_COLOR, |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 198 | /* dmDuplex */ 0, |
| 199 | /* dmYResolution */ 0, |
| 200 | /* dmTTOption */ DMTT_SUBDEV, |
| 201 | /* dmCollate */ 0, |
| 202 | /* dmFormName */ "", |
| 203 | /* dmUnusedPadding */ 0, |
| 204 | /* dmBitsPerPel */ 0, |
| 205 | /* dmPelsWidth */ 0, |
| 206 | /* dmPelsHeight */ 0, |
| 207 | /* dmDisplayFlags */ 0, |
Patrik Stridvall | a9f6a9d | 2000-10-24 02:22:16 +0000 | [diff] [blame] | 208 | /* dmDisplayFrequency */ 0, |
| 209 | /* dmICMMethod */ 0, |
| 210 | /* dmICMIntent */ 0, |
| 211 | /* dmMediaType */ 0, |
| 212 | /* dmDitherType */ 0, |
| 213 | /* dmReserved1 */ 0, |
| 214 | /* dmReserved2 */ 0, |
| 215 | /* dmPanningWidth */ 0, |
| 216 | /* dmPanningHeight */ 0 |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 217 | }, |
| 218 | { /* dmDocPrivate */ |
Patrik Stridvall | a9f6a9d | 2000-10-24 02:22:16 +0000 | [diff] [blame] | 219 | /* dummy */ 0 |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 220 | }, |
| 221 | { /* dmDrvPrivate */ |
Patrik Stridvall | a9f6a9d | 2000-10-24 02:22:16 +0000 | [diff] [blame] | 222 | /* ppdfilename */ "default.ppd", |
| 223 | /* numInstalledOptions */ 0 |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 224 | } |
| 225 | }; |
| 226 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 227 | HANDLE PSDRV_Heap = 0; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 228 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 229 | static HANDLE PSDRV_DefaultFont = 0; |
| 230 | static LOGFONTA DefaultLogFont = { |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 231 | 100, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 0, 0, |
| 232 | DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "" |
| 233 | }; |
| 234 | |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 235 | /********************************************************************* |
| 236 | * PSDRV_Init |
| 237 | * |
| 238 | * Initializes font metrics and registers driver. Called from GDI_Init() |
| 239 | * |
| 240 | */ |
Dimitrie O. Paun | 84bde6a | 2000-05-30 20:27:23 +0000 | [diff] [blame] | 241 | BOOL WINAPI PSDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved ) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 242 | { |
Dimitrie O. Paun | 84bde6a | 2000-05-30 20:27:23 +0000 | [diff] [blame] | 243 | TRACE("(0x%4x, 0x%08lx, %p)\n", hinst, reason, reserved); |
| 244 | |
| 245 | switch(reason) { |
Ian Pilcher | 2ce7bc8 | 2001-04-30 18:17:13 +0000 | [diff] [blame^] | 246 | |
Dimitrie O. Paun | 84bde6a | 2000-05-30 20:27:23 +0000 | [diff] [blame] | 247 | case DLL_PROCESS_ATTACH: |
Ian Pilcher | 2ce7bc8 | 2001-04-30 18:17:13 +0000 | [diff] [blame^] | 248 | |
| 249 | PSDRV_Heap = HeapCreate(0, 0x10000, 0); |
| 250 | if (PSDRV_Heap == (HANDLE)NULL) |
| 251 | return FALSE; |
| 252 | |
| 253 | if (PSDRV_GetFontMetrics() == FALSE) { |
| 254 | HeapDestroy(PSDRV_Heap); |
| 255 | return FALSE; |
| 256 | } |
| 257 | |
| 258 | PSDRV_DefaultFont = CreateFontIndirectA(&DefaultLogFont); |
| 259 | if (PSDRV_DefaultFont == (HANDLE)NULL) { |
| 260 | HeapDestroy(PSDRV_Heap); |
| 261 | return FALSE; |
| 262 | } |
| 263 | |
| 264 | /* Register driver as "WINEPS", "WINEPS.DLL" and "WINEPS.DRV" |
| 265 | to allow an easy configuring for users */ |
| 266 | |
| 267 | if (DRIVER_RegisterDriver("WINEPS", &PSDRV_Funcs) == FALSE) { |
| 268 | HeapDestroy(PSDRV_Heap); |
| 269 | return FALSE; |
| 270 | } |
| 271 | |
| 272 | if (DRIVER_RegisterDriver("WINEPS.DLL", &PSDRV_Funcs) == FALSE) { |
| 273 | DRIVER_UnregisterDriver("WINEPS"); |
| 274 | HeapDestroy(PSDRV_Heap); |
| 275 | return FALSE; |
| 276 | } |
| 277 | |
| 278 | if (DRIVER_RegisterDriver("WINEPS.DRV", &PSDRV_Funcs) == FALSE) { |
| 279 | DRIVER_UnregisterDriver("WINEPS"); |
| 280 | DRIVER_UnregisterDriver("WINEPS.DLL"); |
| 281 | HeapDestroy(PSDRV_Heap); |
| 282 | return FALSE; |
| 283 | } |
| 284 | |
| 285 | break; |
| 286 | |
Dimitrie O. Paun | 84bde6a | 2000-05-30 20:27:23 +0000 | [diff] [blame] | 287 | case DLL_PROCESS_DETACH: |
Ian Pilcher | 2ce7bc8 | 2001-04-30 18:17:13 +0000 | [diff] [blame^] | 288 | |
| 289 | DeleteObject( PSDRV_DefaultFont ); |
| 290 | HeapDestroy( PSDRV_Heap ); |
| 291 | DRIVER_UnregisterDriver( "WINEPS" ); |
| 292 | DRIVER_UnregisterDriver( "WINEPS.DLL" ); |
| 293 | DRIVER_UnregisterDriver( "WINEPS.DRV" ); |
| 294 | |
| 295 | break; |
Dimitrie O. Paun | 84bde6a | 2000-05-30 20:27:23 +0000 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | return TRUE; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 299 | } |
| 300 | |
Dimitrie O. Paun | 84bde6a | 2000-05-30 20:27:23 +0000 | [diff] [blame] | 301 | |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 302 | /********************************************************************** |
| 303 | * PSDRV_CreateDC |
| 304 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 305 | static BOOL PSDRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device, |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 306 | LPCSTR output, const DEVMODEA* initData ) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 307 | { |
| 308 | PSDRV_PDEVICE *physDev; |
Noel Borthwick | 86b686f | 1999-06-05 08:52:30 +0000 | [diff] [blame] | 309 | PRINTERINFO *pi; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 310 | DeviceCaps *devCaps; |
Huw D M Davies | d4b933e | 2001-01-28 23:13:45 +0000 | [diff] [blame] | 311 | PAGESIZE *page; |
| 312 | INT width = 0, height = 0; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 313 | |
Noel Borthwick | 86b686f | 1999-06-05 08:52:30 +0000 | [diff] [blame] | 314 | /* If no device name was specified, retrieve the device name |
| 315 | * from the DEVMODE structure from the DC's physDev. |
| 316 | * (See CreateCompatibleDC) */ |
| 317 | if ( !device && dc->physDev ) |
| 318 | { |
| 319 | physDev = (PSDRV_PDEVICE *)dc->physDev; |
| 320 | device = physDev->Devmode->dmPublic.dmDeviceName; |
| 321 | } |
| 322 | pi = PSDRV_FindPrinterInfo(device); |
| 323 | |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 324 | TRACE("(%s %s %s %p)\n", driver, device, output, initData); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 325 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 326 | if(!pi) return FALSE; |
| 327 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 328 | if(!pi->Fonts) { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 329 | MESSAGE("To use WINEPS you need to install some AFM files.\n"); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 330 | return FALSE; |
| 331 | } |
| 332 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 333 | physDev = (PSDRV_PDEVICE *)HeapAlloc( PSDRV_Heap, HEAP_ZERO_MEMORY, |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 334 | sizeof(*physDev) ); |
| 335 | if (!physDev) return FALSE; |
| 336 | dc->physDev = physDev; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 337 | |
| 338 | physDev->pi = pi; |
| 339 | |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 340 | physDev->Devmode = (PSDRV_DEVMODEA *)HeapAlloc( PSDRV_Heap, 0, |
| 341 | sizeof(PSDRV_DEVMODEA) ); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 342 | if(!physDev->Devmode) { |
| 343 | HeapFree( PSDRV_Heap, 0, physDev ); |
| 344 | return FALSE; |
| 345 | } |
| 346 | |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 347 | memcpy( physDev->Devmode, pi->Devmode, sizeof(PSDRV_DEVMODEA) ); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 348 | |
| 349 | if(initData) { |
Huw D M Davies | e39b676 | 1999-05-17 16:20:51 +0000 | [diff] [blame] | 350 | PSDRV_MergeDevmodes(physDev->Devmode, (PSDRV_DEVMODEA *)initData, pi); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | |
| 354 | devCaps = HeapAlloc( PSDRV_Heap, 0, sizeof(PSDRV_DevCaps) ); |
| 355 | memcpy(devCaps, &PSDRV_DevCaps, sizeof(PSDRV_DevCaps)); |
| 356 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 357 | /* Are aspect[XY] and logPixels[XY] correct? */ |
| 358 | /* Need to handle different res in x and y => fix ppd */ |
| 359 | devCaps->aspectX = devCaps->logPixelsX = |
| 360 | physDev->pi->ppd->DefaultResolution; |
| 361 | devCaps->aspectY = devCaps->logPixelsY = |
| 362 | physDev->pi->ppd->DefaultResolution; |
| 363 | devCaps->aspectXY = (int)hypot( (double)devCaps->aspectX, |
| 364 | (double)devCaps->aspectY ); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 365 | |
Huw D M Davies | d4b933e | 2001-01-28 23:13:45 +0000 | [diff] [blame] | 366 | |
| 367 | for(page = pi->ppd->PageSizes; page; page = page->next) { |
| 368 | if(page->WinPage == physDev->Devmode->dmPublic.u1.s1.dmPaperSize) |
| 369 | break; |
| 370 | } |
| 371 | if(!page) { |
| 372 | FIXME("Can't find page\n"); |
| 373 | physDev->PageSize.left = 0; |
| 374 | physDev->PageSize.right = 0; |
| 375 | physDev->PageSize.bottom = 0; |
| 376 | physDev->PageSize.top = 0; |
| 377 | } else if(page->ImageableArea) { /* PageSize is in device units */ |
| 378 | physDev->PageSize.left = page->ImageableArea->llx * |
| 379 | devCaps->logPixelsX / 72; |
| 380 | physDev->PageSize.right = page->ImageableArea->urx * |
| 381 | devCaps->logPixelsX / 72; |
| 382 | physDev->PageSize.bottom = page->ImageableArea->lly * |
| 383 | devCaps->logPixelsY / 72; |
| 384 | physDev->PageSize.top = page->ImageableArea->ury * |
| 385 | devCaps->logPixelsY / 72; |
| 386 | } else { |
| 387 | physDev->PageSize.left = physDev->PageSize.bottom = 0; |
| 388 | physDev->PageSize.right = page->PaperDimension->x * |
| 389 | devCaps->logPixelsX / 72; |
| 390 | physDev->PageSize.top = page->PaperDimension->y * |
| 391 | devCaps->logPixelsY / 72; |
| 392 | } |
| 393 | TRACE("PageSize = (%d,%d - %d,%d)\n", physDev->PageSize.left, physDev->PageSize.bottom, physDev->PageSize.right, physDev->PageSize.top); |
| 394 | |
| 395 | /* these are in mm */ |
| 396 | width = (physDev->PageSize.right - physDev->PageSize.left) * 25.4 / |
| 397 | devCaps->logPixelsX; |
| 398 | height = (physDev->PageSize.top - physDev->PageSize.bottom) * 25.4 / |
| 399 | devCaps->logPixelsY; |
| 400 | |
| 401 | if(physDev->Devmode->dmPublic.u1.s1.dmOrientation == DMORIENT_PORTRAIT) { |
| 402 | devCaps->horzSize = width; |
| 403 | devCaps->vertSize = height; |
| 404 | } else { |
| 405 | devCaps->horzSize = height; |
| 406 | devCaps->vertSize = width; |
| 407 | } |
| 408 | |
| 409 | devCaps->horzRes = devCaps->logPixelsX * devCaps->horzSize / 25.4; |
| 410 | devCaps->vertRes = devCaps->logPixelsY * devCaps->vertSize / 25.4; |
| 411 | |
| 412 | TRACE("devcaps: horzSize = %dmm, vertSize = %dmm, " |
| 413 | "horzRes = %d, vertRes = %d\n", |
| 414 | devCaps->horzSize, devCaps->vertSize, |
| 415 | devCaps->horzRes, devCaps->vertRes); |
| 416 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 417 | if(physDev->pi->ppd->ColorDevice) { |
| 418 | devCaps->bitsPixel = 8; |
| 419 | devCaps->numColors = 256; |
| 420 | /* FIXME are these values OK? */ |
| 421 | } |
| 422 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 423 | /* etc */ |
| 424 | |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 425 | dc->devCaps = devCaps; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 426 | |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 427 | dc->hVisRgn = CreateRectRgn(0, 0, dc->devCaps->horzRes, |
| 428 | dc->devCaps->vertRes); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 429 | |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 430 | dc->hFont = PSDRV_DefaultFont; |
Huw D M Davies | 91547cb | 1999-07-24 10:11:05 +0000 | [diff] [blame] | 431 | physDev->job.output = output ? |
| 432 | HEAP_strdupA( PSDRV_Heap, 0, output ) : |
| 433 | HEAP_strdupA( PSDRV_Heap, 0, "LPT1:" ); /* HACK */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 434 | physDev->job.hJob = 0; |
| 435 | return TRUE; |
| 436 | } |
| 437 | |
| 438 | |
| 439 | /********************************************************************** |
| 440 | * PSDRV_DeleteDC |
| 441 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 442 | static BOOL PSDRV_DeleteDC( DC *dc ) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 443 | { |
| 444 | PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 445 | |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 446 | TRACE("\n"); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 447 | |
| 448 | HeapFree( PSDRV_Heap, 0, physDev->Devmode ); |
| 449 | HeapFree( PSDRV_Heap, 0, physDev->job.output ); |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 450 | HeapFree( PSDRV_Heap, 0, (void *)dc->devCaps ); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 451 | HeapFree( PSDRV_Heap, 0, physDev ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 452 | dc->physDev = NULL; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 453 | |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 454 | return TRUE; |
| 455 | } |
| 456 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 457 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 458 | /********************************************************************** |
| 459 | * PSDRV_FindPrinterInfo |
| 460 | */ |
| 461 | PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name) |
| 462 | { |
| 463 | static PRINTERINFO *PSDRV_PrinterList; |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 464 | DWORD type = REG_BINARY, needed, res, dwPaperSize; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 465 | PRINTERINFO *pi = PSDRV_PrinterList, **last = &PSDRV_PrinterList; |
| 466 | FONTNAME *font; |
| 467 | AFM *afm; |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 468 | HANDLE hPrinter; |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 469 | const char *ppd = NULL; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 470 | |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 471 | TRACE("'%s'\n", name); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 472 | |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 473 | for( ; pi; last = &pi->next, pi = pi->next) |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 474 | if(!strcmp(pi->FriendlyName, name)) |
| 475 | return pi; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 476 | |
| 477 | pi = *last = HeapAlloc( PSDRV_Heap, 0, sizeof(*pi) ); |
| 478 | pi->FriendlyName = HEAP_strdupA( PSDRV_Heap, 0, name ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 479 | res = DrvGetPrinterData16((LPSTR)name, (LPSTR)INT_PD_DEFAULT_DEVMODE, &type, |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 480 | NULL, 0, &needed ); |
| 481 | |
Huw D M Davies | 450270b | 1999-07-10 11:58:50 +0000 | [diff] [blame] | 482 | if(res == ERROR_INVALID_PRINTER_NAME || needed != sizeof(DefaultDevmode)) { |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 483 | pi->Devmode = HeapAlloc( PSDRV_Heap, 0, sizeof(DefaultDevmode) ); |
| 484 | memcpy(pi->Devmode, &DefaultDevmode, sizeof(DefaultDevmode) ); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 485 | strcpy(pi->Devmode->dmPublic.dmDeviceName,name); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 486 | DrvSetPrinterData16((LPSTR)name, (LPSTR)INT_PD_DEFAULT_DEVMODE, |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 487 | REG_BINARY, (LPBYTE)&DefaultDevmode, sizeof(DefaultDevmode) ); |
| 488 | |
| 489 | /* need to do something here AddPrinter?? */ |
| 490 | } else { |
| 491 | pi->Devmode = HeapAlloc( PSDRV_Heap, 0, needed ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 492 | DrvGetPrinterData16((LPSTR)name, (LPSTR)INT_PD_DEFAULT_DEVMODE, &type, |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 493 | (LPBYTE)pi->Devmode, needed, &needed); |
| 494 | } |
| 495 | |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 496 | if (OpenPrinterA (pi->FriendlyName, &hPrinter, NULL) == 0) { |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 497 | ERR ("OpenPrinterA failed with code %li\n", GetLastError ()); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 498 | goto cleanup; |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 499 | } |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 500 | pi->Devmode->dmDrvPrivate.ppdFileName[0]='\0'; |
| 501 | #ifdef HAVE_CUPS |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 502 | { |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 503 | ppd = cupsGetPPD(name); |
| 504 | |
| 505 | if (ppd) { |
| 506 | strcpy(pi->Devmode->dmDrvPrivate.ppdFileName,ppd); |
| 507 | res = ERROR_SUCCESS; |
| 508 | /* we should unlink() that file later */ |
| 509 | } else { |
| 510 | ERR("Did not find ppd for %s\n",name); |
| 511 | } |
| 512 | } |
| 513 | #endif |
| 514 | if (!pi->Devmode->dmDrvPrivate.ppdFileName[0]) { |
| 515 | res = GetPrinterDataA (hPrinter, "PPD File", NULL, |
| 516 | pi->Devmode->dmDrvPrivate.ppdFileName, 256, &needed); |
| 517 | } |
| 518 | if (res != ERROR_SUCCESS) { |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 519 | ERR ("Error %li getting PPD file name for printer '%s'\n", res, name); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 520 | goto closeprinter; |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | res = GetPrinterDataA (hPrinter, "Paper Size", NULL, (LPBYTE) &dwPaperSize, |
| 524 | sizeof (DWORD), &needed); |
| 525 | if (res == ERROR_SUCCESS) |
| 526 | pi->Devmode->dmPublic.u1.s1.dmPaperSize = (SHORT) dwPaperSize; |
| 527 | else if (res == ERROR_FILE_NOT_FOUND) |
| 528 | TRACE ("No 'Paper Size' for printer '%s'\n", name); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 529 | else { |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 530 | ERR ("GetPrinterDataA returned %li\n", res); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 531 | goto closeprinter; |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | res = EnumPrinterDataExA (hPrinter, "PrinterDriverData\\FontSubTable", NULL, |
| 535 | 0, &needed, &pi->FontSubTableSize); |
| 536 | if (res == ERROR_SUCCESS) |
| 537 | TRACE ("No 'FontSubTable' for printer '%s'\n", name); |
| 538 | else if (res == ERROR_MORE_DATA) |
| 539 | { |
| 540 | pi->FontSubTable = HeapAlloc (PSDRV_Heap, 0, needed); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 541 | if (pi->FontSubTable == NULL) { |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 542 | ERR ("Failed to allocate %li bytes from heap\n", needed); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 543 | goto closeprinter; |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | res = EnumPrinterDataExA (hPrinter, "PrinterDriverData\\FontSubTable", |
| 547 | (LPBYTE) pi->FontSubTable, needed, &needed, |
| 548 | &pi->FontSubTableSize); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 549 | if (res != ERROR_SUCCESS) { |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 550 | ERR ("EnumPrinterDataExA returned %li\n", res); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 551 | goto closeprinter; |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 552 | } |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 553 | } else { |
| 554 | FIXME ("EnumPrinterDataExA returned %li\n", res); |
| 555 | /* ignore error */ |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 558 | if (ClosePrinter (hPrinter) == 0) { |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 559 | ERR ("ClosePrinter failed with code %li\n", GetLastError ()); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 560 | goto cleanup; |
Ian Pilcher | 744820d | 2001-04-02 19:14:41 +0000 | [diff] [blame] | 561 | } |
| 562 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 563 | pi->ppd = PSDRV_ParsePPD(pi->Devmode->dmDrvPrivate.ppdFileName); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 564 | if(!pi->ppd) { |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 565 | MESSAGE("Couldn't find PPD file '%s', expect a crash now!\n", |
Huw D M Davies | bcad255 | 1998-11-01 13:02:27 +0000 | [diff] [blame] | 566 | pi->Devmode->dmDrvPrivate.ppdFileName); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 567 | goto cleanup; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 568 | } |
| 569 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 570 | pi->next = NULL; |
| 571 | pi->Fonts = NULL; |
| 572 | |
| 573 | for(font = pi->ppd->InstalledFonts; font; font = font->next) { |
| 574 | afm = PSDRV_FindAFMinList(PSDRV_AFMFontList, font->Name); |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 575 | if(!afm) |
| 576 | TRACE( "Couldn't find AFM file for installed printer font '%s' - ignoring\n", font->Name); |
| 577 | else |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 578 | PSDRV_AddAFMtoList(&pi->Fonts, afm); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 579 | |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 580 | } |
| 581 | if (ppd) unlink(ppd); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 582 | return pi; |
Marcus Meissner | ab8b7db | 2001-04-27 18:02:46 +0000 | [diff] [blame] | 583 | |
| 584 | closeprinter: |
| 585 | ClosePrinter(hPrinter); |
| 586 | cleanup: |
| 587 | HeapFree (PSDRV_Heap, 0, pi->FontSubTable); |
| 588 | HeapFree(PSDRV_Heap, 0, pi->FriendlyName); |
| 589 | HeapFree(PSDRV_Heap, 0, pi->Devmode); |
| 590 | HeapFree(PSDRV_Heap, 0, pi); |
| 591 | if (ppd) unlink(ppd); |
| 592 | *last = NULL; |
| 593 | return NULL; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 594 | } |