]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Passthrough printing fix
authorToni Wilen <twilen@winuae.net>
Sun, 13 Apr 2025 17:02:30 +0000 (20:02 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 13 Apr 2025 17:02:30 +0000 (20:02 +0300)
od-win32/parser.cpp

index 83f31e165a0ba2a927921610e858d9b7d2b15ffb..08fd86ff65163a7ca0cef621b9ec31aaf2e21a5c 100644 (file)
@@ -501,6 +501,26 @@ void unload_ghostscript (void)
        psmode = 0;
 }
 
+static DWORD GetPrinterDriverVersion(HANDLE handle)
+{
+       DWORD needed = 0;
+       DWORD version = 0;
+       GetPrinterDriver(handle, NULL, 2, NULL, 0, &needed);
+       if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+               return -1;
+       }
+       BYTE *buffer = xcalloc(BYTE, needed);
+       if (buffer) {
+               if (!GetPrinterDriver(handle, NULL, 2, buffer, needed, &needed)) {
+                       xfree(buffer);
+                       return -1;
+               }
+               version = ((DRIVER_INFO_2*)buffer)->cVersion;
+               xfree(buffer);
+       }
+       return version;
+}
+
 static void openprinter (void)
 {
        DOC_INFO_1 DocInfo;
@@ -519,10 +539,11 @@ static void openprinter (void)
        } else if (hPrt == INVALID_HANDLE_VALUE) {
                flushprtbuf ();
                if (OpenPrinter (currprefs.prtname, &hPrt, NULL)) {
+                       DWORD version = GetPrinterDriverVersion(hPrt);
                        // Fill in the structure with info about this "document."
                        DocInfo.pDocName = _T("WinUAE Document");
                        DocInfo.pOutputFile = NULL;
-                       DocInfo.pDatatype = (currprefs.parallel_matrix_emulation || currprefs.parallel_postscript_detection) ? _T("TEXT") : _T("RAW");
+                       DocInfo.pDatatype = (currprefs.parallel_matrix_emulation || currprefs.parallel_postscript_detection) ? _T("TEXT") : (version >= 4 ? _T("XPS_PASS") : _T("RAW"));
                        // Inform the spooler the document is beginning.
                        if ((dwJob = StartDocPrinter (hPrt, 1, (LPBYTE)&DocInfo)) == 0) {
                                error = GetLastError();