r15004 by jghali - fix ps printing problem on win32 after the recent changes in pslib related to landscape printing

scribus-commit scribus-commit at lists.scribus.net
Fri Apr 23 20:50:22 CEST 2010


Revision: 15004
Author: jghali
Date: 2010-04-23T18:43:47.325737Z
Commit message: fix ps printing problem on win32 after the recent changes in pslib related to landscape printing

Changeset: 
M  /branches/Version135/Scribus/scribus/scprintengine_gdi.cpp
M  /branches/Version135/Scribus/scribus/scprintengine_gdi.h

Diffs:
Index: scribus/scprintengine_gdi.h
===================================================================
--- scribus/scprintengine_gdi.h	(revision 15003)
+++ scribus/scprintengine_gdi.h	(revision 15004)
@@ -77,10 +77,11 @@
 	\param printerDC the printer deice context
 	\param pageWidth width
 	\param pageHeight height
+	\parah landscape the page is to be printer in landscape mode
 	\retval bool true on success 
 	\author Jean Ghali
 	*/
-	bool sendPSFile ( QString filePath, HDC printerDC, int pageWidth, int pageHeight );
+	bool sendPSFile ( QString filePath, HDC printerDC, int pageWidth, int pageHeight, bool landscape );
 	/*! \brief Set device params into DEVMODE structure according to print options
 	Set printing params according to options and DEVMODE structure
 	\param options print options
Index: scribus/scprintengine_gdi.cpp
===================================================================
--- scribus/scprintengine_gdi.cpp	(revision 15003)
+++ scribus/scprintengine_gdi.cpp	(revision 15004)
@@ -12,6 +12,7 @@
 #error "This file compiles on win32 platform only!"
 #endif
 
+#include <algorithm>
 #include <memory>
 #include <valarray>
 #include <windows.h>
@@ -471,7 +472,7 @@
 		double bleedH = options.bleeds.Left + options.bleeds.Right;
 		double bleedV = options.bleeds.Top  + options.bleeds.Bottom;
 		StartPage( printerDC );
-		succeed = sendPSFile( tempFilePath, printerDC, page->width() + bleedH, page->height() + bleedV);
+		succeed = sendPSFile( tempFilePath, printerDC, page->width() + bleedH, page->height() + bleedV, (page->PageOri == 1));
 		EndPage( printerDC );
 	}
 	
@@ -497,7 +498,7 @@
 	return succeed;
 }
 
-bool ScPrintEngine_GDI::sendPSFile( QString filePath, HDC printerDC, int pageWidth, int pageHeight  )
+bool ScPrintEngine_GDI::sendPSFile( QString filePath, HDC printerDC, int pageWidth, int pageHeight, bool landscape )
 {
 	int  escape;
 	int  logPixelsX;
@@ -553,9 +554,30 @@
 	if( ExtEscape( printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, NULL) <= 0 )
 		return false;
 
+	// Match Postscript and GDI coordinate system
+	sprintf( (char*) sps.data, "0 %0.3f neg translate\n", (double) physicalHeight );
+	sps.numBytes = strlen( (char*) sps.data );
+	if( ExtEscape( printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, NULL) <= 0 )
+		return false;
+
+	// In case of landscape printing, pslib will rotate the page
+	// we must take that into account
+	if (landscape)
+	{
+		sprintf( (char*) sps.data, "-90 rotate %0.3f %0.3f translate\n", (double) -pageHeight, 0.0);
+		sps.numBytes = strlen( (char*) sps.data );
+		if( ExtEscape( printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, NULL) <= 0 )
+			return false;
+		transx = ( physicalHeight - pageHeight ) / -2.0;
+		transy = ( physicalWidth  - pageWidth ) / 2.0;
+	}
+	else
+	{
+		transx = ( physicalWidth  - pageWidth ) / 2.0;
+		transy = ( physicalHeight - pageHeight ) / 2.0;
+	}
+
 	// Center the printed page in paper zone
-	transx = ( physicalWidth - pageWidth ) / 2.0;
-	transy = ( pageHeight - physicalHeight ) / 2.0 - pageHeight;
 	sprintf( (char*) sps.data, "%0.3f %0.3f translate\n", transx, transy );
 	sps.numBytes = strlen( (char*) sps.data );
 	if( ExtEscape( printerDC, escape, sizeof(sps), (LPCSTR) &sps, 0, NULL) <= 0 )




More information about the scribus-commit mailing list