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
25 #include "wine/wingdi16.h"
26 #include "wine/winuser16.h"
29 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
34 /**********************************************************************
35 * ExtEscape (WINEPS.@)
37 INT PSDRV_ExtEscape( PSDRV_PDEVICE *physDev, INT nEscape, INT cbInput, LPCVOID in_data,
38 INT cbOutput, LPVOID out_data )
43 if(cbInput < sizeof(INT))
45 WARN("cbInput < sizeof(INT) (=%d) for QUERYESCSUPPORT\n", cbInput);
48 UINT num = *(UINT *)in_data;
49 TRACE("QUERYESCSUPPORT for %d\n", num);
64 case POSTSCRIPT_PASSTHROUGH:
65 case POSTSCRIPT_IGNORE:
79 if(!physDev->job.banding) {
80 physDev->job.banding = TRUE;
83 r->right = physDev->horzRes;
84 r->bottom = physDev->vertRes;
85 TRACE("NEXTBAND returning %ld,%ld - %ld,%ld\n", r->left, r->top, r->right, r->bottom );
92 TRACE("NEXTBAND rect to 0,0 - 0,0\n" );
93 physDev->job.banding = FALSE;
94 return EndPage( physDev->hdc );
99 const INT *NumCopies = in_data;
100 INT *ActualCopies = out_data;
101 if(cbInput != sizeof(INT)) {
102 WARN("cbInput != sizeof(INT) (=%d) for SETCOPYCOUNT\n", cbInput);
105 TRACE("SETCOPYCOUNT %d\n", *NumCopies);
113 strcpy(p, "PostScript");
114 *(p + strlen(p) + 1) = '\0'; /* 2 '\0's at end of string */
120 INT newCap = *(INT *)in_data;
121 if(cbInput != sizeof(INT)) {
122 WARN("cbInput != sizeof(INT) (=%d) for SETLINECAP\n", cbInput);
125 TRACE("SETLINECAP %d\n", newCap);
131 INT newJoin = *(INT *)in_data;
132 if(cbInput != sizeof(INT)) {
133 WARN("cbInput != sizeof(INT) (=%d) for SETLINEJOIN\n", cbInput);
136 TRACE("SETLINEJOIN %d\n", newJoin);
142 INT newLimit = *(INT *)in_data;
143 if(cbInput != sizeof(INT)) {
144 WARN("cbInput != sizeof(INT) (=%d) for SETMITERLIMIT\n", cbInput);
147 TRACE("SETMITERLIMIT %d\n", newLimit);
152 /* Undocumented escape used by winword6.
153 Switches between ANSI and a special charset.
154 If *lpInData == 1 we require that
158 0x94 is quotedblright
162 0xa0 is non break space - yeah right.
164 If *lpInData == 0 we get ANSI.
165 Since there's nothing else there, let's just make these the default
166 anyway and see what happens...
170 case EXT_DEVICE_CAPS:
172 UINT cap = *(UINT *)in_data;
173 if(cbInput != sizeof(UINT)) {
174 WARN("cbInput != sizeof(UINT) (=%d) for EXT_DEVICE_CAPS\n", cbInput);
177 TRACE("EXT_DEVICE_CAPS %d\n", cap);
183 const RECT *r = in_data;
184 if(cbInput != sizeof(RECT)) {
185 WARN("cbInput != sizeof(RECT) (=%d) for SET_BOUNDS\n", cbInput);
188 TRACE("SET_BOUNDS (%ld,%ld) - (%ld,%ld)\n", r->left, r->top,
189 r->right, r->bottom);
195 UINT epsprint = *(UINT*)in_data;
196 /* FIXME: In this mode we do not need to send page intros and page
197 * ends according to the doc. But I just ignore that detail
200 TRACE("EPS Printing support %sable.\n",epsprint?"en":"dis");
204 case POSTSCRIPT_DATA:
206 case POSTSCRIPT_PASSTHROUGH:
208 /* Write directly to spool file, bypassing normal PS driver
209 * processing that is done along with writing PostScript code
211 * We have a WORD before the data counting the size, but
212 * cbInput is just this +2.
213 * However Photoshop 7 has a bug that sets cbInput to 2 less than the
214 * length of the string, rather than 2 more. So we'll use the WORD at
215 * in_data[0] instead.
217 return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,*(WORD*)in_data);
220 case POSTSCRIPT_IGNORE:
222 BOOL ret = physDev->job.quiet;
223 TRACE("POSTSCRIPT_IGNORE %d\n", *(short*)in_data);
224 physDev->job.quiet = *(short*)in_data;
228 case GETSETPRINTORIENT:
230 /* If lpInData is present, it is a 20 byte structure, first 32
231 * bit LONG value is the orientation. if lpInData is NULL, it
232 * returns the current orientation.
234 FIXME("GETSETPRINTORIENT not implemented (data %p)!\n",in_data);
238 TRACE("BEGIN_PATH\n");
239 if(physDev->pathdepth)
240 FIXME("Nested paths not yet handled\n");
241 return ++physDev->pathdepth;
245 struct PATH_INFO *info = (struct PATH_INFO*)in_data;
248 if(!physDev->pathdepth) {
249 ERR("END_PATH called without a BEIGN_PATH\n");
252 TRACE("RenderMode = %d, FillMode = %d, BkMode = %d\n",
253 info->RenderMode, info->FillMode, info->BkMode);
254 switch(info->RenderMode) {
255 case RENDERMODE_NO_DISPLAY:
256 PSDRV_WriteClosePath(physDev); /* not sure if this is necessary, but it can't hurt */
258 case RENDERMODE_OPEN:
259 case RENDERMODE_CLOSED:
261 FIXME("END_PATH: RenderMode %d, not yet supported\n", info->RenderMode);
264 return --physDev->pathdepth;
269 WORD mode = *(WORD*)in_data;
273 TRACE("CLIP_TO_PATH: CLIP_SAVE\n");
274 PSDRV_WriteGSave(physDev);
277 TRACE("CLIP_TO_PATH: CLIP_RESTORE\n");
278 PSDRV_WriteGRestore(physDev);
281 TRACE("CLIP_TO_PATH: CLIP_INCLUSIVE\n");
282 /* FIXME to clip or eoclip ? (see PATH_INFO.FillMode) */
283 PSDRV_WriteClip(physDev);
286 FIXME("CLIP_EXCLUSIVE: not implemented\n");
289 FIXME("Unknown CLIP_TO_PATH mode %d\n", mode);
295 FIXME("Unimplemented code 0x%x\n", nEscape);
300 /************************************************************************
303 INT PSDRV_StartPage( PSDRV_PDEVICE *physDev )
305 if(!physDev->job.OutOfPage) {
306 FIXME("Already started a page?\n");
309 physDev->job.PageNo++;
310 if(!PSDRV_WriteNewPage( physDev ))
312 physDev->job.OutOfPage = FALSE;
317 /************************************************************************
320 INT PSDRV_EndPage( PSDRV_PDEVICE *physDev )
322 if(physDev->job.OutOfPage) {
323 FIXME("Already ended a page?\n");
326 if(!PSDRV_WriteEndPage( physDev ))
328 PSDRV_EmptyDownloadList(physDev, FALSE);
329 physDev->job.OutOfPage = TRUE;
334 /************************************************************************
337 INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOA *doc )
339 LPCSTR output = "LPT1:";
341 HANDLE hprn = INVALID_HANDLE_VALUE;
342 PRINTER_INFO_5A *pi5 = (PRINTER_INFO_5A*)buf;
345 if(physDev->job.hJob) {
346 FIXME("hJob != 0. Now what?\n");
351 output = doc->lpszOutput;
352 else if(physDev->job.output)
353 output = physDev->job.output;
355 if(OpenPrinterA(physDev->pi->FriendlyName, &hprn, NULL) &&
356 GetPrinterA(hprn, 5, buf, sizeof(buf), &needed)) {
357 output = pi5->pPortName;
359 if(hprn != INVALID_HANDLE_VALUE)
363 physDev->job.hJob = OpenJob16(output, doc->lpszDocName, HDC_16(physDev->hdc) );
364 if(!physDev->job.hJob) {
365 WARN("OpenJob failed\n");
368 physDev->job.banding = FALSE;
369 physDev->job.OutOfPage = TRUE;
370 physDev->job.PageNo = 0;
371 if(!PSDRV_WriteHeader( physDev, doc->lpszDocName ))
374 return physDev->job.hJob;
378 /************************************************************************
381 INT PSDRV_EndDoc( PSDRV_PDEVICE *physDev )
384 if(!physDev->job.hJob) {
385 FIXME("hJob == 0. Now what?\n");
389 if(!physDev->job.OutOfPage) {
390 WARN("Somebody forgot a EndPage\n");
391 PSDRV_EndPage( physDev );
393 PSDRV_WriteFooter( physDev );
395 if( CloseJob16( physDev->job.hJob ) == SP_ERROR ) {
396 WARN("CloseJob error\n");
399 physDev->job.hJob = 0;