8186987: NullPointerException in RasterPrinterJob without PrinterResolution
Reviewed-by: prr, pnarayanan
--- 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;
}