8011069: Printing: NullPointerException since jdk8 b82 showing native Page Setup Dialog.
Reviewed-by: bae, prr
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Mon May 06 12:57:42 2013 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Tue May 07 09:32:37 2013 -0700
@@ -35,6 +35,7 @@
import javax.print.*;
import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.HashPrintRequestAttributeSet;
import sun.java2d.*;
import sun.print.*;
@@ -96,6 +97,14 @@
return false;
}
+ if (attributes == null) {
+ attributes = new HashPrintRequestAttributeSet();
+ }
+
+ if (getPrintService() instanceof StreamPrintService) {
+ return super.printDialog(attributes);
+ }
+
return jobSetup(getPageable(), checkAllowedToPrintToFile());
}
@@ -130,6 +139,10 @@
return page;
}
+ if (getPrintService() instanceof StreamPrintService) {
+ return super.pageDialog(page);
+ }
+
PageFormat pageClone = (PageFormat) page.clone();
boolean doIt = pageSetup(pageClone, null);
return doIt ? pageClone : page;
--- a/jdk/src/share/classes/sun/print/RasterPrinterJob.java Mon May 06 12:57:42 2013 -0700
+++ b/jdk/src/share/classes/sun/print/RasterPrinterJob.java Tue May 07 09:32:37 2013 -0700
@@ -607,13 +607,17 @@
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 @@
orient = OrientationRequested.PORTRAIT;
}
- if (attributes == null) {
- attributes = new HashPrintRequestAttributeSet();
+ if (media != null) {
+ pageAttributes.add(media);
}
- if (media != null) {
- attributes.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 @@
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) {
}