Module: wine Branch: master Commit: a152666920b32be11b0c5d70e1b1e23f3155001b URL: http://source.winehq.org/git/wine.git/?a=commit;h=a152666920b32be11b0c5d70e1...
Author: Huw Davies huw@codeweavers.com Date: Tue Apr 3 15:25:52 2012 +0100
wineps: Store the document title as a unicode string.
---
dlls/wineps.drv/escape.c | 13 ++++--------- dlls/wineps.drv/init.c | 13 ------------- dlls/wineps.drv/ps.c | 20 ++++++++++++++------ dlls/wineps.drv/psdrv.h | 16 ++++++++++++++-- 4 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/dlls/wineps.drv/escape.c b/dlls/wineps.drv/escape.c index 66a1a89..a8a89d1 100644 --- a/dlls/wineps.drv/escape.c +++ b/dlls/wineps.drv/escape.c @@ -378,7 +378,7 @@ INT PSDRV_StartPage( PHYSDEV dev ) }
if(physDev->job.PageNo++ == 0) { - if(!PSDRV_WriteHeader( dev, physDev->job.DocName )) + if(!PSDRV_WriteHeader( dev, physDev->job.doc_name )) return 0; }
@@ -457,12 +457,7 @@ INT PSDRV_StartDoc( PHYSDEV dev, const DOCINFOW *doc ) physDev->job.quiet = FALSE; physDev->job.in_passthrough = FALSE; physDev->job.had_passthrough_rect = FALSE; - if(doc->lpszDocName) { - INT len = WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, NULL, 0, NULL, NULL ); - physDev->job.DocName = HeapAlloc( GetProcessHeap(), 0, len ); - WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, physDev->job.DocName, len, NULL, NULL ); - } else - physDev->job.DocName = NULL; + physDev->job.doc_name = strdupW( doc->lpszDocName );
return physDev->job.id; } @@ -492,8 +487,8 @@ INT PSDRV_EndDoc( PHYSDEV dev ) ClosePrinter(physDev->job.hprinter); physDev->job.hprinter = NULL; physDev->job.id = 0; - HeapFree(GetProcessHeap(), 0, physDev->job.DocName); - physDev->job.DocName = NULL; + HeapFree( GetProcessHeap(), 0, physDev->job.doc_name ); + physDev->job.doc_name = NULL;
return ret; } diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index a927338..d5c8547 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -41,7 +41,6 @@ #include "winnls.h" #include "psdrv.h" #include "winspool.h" -#include "wine/unicode.h" #include "wine/library.h" #include "wine/debug.h"
@@ -172,18 +171,6 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) return TRUE; }
-static inline WCHAR *strdupW( const WCHAR *str ) -{ - int size; - WCHAR *ret; - - if (!str) return NULL; - size = (strlenW( str ) + 1) * sizeof(WCHAR); - ret = HeapAlloc( GetProcessHeap(), 0, size ); - if (ret) memcpy( ret, str, size ); - return ret; -} - static void PSDRV_UpdateDevCaps( PSDRV_PDEVICE *physDev ) { PAGESIZE *page; diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 19784f3..8b0d576 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -241,18 +241,23 @@ static INT PSDRV_WriteFeature(PHYSDEV dev, LPCSTR feature, LPCSTR value, LPCSTR * in brackets. Truncate string to represent at most 0x80 characters. * */ -static char *escape_title(LPCSTR str) +static char *escape_title(LPCWSTR wstr) { - char *ret, *cp; + char *ret, *cp, *str; int i, extra = 0;
- if(!str) + if(!wstr) { ret = HeapAlloc(GetProcessHeap(), 0, 1); *ret = '\0'; return ret; }
+ i = WideCharToMultiByte( CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL ); + str = HeapAlloc( GetProcessHeap(), 0, i ); + if (!str) return NULL; + WideCharToMultiByte( CP_ACP, 0, wstr, -1, str, i, NULL, NULL ); + for(i = 0; i < 0x80 && str[i]; i++) { if(!isprint(str[i])) @@ -264,7 +269,7 @@ static char *escape_title(LPCSTR str) ret = HeapAlloc(GetProcessHeap(), 0, i + 1); memcpy(ret, str, i); ret[i] = '\0'; - return ret; + goto done; }
extra += 2; /* two for the brackets */ @@ -285,11 +290,14 @@ static char *escape_title(LPCSTR str) } *cp++ = ')'; *cp = '\0'; + +done: + HeapFree( GetProcessHeap(), 0, str ); return ret; }
-INT PSDRV_WriteHeader( PHYSDEV dev, LPCSTR title ) +INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title ) { PSDRV_PDEVICE *physDev = get_psdrv_dev( dev ); char *buf, *escaped_title; @@ -299,7 +307,7 @@ INT PSDRV_WriteHeader( PHYSDEV dev, LPCSTR title ) int win_duplex; int llx, lly, urx, ury;
- TRACE("%s\n", debugstr_a(title)); + TRACE("%s\n", debugstr_w(title));
escaped_title = escape_title(title); buf = HeapAlloc( PSDRV_Heap, 0, sizeof(psheader) + diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index fd82bd5..13d8de2 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -28,6 +28,7 @@ #include "wingdi.h" #include "winspool.h"
+#include "wine/unicode.h" #include "wine/gdi_driver.h" #include "wine/list.h"
@@ -347,7 +348,7 @@ typedef struct { DWORD id; /* Job id */ HANDLE hprinter; /* Printer handle */ LPWSTR output; /* Output file/port */ - LPSTR DocName; /* Document Name */ + LPWSTR doc_name; /* Document Name */ BOOL banding; /* Have we received a NEXTBAND */ BOOL OutOfPage; /* Page header not sent yet */ INT PageNo; @@ -491,7 +492,7 @@ extern void PSDRV_CreateColor( PHYSDEV dev, PSCOLOR *pscolor, COLORREF wincolor ) DECLSPEC_HIDDEN; extern char PSDRV_UnicodeToANSI(int u) DECLSPEC_HIDDEN;
-extern INT PSDRV_WriteHeader( PHYSDEV dev, LPCSTR title ) DECLSPEC_HIDDEN; +extern INT PSDRV_WriteHeader( PHYSDEV dev, LPCWSTR title ) DECLSPEC_HIDDEN; extern INT PSDRV_WriteFooter( PHYSDEV dev ) DECLSPEC_HIDDEN; extern INT PSDRV_WriteNewPage( PHYSDEV dev ) DECLSPEC_HIDDEN; extern INT PSDRV_WriteEndPage( PHYSDEV dev ) DECLSPEC_HIDDEN; @@ -580,5 +581,16 @@ extern DWORD ASCII85_encode(BYTE *in_buf, DWORD len, BYTE *out_buf) DECLSPEC_HID setlocale(LC_NUMERIC,tmplocale); \ } while (0)
+static inline WCHAR *strdupW( const WCHAR *str ) +{ + int size; + WCHAR *ret; + + if (!str) return NULL; + size = (strlenW( str ) + 1) * sizeof(WCHAR); + ret = HeapAlloc( GetProcessHeap(), 0, size ); + if (ret) memcpy( ret, str, size ); + return ret; +}
#endif