| Summary: | draw2d print to new widows7 XPS format not operational | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Steven Punte <steven.punte> |
| Component: | GEF-Legacy Draw2d | Assignee: | Alex Boyko <aboyko> |
| Status: | RESOLVED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | aboyko, ahunter.eclipse, nyssen, steven.punte |
| Version: | 3.5.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
| Bug Depends on: | 313357 | ||
| Bug Blocks: | |||
Note that GEF examples, at least Logic, do NOT exhibit this problem. Note that it seems like ONLY the last figure in a depth first recursive walk of a Figure tree, is rendered onto XPS. 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.
The snippet works on XP - SWT issue. Resolving as INVALID due to comment #4. |
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(); } }