2 * PostScript driver Escape function
4 * Copyright 1998 Huw D M Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "wine/wingdi16.h"
26 #include "wine/winuser16.h"
29 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
35 static const char psbegindocument
[] =
36 "%%BeginDocument: Wine passthrough\n";
38 /**********************************************************************
39 * ExtEscape (WINEPS.@)
41 INT
PSDRV_ExtEscape( PSDRV_PDEVICE
*physDev
, INT nEscape
, INT cbInput
, LPCVOID in_data
,
42 INT cbOutput
, LPVOID out_data
)
47 if(cbInput
< sizeof(INT
))
49 WARN("cbInput < sizeof(INT) (=%d) for QUERYESCSUPPORT\n", cbInput
);
52 UINT num
= *(const UINT
*)in_data
;
53 TRACE("QUERYESCSUPPORT for %d\n", num
);
69 case POSTSCRIPT_PASSTHROUGH
:
70 case POSTSCRIPT_IGNORE
:
74 /*case DRAWPATTERNRECT:*/
78 FIXME("QUERYESCSUPPORT(%d) - not supported.\n", num
);
86 FIXME("MFCOMMENT(%p, %d)\n", in_data
, cbInput
);
87 for (i
=0;i
<cbInput
;i
++) MESSAGE("%02x ", ((LPBYTE
)in_data
)[i
]);
93 DRAWPATRECT
*dpr
= (DRAWPATRECT
*)in_data
;
95 FIXME("DRAWPATTERNRECT(pos (%ld,%ld), size %ldx%ld, style %d, pattern %x), stub!\n",
96 dpr
->ptPosition
.x
, dpr
->ptPosition
.y
,
97 dpr
->ptSize
.x
, dpr
->ptSize
.y
,
98 dpr
->wStyle
, dpr
->wPattern
104 BANDINFOSTRUCT
*ibi
= (BANDINFOSTRUCT
*)in_data
;
105 BANDINFOSTRUCT
*obi
= (BANDINFOSTRUCT
*)out_data
;
107 FIXME("BANDINFO(graphics %d, text %d, rect [%ldx%ld-%ldx%ld]), stub!\n",
110 ibi
->GraphicsRect
.top
,
111 ibi
->GraphicsRect
.bottom
,
112 ibi
->GraphicsRect
.left
,
113 ibi
->GraphicsRect
.right
115 memcpy (obi
, ibi
, sizeof(*ibi
));
121 if(!physDev
->job
.banding
) {
122 physDev
->job
.banding
= TRUE
;
125 r
->right
= physDev
->horzRes
;
126 r
->bottom
= physDev
->vertRes
;
127 TRACE("NEXTBAND returning %ld,%ld - %ld,%ld\n", r
->left
, r
->top
, r
->right
, r
->bottom
);
134 TRACE("NEXTBAND rect to 0,0 - 0,0\n" );
135 physDev
->job
.banding
= FALSE
;
136 return EndPage( physDev
->hdc
);
141 const INT
*NumCopies
= in_data
;
142 INT
*ActualCopies
= out_data
;
143 if(cbInput
!= sizeof(INT
)) {
144 WARN("cbInput != sizeof(INT) (=%d) for SETCOPYCOUNT\n", cbInput
);
147 TRACE("SETCOPYCOUNT %d\n", *NumCopies
);
155 strcpy(p
, "PostScript");
156 *(p
+ strlen(p
) + 1) = '\0'; /* 2 '\0's at end of string */
162 INT newCap
= *(const INT
*)in_data
;
163 if(cbInput
!= sizeof(INT
)) {
164 WARN("cbInput != sizeof(INT) (=%d) for SETLINECAP\n", cbInput
);
167 TRACE("SETLINECAP %d\n", newCap
);
173 INT newJoin
= *(const INT
*)in_data
;
174 if(cbInput
!= sizeof(INT
)) {
175 WARN("cbInput != sizeof(INT) (=%d) for SETLINEJOIN\n", cbInput
);
178 TRACE("SETLINEJOIN %d\n", newJoin
);
184 INT newLimit
= *(const INT
*)in_data
;
185 if(cbInput
!= sizeof(INT
)) {
186 WARN("cbInput != sizeof(INT) (=%d) for SETMITERLIMIT\n", cbInput
);
189 TRACE("SETMITERLIMIT %d\n", newLimit
);
194 /* Undocumented escape used by winword6.
195 Switches between ANSI and a special charset.
196 If *lpInData == 1 we require that
200 0x94 is quotedblright
204 0xa0 is non break space - yeah right.
206 If *lpInData == 0 we get ANSI.
207 Since there's nothing else there, let's just make these the default
208 anyway and see what happens...
212 case EXT_DEVICE_CAPS
:
214 UINT cap
= *(const UINT
*)in_data
;
215 if(cbInput
!= sizeof(UINT
)) {
216 WARN("cbInput != sizeof(UINT) (=%d) for EXT_DEVICE_CAPS\n", cbInput
);
219 TRACE("EXT_DEVICE_CAPS %d\n", cap
);
225 const RECT
*r
= in_data
;
226 if(cbInput
!= sizeof(RECT
)) {
227 WARN("cbInput != sizeof(RECT) (=%d) for SET_BOUNDS\n", cbInput
);
230 TRACE("SET_BOUNDS (%ld,%ld) - (%ld,%ld)\n", r
->left
, r
->top
,
231 r
->right
, r
->bottom
);
237 UINT epsprint
= *(const UINT
*)in_data
;
238 /* FIXME: In this mode we do not need to send page intros and page
239 * ends according to the doc. But I just ignore that detail
242 TRACE("EPS Printing support %sable.\n",epsprint
?"en":"dis");
246 case POSTSCRIPT_DATA
:
248 case POSTSCRIPT_PASSTHROUGH
:
250 /* Write directly to spool file, bypassing normal PS driver
251 * processing that is done along with writing PostScript code
253 * We have a WORD before the data counting the size, but
254 * cbInput is just this +2.
255 * However Photoshop 7 has a bug that sets cbInput to 2 less than the
256 * length of the string, rather than 2 more. So we'll use the WORD at
257 * in_data[0] instead.
259 if(!physDev
->job
.in_passthrough
) {
260 WriteSpool16(physDev
->job
.hJob
, (LPSTR
)psbegindocument
, sizeof(psbegindocument
)-1);
261 physDev
->job
.in_passthrough
= TRUE
;
263 return WriteSpool16(physDev
->job
.hJob
,((char*)in_data
)+2,*(const WORD
*)in_data
);
266 case POSTSCRIPT_IGNORE
:
268 BOOL ret
= physDev
->job
.quiet
;
269 TRACE("POSTSCRIPT_IGNORE %d\n", *(const short*)in_data
);
270 physDev
->job
.quiet
= *(const short*)in_data
;
274 case GETSETPRINTORIENT
:
276 /* If lpInData is present, it is a 20 byte structure, first 32
277 * bit LONG value is the orientation. if lpInData is NULL, it
278 * returns the current orientation.
280 FIXME("GETSETPRINTORIENT not implemented (data %p)!\n",in_data
);
284 TRACE("BEGIN_PATH\n");
285 if(physDev
->pathdepth
)
286 FIXME("Nested paths not yet handled\n");
287 return ++physDev
->pathdepth
;
291 const struct PATH_INFO
*info
= (const struct PATH_INFO
*)in_data
;
294 if(!physDev
->pathdepth
) {
295 ERR("END_PATH called without a BEIGN_PATH\n");
298 TRACE("RenderMode = %d, FillMode = %d, BkMode = %d\n",
299 info
->RenderMode
, info
->FillMode
, info
->BkMode
);
300 switch(info
->RenderMode
) {
301 case RENDERMODE_NO_DISPLAY
:
302 PSDRV_WriteClosePath(physDev
); /* not sure if this is necessary, but it can't hurt */
304 case RENDERMODE_OPEN
:
305 case RENDERMODE_CLOSED
:
307 FIXME("END_PATH: RenderMode %d, not yet supported\n", info
->RenderMode
);
310 return --physDev
->pathdepth
;
315 WORD mode
= *(const WORD
*)in_data
;
319 TRACE("CLIP_TO_PATH: CLIP_SAVE\n");
320 PSDRV_WriteGSave(physDev
);
323 TRACE("CLIP_TO_PATH: CLIP_RESTORE\n");
324 PSDRV_WriteGRestore(physDev
);
327 TRACE("CLIP_TO_PATH: CLIP_INCLUSIVE\n");
328 /* FIXME to clip or eoclip ? (see PATH_INFO.FillMode) */
329 PSDRV_WriteClip(physDev
);
330 PSDRV_WriteNewPath(physDev
);
333 FIXME("CLIP_EXCLUSIVE: not implemented\n");
336 FIXME("Unknown CLIP_TO_PATH mode %d\n", mode
);
341 FIXME("Unimplemented code 0x%x\n", nEscape
);
346 /************************************************************************
349 INT
PSDRV_StartPage( PSDRV_PDEVICE
*physDev
)
351 if(!physDev
->job
.OutOfPage
) {
352 FIXME("Already started a page?\n");
356 if(physDev
->job
.PageNo
++ == 0) {
357 if(!PSDRV_WriteHeader( physDev
, physDev
->job
.DocName
))
361 if(!PSDRV_WriteNewPage( physDev
))
363 physDev
->job
.OutOfPage
= FALSE
;
368 /************************************************************************
371 INT
PSDRV_EndPage( PSDRV_PDEVICE
*physDev
)
373 if(physDev
->job
.OutOfPage
) {
374 FIXME("Already ended a page?\n");
377 if(!PSDRV_WriteEndPage( physDev
))
379 PSDRV_EmptyDownloadList(physDev
, FALSE
);
380 physDev
->job
.OutOfPage
= TRUE
;
385 /************************************************************************
388 INT
PSDRV_StartDocA( PSDRV_PDEVICE
*physDev
, const DOCINFOA
*doc
)
390 LPCSTR output
= "LPT1:";
392 HANDLE hprn
= INVALID_HANDLE_VALUE
;
393 PRINTER_INFO_5A
*pi5
= (PRINTER_INFO_5A
*)buf
;
396 if(physDev
->job
.hJob
) {
397 FIXME("hJob != 0. Now what?\n");
402 output
= doc
->lpszOutput
;
403 else if(physDev
->job
.output
)
404 output
= physDev
->job
.output
;
406 if(OpenPrinterA(physDev
->pi
->FriendlyName
, &hprn
, NULL
) &&
407 GetPrinterA(hprn
, 5, buf
, sizeof(buf
), &needed
)) {
408 output
= pi5
->pPortName
;
410 if(hprn
!= INVALID_HANDLE_VALUE
)
414 physDev
->job
.hJob
= OpenJob16(output
, doc
->lpszDocName
, HDC_16(physDev
->hdc
) );
415 if(!physDev
->job
.hJob
) {
416 WARN("OpenJob failed\n");
419 physDev
->job
.banding
= FALSE
;
420 physDev
->job
.OutOfPage
= TRUE
;
421 physDev
->job
.PageNo
= 0;
422 physDev
->job
.quiet
= FALSE
;
423 physDev
->job
.in_passthrough
= FALSE
;
424 physDev
->job
.had_passthrough_rect
= FALSE
;
425 if(doc
->lpszDocName
) {
426 physDev
->job
.DocName
= HeapAlloc(GetProcessHeap(), 0, strlen(doc
->lpszDocName
)+1);
427 strcpy(physDev
->job
.DocName
, doc
->lpszDocName
);
429 physDev
->job
.DocName
= NULL
;
431 return physDev
->job
.hJob
;
434 /************************************************************************
437 INT
PSDRV_StartDoc( PSDRV_PDEVICE
*physDev
, const DOCINFOW
*doc
)
442 docA
.cbSize
= doc
->cbSize
;
443 docA
.lpszDocName
= doc
->lpszDocName
?
444 HEAP_strdupWtoA( GetProcessHeap(), 0, doc
->lpszDocName
) : NULL
;
445 docA
.lpszOutput
= doc
->lpszOutput
?
446 HEAP_strdupWtoA( GetProcessHeap(), 0, doc
->lpszOutput
) : NULL
;
447 docA
.lpszDatatype
= doc
->lpszDatatype
?
448 HEAP_strdupWtoA( GetProcessHeap(), 0, doc
->lpszDatatype
) : NULL
;
449 docA
.fwType
= doc
->fwType
;
451 ret
= PSDRV_StartDocA(physDev
, &docA
);
453 HeapFree( GetProcessHeap(), 0, (LPSTR
)docA
.lpszDocName
);
454 HeapFree( GetProcessHeap(), 0, (LPSTR
)docA
.lpszOutput
);
455 HeapFree( GetProcessHeap(), 0, (LPSTR
)docA
.lpszDatatype
);
460 /************************************************************************
463 INT
PSDRV_EndDoc( PSDRV_PDEVICE
*physDev
)
466 if(!physDev
->job
.hJob
) {
467 FIXME("hJob == 0. Now what?\n");
471 if(!physDev
->job
.OutOfPage
) {
472 WARN("Somebody forgot an EndPage\n");
473 PSDRV_EndPage( physDev
);
475 PSDRV_WriteFooter( physDev
);
477 if( CloseJob16( physDev
->job
.hJob
) == SP_ERROR
) {
478 WARN("CloseJob error\n");
481 physDev
->job
.hJob
= 0;
482 HeapFree(GetProcessHeap(), 0, physDev
->job
.DocName
);
483 physDev
->job
.DocName
= NULL
;