8186987: NullPointerException in RasterPrinterJob without PrinterResolution
authorpsadhukhan
Thu, 21 Sep 2017 16:21:14 +0530
changeset 47230 9712e5af1645
parent 47229 7d4896d180e7
child 47231 8fb3178bef87
8186987: NullPointerException in RasterPrinterJob without PrinterResolution Reviewed-by: prr, pnarayanan
src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp
--- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp	Thu Sep 21 16:17:37 2017 +0530
+++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp	Thu Sep 21 16:21:14 2017 +0530
@@ -898,11 +898,25 @@
       defIndices[1] = pDevMode->dmMediaType;
   }
 
-  if (pDevMode->dmFields & DM_YRESOLUTION) {
-     defIndices[2]  = pDevMode->dmYResolution;
+  /*
+   * For some printer like Brother HL-2240D series
+   * pDevMode->dmYResolution is not set in pDevMode->dmFields
+   * even though pDevMode->dmYResolution is populated
+   * via ::DocumentProperties API, so for this case
+   * we populate the resolution index in default array
+   */
+  if (pDevMode->dmFields & DM_YRESOLUTION || pDevMode->dmYResolution > 0) {
+      defIndices[2]  = pDevMode->dmYResolution;
   }
 
-  if (pDevMode->dmFields & DM_PRINTQUALITY) {
+  /*
+   * For some printer like Brother HL-2240D series
+   * pDevMode->dmPrintQuality is not set in pDevMode->dmFields
+   * even though pDevMode->dmPrintQuality is populated
+   * via ::DocumentProperties API, so for this case
+   * we populate the print quality index in default array
+   */
+  if (pDevMode->dmFields & DM_PRINTQUALITY || pDevMode->dmPrintQuality != 0) {
       defIndices[3] = pDevMode->dmPrintQuality;
   }