2 * PostScript driver Escape function
4 * Copyright 1998 Huw D M Davies
8 #include "wine/winuser16.h"
10 #include "debugtools.h"
13 DEFAULT_DEBUG_CHANNEL(psdrv);
16 /**********************************************************************
17 * ExtEscape (WINEPS.@)
19 INT PSDRV_ExtEscape( DC *dc, INT nEscape, INT cbInput, LPCVOID in_data,
20 INT cbOutput, LPVOID out_data )
22 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
27 if(cbInput < sizeof(INT))
29 WARN("cbInput < sizeof(INT) (=%d) for QUERYESCSUPPORT\n", cbInput);
32 UINT num = *(UINT *)in_data;
33 TRACE("QUERYESCSUPPORT for %d\n", num);
47 case POSTSCRIPT_PASSTHROUGH:
58 if(!physDev->job.banding) {
59 physDev->job.banding = TRUE;
62 r->right = physDev->horzRes;
63 r->bottom = physDev->vertRes;
64 TRACE("NEXTBAND returning %d,%d - %d,%d\n", r->left, r->top, r->right, r->bottom );
71 TRACE("NEXTBAND rect to 0,0 - 0,0\n" );
72 physDev->job.banding = FALSE;
73 return EndPage( dc->hSelf );
78 const INT *NumCopies = in_data;
79 INT *ActualCopies = out_data;
80 if(cbInput != sizeof(INT)) {
81 WARN("cbInput != sizeof(INT) (=%d) for SETCOPYCOUNT\n", cbInput);
84 TRACE("SETCOPYCOUNT %d\n", *NumCopies);
92 strcpy(p, "PostScript");
93 *(p + strlen(p) + 1) = '\0'; /* 2 '\0's at end of string */
99 INT newCap = *(INT *)in_data;
100 if(cbInput != sizeof(INT)) {
101 WARN("cbInput != sizeof(INT) (=%d) for SETLINECAP\n", cbInput);
104 TRACE("SETLINECAP %d\n", newCap);
110 INT newJoin = *(INT *)in_data;
111 if(cbInput != sizeof(INT)) {
112 WARN("cbInput != sizeof(INT) (=%d) for SETLINEJOIN\n", cbInput);
115 TRACE("SETLINEJOIN %d\n", newJoin);
121 INT newLimit = *(INT *)in_data;
122 if(cbInput != sizeof(INT)) {
123 WARN("cbInput != sizeof(INT) (=%d) for SETMITERLIMIT\n", cbInput);
126 TRACE("SETMITERLIMIT %d\n", newLimit);
131 /* Undocumented escape used by winword6.
132 Switches between ANSI and a special charset.
133 If *lpInData == 1 we require that
137 0x94 is quotedblright
141 0xa0 is non break space - yeah right.
143 If *lpInData == 0 we get ANSI.
144 Since there's nothing else there, let's just make these the default
145 anyway and see what happens...
149 case EXT_DEVICE_CAPS:
151 UINT cap = *(UINT *)in_data;
152 if(cbInput != sizeof(UINT)) {
153 WARN("cbInput != sizeof(UINT) (=%d) for EXT_DEVICE_CAPS\n", cbInput);
156 TRACE("EXT_DEVICE_CAPS %d\n", cap);
162 const RECT *r = in_data;
163 if(cbInput != sizeof(RECT)) {
164 WARN("cbInput != sizeof(RECT) (=%d) for SET_BOUNDS\n", cbInput);
167 TRACE("SET_BOUNDS (%d,%d) - (%d,%d)\n", r->left, r->top,
168 r->right, r->bottom);
174 UINT epsprint = *(UINT*)in_data;
175 /* FIXME: In this mode we do not need to send page intros and page
176 * ends according to the doc. But I just ignore that detail
179 TRACE("EPS Printing support %sable.\n",epsprint?"en":"dis");
183 case POSTSCRIPT_PASSTHROUGH:
185 /* Write directly to spool file, bypassing normal PS driver
186 * processing that is done along with writing PostScript code
188 * (Usually we have a WORD before the data counting the size, but
189 * cbInput is just this +2.)
191 return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,cbInput-2);
194 case GETSETPRINTORIENT:
196 /* If lpInData is present, it is a 20 byte structure, first 32
197 * bit LONG value is the orientation. if lpInData is NULL, it
198 * returns the current orientation.
200 FIXME("GETSETPRINTORIENT not implemented (data %p)!\n",in_data);
204 FIXME("Unimplemented code 0x%x\n", nEscape);
209 /************************************************************************
212 INT PSDRV_StartPage( DC *dc )
214 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
216 if(!physDev->job.OutOfPage) {
217 FIXME("Already started a page?\n");
220 physDev->job.PageNo++;
221 if(!PSDRV_WriteNewPage( dc ))
223 physDev->job.OutOfPage = FALSE;
228 /************************************************************************
231 INT PSDRV_EndPage( DC *dc )
233 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
235 if(physDev->job.OutOfPage) {
236 FIXME("Already ended a page?\n");
239 if(!PSDRV_WriteEndPage( dc ))
241 physDev->job.OutOfPage = TRUE;
246 /************************************************************************
249 INT PSDRV_StartDoc( DC *dc, const DOCINFOA *doc )
251 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
253 if(physDev->job.hJob) {
254 FIXME("hJob != 0. Now what?\n");
258 if(doc->lpszOutput) {
259 HeapFree( PSDRV_Heap, 0, physDev->job.output );
260 physDev->job.output = HeapAlloc( PSDRV_Heap, 0, strlen(doc->lpszOutput)+1 );
261 strcpy( physDev->job.output, doc->lpszOutput );
263 physDev->job.hJob = OpenJob16(physDev->job.output, doc->lpszDocName,
265 if(!physDev->job.hJob) {
266 WARN("OpenJob failed\n");
269 physDev->job.banding = FALSE;
270 physDev->job.OutOfPage = TRUE;
271 physDev->job.PageNo = 0;
272 if(!PSDRV_WriteHeader( dc, doc->lpszDocName ))
275 return physDev->job.hJob;
279 /************************************************************************
282 INT PSDRV_EndDoc( DC *dc )
284 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
286 if(!physDev->job.hJob) {
287 FIXME("hJob == 0. Now what?\n");
291 if(!physDev->job.OutOfPage) {
292 WARN("Somebody forgot a EndPage\n");
295 if(!PSDRV_WriteFooter( dc ))
298 if( CloseJob16( physDev->job.hJob ) == SP_ERROR ) {
299 WARN("CloseJob error\n");
302 physDev->job.hJob = 0;