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
32 #include "wine/wingdi16.h"
36 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(psdrv
);
41 BOOL
flush_spool( print_ctx
*ctx
)
45 if (ctx
->job
.data_cnt
)
47 if (!WritePrinter(ctx
->job
.hprinter
, ctx
->job
.data
, ctx
->job
.data_cnt
, &written
) ||
48 written
!= ctx
->job
.data_cnt
)
51 ctx
->job
.data_cnt
= 0;
55 DWORD
write_spool( print_ctx
*ctx
, const void *data
, DWORD num
)
59 if (ctx
->job
.data_cnt
+ num
> ARRAY_SIZE(ctx
->job
.data
))
61 if (!flush_spool(ctx
))
65 if (ctx
->job
.data_cnt
+ num
> ARRAY_SIZE(ctx
->job
.data
))
67 if (!WritePrinter(ctx
->job
.hprinter
, (LPBYTE
) data
, num
, &written
) ||
73 memcpy(ctx
->job
.data
+ ctx
->job
.data_cnt
, data
, num
);
74 ctx
->job
.data_cnt
+= num
;
79 /**********************************************************************
82 INT
PSDRV_ExtEscape( print_ctx
*ctx
, INT nEscape
, INT cbInput
, LPCVOID in_data
,
83 INT cbOutput
, LPVOID out_data
)
85 TRACE("%p,%d,%d,%p,%d,%p\n",
86 ctx
->hdc
, nEscape
, cbInput
, in_data
, cbOutput
, out_data
);
92 case POSTSCRIPT_PASSTHROUGH
:
94 /* Write directly to spool file, bypassing normal PS driver
95 * processing that is done along with writing PostScript code
97 * We have a WORD before the data counting the size, but
98 * cbInput is just this +2.
99 * However Photoshop 7 has a bug that sets cbInput to 2 less than the
100 * length of the string, rather than 2 more. So we'll use the WORD at
101 * in_data[0] instead.
103 passthrough_enter(ctx
);
104 return write_spool(ctx
, ((char*)in_data
) + 2, *(const WORD
*)in_data
);
107 case POSTSCRIPT_IGNORE
:
109 BOOL ret
= ctx
->job
.quiet
;
110 TRACE("POSTSCRIPT_IGNORE %d\n", *(const short*)in_data
);
111 ctx
->job
.quiet
= *(const short*)in_data
;
116 TRACE("BEGIN_PATH\n");
118 FIXME("Nested paths not yet handled\n");
119 return ++ctx
->pathdepth
;
123 const struct PATH_INFO
*info
= (const struct PATH_INFO
*)in_data
;
126 if(!ctx
->pathdepth
) {
127 ERR("END_PATH called without a BEGIN_PATH\n");
130 TRACE("RenderMode = %d, FillMode = %d, BkMode = %d\n",
131 info
->RenderMode
, info
->FillMode
, info
->BkMode
);
132 switch(info
->RenderMode
) {
133 case RENDERMODE_NO_DISPLAY
:
134 PSDRV_WriteClosePath(ctx
); /* not sure if this is necessary, but it can't hurt */
136 case RENDERMODE_OPEN
:
137 case RENDERMODE_CLOSED
:
139 FIXME("END_PATH: RenderMode %d, not yet supported\n", info
->RenderMode
);
142 return --ctx
->pathdepth
;
147 WORD mode
= *(const WORD
*)in_data
;
151 TRACE("CLIP_TO_PATH: CLIP_SAVE\n");
152 PSDRV_WriteGSave(ctx
);
155 TRACE("CLIP_TO_PATH: CLIP_RESTORE\n");
156 PSDRV_WriteGRestore(ctx
);
159 TRACE("CLIP_TO_PATH: CLIP_INCLUSIVE\n");
160 /* FIXME to clip or eoclip ? (see PATH_INFO.FillMode) */
161 PSDRV_WriteClip(ctx
);
162 PSDRV_WriteNewPath(ctx
);
165 FIXME("CLIP_EXCLUSIVE: not implemented\n");
168 FIXME("Unknown CLIP_TO_PATH mode %d\n", mode
);
178 /************************************************************************
181 INT
PSDRV_StartPage( print_ctx
*ctx
)
183 TRACE("%p\n", ctx
->hdc
);
185 if(!ctx
->job
.OutOfPage
) {
186 FIXME("Already started a page?\n");
192 if(!PSDRV_WriteNewPage( ctx
))
194 ctx
->job
.OutOfPage
= FALSE
;
199 /************************************************************************
202 INT
PSDRV_EndPage( print_ctx
*ctx
)
204 TRACE("%p\n", ctx
->hdc
);
206 if(ctx
->job
.OutOfPage
) {
207 FIXME("Already ended a page?\n");
211 passthrough_leave(ctx
);
212 if(!PSDRV_WriteEndPage( ctx
))
214 PSDRV_EmptyDownloadList(ctx
, FALSE
);
215 ctx
->job
.OutOfPage
= TRUE
;