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
22 #include "wine/wingdi16.h"
23 #include "wine/winuser16.h"
26 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
31 /**********************************************************************
32 * ExtEscape (WINEPS.@)
34 INT PSDRV_ExtEscape( PSDRV_PDEVICE *physDev, INT nEscape, INT cbInput, LPCVOID in_data,
35 INT cbOutput, LPVOID out_data )
40 if(cbInput < sizeof(INT))
42 WARN("cbInput < sizeof(INT) (=%d) for QUERYESCSUPPORT\n", cbInput);
45 UINT num = *(UINT *)in_data;
46 TRACE("QUERYESCSUPPORT for %d\n", num);
61 case POSTSCRIPT_PASSTHROUGH:
62 case POSTSCRIPT_IGNORE:
76 if(!physDev->job.banding) {
77 physDev->job.banding = TRUE;
80 r->right = physDev->horzRes;
81 r->bottom = physDev->vertRes;
82 TRACE("NEXTBAND returning %ld,%ld - %ld,%ld\n", r->left, r->top, r->right, r->bottom );
89 TRACE("NEXTBAND rect to 0,0 - 0,0\n" );
90 physDev->job.banding = FALSE;
91 return EndPage( physDev->hdc );
96 const INT *NumCopies = in_data;
97 INT *ActualCopies = out_data;
98 if(cbInput != sizeof(INT)) {
99 WARN("cbInput != sizeof(INT) (=%d) for SETCOPYCOUNT\n", cbInput);
102 TRACE("SETCOPYCOUNT %d\n", *NumCopies);
110 strcpy(p, "PostScript");
111 *(p + strlen(p) + 1) = '\0'; /* 2 '\0's at end of string */
117 INT newCap = *(INT *)in_data;
118 if(cbInput != sizeof(INT)) {
119 WARN("cbInput != sizeof(INT) (=%d) for SETLINECAP\n", cbInput);
122 TRACE("SETLINECAP %d\n", newCap);
128 INT newJoin = *(INT *)in_data;
129 if(cbInput != sizeof(INT)) {
130 WARN("cbInput != sizeof(INT) (=%d) for SETLINEJOIN\n", cbInput);
133 TRACE("SETLINEJOIN %d\n", newJoin);
139 INT newLimit = *(INT *)in_data;
140 if(cbInput != sizeof(INT)) {
141 WARN("cbInput != sizeof(INT) (=%d) for SETMITERLIMIT\n", cbInput);
144 TRACE("SETMITERLIMIT %d\n", newLimit);
149 /* Undocumented escape used by winword6.
150 Switches between ANSI and a special charset.
151 If *lpInData == 1 we require that
155 0x94 is quotedblright
159 0xa0 is non break space - yeah right.
161 If *lpInData == 0 we get ANSI.
162 Since there's nothing else there, let's just make these the default
163 anyway and see what happens...
167 case EXT_DEVICE_CAPS:
169 UINT cap = *(UINT *)in_data;
170 if(cbInput != sizeof(UINT)) {
171 WARN("cbInput != sizeof(UINT) (=%d) for EXT_DEVICE_CAPS\n", cbInput);
174 TRACE("EXT_DEVICE_CAPS %d\n", cap);
180 const RECT *r = in_data;
181 if(cbInput != sizeof(RECT)) {
182 WARN("cbInput != sizeof(RECT) (=%d) for SET_BOUNDS\n", cbInput);
185 TRACE("SET_BOUNDS (%ld,%ld) - (%ld,%ld)\n", r->left, r->top,
186 r->right, r->bottom);
192 UINT epsprint = *(UINT*)in_data;
193 /* FIXME: In this mode we do not need to send page intros and page
194 * ends according to the doc. But I just ignore that detail
197 TRACE("EPS Printing support %sable.\n",epsprint?"en":"dis");
201 case POSTSCRIPT_DATA:
203 case POSTSCRIPT_PASSTHROUGH:
205 /* Write directly to spool file, bypassing normal PS driver
206 * processing that is done along with writing PostScript code
208 * (Usually we have a WORD before the data counting the size, but
209 * cbInput is just this +2.)
211 return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,cbInput-2);
214 case POSTSCRIPT_IGNORE:
216 BOOL ret = physDev->job.quiet;
217 TRACE("POSTSCRIPT_IGNORE %d\n", *(short*)in_data);
218 physDev->job.quiet = *(short*)in_data;
222 case GETSETPRINTORIENT:
224 /* If lpInData is present, it is a 20 byte structure, first 32
225 * bit LONG value is the orientation. if lpInData is NULL, it
226 * returns the current orientation.
228 FIXME("GETSETPRINTORIENT not implemented (data %p)!\n",in_data);
232 TRACE("BEGIN_PATH\n");
233 if(physDev->pathdepth)
234 FIXME("Nested paths not yet handled\n");
235 return ++physDev->pathdepth;
239 struct PATH_INFO *info = (struct PATH_INFO*)in_data;
242 if(!physDev->pathdepth) {
243 ERR("END_PATH called without a BEIGN_PATH\n");
246 TRACE("RenderMode = %d, FillMode = %d, BkMode = %d\n",
247 info->RenderMode, info->FillMode, info->BkMode);
248 switch(info->RenderMode) {
249 case RENDERMODE_NO_DISPLAY:
250 PSDRV_WriteClosePath(physDev); /* not sure if this is necessary, but it can't hurt */
252 case RENDERMODE_OPEN:
253 case RENDERMODE_CLOSED:
255 FIXME("END_PATH: RenderMode %d, not yet supported\n", info->RenderMode);
258 return --physDev->pathdepth;
263 WORD mode = *(WORD*)in_data;
267 TRACE("CLIP_TO_PATH: CLIP_SAVE\n");
268 PSDRV_WriteGSave(physDev);
271 TRACE("CLIP_TO_PATH: CLIP_RESTORE\n");
272 PSDRV_WriteGRestore(physDev);
275 TRACE("CLIP_TO_PATH: CLIP_INCLUSIVE\n");
276 /* FIXME to clip or eoclip ? (see PATH_INFO.FillMode) */
277 PSDRV_WriteClip(physDev);
280 FIXME("CLIP_EXCLUSIVE: not implemented\n");
283 FIXME("Unknown CLIP_TO_PATH mode %d\n", mode);
289 FIXME("Unimplemented code 0x%x\n", nEscape);
294 /************************************************************************
297 INT PSDRV_StartPage( PSDRV_PDEVICE *physDev )
299 if(!physDev->job.OutOfPage) {
300 FIXME("Already started a page?\n");
303 physDev->job.PageNo++;
304 if(!PSDRV_WriteNewPage( physDev ))
306 physDev->job.OutOfPage = FALSE;
311 /************************************************************************
314 INT PSDRV_EndPage( PSDRV_PDEVICE *physDev )
316 if(physDev->job.OutOfPage) {
317 FIXME("Already ended a page?\n");
320 if(!PSDRV_WriteEndPage( physDev ))
322 PSDRV_EmptyDownloadList(physDev);
323 physDev->job.OutOfPage = TRUE;
328 /************************************************************************
331 INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOA *doc )
333 if(physDev->job.hJob) {
334 FIXME("hJob != 0. Now what?\n");
338 if(doc->lpszOutput) {
339 HeapFree( PSDRV_Heap, 0, physDev->job.output );
340 physDev->job.output = HeapAlloc( PSDRV_Heap, 0, strlen(doc->lpszOutput)+1 );
341 strcpy( physDev->job.output, doc->lpszOutput );
343 physDev->job.hJob = OpenJob16(physDev->job.output, doc->lpszDocName, HDC_16(physDev->hdc) );
344 if(!physDev->job.hJob) {
345 WARN("OpenJob failed\n");
348 physDev->job.banding = FALSE;
349 physDev->job.OutOfPage = TRUE;
350 physDev->job.PageNo = 0;
351 if(!PSDRV_WriteHeader( physDev, doc->lpszDocName ))
354 return physDev->job.hJob;
358 /************************************************************************
361 INT PSDRV_EndDoc( PSDRV_PDEVICE *physDev )
364 if(!physDev->job.hJob) {
365 FIXME("hJob == 0. Now what?\n");
369 if(!physDev->job.OutOfPage) {
370 WARN("Somebody forgot a EndPage\n");
371 PSDRV_EndPage( physDev );
373 PSDRV_WriteFooter( physDev );
375 if( CloseJob16( physDev->job.hJob ) == SP_ERROR ) {
376 WARN("CloseJob error\n");
379 physDev->job.hJob = 0;