Commit 3a910c7d authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Convert CreateDC to unicode in the driver interface.

parent 06e34ffc
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "winreg.h" #include "winreg.h"
#include "gdi.h" #include "gdi.h"
#include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(driver); WINE_DEFAULT_DEBUG_CHANNEL(driver);
...@@ -232,22 +233,23 @@ static struct graphics_driver *load_display_driver(void) ...@@ -232,22 +233,23 @@ static struct graphics_driver *load_display_driver(void)
/********************************************************************** /**********************************************************************
* DRIVER_load_driver * DRIVER_load_driver
*/ */
const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name ) const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
{ {
HMODULE module; HMODULE module;
struct graphics_driver *driver; struct graphics_driver *driver;
static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
EnterCriticalSection( &driver_section ); EnterCriticalSection( &driver_section );
/* display driver is a special case */ /* display driver is a special case */
if (!strcasecmp( name, "display" )) if (!strcmpiW( name, displayW ))
{ {
driver = load_display_driver(); driver = load_display_driver();
LeaveCriticalSection( &driver_section ); LeaveCriticalSection( &driver_section );
return &driver->funcs; return &driver->funcs;
} }
if ((module = GetModuleHandleA( name ))) if ((module = GetModuleHandleW( name )))
{ {
for (driver = first_driver; driver; driver = driver->next) for (driver = first_driver; driver; driver = driver->next)
{ {
...@@ -260,7 +262,7 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name ) ...@@ -260,7 +262,7 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name )
} }
} }
if (!(module = LoadLibraryA( name ))) if (!(module = LoadLibraryW( name )))
{ {
LeaveCriticalSection( &driver_section ); LeaveCriticalSection( &driver_section );
return NULL; return NULL;
...@@ -273,7 +275,7 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name ) ...@@ -273,7 +275,7 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name )
return NULL; return NULL;
} }
TRACE( "loaded driver %p for %s\n", driver, name ); TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
LeaveCriticalSection( &driver_section ); LeaveCriticalSection( &driver_section );
return &driver->funcs; return &driver->funcs;
} }
...@@ -332,33 +334,74 @@ void DRIVER_release_driver( const DC_FUNCTIONS *funcs ) ...@@ -332,33 +334,74 @@ void DRIVER_release_driver( const DC_FUNCTIONS *funcs )
* DRIVER_GetDriverName * DRIVER_GetDriverName
* *
*/ */
BOOL DRIVER_GetDriverName( LPCSTR device, LPSTR driver, DWORD size ) BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
{ {
char *p; static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
static const WCHAR empty_strW[] = { 0 };
WCHAR *p;
/* display is a special case */ /* display is a special case */
if (!strcasecmp( device, "display" )) if (!strcmpiW( device, displayW ))
{ {
lstrcpynA( driver, "display", size ); lstrcpynW( driver, displayW, size );
return TRUE; return TRUE;
} }
size = GetProfileStringA("devices", device, "", driver, size); size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
if(!size) { if(!size) {
WARN("Unable to find '%s' in [devices] section of win.ini\n", device); WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
return FALSE; return FALSE;
} }
p = strchr(driver, ','); p = strchrW(driver, ',');
if(!p) if(!p)
{ {
WARN("'%s' entry in [devices] section of win.ini is malformed.\n", device); WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
return FALSE; return FALSE;
} }
*p = '\0'; *p = 0;
TRACE("Found '%s' for '%s'\n", driver, device); TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
return TRUE; return TRUE;
} }
/***********************************************************************
* GdiConvertToDevmodeW (GDI32.@)
*/
DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
{
DEVMODEW *dmW;
WORD dmW_size;
dmW_size = dmA->dmSize + CCHDEVICENAME;
if (dmA->dmSize >= (char *)dmA->dmFormName - (char *)dmA + CCHFORMNAME)
dmW_size += CCHFORMNAME;
dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
if (!dmW) return NULL;
MultiByteToWideChar(CP_ACP, 0, dmA->dmDeviceName, CCHDEVICENAME,
dmW->dmDeviceName, CCHDEVICENAME);
/* copy slightly more, to avoid long computations */
memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA->dmSize - CCHDEVICENAME);
if (dmA->dmSize >= (char *)dmA->dmFormName - (char *)dmA + CCHFORMNAME)
{
MultiByteToWideChar(CP_ACP, 0, dmA->dmFormName, CCHFORMNAME,
dmW->dmFormName, CCHFORMNAME);
if (dmA->dmSize > (char *)&dmA->dmLogPixels - (char *)dmA)
memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA->dmSize - ((char *)&dmA->dmLogPixels - (char *)dmA));
}
if (dmA->dmDriverExtra)
memcpy((char *)dmW + dmW_size, (char *)dmA + dmA->dmSize, dmA->dmDriverExtra);
dmW->dmSize = dmW_size;
return dmW;
}
/***************************************************************************** /*****************************************************************************
* @ [GDI32.100] * @ [GDI32.100]
* *
...@@ -400,12 +443,16 @@ INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice, ...@@ -400,12 +443,16 @@ INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
* *
* This should load the correct driver for lpszDevice and calls this driver's * This should load the correct driver for lpszDevice and calls this driver's
* ExtDeviceMode proc. * ExtDeviceMode proc.
*
* FIXME: convert ExtDeviceMode to unicode in the driver interface
*/ */
INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd, INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
LPDEVMODEA lpdmOutput, LPSTR lpszDevice, LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
LPSTR lpszPort, LPDEVMODEA lpdmInput, LPSTR lpszPort, LPDEVMODEA lpdmInput,
LPSTR lpszProfile, DWORD fwMode ) LPSTR lpszProfile, DWORD fwMode )
{ {
WCHAR deviceW[300];
WCHAR bufW[300];
char buf[300]; char buf[300];
HDC hdc; HDC hdc;
DC *dc; DC *dc;
...@@ -415,7 +462,12 @@ INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd, ...@@ -415,7 +462,12 @@ INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
TRACE("(%p, %p, %s, %s, %p, %s, %ld)\n", TRACE("(%p, %p, %s, %s, %p, %s, %ld)\n",
hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode ); hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
if(!DRIVER_GetDriverName( lpszDevice, buf, sizeof(buf) )) return -1; if (!lpszDevice) return -1;
if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1; if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
...@@ -449,11 +501,15 @@ INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice, ...@@ -449,11 +501,15 @@ INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
* *
* This should load the correct driver for lpszDevice and calls this driver's * This should load the correct driver for lpszDevice and calls this driver's
* DeviceCapabilities proc. * DeviceCapabilities proc.
*
* FIXME: convert DeviceCapabilities to unicode in the driver interface
*/ */
DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort, DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
WORD fwCapability, LPSTR lpszOutput, WORD fwCapability, LPSTR lpszOutput,
LPDEVMODEA lpdm ) LPDEVMODEA lpdm )
{ {
WCHAR deviceW[300];
WCHAR bufW[300];
char buf[300]; char buf[300];
HDC hdc; HDC hdc;
DC *dc; DC *dc;
...@@ -461,7 +517,12 @@ DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort, ...@@ -461,7 +517,12 @@ DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm ); TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
if(!DRIVER_GetDriverName( lpszDevice, buf, sizeof(buf) )) return -1; if (!lpszDevice) return -1;
if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1; if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
......
...@@ -130,6 +130,7 @@ ...@@ -130,6 +130,7 @@
@ stub GdiConvertMetaFilePict @ stub GdiConvertMetaFilePict
@ stub GdiConvertPalette @ stub GdiConvertPalette
@ stub GdiConvertRegion @ stub GdiConvertRegion
@ stdcall GdiConvertToDevmodeW(ptr)
@ stub GdiCreateLocalBitmap @ stub GdiCreateLocalBitmap
@ stub GdiCreateLocalBrush @ stub GdiCreateLocalBrush
@ stub GdiCreateLocalEnhMetaFile @ stub GdiCreateLocalEnhMetaFile
......
...@@ -39,14 +39,14 @@ BOOL TTYDRV_GDI_Initialize(void) ...@@ -39,14 +39,14 @@ BOOL TTYDRV_GDI_Initialize(void)
/*********************************************************************** /***********************************************************************
* TTYDRV_DC_CreateDC * TTYDRV_DC_CreateDC
*/ */
BOOL TTYDRV_DC_CreateDC(DC *dc, TTYDRV_PDEVICE **pdev, LPCSTR driver, LPCSTR device, BOOL TTYDRV_DC_CreateDC(DC *dc, TTYDRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR device,
LPCSTR output, const DEVMODEA *initData) LPCWSTR output, const DEVMODEW *initData)
{ {
TTYDRV_PDEVICE *physDev; TTYDRV_PDEVICE *physDev;
TRACE("(%p, %s, %s, %s, %p)\n", TRACE("(%p, %s, %s, %s, %p)\n",
dc, debugstr_a(driver), debugstr_a(device), dc, debugstr_w(driver), debugstr_w(device),
debugstr_a(output), initData); debugstr_w(output), initData);
physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TTYDRV_PDEVICE)); physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TTYDRV_PDEVICE));
if(!physDev) { if(!physDev) {
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "winreg.h" #include "winreg.h"
#include "winspool.h" #include "winspool.h"
#include "winerror.h" #include "winerror.h"
#include "heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(psdrv); WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
...@@ -251,14 +252,53 @@ static void PSDRV_UpdateDevCaps( PSDRV_PDEVICE *physDev ) ...@@ -251,14 +252,53 @@ static void PSDRV_UpdateDevCaps( PSDRV_PDEVICE *physDev )
} }
/***********************************************************
* DEVMODEdupWtoA
*
* Creates an ascii copy of supplied devmode on heap
*
* Copied from dlls/winspool/info.c until full unicodification
*/
static LPDEVMODEA DEVMODEdupWtoA(HANDLE heap, const DEVMODEW *dmW)
{
LPDEVMODEA dmA;
DWORD size;
BOOL Formname;
ptrdiff_t off_formname = (char *)dmW->dmFormName - (char *)dmW;
if(!dmW) return NULL;
Formname = (dmW->dmSize > off_formname);
size = dmW->dmSize - CCHDEVICENAME - (Formname ? CCHFORMNAME : 0);
dmA = HeapAlloc(heap, HEAP_ZERO_MEMORY, size + dmW->dmDriverExtra);
WideCharToMultiByte(CP_ACP, 0, dmW->dmDeviceName, -1, dmA->dmDeviceName,
CCHDEVICENAME, NULL, NULL);
if(!Formname) {
memcpy(&dmA->dmSpecVersion, &dmW->dmSpecVersion,
dmW->dmSize - CCHDEVICENAME * sizeof(WCHAR));
} else {
memcpy(&dmA->dmSpecVersion, &dmW->dmSpecVersion,
off_formname - CCHDEVICENAME * sizeof(WCHAR));
WideCharToMultiByte(CP_ACP, 0, dmW->dmFormName, -1, dmA->dmFormName,
CCHFORMNAME, NULL, NULL);
memcpy(&dmA->dmLogPixels, &dmW->dmLogPixels, dmW->dmSize -
(off_formname + CCHFORMNAME * sizeof(WCHAR)));
}
dmA->dmSize = size;
memcpy((char *)dmA + dmA->dmSize, (char *)dmW + dmW->dmSize,
dmW->dmDriverExtra);
return dmA;
}
/********************************************************************** /**********************************************************************
* PSDRV_CreateDC * PSDRV_CreateDC
*/ */
BOOL PSDRV_CreateDC( DC *dc, PSDRV_PDEVICE **pdev, LPCSTR driver, LPCSTR device, BOOL PSDRV_CreateDC( DC *dc, PSDRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR device,
LPCSTR output, const DEVMODEA* initData ) LPCWSTR output, const DEVMODEW* initData )
{ {
PSDRV_PDEVICE *physDev; PSDRV_PDEVICE *physDev;
PRINTERINFO *pi; PRINTERINFO *pi;
char deviceA[CCHDEVICENAME];
/* If no device name was specified, retrieve the device name /* If no device name was specified, retrieve the device name
* from the DEVMODE structure from the DC's physDev. * from the DEVMODE structure from the DC's physDev.
...@@ -266,11 +306,14 @@ BOOL PSDRV_CreateDC( DC *dc, PSDRV_PDEVICE **pdev, LPCSTR driver, LPCSTR device, ...@@ -266,11 +306,14 @@ BOOL PSDRV_CreateDC( DC *dc, PSDRV_PDEVICE **pdev, LPCSTR driver, LPCSTR device,
if ( !device && *pdev ) if ( !device && *pdev )
{ {
physDev = *pdev; physDev = *pdev;
device = physDev->Devmode->dmPublic.dmDeviceName; strcpy(deviceA, physDev->Devmode->dmPublic.dmDeviceName);
} }
pi = PSDRV_FindPrinterInfo(device); else
WideCharToMultiByte(CP_ACP, 0, device, -1, deviceA, sizeof(deviceA), NULL, NULL);
pi = PSDRV_FindPrinterInfo(deviceA);
TRACE("(%s %s %s %p)\n", driver, device, output, initData); TRACE("(%s %s %s %p)\n", debugstr_w(driver), debugstr_w(device),
debugstr_w(output), initData);
if(!pi) return FALSE; if(!pi) return FALSE;
...@@ -301,14 +344,15 @@ BOOL PSDRV_CreateDC( DC *dc, PSDRV_PDEVICE **pdev, LPCSTR driver, LPCSTR device, ...@@ -301,14 +344,15 @@ BOOL PSDRV_CreateDC( DC *dc, PSDRV_PDEVICE **pdev, LPCSTR driver, LPCSTR device,
physDev->logPixelsY = physDev->pi->ppd->DefaultResolution; physDev->logPixelsY = physDev->pi->ppd->DefaultResolution;
if (output) { if (output) {
physDev->job.output = HeapAlloc( PSDRV_Heap, 0, strlen(output)+1 ); physDev->job.output = HEAP_strdupWtoA( PSDRV_Heap, 0, output );
strcpy( physDev->job.output, output );
} else } else
physDev->job.output = NULL; physDev->job.output = NULL;
physDev->job.hJob = 0; physDev->job.hJob = 0;
if(initData) { if(initData) {
PSDRV_MergeDevmodes(physDev->Devmode, (PSDRV_DEVMODEA *)initData, pi); DEVMODEA *devmodeA = DEVMODEdupWtoA(PSDRV_Heap, initData);
PSDRV_MergeDevmodes(physDev->Devmode, (PSDRV_DEVMODEA *)devmodeA, pi);
HeapFree(PSDRV_Heap, 0, devmodeA);
} }
PSDRV_UpdateDevCaps(physDev); PSDRV_UpdateDevCaps(physDev);
......
...@@ -4,7 +4,7 @@ TOPOBJDIR = ../.. ...@@ -4,7 +4,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = winspool.drv MODULE = winspool.drv
IMPORTS = user32 advapi32 kernel32 ntdll IMPORTS = user32 gdi32 advapi32 kernel32 ntdll
LDDLLFLAGS = @LDDLLFLAGS@ LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o SYMBOLFILE = $(MODULE).tmp.o
......
...@@ -516,27 +516,6 @@ static LPDEVMODEW DEVMODEcpyAtoW(DEVMODEW *dmW, const DEVMODEA *dmA) ...@@ -516,27 +516,6 @@ static LPDEVMODEW DEVMODEcpyAtoW(DEVMODEW *dmW, const DEVMODEA *dmA)
} }
/*********************************************************** /***********************************************************
* DEVMODEdupAtoW
* Creates a unicode copy of supplied devmode on heap
*/
static LPDEVMODEW DEVMODEdupAtoW(HANDLE heap, const DEVMODEA *dmA)
{
LPDEVMODEW dmW;
DWORD size;
BOOL Formname;
ptrdiff_t off_formname;
TRACE("\n");
if(!dmA) return NULL;
off_formname = (char *)dmA->dmFormName - (char *)dmA;
Formname = (dmA->dmSize > off_formname);
size = dmA->dmSize + CCHDEVICENAME + (Formname ? CCHFORMNAME : 0);
dmW = HeapAlloc(heap, HEAP_ZERO_MEMORY, size + dmA->dmDriverExtra);
return DEVMODEcpyAtoW(dmW, dmA);
}
/***********************************************************
* DEVMODEdupWtoA * DEVMODEdupWtoA
* Creates an ascii copy of supplied devmode on heap * Creates an ascii copy of supplied devmode on heap
*/ */
...@@ -590,7 +569,7 @@ static LPPRINTER_INFO_2W PRINTER_INFO_2AtoW(HANDLE heap, LPPRINTER_INFO_2A piA) ...@@ -590,7 +569,7 @@ static LPPRINTER_INFO_2W PRINTER_INFO_2AtoW(HANDLE heap, LPPRINTER_INFO_2A piA)
piW->pDriverName = asciitounicode(&usBuffer,piA->pDriverName); piW->pDriverName = asciitounicode(&usBuffer,piA->pDriverName);
piW->pComment = asciitounicode(&usBuffer,piA->pComment); piW->pComment = asciitounicode(&usBuffer,piA->pComment);
piW->pLocation = asciitounicode(&usBuffer,piA->pLocation); piW->pLocation = asciitounicode(&usBuffer,piA->pLocation);
piW->pDevMode = DEVMODEdupAtoW(heap, piA->pDevMode); piW->pDevMode = GdiConvertToDevmodeW(piA->pDevMode);
piW->pSepFile = asciitounicode(&usBuffer,piA->pSepFile); piW->pSepFile = asciitounicode(&usBuffer,piA->pSepFile);
piW->pPrintProcessor = asciitounicode(&usBuffer,piA->pPrintProcessor); piW->pPrintProcessor = asciitounicode(&usBuffer,piA->pPrintProcessor);
piW->pDatatype = asciitounicode(&usBuffer,piA->pDatatype); piW->pDatatype = asciitounicode(&usBuffer,piA->pDatatype);
...@@ -711,6 +690,7 @@ INT WINAPI DeviceCapabilitiesW(LPCWSTR pDevice, LPCWSTR pPort, ...@@ -711,6 +690,7 @@ INT WINAPI DeviceCapabilitiesW(LPCWSTR pDevice, LPCWSTR pPort,
/****************************************************************** /******************************************************************
* DocumentPropertiesA [WINSPOOL.@] * DocumentPropertiesA [WINSPOOL.@]
* *
* FIXME: implement DocumentPropertiesA via DocumentPropertiesW, not vice versa
*/ */
LONG WINAPI DocumentPropertiesA(HWND hWnd,HANDLE hPrinter, LONG WINAPI DocumentPropertiesA(HWND hWnd,HANDLE hPrinter,
LPSTR pDeviceName, LPDEVMODEA pDevModeOutput, LPSTR pDeviceName, LPDEVMODEA pDevModeOutput,
...@@ -752,6 +732,8 @@ LONG WINAPI DocumentPropertiesA(HWND hWnd,HANDLE hPrinter, ...@@ -752,6 +732,8 @@ LONG WINAPI DocumentPropertiesA(HWND hWnd,HANDLE hPrinter,
/***************************************************************************** /*****************************************************************************
* DocumentPropertiesW (WINSPOOL.@) * DocumentPropertiesW (WINSPOOL.@)
*
* FIXME: implement DocumentPropertiesA via DocumentPropertiesW, not vice versa
*/ */
LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter, LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter,
LPWSTR pDeviceName, LPWSTR pDeviceName,
...@@ -802,8 +784,7 @@ BOOL WINAPI OpenPrinterA(LPSTR lpPrinterName,HANDLE *phPrinter, ...@@ -802,8 +784,7 @@ BOOL WINAPI OpenPrinterA(LPSTR lpPrinterName,HANDLE *phPrinter,
if(pDefault) { if(pDefault) {
DefaultW.pDatatype = asciitounicode(&usBuffer,pDefault->pDatatype); DefaultW.pDatatype = asciitounicode(&usBuffer,pDefault->pDatatype);
DefaultW.pDevMode = DEVMODEdupAtoW(GetProcessHeap(), DefaultW.pDevMode = GdiConvertToDevmodeW(pDefault->pDevMode);
pDefault->pDevMode);
DefaultW.DesiredAccess = pDefault->DesiredAccess; DefaultW.DesiredAccess = pDefault->DesiredAccess;
pDefaultW = &DefaultW; pDefaultW = &DefaultW;
} }
...@@ -1565,7 +1546,7 @@ static void WINSPOOL_GetDefaultDevMode( ...@@ -1565,7 +1546,7 @@ static void WINSPOOL_GetDefaultDevMode(
if(unicode) { if(unicode) {
if(buflen >= sizeof(DEVMODEW)) { if(buflen >= sizeof(DEVMODEW)) {
DEVMODEW *pdmW = DEVMODEdupAtoW(GetProcessHeap(), &dm ); DEVMODEW *pdmW = GdiConvertToDevmodeW(&dm);
memcpy(ptr, pdmW, sizeof(DEVMODEW)); memcpy(ptr, pdmW, sizeof(DEVMODEW));
HeapFree(GetProcessHeap(),0,pdmW); HeapFree(GetProcessHeap(),0,pdmW);
} }
...@@ -1608,7 +1589,7 @@ static BOOL WINSPOOL_GetDevModeFromReg(HKEY hkey, LPCWSTR ValueName, ...@@ -1608,7 +1589,7 @@ static BOOL WINSPOOL_GetDevModeFromReg(HKEY hkey, LPCWSTR ValueName,
if(unicode) { if(unicode) {
sz += (CCHDEVICENAME + CCHFORMNAME); sz += (CCHDEVICENAME + CCHFORMNAME);
if(buflen >= sz) { if(buflen >= sz) {
DEVMODEW *dmW = DEVMODEdupAtoW(GetProcessHeap(), (DEVMODEA*)ptr); DEVMODEW *dmW = GdiConvertToDevmodeW((DEVMODEA*)ptr);
memcpy(ptr, dmW, sz); memcpy(ptr, dmW, sz);
HeapFree(GetProcessHeap(),0,dmW); HeapFree(GetProcessHeap(),0,dmW);
} }
......
...@@ -87,8 +87,8 @@ void X11DRV_GDI_Finalize(void) ...@@ -87,8 +87,8 @@ void X11DRV_GDI_Finalize(void)
/********************************************************************** /**********************************************************************
* X11DRV_CreateDC * X11DRV_CreateDC
*/ */
BOOL X11DRV_CreateDC( DC *dc, X11DRV_PDEVICE **pdev, LPCSTR driver, LPCSTR device, BOOL X11DRV_CreateDC( DC *dc, X11DRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR device,
LPCSTR output, const DEVMODEA* initData ) LPCWSTR output, const DEVMODEW* initData )
{ {
X11DRV_PDEVICE *physDev; X11DRV_PDEVICE *physDev;
......
...@@ -181,7 +181,7 @@ typedef struct tagDC_FUNCS ...@@ -181,7 +181,7 @@ typedef struct tagDC_FUNCS
BOOL (*pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT); BOOL (*pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT);
BOOL (*pCloseFigure)(PHYSDEV); BOOL (*pCloseFigure)(PHYSDEV);
BOOL (*pCreateBitmap)(PHYSDEV,HBITMAP); BOOL (*pCreateBitmap)(PHYSDEV,HBITMAP);
BOOL (*pCreateDC)(DC *,PHYSDEV *,LPCSTR,LPCSTR,LPCSTR,const DEVMODEA*); BOOL (*pCreateDC)(DC *,PHYSDEV *,LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*);
HBITMAP (*pCreateDIBSection)(PHYSDEV,BITMAPINFO *,UINT,LPVOID *,HANDLE,DWORD,DWORD); HBITMAP (*pCreateDIBSection)(PHYSDEV,BITMAPINFO *,UINT,LPVOID *,HANDLE,DWORD,DWORD);
BOOL (*pDeleteBitmap)(HBITMAP); BOOL (*pDeleteBitmap)(HBITMAP);
BOOL (*pDeleteDC)(PHYSDEV); BOOL (*pDeleteDC)(PHYSDEV);
...@@ -451,10 +451,10 @@ extern void *GDI_GetObjPtr( HGDIOBJ, WORD ); ...@@ -451,10 +451,10 @@ extern void *GDI_GetObjPtr( HGDIOBJ, WORD );
extern void GDI_ReleaseObj( HGDIOBJ ); extern void GDI_ReleaseObj( HGDIOBJ );
extern void GDI_CheckNotLock(void); extern void GDI_CheckNotLock(void);
extern const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name ); extern const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name );
extern const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs ); extern const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs );
extern void DRIVER_release_driver( const DC_FUNCTIONS *funcs ); extern void DRIVER_release_driver( const DC_FUNCTIONS *funcs );
extern BOOL DRIVER_GetDriverName( LPCSTR device, LPSTR driver, DWORD size ); extern BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size );
extern POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut ); extern POINT *GDI_Bezier( const POINT *Points, INT count, INT *nPtsOut );
......
...@@ -3228,6 +3228,7 @@ BOOL WINAPI FlattenPath(HDC); ...@@ -3228,6 +3228,7 @@ BOOL WINAPI FlattenPath(HDC);
BOOL WINAPI FloodFill(HDC,INT,INT,COLORREF); BOOL WINAPI FloodFill(HDC,INT,INT,COLORREF);
BOOL WINAPI FrameRgn(HDC,HRGN,HBRUSH,INT,INT); BOOL WINAPI FrameRgn(HDC,HRGN,HBRUSH,INT,INT);
BOOL WINAPI GdiComment(HDC,UINT,const BYTE *); BOOL WINAPI GdiComment(HDC,UINT,const BYTE *);
DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *);
BOOL WINAPI GdiFlush(void); BOOL WINAPI GdiFlush(void);
INT WINAPI GetArcDirection(HDC); INT WINAPI GetArcDirection(HDC);
BOOL WINAPI GetAspectRatioFilterEx(HDC,LPSIZE); BOOL WINAPI GetAspectRatioFilterEx(HDC,LPSIZE);
......
...@@ -24,11 +24,13 @@ ...@@ -24,11 +24,13 @@
#include <string.h> #include <string.h>
#include "windef.h" #include "windef.h"
#include "wingdi.h" #include "wingdi.h"
#include "winternl.h"
#include "winerror.h" #include "winerror.h"
#include "wownt32.h" #include "wownt32.h"
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "gdi.h" #include "gdi.h"
#include "heap.h" #include "heap.h"
#include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dc); WINE_DEFAULT_DEBUG_CHANNEL(dc);
...@@ -565,27 +567,27 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level ) ...@@ -565,27 +567,27 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level )
/*********************************************************************** /***********************************************************************
* CreateDCA (GDI32.@) * CreateDCW (GDI32.@)
*/ */
HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output, HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
const DEVMODEA *initData ) const DEVMODEW *initData )
{ {
HDC hdc; HDC hdc;
DC * dc; DC * dc;
const DC_FUNCTIONS *funcs; const DC_FUNCTIONS *funcs;
char buf[300]; WCHAR buf[300];
GDI_CheckNotLock(); GDI_CheckNotLock();
if (!device || !DRIVER_GetDriverName( device, buf, sizeof(buf) )) if (!device || !DRIVER_GetDriverName( device, buf, 300 ))
{ {
if (!driver) return 0; if (!driver) return 0;
strcpy(buf, driver); strcpyW(buf, driver);
} }
if (!(funcs = DRIVER_load_driver( buf ))) if (!(funcs = DRIVER_load_driver( buf )))
{ {
ERR( "no driver found for %s\n", buf ); ERR( "no driver found for %s\n", debugstr_w(buf) );
return 0; return 0;
} }
if (!(dc = DC_AllocDC( funcs, DC_MAGIC ))) if (!(dc = DC_AllocDC( funcs, DC_MAGIC )))
...@@ -597,7 +599,7 @@ HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output, ...@@ -597,7 +599,7 @@ HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output,
dc->hBitmap = GetStockObject( DEFAULT_BITMAP ); dc->hBitmap = GetStockObject( DEFAULT_BITMAP );
TRACE("(driver=%s, device=%s, output=%s): returning %p\n", TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
debugstr_a(driver), debugstr_a(device), debugstr_a(output), dc->hSelf ); debugstr_w(driver), debugstr_w(device), debugstr_w(output), dc->hSelf );
if (dc->funcs->pCreateDC && if (dc->funcs->pCreateDC &&
!dc->funcs->pCreateDC( dc, &dc->physDev, buf, device, output, initData )) !dc->funcs->pCreateDC( dc, &dc->physDev, buf, device, output, initData ))
...@@ -622,20 +624,31 @@ HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output, ...@@ -622,20 +624,31 @@ HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output,
/*********************************************************************** /***********************************************************************
* CreateDCW (GDI32.@) * CreateDCA (GDI32.@)
*/ */
HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output,
const DEVMODEW *initData ) const DEVMODEA *initData )
{ {
LPSTR driverA = HEAP_strdupWtoA( GetProcessHeap(), 0, driver ); UNICODE_STRING driverW, deviceW, outputW;
LPSTR deviceA = HEAP_strdupWtoA( GetProcessHeap(), 0, device ); HDC ret;
LPSTR outputA = HEAP_strdupWtoA( GetProcessHeap(), 0, output );
HDC res = CreateDCA( driverA, deviceA, outputA, if (driver) RtlCreateUnicodeStringFromAsciiz(&driverW, driver);
(const DEVMODEA *)initData /*FIXME*/ ); else driverW.Buffer = NULL;
HeapFree( GetProcessHeap(), 0, driverA );
HeapFree( GetProcessHeap(), 0, deviceA ); if (device) RtlCreateUnicodeStringFromAsciiz(&deviceW, device);
HeapFree( GetProcessHeap(), 0, outputA ); else deviceW.Buffer = NULL;
return res;
if (output) RtlCreateUnicodeStringFromAsciiz(&outputW, output);
else outputW.Buffer = NULL;
ret = CreateDCW( driverW.Buffer, deviceW.Buffer, outputW.Buffer,
(const DEVMODEW *)initData /*FIXME*/ );
RtlFreeUnicodeString(&driverW);
RtlFreeUnicodeString(&deviceW);
RtlFreeUnicodeString(&outputW);
return ret;
} }
...@@ -681,7 +694,8 @@ HDC WINAPI CreateCompatibleDC( HDC hdc ) ...@@ -681,7 +694,8 @@ HDC WINAPI CreateCompatibleDC( HDC hdc )
} }
else else
{ {
funcs = DRIVER_load_driver( "DISPLAY" ); static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
funcs = DRIVER_load_driver( displayW );
physDev = NULL; physDev = NULL;
} }
......
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