8011069: Printing: NullPointerException since jdk8 b82 showing native Page Setup Dialog
Reviewed-by: bae, prr
This commit is contained in:
parent
dbb7fe4b2a
commit
6bae4c82a9
@ -35,6 +35,7 @@ import java.security.PrivilegedAction;
|
||||
|
||||
import javax.print.*;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||
|
||||
import sun.java2d.*;
|
||||
import sun.print.*;
|
||||
@ -96,6 +97,14 @@ public class CPrinterJob extends RasterPrinterJob {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (attributes == null) {
|
||||
attributes = new HashPrintRequestAttributeSet();
|
||||
}
|
||||
|
||||
if (getPrintService() instanceof StreamPrintService) {
|
||||
return super.printDialog(attributes);
|
||||
}
|
||||
|
||||
return jobSetup(getPageable(), checkAllowedToPrintToFile());
|
||||
}
|
||||
|
||||
@ -130,6 +139,10 @@ public class CPrinterJob extends RasterPrinterJob {
|
||||
return page;
|
||||
}
|
||||
|
||||
if (getPrintService() instanceof StreamPrintService) {
|
||||
return super.pageDialog(page);
|
||||
}
|
||||
|
||||
PageFormat pageClone = (PageFormat) page.clone();
|
||||
boolean doIt = pageSetup(pageClone, null);
|
||||
return doIt ? pageClone : page;
|
||||
|
@ -607,13 +607,17 @@ public abstract class RasterPrinterJob extends PrinterJob {
|
||||
|
||||
protected void updatePageAttributes(PrintService service,
|
||||
PageFormat page) {
|
||||
if (this.attributes == null) {
|
||||
this.attributes = new HashPrintRequestAttributeSet();
|
||||
}
|
||||
|
||||
updateAttributesWithPageFormat(service, page, this.attributes);
|
||||
}
|
||||
|
||||
protected void updateAttributesWithPageFormat(PrintService service,
|
||||
PageFormat page,
|
||||
PrintRequestAttributeSet attributes) {
|
||||
if (service == null || page == null) {
|
||||
PrintRequestAttributeSet pageAttributes) {
|
||||
if (service == null || page == null || pageAttributes == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -653,13 +657,10 @@ public abstract class RasterPrinterJob extends PrinterJob {
|
||||
orient = OrientationRequested.PORTRAIT;
|
||||
}
|
||||
|
||||
if (attributes == null) {
|
||||
attributes = new HashPrintRequestAttributeSet();
|
||||
}
|
||||
if (media != null) {
|
||||
attributes.add(media);
|
||||
pageAttributes.add(media);
|
||||
}
|
||||
attributes.add(orient);
|
||||
pageAttributes.add(orient);
|
||||
|
||||
float ix = (float)(page.getPaper().getImageableX()/DPI);
|
||||
float iw = (float)(page.getPaper().getImageableWidth()/DPI);
|
||||
@ -667,7 +668,7 @@ public abstract class RasterPrinterJob extends PrinterJob {
|
||||
float ih = (float)(page.getPaper().getImageableHeight()/DPI);
|
||||
if (ix < 0) ix = 0f; if (iy < 0) iy = 0f;
|
||||
try {
|
||||
attributes.add(new MediaPrintableArea(ix, iy, iw, ih,
|
||||
pageAttributes.add(new MediaPrintableArea(ix, iy, iw, ih,
|
||||
MediaPrintableArea.INCH));
|
||||
} catch (IllegalArgumentException iae) {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user