dinput: Clear DIA_APPNOMAP BuildActionMap flag with specific device semantic.
[wine.git] / dlls / wineps.drv / escape.c
blob1d639d0c3d47503c196cbb4f01403d080b57bf96
1 /*
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <signal.h>
26 #include <errno.h>
27 #include <fcntl.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "wine/wingdi16.h"
33 #include "winuser.h"
34 #include "winreg.h"
35 #include "psdrv.h"
36 #include "wine/debug.h"
37 #include "winspool.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
41 DWORD write_spool( print_ctx *ctx, const void *data, DWORD num )
43 DWORD written;
45 if (!WritePrinter(ctx->job.hprinter, (LPBYTE) data, num, &written) || (written != num))
46 return SP_OUTOFDISK;
48 return num;
51 /**********************************************************************
52 * ExtEscape (WINEPS.@)
54 INT CDECL PSDRV_ExtEscape( print_ctx *ctx, INT nEscape, INT cbInput, LPCVOID in_data,
55 INT cbOutput, LPVOID out_data )
57 TRACE("%p,%d,%d,%p,%d,%p\n",
58 ctx->hdc, nEscape, cbInput, in_data, cbOutput, out_data);
60 switch(nEscape)
62 case POSTSCRIPT_DATA:
63 case PASSTHROUGH:
64 case POSTSCRIPT_PASSTHROUGH:
66 /* Write directly to spool file, bypassing normal PS driver
67 * processing that is done along with writing PostScript code
68 * to the spool.
69 * We have a WORD before the data counting the size, but
70 * cbInput is just this +2.
71 * However Photoshop 7 has a bug that sets cbInput to 2 less than the
72 * length of the string, rather than 2 more. So we'll use the WORD at
73 * in_data[0] instead.
75 passthrough_enter(ctx);
76 return write_spool(ctx, ((char*)in_data) + 2, *(const WORD*)in_data);
79 case POSTSCRIPT_IGNORE:
81 BOOL ret = ctx->job.quiet;
82 TRACE("POSTSCRIPT_IGNORE %d\n", *(const short*)in_data);
83 ctx->job.quiet = *(const short*)in_data;
84 return ret;
87 case BEGIN_PATH:
88 TRACE("BEGIN_PATH\n");
89 if(ctx->pathdepth)
90 FIXME("Nested paths not yet handled\n");
91 return ++ctx->pathdepth;
93 case END_PATH:
95 const struct PATH_INFO *info = (const struct PATH_INFO*)in_data;
97 TRACE("END_PATH\n");
98 if(!ctx->pathdepth) {
99 ERR("END_PATH called without a BEGIN_PATH\n");
100 return -1;
102 TRACE("RenderMode = %d, FillMode = %d, BkMode = %d\n",
103 info->RenderMode, info->FillMode, info->BkMode);
104 switch(info->RenderMode) {
105 case RENDERMODE_NO_DISPLAY:
106 PSDRV_WriteClosePath(ctx); /* not sure if this is necessary, but it can't hurt */
107 break;
108 case RENDERMODE_OPEN:
109 case RENDERMODE_CLOSED:
110 default:
111 FIXME("END_PATH: RenderMode %d, not yet supported\n", info->RenderMode);
112 break;
114 return --ctx->pathdepth;
117 case CLIP_TO_PATH:
119 WORD mode = *(const WORD*)in_data;
121 switch(mode) {
122 case CLIP_SAVE:
123 TRACE("CLIP_TO_PATH: CLIP_SAVE\n");
124 PSDRV_WriteGSave(ctx);
125 return 1;
126 case CLIP_RESTORE:
127 TRACE("CLIP_TO_PATH: CLIP_RESTORE\n");
128 PSDRV_WriteGRestore(ctx);
129 return 1;
130 case CLIP_INCLUSIVE:
131 TRACE("CLIP_TO_PATH: CLIP_INCLUSIVE\n");
132 /* FIXME to clip or eoclip ? (see PATH_INFO.FillMode) */
133 PSDRV_WriteClip(ctx);
134 PSDRV_WriteNewPath(ctx);
135 return 1;
136 case CLIP_EXCLUSIVE:
137 FIXME("CLIP_EXCLUSIVE: not implemented\n");
138 return 0;
139 default:
140 FIXME("Unknown CLIP_TO_PATH mode %d\n", mode);
141 return 0;
145 default:
146 return 0;
150 /************************************************************************
151 * PSDRV_StartPage
153 INT CDECL PSDRV_StartPage( print_ctx *ctx )
155 TRACE("%p\n", ctx->hdc);
157 if(!ctx->job.OutOfPage) {
158 FIXME("Already started a page?\n");
159 return 1;
162 ctx->job.PageNo++;
164 if(!PSDRV_WriteNewPage( ctx ))
165 return 0;
166 ctx->job.OutOfPage = FALSE;
167 return 1;
171 /************************************************************************
172 * PSDRV_EndPage
174 INT CDECL PSDRV_EndPage( print_ctx *ctx )
176 TRACE("%p\n", ctx->hdc);
178 if(ctx->job.OutOfPage) {
179 FIXME("Already ended a page?\n");
180 return 1;
183 passthrough_leave(ctx);
184 if(!PSDRV_WriteEndPage( ctx ))
185 return 0;
186 PSDRV_EmptyDownloadList(ctx, FALSE);
187 ctx->job.OutOfPage = TRUE;
188 return 1;