From 69c7164977f177fc83af8b35df6f2fbeae94294a Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Tue, 20 May 2003 02:24:50 +0000 Subject: [PATCH] Look up the printer's port in the registry if neither CreateDC or StartDoc specify one. Photoshop 7 has a bug that results in cbInput being 2 less than the length of the string rather than 2 more. So use the WORD at in_data[0] instead. --- dlls/wineps/escape.c | 33 +++++++++++++++++++++++++-------- dlls/wineps/init.c | 11 +++++++---- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/dlls/wineps/escape.c b/dlls/wineps/escape.c index 1598cdaec16..31ef9aa2115 100644 --- a/dlls/wineps/escape.c +++ b/dlls/wineps/escape.c @@ -205,10 +205,13 @@ INT PSDRV_ExtEscape( PSDRV_PDEVICE *physDev, INT nEscape, INT cbInput, LPCVOID i /* Write directly to spool file, bypassing normal PS driver * processing that is done along with writing PostScript code * to the spool. - * (Usually we have a WORD before the data counting the size, but - * cbInput is just this +2.) + * We have a WORD before the data counting the size, but + * cbInput is just this +2. + * However Photoshop 7 has a bug that sets cbInput to 2 less than the + * length of the string, rather than 2 more. So we'll use the WORD at + * in_data[0] instead. */ - return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,cbInput-2); + return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,*(WORD*)in_data); } case POSTSCRIPT_IGNORE: @@ -330,17 +333,31 @@ INT PSDRV_EndPage( PSDRV_PDEVICE *physDev ) */ INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOA *doc ) { + LPCSTR output = "LPT1:"; + BYTE buf[300]; + HANDLE hprn = INVALID_HANDLE_VALUE; + PRINTER_INFO_5A *pi5 = (PRINTER_INFO_5A*)buf; + DWORD needed; + if(physDev->job.hJob) { FIXME("hJob != 0. Now what?\n"); return 0; } - if(doc->lpszOutput) { - HeapFree( PSDRV_Heap, 0, physDev->job.output ); - physDev->job.output = HeapAlloc( PSDRV_Heap, 0, strlen(doc->lpszOutput)+1 ); - strcpy( physDev->job.output, doc->lpszOutput ); + if(doc->lpszOutput) + output = doc->lpszOutput; + else if(physDev->job.output) + output = physDev->job.output; + else { + if(OpenPrinterA(physDev->pi->FriendlyName, &hprn, NULL) && + GetPrinterA(hprn, 5, buf, sizeof(buf), &needed)) { + output = pi5->pPortName; + } + if(hprn != INVALID_HANDLE_VALUE) + ClosePrinter(hprn); } - physDev->job.hJob = OpenJob16(physDev->job.output, doc->lpszDocName, HDC_16(physDev->hdc) ); + + physDev->job.hJob = OpenJob16(output, doc->lpszDocName, HDC_16(physDev->hdc) ); if(!physDev->job.hJob) { WARN("OpenJob failed\n"); return 0; diff --git a/dlls/wineps/init.c b/dlls/wineps/init.c index 91e2c5d2db1..d9819006a2e 100644 --- a/dlls/wineps/init.c +++ b/dlls/wineps/init.c @@ -299,9 +299,11 @@ BOOL PSDRV_CreateDC( DC *dc, PSDRV_PDEVICE **pdev, LPCSTR driver, LPCSTR device, physDev->logPixelsX = physDev->pi->ppd->DefaultResolution; physDev->logPixelsY = physDev->pi->ppd->DefaultResolution; - if (!output) output = "LPT1:"; /* HACK */ - physDev->job.output = HeapAlloc( PSDRV_Heap, 0, strlen(output)+1 ); - strcpy( physDev->job.output, output ); + if (output) { + physDev->job.output = HeapAlloc( PSDRV_Heap, 0, strlen(output)+1 ); + strcpy( physDev->job.output, output ); + } else + physDev->job.output = NULL; physDev->job.hJob = 0; if(initData) { @@ -323,7 +325,8 @@ BOOL PSDRV_DeleteDC( PSDRV_PDEVICE *physDev ) TRACE("\n"); HeapFree( PSDRV_Heap, 0, physDev->Devmode ); - HeapFree( PSDRV_Heap, 0, physDev->job.output ); + if(physDev->job.output) + HeapFree( PSDRV_Heap, 0, physDev->job.output ); HeapFree( PSDRV_Heap, 0, physDev ); return TRUE;