changeset 47230:9712e5af1645

8186987: NullPointerException in RasterPrinterJob without PrinterResolution Reviewed-by: prr, pnarayanan
author psadhukhan
date Thu, 21 Sep 2017 16:21:14 +0530
parents 7d4896d180e7
children 8fb3178bef87
files src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp
diffstat 1 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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;
   }