[WINSPOOL]
authorColin Finck <colin@reactos.org>
Sun, 17 May 2015 17:19:37 +0000 (17:19 +0000)
committerColin Finck <colin@reactos.org>
Sun, 17 May 2015 17:19:37 +0000 (17:19 +0000)
- Use GdiConvertToDevmodeW instead of duplicating code.
- Fix the spec2def call here as well.

svn path=/branches/colins-printing-for-freedom/; revision=67816

reactos/win32ss/printing/base/winspool/CMakeLists.txt
reactos/win32ss/printing/base/winspool/main.c

index 670959e..4227804 100644 (file)
@@ -1,7 +1,7 @@
 
 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/idl)
 add_rpc_files(client ${REACTOS_SOURCE_DIR}/include/reactos/idl/winspool.idl)
-spec2def(winspool winspool.spec ADD_IMPORTLIB)
+spec2def(winspool.drv winspool.spec ADD_IMPORTLIB)
 
 list(APPEND SOURCE
     main.c
@@ -17,6 +17,6 @@ add_library(winspool SHARED
 set_target_properties(winspool PROPERTIES SUFFIX ".drv")
 set_module_type(winspool win32dll UNICODE)
 target_link_libraries(winspool wine ${PSEH_LIB})
-add_importlibs(winspool rpcrt4 msvcrt kernel32 ntdll)
+add_importlibs(winspool gdi32 rpcrt4 msvcrt kernel32 ntdll)
 add_pch(winspool precomp.h SOURCE)
 add_cd_file(TARGET winspool DESTINATION reactos/system32 FOR all)
index 32c9fa2..5e798c3 100644 (file)
@@ -165,7 +165,6 @@ BOOL WINAPI
 OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
 {
     BOOL ReturnValue = FALSE;
-    DEVMODEW wDevMode;
     PWSTR pwszPrinterName = NULL;
     PWSTR pwszDatatype = NULL;
     PRINTER_DEFAULTSW wDefault = { 0 };
@@ -207,22 +206,15 @@ OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefaul
         }
 
         if (pDefault->pDevMode)
-        {
-            // Fixed size strings, so no additional memory needs to be allocated
-            MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pDefault->pDevMode->dmDeviceName, -1, wDevMode.dmDeviceName, sizeof(wDevMode.dmDeviceName) / sizeof(WCHAR));
-            MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pDefault->pDevMode->dmFormName, -1, wDevMode.dmFormName, sizeof(wDevMode.dmFormName) / sizeof(WCHAR));
-
-            // Use CopyMemory to copy over several structure values in one step
-            CopyMemory(&wDevMode.dmSpecVersion, &pDefault->pDevMode->dmSpecVersion, (ULONG_PTR)&wDevMode.dmCollate - (ULONG_PTR)&wDevMode.dmSpecVersion + sizeof(wDevMode.dmCollate));
-            CopyMemory(&wDevMode.dmLogPixels, &pDefault->pDevMode->dmLogPixels, (ULONG_PTR)&wDevMode.dmPanningHeight - (ULONG_PTR)&wDevMode.dmLogPixels + sizeof(wDevMode.dmPanningHeight));
-
-            wDefault.pDevMode = &wDevMode;
-        }
+            wDefault.pDevMode = GdiConvertToDevmodeW(pDefault->pDevMode);
     }
 
     ReturnValue = OpenPrinterW(pwszPrinterName, phPrinter, &wDefault);
 
 Cleanup:
+    if (wDefault.pDevMode)
+        HeapFree(GetProcessHeap(), 0, wDefault.pDevMode);
+
     if (pwszPrinterName)
         HeapFree(GetProcessHeap(), 0, pwszPrinterName);