2 * PostScript driver Escape function
4 * Copyright 1998 Huw D M Davies
8 #include "wine/winuser16.h"
10 #include "debugtools.h"
14 DEFAULT_DEBUG_CHANNEL(psdrv)
17 INT PSDRV_Escape( DC *dc, INT nEscape, INT cbInput,
18 SEGPTR lpInData, SEGPTR lpOutData )
20 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
25 RECT16 *r = (RECT16 *)PTR_SEG_TO_LIN(lpOutData);
26 if(!physDev->job.banding) {
27 physDev->job.banding = TRUE;
30 r->right = dc->w.devCaps->horzRes;
31 r->bottom = dc->w.devCaps->vertRes;
32 TRACE("NEXTBAND returning %d,%d - %d,%d\n", r->left,
33 r->top, r->right, r->bottom );
40 TRACE("NEXTBAND rect to 0,0 - 0,0\n" );
41 physDev->job.banding = FALSE;
47 if(!physDev->job.hJob) {
48 FIXME("hJob == 0. Now what?\n");
52 if(!PSDRV_EndPage( dc ))
58 WARN("cbInput < 2 (=%d) for QUERYESCSUPPORT\n", cbInput);
61 UINT16 num = *(UINT16 *)PTR_SEG_TO_LIN(lpInData);
62 TRACE("QUERYESCSUPPORT for %d\n", num);
72 case GETPRINTINGOFFSET:
73 case GETSCALINGFACTOR:
90 TRACE("SETABORTPROC\n");
101 /* lpInData may not be 0 terminated so we must copy it */
103 name = HeapAlloc( GetProcessHeap(), 0, cbInput+1 );
104 memcpy(name, PTR_SEG_TO_LIN(lpInData), cbInput);
105 name[cbInput] = '\0';
107 doc.cbSize = sizeof(doc);
108 doc.lpszDocName = name;
109 doc.lpszOutput = doc.lpszDatatype = NULL;
112 ret = PSDRV_StartDoc(dc, &doc);
113 if(name) HeapFree( GetProcessHeap(), 0, name );
114 if(ret <= 0) return -1;
115 ret = PSDRV_StartPage(dc);
116 if(ret <= 0) return -1;
122 return PSDRV_EndDoc( dc );
124 case GETPHYSPAGESIZE:
126 POINT16 *p = (POINT16 *)PTR_SEG_TO_LIN(lpOutData);
128 p->x = dc->w.devCaps->horzRes;
129 p->y = dc->w.devCaps->vertRes;
130 TRACE("GETPHYSPAGESIZE: returning %dx%d\n", p->x, p->y);
134 case GETPRINTINGOFFSET:
136 POINT16 *p = (POINT16 *)PTR_SEG_TO_LIN(lpOutData);
139 TRACE("GETPRINTINGOFFSET: returning %dx%d\n", p->x, p->y);
143 case GETSCALINGFACTOR:
145 POINT16 *p = (POINT16 *)PTR_SEG_TO_LIN(lpOutData);
148 TRACE("GETSCALINGFACTOR: returning %dx%d\n", p->x, p->y);
154 INT16 *NumCopies = (INT16 *)PTR_SEG_TO_LIN(lpInData);
155 INT16 *ActualCopies = (INT16 *)PTR_SEG_TO_LIN(lpOutData);
157 WARN("cbInput != 2 (=%d) for SETCOPYCOUNT\n", cbInput);
160 TRACE("SETCOPYCOUNT %d\n", *NumCopies);
167 LPSTR p = (LPSTR)PTR_SEG_TO_LIN(lpOutData);
168 strcpy(p, "PostScript");
169 *(p + strlen(p) + 1) = '\0'; /* 2 '\0's at end of string */
175 INT16 newCap = *(INT16 *)PTR_SEG_TO_LIN(lpInData);
177 WARN("cbInput != 2 (=%d) for SETLINECAP\n", cbInput);
180 TRACE("SETLINECAP %d\n", newCap);
186 INT16 newJoin = *(INT16 *)PTR_SEG_TO_LIN(lpInData);
188 WARN("cbInput != 2 (=%d) for SETLINEJOIN\n", cbInput);
191 TRACE("SETLINEJOIN %d\n", newJoin);
197 INT16 newLimit = *(INT16 *)PTR_SEG_TO_LIN(lpInData);
199 WARN("cbInput != 2 (=%d) for SETMITERLIMIT\n", cbInput);
202 TRACE("SETMITERLIMIT %d\n", newLimit);
207 /* Undocumented escape used by winword6.
208 Switches between ANSI and a special charset.
209 If *lpInData == 1 we require that
213 0x94 is quotedblright
217 0xa0 is non break space - yeah right.
219 If *lpInData == 0 we get ANSI.
220 Since there's nothing else there, let's just make these the default
221 anyway and see what happens...
225 case EXT_DEVICE_CAPS:
227 UINT16 cap = *(UINT16 *)PTR_SEG_TO_LIN(lpInData);
229 WARN("cbInput != 2 (=%d) for EXT_DEVICE_CAPS\n",
233 TRACE("EXT_DEVICE_CAPS %d\n", cap);
239 RECT16 *r = (RECT16 *)PTR_SEG_TO_LIN(lpInData);
241 WARN("cbInput != 8 (=%d) for SET_BOUNDS\n", cbInput);
244 TRACE("SET_BOUNDS (%d,%d) - (%d,%d)\n", r->left, r->top,
245 r->right, r->bottom);
250 FIXME("Unimplemented code 0x%x\n", nEscape);
255 /************************************************************************
258 INT PSDRV_StartPage( DC *dc )
260 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
262 if(!physDev->job.OutOfPage) {
263 FIXME("Already started a page?\n");
266 physDev->job.PageNo++;
267 if(!PSDRV_WriteNewPage( dc ))
269 physDev->job.OutOfPage = FALSE;
274 /************************************************************************
277 INT PSDRV_EndPage( DC *dc )
279 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
281 if(physDev->job.OutOfPage) {
282 FIXME("Already ended a page?\n");
285 if(!PSDRV_WriteEndPage( dc ))
287 physDev->job.OutOfPage = TRUE;
292 /************************************************************************
295 INT PSDRV_StartDoc( DC *dc, const DOCINFOA *doc )
297 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
299 if(physDev->job.hJob) {
300 FIXME("hJob != 0. Now what?\n");
304 if(doc->lpszOutput) {
305 HeapFree( PSDRV_Heap, 0, physDev->job.output );
306 physDev->job.output = HEAP_strdupA( PSDRV_Heap, 0, doc->lpszOutput );
308 physDev->job.hJob = OpenJob16(physDev->job.output, doc->lpszDocName,
310 if(!physDev->job.hJob) {
311 WARN("OpenJob failed\n");
314 physDev->job.banding = FALSE;
315 physDev->job.OutOfPage = TRUE;
316 physDev->job.PageNo = 0;
317 if(!PSDRV_WriteHeader( dc, doc->lpszDocName ))
320 return physDev->job.hJob;
324 /************************************************************************
327 INT PSDRV_EndDoc( DC *dc )
329 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
331 if(!physDev->job.hJob) {
332 FIXME("hJob == 0. Now what?\n");
336 if(!physDev->job.OutOfPage) {
337 WARN("Somebody forgot a EndPage\n");
340 if(!PSDRV_WriteFooter( dc ))
343 if( CloseJob16( physDev->job.hJob ) == SP_ERROR ) {
344 WARN("CloseJob error\n");
347 physDev->job.hJob = 0;