wineps: fix for eps files

Huw D M Davies h.davies1 at physics.ox.ac.uk
Thu Feb 12 06:06:06 CST 2004


        Huw Davies <huw at codeweavers.com>
        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.
-- 
Huw Davies
huw at codeweavers.com
Index: dlls/wineps/escape.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/escape.c,v
retrieving revision 1.22
diff -u -r1.22 escape.c
--- dlls/wineps/escape.c	11 Nov 2003 20:41:14 -0000	1.22
+++ dlls/wineps/escape.c	12 Feb 2004 11:58:57 -0000
@@ -31,6 +31,9 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
 
+static const char psbegindocument[] =
+"%%BeginDocument: Wine passthrough\n";
+
 /**********************************************************************
  *           ExtEscape  (WINEPS.@)
  */
@@ -214,6 +217,10 @@
              * length of the string, rather than 2 more.  So we'll use the WORD at
              * 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);
         }
 
@@ -373,7 +380,9 @@
     physDev->job.banding = FALSE;
     physDev->job.OutOfPage = TRUE;
     physDev->job.PageNo = 0;
-
+    physDev->job.quiet = FALSE;
+    physDev->job.in_passthrough = FALSE;
+    physDev->job.had_passthrough_rect = FALSE;
     if(doc->lpszDocName) {
         physDev->job.DocName = HeapAlloc(GetProcessHeap(), 0, strlen(doc->lpszDocName)+1);
         strcpy(physDev->job.DocName, doc->lpszDocName);
Index: dlls/wineps/graphics.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/graphics.c,v
retrieving revision 1.13
diff -u -r1.13 graphics.c
--- dlls/wineps/graphics.c	15 Jan 2004 06:19:36 -0000	1.13
+++ dlls/wineps/graphics.c	12 Feb 2004 11:58:57 -0000
@@ -124,11 +124,14 @@
     rect.bottom = bottom;
     LPtoDP( physDev->hdc, (POINT *)&rect, 2 );
 
-    /* HACK to get inserted eps files printing from Office 2k */
-    if(GetROP2(physDev->hdc) == R2_NOP) {
+    /* Windows does something truely hacky here.  If we're in passthrough mode
+       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];
-      sprintf(buf, "%ld %ld %ld %ld B\n", rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top);
-      PSDRV_WriteSpool(physDev, buf, strlen(buf));
+      sprintf(buf, "N %ld %ld %ld %ld B\n", rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top);
+      WriteSpool16(physDev->job.hJob, buf, strlen(buf));
+      physDev->job.had_passthrough_rect = TRUE;
       return TRUE;
     }
 
Index: dlls/wineps/ps.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/ps.c,v
retrieving revision 1.25
diff -u -r1.25 ps.c
--- dlls/wineps/ps.c	23 Jan 2004 02:11:29 -0000	1.25
+++ dlls/wineps/ps.c	12 Feb 2004 11:58:57 -0000
@@ -60,6 +60,7 @@
 "  for\n"
 "} bind def\n"
 "/B {pop pop pop pop} def\n"
+"/N {newpath} def\n"
 "/havetype42gdir {version cvi 2015 ge} bind def\n";
 
 static const char psbeginsetup[] =
@@ -195,6 +196,8 @@
 static const char psarraydef[] =
 "/%s %d array def\n";
 
+static const char psenddocument[] =
+"\n%%EndDocument\n";
 
 DWORD PSDRV_WriteSpool(PSDRV_PDEVICE *physDev, LPCSTR lpData, DWORD cch)
 {
@@ -203,6 +206,11 @@
     if(physDev->job.quiet) {
         TRACE("ignoring output\n");
 	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 */
Index: dlls/wineps/psdrv.h
===================================================================
RCS file: /home/wine/wine/dlls/wineps/psdrv.h,v
retrieving revision 1.48
diff -u -r1.48 psdrv.h
--- dlls/wineps/psdrv.h	15 Jan 2004 06:19:36 -0000	1.48
+++ dlls/wineps/psdrv.h	12 Feb 2004 11:58:57 -0000
@@ -321,6 +321,8 @@
     BOOL		OutOfPage;      /* Page header not sent yet */
     INT			PageNo;
     BOOL                quiet;          /* Don't actually output anything */
+    BOOL                in_passthrough; /* In PASSTHROUGH mode */
+    BOOL                had_passthrough_rect; /* See the comment in PSDRV_Rectangle */
 } JOB;
 
 typedef struct {



More information about the wine-patches mailing list