https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8ad75174465ff45af8f9b…
commit 8ad75174465ff45af8f9bac12ed412df10643f62
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sun Jan 6 02:24:42 2019 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Jan 6 21:07:27 2019 +0100
[WINSPOOL] Semi implement DocumentPropertiesW
CORE-15522
---
win32ss/printing/base/winspool/printers.c | 83 ++++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 2 deletions(-)
diff --git a/win32ss/printing/base/winspool/printers.c
b/win32ss/printing/base/winspool/printers.c
index 5f130a3d15..28bce50202 100644
--- a/win32ss/printing/base/winspool/printers.c
+++ b/win32ss/printing/base/winspool/printers.c
@@ -201,12 +201,91 @@ DocumentPropertiesA(HWND hWnd, HANDLE hPrinter, LPSTR pDeviceName,
PDEVMODEA pDe
return -1;
}
+static PRINTER_INFO_9W * get_devmodeW(HANDLE hprn)
+{
+ PRINTER_INFO_9W *pi9 = NULL;
+ DWORD needed = 0;
+ BOOL res;
+
+ res = GetPrinterW(hprn, 9, NULL, 0, &needed);
+ if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER))
+ {
+ pi9 = HeapAlloc(hProcessHeap, 0, needed);
+ res = GetPrinterW(hprn, 9, (LPBYTE)pi9, needed, &needed);
+ }
+
+ if (res)
+ return pi9;
+
+ ERR("GetPrinterW failed with %u\n", GetLastError());
+ HeapFree(hProcessHeap, 0, pi9);
+ return NULL;
+}
+
LONG WINAPI
DocumentPropertiesW(HWND hWnd, HANDLE hPrinter, LPWSTR pDeviceName, PDEVMODEW
pDevModeOutput, PDEVMODEW pDevModeInput, DWORD fMode)
{
+ HANDLE hUseHandle = NULL;
+ PRINTER_INFO_9W *pi9 = NULL;
+ LONG Result = -1, Length;
+
TRACE("DocumentPropertiesW(%p, %p, %S, %p, %p, %lu)\n", hWnd, hPrinter,
pDeviceName, pDevModeOutput, pDevModeInput, fMode);
- UNIMPLEMENTED;
- return -1;
+ if (hPrinter)
+ {
+ hUseHandle = hPrinter;
+ }
+ else if (!OpenPrinterW(pDeviceName, &hUseHandle, NULL))
+ {
+ ERR("No handle, and no usable printer name passed in\n");
+ return -1;
+ }
+
+ pi9 = get_devmodeW(hUseHandle);
+
+ if (pi9)
+ {
+ Length = pi9->pDevMode->dmSize + pi9->pDevMode->dmDriverExtra;
+ // See wineps.drv PSDRV_ExtDeviceMode
+ if (fMode)
+ {
+ Result = 1; /* IDOK */
+
+ if (fMode & DM_IN_BUFFER)
+ {
+ FIXME("Merge pDevModeInput with pi9, write back to
driver!\n");
+ // See wineps.drv PSDRV_MergeDevmodes
+ }
+
+ if (fMode & DM_IN_PROMPT)
+ {
+ FIXME("Show property sheet!\n");
+ Result = 2; /* IDCANCEL */
+ }
+
+ if (fMode & (DM_OUT_BUFFER | DM_OUT_DEFAULT))
+ {
+ if (pDevModeOutput)
+ {
+ memcpy(pDevModeOutput, pi9->pDevMode, pi9->pDevMode->dmSize
+ pi9->pDevMode->dmDriverExtra);
+ }
+ else
+ {
+ ERR("No pDevModeOutput\n");
+ Result = -1;
+ }
+ }
+ }
+ else
+ {
+ Result = Length;
+ }
+
+ HeapFree(hProcessHeap, 0, pi9);
+ }
+
+ if (hUseHandle && !hPrinter)
+ ClosePrinter(hUseHandle);
+ return Result;
}
BOOL WINAPI