winspool: Use configuration file for DocumentPropertiesW.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-09-13 13:50:08 +02:00 committed by Alexandre Julliard
parent 0da3ffc4b9
commit 68feb134af
1 changed files with 21 additions and 52 deletions

View File

@ -187,6 +187,7 @@ typedef struct
/* entry points */ /* entry points */
DWORD (WINAPI *pDrvDeviceCapabilities)(HANDLE, const WCHAR *, WORD, void *, const DEVMODEW *); DWORD (WINAPI *pDrvDeviceCapabilities)(HANDLE, const WCHAR *, WORD, void *, const DEVMODEW *);
INT (WINAPI *pDrvDocumentProperties)(HWND, const WCHAR *, DEVMODEW *, DEVMODEW *, DWORD);
WCHAR name[1]; WCHAR name[1];
} config_module_t; } config_module_t;
@ -623,6 +624,7 @@ static config_module_t *get_config_module(const WCHAR *device, BOOL grab)
ret->ref = 2; /* one for config_module and one for the caller */ ret->ref = 2; /* one for config_module and one for the caller */
ret->module = driver_module; ret->module = driver_module;
ret->pDrvDeviceCapabilities = (void *)GetProcAddress(driver_module, "DrvDeviceCapabilities"); ret->pDrvDeviceCapabilities = (void *)GetProcAddress(driver_module, "DrvDeviceCapabilities");
ret->pDrvDocumentProperties = (void *)GetProcAddress(driver_module, "DrvDocumentProperties");
lstrcpyW(ret->name, device); lstrcpyW(ret->name, device);
wine_rb_put(&config_modules, ret->name, &ret->entry); wine_rb_put(&config_modules, ret->name, &ret->entry);
@ -1878,36 +1880,6 @@ static job_t *get_job(HANDLE hprn, DWORD JobId)
return NULL; return NULL;
} }
/***********************************************************
* DEVMODEcpyAtoW
*/
static LPDEVMODEW DEVMODEcpyAtoW(DEVMODEW *dmW, const DEVMODEA *dmA)
{
BOOL Formname;
ptrdiff_t off_formname = (const char *)dmA->dmFormName - (const char *)dmA;
DWORD size;
Formname = (dmA->dmSize > off_formname);
size = dmA->dmSize + CCHDEVICENAME + (Formname ? CCHFORMNAME : 0);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dmA->dmDeviceName, -1,
dmW->dmDeviceName, CCHDEVICENAME);
if(!Formname) {
memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion,
dmA->dmSize - CCHDEVICENAME);
} else {
memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion,
off_formname - CCHDEVICENAME);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dmA->dmFormName, -1,
dmW->dmFormName, CCHFORMNAME);
memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA->dmSize -
(off_formname + CCHFORMNAME));
}
dmW->dmSize = size;
memcpy((char *)dmW + dmW->dmSize, (const char *)dmA + dmA->dmSize,
dmA->dmDriverExtra);
return dmW;
}
/****************************************************************** /******************************************************************
* convert_printerinfo_W_to_A [internal] * convert_printerinfo_W_to_A [internal]
* *
@ -2587,39 +2559,36 @@ end:
/***************************************************************************** /*****************************************************************************
* 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,
LPDEVMODEW pDevModeOutput, LPDEVMODEW pDevModeOutput,
LPDEVMODEW pDevModeInput, DWORD fMode) LPDEVMODEW pDevModeInput, DWORD fMode)
{ {
config_module_t *config = NULL;
LPSTR pDeviceNameA = strdupWtoA(pDeviceName); const WCHAR *device = NULL;
LPDEVMODEA pDevModeInputA;
LPDEVMODEA pDevModeOutputA = NULL;
LONG ret; LONG ret;
TRACE("(%p,%p,%s,%p,%p,%d)\n", TRACE("(%p,%p,%s,%p,%p,%d)\n",
hWnd,hPrinter,debugstr_w(pDeviceName),pDevModeOutput,pDevModeInput, hWnd, hPrinter, debugstr_w(pDeviceName), pDevModeOutput, pDevModeInput, fMode);
fMode);
if(pDevModeOutput) { device = pDeviceName && pDeviceName[0] ? pDeviceName : get_opened_printer_name(hPrinter);
ret = DocumentPropertiesA(hWnd, hPrinter, pDeviceNameA, NULL, NULL, 0); if (!device) {
if(ret < 0) return ret; ERR("no device name\n");
pDevModeOutputA = HeapAlloc(GetProcessHeap(), 0, ret); return -1;
} }
pDevModeInputA = (fMode & DM_IN_BUFFER) ? DEVMODEdupWtoA(pDevModeInput) : NULL;
ret = DocumentPropertiesA(hWnd, hPrinter, pDeviceNameA, pDevModeOutputA, config = get_config_module(device, TRUE);
pDevModeInputA, fMode); if (!config) {
if(pDevModeOutput) { ERR("Could not load config module for %s\n", debugstr_w(device));
DEVMODEcpyAtoW(pDevModeOutput, pDevModeOutputA); return -1;
HeapFree(GetProcessHeap(),0,pDevModeOutputA);
} }
if(fMode == 0 && ret > 0)
ret += (CCHDEVICENAME + CCHFORMNAME); /* FIXME: This uses Wine-specific config file entry point.
HeapFree(GetProcessHeap(),0,pDevModeInputA); * We should use DrvDevicePropertySheets instead (requires CPSUI support first).
HeapFree(GetProcessHeap(),0,pDeviceNameA); */
ret = config->pDrvDocumentProperties(hWnd, device, pDevModeOutput, pDevModeInput, fMode);
release_config_module(config);
return ret; return ret;
} }