diff --git a/ChangeLog b/ChangeLog index 5092125ba..748bc79c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-09-27 12:19-EDT Gregory John Casamento + + * Printing/GSWIN32/GSWIN32PrinterOperation.m: Addition of function + to output to printer directly. + * Printing/GSWIN32/GNUmakefile: Change to correct linker issue + winspool was not being linked in the proper place so it was + causing unresolved references. + 2014-09-16 12:19-EDT Gregory John Casamento * Source/GSPrinting.m: Reorder printing backend load order. diff --git a/Printing/GSWIN32/GNUmakefile.preamble b/Printing/GSWIN32/GNUmakefile.preamble index bb41eebc0..80cf38d02 100644 --- a/Printing/GSWIN32/GNUmakefile.preamble +++ b/Printing/GSWIN32/GNUmakefile.preamble @@ -18,7 +18,7 @@ ADDITIONAL_INCLUDE_DIRS += -I../../Headers/Additions -I../../Headers \ -I../../Source/$(GNUSTEP_TARGET_DIR) # Additional LDFLAGS to pass to the linker -ADDITIONAL_LDFLAGS += -lwinspool +ADDITIONAL_LDFLAGS += # Additional library directories the linker should search ADDITIONAL_LIB_DIRS += -L../../Source/$(GNUSTEP_OBJ_DIR) @@ -32,7 +32,7 @@ ADDITIONAL_GUI_LIBS += # Libraries ADDITIONAL_LIBRARY_LIBS += # ObjC stuff -ADDITIONAL_OBJC_LIBS += +ADDITIONAL_OBJC_LIBS += -lwinspool #-lgnustep-gui $(SYSTEM_LIBS) # Tools ADDITIONAL_TOOL_LIBS += diff --git a/Printing/GSWIN32/GSWIN32PrintOperation.m b/Printing/GSWIN32/GSWIN32PrintOperation.m index ff9ab31ad..4aaa15f1b 100644 --- a/Printing/GSWIN32/GSWIN32PrintOperation.m +++ b/Printing/GSWIN32/GSWIN32PrintOperation.m @@ -51,6 +51,75 @@ #import "GSGuiPrivate.h" #import "GSWIN32PrintOperation.h" +BOOL RawDataToPrinter(LPSTR szPrinterName, LPBYTE lpData, DWORD dwCount) +{ + HANDLE hPrinter; + DOC_INFO_1 DocInfo; + DWORD dwJob; + DWORD dwBytesWritten; + + // Need a handle to the printer. + if( ! OpenPrinter( szPrinterName, &hPrinter, NULL ) ) + { + return FALSE; + } + + // Fill in the structure with info about this "document." + DocInfo.pDocName = "My Document"; + DocInfo.pOutputFile = NULL; + DocInfo.pDatatype = "RAW"; + + // Inform the spooler the document is beginning. + if( (dwJob = StartDocPrinter( hPrinter, 1, (LPSTR)&DocInfo )) == 0 ) + { + ClosePrinter( hPrinter ); + return FALSE; + } + + // Start a page. + if( ! StartPagePrinter( hPrinter ) ) + { + EndDocPrinter( hPrinter ); + ClosePrinter( hPrinter ); + return FALSE; + } + + // Send the data to the printer. + if( ! WritePrinter( hPrinter, lpData, dwCount, &dwBytesWritten ) ) + { + EndPagePrinter( hPrinter ); + EndDocPrinter( hPrinter ); + ClosePrinter( hPrinter ); + return FALSE; + } + + // End the page. + if( ! EndPagePrinter( hPrinter ) ) + { + EndDocPrinter( hPrinter ); + ClosePrinter( hPrinter ); + return FALSE; + } + + // Inform the spooler that the document is ending. + if( ! EndDocPrinter( hPrinter ) ) + { + ClosePrinter( hPrinter ); + return FALSE; + } + + // Tidy up the printer handle. + ClosePrinter( hPrinter ); + + // Check to see if correct number of bytes were written. + if( dwBytesWritten != dwCount ) + { + return FALSE; + } + + return TRUE; +} + //A subclass of GSPrintOperation, NOT NSPrintOperation. @implementation GSWIN32PrintOperation // @@ -61,7 +130,6 @@ return NSAllocateObject(self, 0, zone); } - - (id)initWithView:(NSView *)aView printInfo:(NSPrintInfo *)aPrintInfo {