Huw Davies : wineps: Add a helper to find a duplex entry.

Alexandre Julliard julliard at winehq.org
Mon Apr 16 13:35:46 CDT 2012


Module: wine
Branch: master
Commit: 64edac40efb156156ccaac5d24d90caefdc20708
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=64edac40efb156156ccaac5d24d90caefdc20708

Author: Huw Davies <huw at codeweavers.com>
Date:   Mon Apr 16 13:18:39 2012 +0100

wineps: Add a helper to find a duplex entry.

---

 dlls/wineps.drv/driver.c |   14 ++++++++++++++
 dlls/wineps.drv/ps.c     |   17 +++--------------
 dlls/wineps.drv/psdrv.h  |    1 +
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/dlls/wineps.drv/driver.c b/dlls/wineps.drv/driver.c
index c9c5b19..9443c66 100644
--- a/dlls/wineps.drv/driver.c
+++ b/dlls/wineps.drv/driver.c
@@ -67,6 +67,20 @@ PAGESIZE *find_pagesize( PPD *ppd, PSDRV_DEVMODE *dm )
     return NULL;
 }
 
+DUPLEX *find_duplex( PPD *ppd, PSDRV_DEVMODE *dm )
+{
+    DUPLEX *duplex;
+    WORD win_duplex = dm->dmPublic.dmFields & DM_DUPLEX ? dm->dmPublic.dmDuplex : 0;
+
+    if (win_duplex == 0) return NULL; /* Not capable */
+
+    LIST_FOR_EACH_ENTRY( duplex, &ppd->Duplexes, DUPLEX, entry )
+        if (duplex->WinDuplex == win_duplex)
+            return duplex;
+
+    return NULL;
+}
+
 /************************************************************************
  *
  *		PSDRV_MergeDevmodes
diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c
index f4444e8..4aca6f1 100644
--- a/dlls/wineps.drv/ps.c
+++ b/dlls/wineps.drv/ps.c
@@ -303,8 +303,7 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title )
     char *buf, *escaped_title;
     INPUTSLOT *slot = find_slot( physDev->pi->ppd, physDev->Devmode );
     PAGESIZE *page = find_pagesize( physDev->pi->ppd, physDev->Devmode );
-    DUPLEX *duplex;
-    int win_duplex;
+    DUPLEX *duplex = find_duplex( physDev->pi->ppd, physDev->Devmode );
     int llx, lly, urx, ury;
     int ret, len;
 
@@ -356,18 +355,8 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title )
     if (page && page->InvocationString)
         PSDRV_WriteFeature( dev, "*PageSize", page->Name, page->InvocationString );
 
-    win_duplex = physDev->Devmode->dmPublic.dmFields & DM_DUPLEX ?
-        physDev->Devmode->dmPublic.dmDuplex : 0;
-    LIST_FOR_EACH_ENTRY( duplex, &physDev->pi->ppd->Duplexes, DUPLEX, entry )
-    {
-        if(duplex->WinDuplex == win_duplex) {
-	    if(duplex->InvocationString) {
-	        PSDRV_WriteFeature(dev, "*Duplex", duplex->Name,
-			     duplex->InvocationString);
-		break;
-	    }
-	}
-    }
+    if (duplex && duplex->InvocationString)
+        PSDRV_WriteFeature( dev, "*Duplex", duplex->Name, duplex->InvocationString );
 
     write_spool( dev, psendsetup, strlen(psendsetup) );
 
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index f314dd9..38e8306 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -403,6 +403,7 @@ extern char *PSDRV_ANSIVector[256] DECLSPEC_HIDDEN;
 
 extern INPUTSLOT *find_slot( PPD *ppd, PSDRV_DEVMODE *dm );
 extern PAGESIZE *find_pagesize( PPD *ppd, PSDRV_DEVMODE *dm );
+extern DUPLEX *find_duplex( PPD *ppd, PSDRV_DEVMODE *dm );
 
 /* GDI driver functions */
 extern BOOL PSDRV_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,




More information about the wine-cvs mailing list