From 934462de8ef6406b91bc61886886de16de1d840c Mon Sep 17 00:00:00 2001 From: mjudd Date: Fri, 25 Mar 2011 23:59:36 -0500 Subject: [PATCH] BUG [3104044] - Fix NPE in PrintService see: https://sourceforge.net/tracker/?func=detail&aid=3104044&group_id=176962&atid=879332 Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=3104044 --- .../src/org/compiere/print/CPaper.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/print/CPaper.java b/org.adempiere.base/src/org/compiere/print/CPaper.java index 2d93463aa0..e6ec31d904 100644 --- a/org.adempiere.base/src/org/compiere/print/CPaper.java +++ b/org.adempiere.base/src/org/compiere/print/CPaper.java @@ -365,16 +365,23 @@ public class CPaper extends Paper StringBuffer sb = new StringBuffer(); // Print Media size //AA Goodwill : Custom Paper Support - if (m_mediaSize != null){ - sb.append(m_mediaSize.getMediaSizeName()); + if (m_mediaSize != null && m_mediaSize.getMediaSizeName() != null) + { + // Print dimension + sb.append(m_mediaSize.getMediaSizeName()); String name = m_mediaSize.getMediaSizeName().toString(); - if (!name.startsWith("iso")) - sb.append(" - ").append(m_mediaSize.toString(MediaSize.INCH,"\"")) - .append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.INCH,"\"")); - if (!name.startsWith("na")) - sb.append(" - ").append(m_mediaSize.toString(MediaSize.MM,"mm")) - .append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.MM,"mm")); + + if(name != null) + { + if (!name.startsWith("iso")) + sb.append(" - ").append(m_mediaSize.toString(MediaSize.INCH,"\"")) + .append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.INCH,"\"")); + if (!name.startsWith("na")) + sb.append(" - ").append(m_mediaSize.toString(MediaSize.MM,"mm")) + .append(" (").append(getMediaPrintableArea().toString(MediaPrintableArea.MM,"mm")); + } + // Print Orientation sb.append(") - ") .append(Msg.getMsg(ctx, m_landscape ? "Landscape" : "Portrait"));