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 * We have a WORD before the data counting the size, but
209 * cbInput is just this +2.
210 * However Photoshop 7 has a bug that sets cbInput to 2 less than the
211 * length of the string, rather than 2 more. So we'll use the WORD at
212 * in_data[0] instead.
214 return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,*(WORD*)in_data);
217 case POSTSCRIPT_IGNORE:
219 BOOL ret = physDev->job.quiet;
220 TRACE("POSTSCRIPT_IGNORE %d\n", *(short*)in_data);
221 physDev->job.quiet = *(short*)in_data;
225 case GETSETPRINTORIENT:
227 /* If lpInData is present, it is a 20 byte structure, first 32
228 * bit LONG value is the orientation. if lpInData is NULL, it
229 * returns the current orientation.
231 FIXME("GETSETPRINTORIENT not implemented (data %p)!\n",in_data);
235 TRACE("BEGIN_PATH\n");
236 if(physDev->pathdepth)
237 FIXME("Nested paths not yet handled\n");
238 return ++physDev->pathdepth;
242 struct PATH_INFO *info = (struct PATH_INFO*)in_data;
245 if(!physDev->pathdepth) {
246 ERR("END_PATH called without a BEIGN_PATH\n");
249 TRACE("RenderMode = %d, FillMode = %d, BkMode = %d\n",
250 info->RenderMode, info->FillMode, info->BkMode);
251 switch(info->RenderMode) {
252 case RENDERMODE_NO_DISPLAY:
253 PSDRV_WriteClosePath(physDev); /* not sure if this is necessary, but it can't hurt */
255 case RENDERMODE_OPEN:
256 case RENDERMODE_CLOSED:
258 FIXME("END_PATH: RenderMode %d, not yet supported\n", info->RenderMode);
261 return --physDev->pathdepth;
266 WORD mode = *(WORD*)in_data;
270 TRACE("CLIP_TO_PATH: CLIP_SAVE\n");
271 PSDRV_WriteGSave(physDev);
274 TRACE("CLIP_TO_PATH: CLIP_RESTORE\n");
275 PSDRV_WriteGRestore(physDev);
278 TRACE("CLIP_TO_PATH: CLIP_INCLUSIVE\n");
279 /* FIXME to clip or eoclip ? (see PATH_INFO.FillMode) */
280 PSDRV_WriteClip(physDev);
283 FIXME("CLIP_EXCLUSIVE: not implemented\n");
286 FIXME("Unknown CLIP_TO_PATH mode %d\n", mode);
292 FIXME("Unimplemented code 0x%x\n", nEscape);
297 /************************************************************************
300 INT PSDRV_StartPage( PSDRV_PDEVICE *physDev )
302 if(!physDev->job.OutOfPage) {
303 FIXME("Already started a page?\n");
306 physDev->job.PageNo++;
307 if(!PSDRV_WriteNewPage( physDev ))
309 physDev->job.OutOfPage = FALSE;
314 /************************************************************************
317 INT PSDRV_EndPage( PSDRV_PDEVICE *physDev )
319 if(physDev->job.OutOfPage) {
320 FIXME("Already ended a page?\n");
323 if(!PSDRV_WriteEndPage( physDev ))
325 PSDRV_EmptyDownloadList(physDev, FALSE);
326 physDev->job.OutOfPage = TRUE;
331 /************************************************************************
334 INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOA *doc )
336 LPCSTR output = "LPT1:";
338 HANDLE hprn = INVALID_HANDLE_VALUE;
339 PRINTER_INFO_5A *pi5 = (PRINTER_INFO_5A*)buf;
342 if(physDev->job.hJob) {
343 FIXME("hJob != 0. Now what?\n");
348 output = doc->lpszOutput;
349 else if(physDev->job.output)
350 output = physDev->job.output;
352 if(OpenPrinterA(physDev->pi->FriendlyName, &hprn, NULL) &&
353 GetPrinterA(hprn, 5, buf, sizeof(buf), &needed)) {
354 output = pi5->pPortName;
356 if(hprn != INVALID_HANDLE_VALUE)
360 physDev->job.hJob = OpenJob16(output, doc->lpszDocName, HDC_16(physDev->hdc) );
361 if(!physDev->job.hJob) {
362 WARN("OpenJob failed\n");
365 physDev->job.banding = FALSE;
366 physDev->job.OutOfPage = TRUE;
367 physDev->job.PageNo = 0;
368 if(!PSDRV_WriteHeader( physDev, doc->lpszDocName ))
371 return physDev->job.hJob;
375 /************************************************************************
378 INT PSDRV_EndDoc( PSDRV_PDEVICE *physDev )
381 if(!physDev->job.hJob) {
382 FIXME("hJob == 0. Now what?\n");
386 if(!physDev->job.OutOfPage) {
387 WARN("Somebody forgot a EndPage\n");
388 PSDRV_EndPage( physDev );
390 PSDRV_WriteFooter( physDev );
392 if( CloseJob16( physDev->job.hJob ) == SP_ERROR ) {
393 WARN("CloseJob error\n");
396 physDev->job.hJob = 0;