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/winuser16.h"
25 #include "wine/debug.h"
28 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);
60 case POSTSCRIPT_PASSTHROUGH:
71 if(!physDev->job.banding) {
72 physDev->job.banding = TRUE;
75 r->right = physDev->horzRes;
76 r->bottom = physDev->vertRes;
77 TRACE("NEXTBAND returning %d,%d - %d,%d\n", r->left, r->top, r->right, r->bottom );
84 TRACE("NEXTBAND rect to 0,0 - 0,0\n" );
85 physDev->job.banding = FALSE;
86 return EndPage( physDev->hdc );
91 const INT *NumCopies = in_data;
92 INT *ActualCopies = out_data;
93 if(cbInput != sizeof(INT)) {
94 WARN("cbInput != sizeof(INT) (=%d) for SETCOPYCOUNT\n", cbInput);
97 TRACE("SETCOPYCOUNT %d\n", *NumCopies);
105 strcpy(p, "PostScript");
106 *(p + strlen(p) + 1) = '\0'; /* 2 '\0's at end of string */
112 INT newCap = *(INT *)in_data;
113 if(cbInput != sizeof(INT)) {
114 WARN("cbInput != sizeof(INT) (=%d) for SETLINECAP\n", cbInput);
117 TRACE("SETLINECAP %d\n", newCap);
123 INT newJoin = *(INT *)in_data;
124 if(cbInput != sizeof(INT)) {
125 WARN("cbInput != sizeof(INT) (=%d) for SETLINEJOIN\n", cbInput);
128 TRACE("SETLINEJOIN %d\n", newJoin);
134 INT newLimit = *(INT *)in_data;
135 if(cbInput != sizeof(INT)) {
136 WARN("cbInput != sizeof(INT) (=%d) for SETMITERLIMIT\n", cbInput);
139 TRACE("SETMITERLIMIT %d\n", newLimit);
144 /* Undocumented escape used by winword6.
145 Switches between ANSI and a special charset.
146 If *lpInData == 1 we require that
150 0x94 is quotedblright
154 0xa0 is non break space - yeah right.
156 If *lpInData == 0 we get ANSI.
157 Since there's nothing else there, let's just make these the default
158 anyway and see what happens...
162 case EXT_DEVICE_CAPS:
164 UINT cap = *(UINT *)in_data;
165 if(cbInput != sizeof(UINT)) {
166 WARN("cbInput != sizeof(UINT) (=%d) for EXT_DEVICE_CAPS\n", cbInput);
169 TRACE("EXT_DEVICE_CAPS %d\n", cap);
175 const RECT *r = in_data;
176 if(cbInput != sizeof(RECT)) {
177 WARN("cbInput != sizeof(RECT) (=%d) for SET_BOUNDS\n", cbInput);
180 TRACE("SET_BOUNDS (%d,%d) - (%d,%d)\n", r->left, r->top,
181 r->right, r->bottom);
187 UINT epsprint = *(UINT*)in_data;
188 /* FIXME: In this mode we do not need to send page intros and page
189 * ends according to the doc. But I just ignore that detail
192 TRACE("EPS Printing support %sable.\n",epsprint?"en":"dis");
196 case POSTSCRIPT_PASSTHROUGH:
198 /* Write directly to spool file, bypassing normal PS driver
199 * processing that is done along with writing PostScript code
201 * (Usually we have a WORD before the data counting the size, but
202 * cbInput is just this +2.)
204 return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,cbInput-2);
207 case GETSETPRINTORIENT:
209 /* If lpInData is present, it is a 20 byte structure, first 32
210 * bit LONG value is the orientation. if lpInData is NULL, it
211 * returns the current orientation.
213 FIXME("GETSETPRINTORIENT not implemented (data %p)!\n",in_data);
217 FIXME("Unimplemented code 0x%x\n", nEscape);
222 /************************************************************************
225 INT PSDRV_StartPage( PSDRV_PDEVICE *physDev )
227 if(!physDev->job.OutOfPage) {
228 FIXME("Already started a page?\n");
231 physDev->job.PageNo++;
232 if(!PSDRV_WriteNewPage( physDev ))
234 physDev->job.OutOfPage = FALSE;
239 /************************************************************************
242 INT PSDRV_EndPage( PSDRV_PDEVICE *physDev )
244 if(physDev->job.OutOfPage) {
245 FIXME("Already ended a page?\n");
248 if(!PSDRV_WriteEndPage( physDev ))
250 PSDRV_EmptyDownloadList(physDev);
251 physDev->job.OutOfPage = TRUE;
256 /************************************************************************
259 INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOA *doc )
261 if(physDev->job.hJob) {
262 FIXME("hJob != 0. Now what?\n");
266 if(doc->lpszOutput) {
267 HeapFree( PSDRV_Heap, 0, physDev->job.output );
268 physDev->job.output = HeapAlloc( PSDRV_Heap, 0, strlen(doc->lpszOutput)+1 );
269 strcpy( physDev->job.output, doc->lpszOutput );
271 physDev->job.hJob = OpenJob16(physDev->job.output, doc->lpszDocName, HDC_16(physDev->hdc) );
272 if(!physDev->job.hJob) {
273 WARN("OpenJob failed\n");
276 physDev->job.banding = FALSE;
277 physDev->job.OutOfPage = TRUE;
278 physDev->job.PageNo = 0;
279 if(!PSDRV_WriteHeader( physDev, doc->lpszDocName ))
282 return physDev->job.hJob;
286 /************************************************************************
289 INT PSDRV_EndDoc( PSDRV_PDEVICE *physDev )
291 if(!physDev->job.hJob) {
292 FIXME("hJob == 0. Now what?\n");
296 if(!physDev->job.OutOfPage) {
297 WARN("Somebody forgot a EndPage\n");
298 PSDRV_EndPage( physDev );
300 if(!PSDRV_WriteFooter( physDev ))
303 if( CloseJob16( physDev->job.hJob ) == SP_ERROR ) {
304 WARN("CloseJob error\n");
307 physDev->job.hJob = 0;