Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 311121 - draw2d print to new widows7 XPS format not operational
Summary: draw2d print to new widows7 XPS format not operational
Status: RESOLVED INVALID
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Alex Boyko CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 313357
Blocks:
  Show dependency tree
 
Reported: 2010-04-29 18:08 EDT by Steven Punte CLA
Modified: 2015-11-21 08:22 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Punte CLA 2010-04-29 18:08:12 EDT
Build Identifier: M20080911-1700

On Windows XP, a conventional print option is to output to an <>.mdi (Microsoft Document Image) file.  On Windows, this has been replaced with format XPS (microsoft's XML Paper Specification).

A modified "org.eclipse.draw2d.printing.PrintExample.java" will properly output to the MDI format on Windows XP, but not output to XPS on Windows7.  The modification is simply to include a Print Dialog that allows the user to select desired printer.

This problem is also verified with Eclipse 3.5.2

Reproducible: Always

Steps to Reproduce:
1.  Modify "org.eclipse.draw2d.printing.PrintExample.java" with new printIt() as provided below.
2.  Run example on Windows XP: confirm printing to MDI file and format works.
3.  run example on Widwos 7, confirm printing to XPS file and format does NOT work.

static private void printIt(IFigure fig){

	PrintDialog dialog = new PrintDialog(Display.getCurrent().getActiveShell(), SWT.NULL);
	PrinterData data = dialog.open();

	if (data != null) {

		Printer p = new Printer(data);
		PrintOperation op = new PrintFigureOperation(p, fig);
		op.setPrintMargin(new Insets(0,0,0,0));
		op.run("Test");  // "Test" is the print job name
		p.dispose();
	}
}
Comment 1 Steven Punte CLA 2010-04-29 18:30:48 EDT
Note that GEF examples, at least Logic, do NOT exhibit this problem.
Comment 2 Steven Punte CLA 2010-04-29 18:31:51 EDT
Note that it seems like ONLY the last figure in a depth first recursive walk of a Figure tree, is rendered onto XPS.
Comment 3 Alex Boyko CLA 2010-05-18 00:42:44 EDT
This is most likely an issue with SWT Win 7 printing.

Here is an SWT snippet that reproduces the problem:
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.printing.*;

public class TestSnippet {

public static void main (String [] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.open ();
	PrinterData data = Printer.getDefaultPrinterData();
	if (data == null) {
		System.out.println("Warning: No default printer.");
		display.dispose();
		return;
	}
	Printer printer = new Printer(data);
	if (printer.startJob("SWT Printing Snippet")) {
		Color black = printer.getSystemColor(SWT.COLOR_BLACK);
		Color white = printer.getSystemColor(SWT.COLOR_WHITE);
		Rectangle trim = printer.computeTrim(0, 0, 0, 0);
		Point dpi = printer.getDPI();
		int leftMargin = dpi.x + trim.x; // one inch from left side of paper
		if (leftMargin < 0) leftMargin = -trim.x;  // make sure to print on the printable area 
		int topMargin = dpi.y / 2 + trim.y; // one-half inch from top edge of paper
		if (topMargin < 0) topMargin = -trim.y;  // make sure to print on the printable area 
		GC gc = new GC(printer);
		if (printer.startPage()) {
			gc.setBackground(white);
			gc.setForeground(black);
			float scale = Math.round((float) printer.getDPI().x / display.getDPI().x);
			int size = Math.round(scale * 50);
			int offset = Math.round(scale * 5);
			gc.setClipping(leftMargin, topMargin, size , size);
			gc.drawRectangle(leftMargin, topMargin, size, size);
			gc.setClipping(leftMargin + size + offset, topMargin, size, size);
			gc.drawRectangle(leftMargin + size + offset, topMargin, size, size);
			printer.endPage();
		}
		gc.dispose();
		printer.endJob();
	}
	printer.dispose();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose();
}
}

Snippet needs to be verified on Win XP. If it works on XP, I'll raise a defect against SWT.
Comment 4 Alex Boyko CLA 2010-05-18 10:02:27 EDT
The snippet works on XP - SWT issue.
Comment 5 Alexander Nyßen CLA 2015-11-21 08:22:20 EST
Resolving as INVALID due to comment #4.