Commit 780667fe authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

Bracket code inserted by the PASSTHROUGH escapes by

%%{Begin,End}Document. This stops cups' pstops becoming confused if it comes across an %%EOF in an imported eps file. The hack in PSDRV_Rectangle to fix eps files in office2k turns out to be almost what Windows really does - update the code and the comment to match Windows behaviour more precisely.
parent fe13d6a0
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
static const char psbegindocument[] =
"%%BeginDocument: Wine passthrough\n";
/********************************************************************** /**********************************************************************
* ExtEscape (WINEPS.@) * ExtEscape (WINEPS.@)
*/ */
...@@ -214,6 +217,10 @@ INT PSDRV_ExtEscape( PSDRV_PDEVICE *physDev, INT nEscape, INT cbInput, LPCVOID i ...@@ -214,6 +217,10 @@ INT PSDRV_ExtEscape( PSDRV_PDEVICE *physDev, INT nEscape, INT cbInput, LPCVOID i
* length of the string, rather than 2 more. So we'll use the WORD at * length of the string, rather than 2 more. So we'll use the WORD at
* in_data[0] instead. * in_data[0] instead.
*/ */
if(!physDev->job.in_passthrough) {
WriteSpool16(physDev->job.hJob, (LPSTR)psbegindocument, sizeof(psbegindocument)-1);
physDev->job.in_passthrough = TRUE;
}
return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,*(WORD*)in_data); return WriteSpool16(physDev->job.hJob,((char*)in_data)+2,*(WORD*)in_data);
} }
...@@ -373,7 +380,9 @@ INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOA *doc ) ...@@ -373,7 +380,9 @@ INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOA *doc )
physDev->job.banding = FALSE; physDev->job.banding = FALSE;
physDev->job.OutOfPage = TRUE; physDev->job.OutOfPage = TRUE;
physDev->job.PageNo = 0; physDev->job.PageNo = 0;
physDev->job.quiet = FALSE;
physDev->job.in_passthrough = FALSE;
physDev->job.had_passthrough_rect = FALSE;
if(doc->lpszDocName) { if(doc->lpszDocName) {
physDev->job.DocName = HeapAlloc(GetProcessHeap(), 0, strlen(doc->lpszDocName)+1); physDev->job.DocName = HeapAlloc(GetProcessHeap(), 0, strlen(doc->lpszDocName)+1);
strcpy(physDev->job.DocName, doc->lpszDocName); strcpy(physDev->job.DocName, doc->lpszDocName);
......
...@@ -124,11 +124,14 @@ BOOL PSDRV_Rectangle( PSDRV_PDEVICE *physDev, INT left, INT top, INT right, INT ...@@ -124,11 +124,14 @@ BOOL PSDRV_Rectangle( PSDRV_PDEVICE *physDev, INT left, INT top, INT right, INT
rect.bottom = bottom; rect.bottom = bottom;
LPtoDP( physDev->hdc, (POINT *)&rect, 2 ); LPtoDP( physDev->hdc, (POINT *)&rect, 2 );
/* HACK to get inserted eps files printing from Office 2k */ /* Windows does something truely hacky here. If we're in passthrough mode
if(GetROP2(physDev->hdc) == R2_NOP) { and our rop is R2_NOP, then we output the string below. This is used in
Office 2k when inserting eps files */
if(physDev->job.in_passthrough && !physDev->job.had_passthrough_rect && GetROP2(physDev->hdc) == R2_NOP) {
char buf[256]; char buf[256];
sprintf(buf, "%ld %ld %ld %ld B\n", rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top); sprintf(buf, "N %ld %ld %ld %ld B\n", rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top);
PSDRV_WriteSpool(physDev, buf, strlen(buf)); WriteSpool16(physDev->job.hJob, buf, strlen(buf));
physDev->job.had_passthrough_rect = TRUE;
return TRUE; return TRUE;
} }
......
...@@ -60,6 +60,7 @@ static const char psprolog[] = ...@@ -60,6 +60,7 @@ static const char psprolog[] =
" for\n" " for\n"
"} bind def\n" "} bind def\n"
"/B {pop pop pop pop} def\n" "/B {pop pop pop pop} def\n"
"/N {newpath} def\n"
"/havetype42gdir {version cvi 2015 ge} bind def\n"; "/havetype42gdir {version cvi 2015 ge} bind def\n";
static const char psbeginsetup[] = static const char psbeginsetup[] =
...@@ -195,6 +196,8 @@ static const char psarrayput[] = ...@@ -195,6 +196,8 @@ static const char psarrayput[] =
static const char psarraydef[] = static const char psarraydef[] =
"/%s %d array def\n"; "/%s %d array def\n";
static const char psenddocument[] =
"\n%%EndDocument\n";
DWORD PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, DWORD cch) DWORD PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, DWORD cch)
{ {
...@@ -205,6 +208,11 @@ DWORD PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, DWORD cch) ...@@ -205,6 +208,11 @@ DWORD PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, DWORD cch)
return 0; return 0;
} }
if(physDev->job.in_passthrough) { /* Was in PASSTHROUGH mode */
WriteSpool16( physDev->job.hJob, (LPSTR)psenddocument, sizeof(psenddocument)-1 );
physDev->job.in_passthrough = physDev->job.had_passthrough_rect = FALSE;
}
if(physDev->job.OutOfPage) { /* Will get here after NEWFRAME Escape */ if(physDev->job.OutOfPage) { /* Will get here after NEWFRAME Escape */
if( !PSDRV_StartPage(physDev) ) if( !PSDRV_StartPage(physDev) )
return 0; return 0;
......
...@@ -321,6 +321,8 @@ typedef struct { ...@@ -321,6 +321,8 @@ typedef struct {
BOOL OutOfPage; /* Page header not sent yet */ BOOL OutOfPage; /* Page header not sent yet */
INT PageNo; INT PageNo;
BOOL quiet; /* Don't actually output anything */ BOOL quiet; /* Don't actually output anything */
BOOL in_passthrough; /* In PASSTHROUGH mode */
BOOL had_passthrough_rect; /* See the comment in PSDRV_Rectangle */
} JOB; } JOB;
typedef struct { typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment