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"
24 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
30 /**********************************************************************
31 * ExtEscape (WINEPS.@)
33 INT PSDRV_ExtEscape( DC *dc, INT nEscape, INT cbInput, LPCVOID in_data,
34 INT cbOutput, LPVOID out_data )
36 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
41 if(cbInput < sizeof(INT))
43 WARN("cbInput < sizeof(INT) (=%d) for QUERYESCSUPPORT\n", cbInput);
46 UINT num = *(UINT *)in_data;
47 TRACE("QUERYESCSUPPORT for %d\n", num);
61 case POSTSCRIPT_PASSTHROUGH:
72 if(!physDev->job.banding) {
73 physDev->job.banding = TRUE;
76 r->right = physDev->horzRes;
77 r->bottom = physDev->vertRes;
78 TRACE("NEXTBAND returning %d,%d - %d,%d\n", r->left, r->top, r->right, r->bottom );
85 TRACE("NEXTBAND rect to 0,0 - 0,0\n" );
86 physDev->job.banding = FALSE;
87 return EndPage( dc->hSelf );
92 const INT *NumCopies = in_data;
93 INT *ActualCopies = out_data;
94 if(cbInput != sizeof(INT)) {
95 WARN("cbInput != sizeof(INT) (=%d) for SETCOPYCOUNT\n", cbInput);
98 TRACE("SETCOPYCOUNT %d\n", *NumCopies);
106 strcpy(p, "PostScript");
107 *(p + strlen(p) + 1) = '\0'; /* 2 '\0's at end of string */
113 INT newCap = *(INT *)in_data;
114 if(cbInput != sizeof(INT)) {
115 WARN("cbInput != sizeof(INT) (=%d) for SETLINECAP\n", cbInput);
118 TRACE("SETLINECAP %d\n", newCap);
124 INT newJoin = *(INT *)in_data;
125 if(cbInput != sizeof(INT)) {
126 WARN("cbInput != sizeof(INT) (=%d) for SETLINEJOIN\n", cbInput);
129 TRACE("SETLINEJOIN %d\n", newJoin);
135 INT newLimit = *(INT *)in_data;
136 if(cbInput != sizeof(INT)) {
137 WARN("cbInput != sizeof(INT) (=%d) for SETMITERLIMIT\n", cbInput);
140 TRACE("SETMITERLIMIT %d\n", newLimit);
145 /* Undocumented escape used by winword6.
146 Switches between ANSI and a special charset.
147 If *lpInData == 1 we require that
151 0x94 is quotedblright
155 0xa0 is non break space - yeah right.
157 If *lpInData == 0 we get ANSI.
158 Since there's nothing else there, let's just make these the default
159 anyway and see what happens...
163 case EXT_DEVICE_CAPS:
165 UINT cap = *(UINT *)in_data;
166 if(cbInput != sizeof(UINT)) {
167 WARN("cbInput != sizeof(UINT) (=%d) for EXT_DEVICE_CAPS\n", cbInput);
170 TRACE("EXT_DEVICE_CAPS %d\n", cap);
176 const RECT *r = in_data;
177 if(cbInput != sizeof(RECT)) {
178 WARN("cbInput != sizeof(RECT) (=%d) for SET_BOUNDS\n", cbInput);
181 TRACE("SET_BOUNDS (%d,%d) - (%d,%d)\n", r->left, r->top,
182 r->right, r->bottom);
188 UINT epsprint = *(UINT*)in_data;
189 /* FIXME: In this mode we do not need to send page intros and page
190 * ends according to the doc. But I just ignore that detail
193 TRACE("EPS Printing support %sable.\n",epsprint?"en":"dis");
197 case POSTSCRIPT_PASSTHROUGH:
199 /* Write directly to spool file, bypassing normal PS driver
200 * processing that is done along with writing PostScript code
202 * (Usually we have a WORD before the data counting the size, but
203 * cbInput is just this +2.)
205 return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,cbInput-2);
208 case GETSETPRINTORIENT:
210 /* If lpInData is present, it is a 20 byte structure, first 32
211 * bit LONG value is the orientation. if lpInData is NULL, it
212 * returns the current orientation.
214 FIXME("GETSETPRINTORIENT not implemented (data %p)!\n",in_data);
218 FIXME("Unimplemented code 0x%x\n", nEscape);
223 /************************************************************************
226 INT PSDRV_StartPage( DC *dc )
228 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
230 if(!physDev->job.OutOfPage) {
231 FIXME("Already started a page?\n");
234 physDev->job.PageNo++;
235 if(!PSDRV_WriteNewPage( dc ))
237 physDev->job.OutOfPage = FALSE;
242 /************************************************************************
245 INT PSDRV_EndPage( DC *dc )
247 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
249 if(physDev->job.OutOfPage) {
250 FIXME("Already ended a page?\n");
253 if(!PSDRV_WriteEndPage( dc ))
255 physDev->job.OutOfPage = TRUE;
260 /************************************************************************
263 INT PSDRV_StartDoc( DC *dc, const DOCINFOA *doc )
265 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
267 if(physDev->job.hJob) {
268 FIXME("hJob != 0. Now what?\n");
272 if(doc->lpszOutput) {
273 HeapFree( PSDRV_Heap, 0, physDev->job.output );
274 physDev->job.output = HeapAlloc( PSDRV_Heap, 0, strlen(doc->lpszOutput)+1 );
275 strcpy( physDev->job.output, doc->lpszOutput );
277 physDev->job.hJob = OpenJob16(physDev->job.output, doc->lpszDocName,
279 if(!physDev->job.hJob) {
280 WARN("OpenJob failed\n");
283 physDev->job.banding = FALSE;
284 physDev->job.OutOfPage = TRUE;
285 physDev->job.PageNo = 0;
286 if(!PSDRV_WriteHeader( dc, doc->lpszDocName ))
289 return physDev->job.hJob;
293 /************************************************************************
296 INT PSDRV_EndDoc( DC *dc )
298 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
300 if(!physDev->job.hJob) {
301 FIXME("hJob == 0. Now what?\n");
305 if(!physDev->job.OutOfPage) {
306 WARN("Somebody forgot a EndPage\n");
309 if(!PSDRV_WriteFooter( dc ))
312 if( CloseJob16( physDev->job.hJob ) == SP_ERROR ) {
313 WARN("CloseJob error\n");
316 physDev->job.hJob = 0;