From 3f35202a0135f9e19f5481a1186c48eb8c2d2b24 Mon Sep 17 00:00:00 2001 From: armenrz Date: Tue, 10 Feb 2009 14:22:05 +0000 Subject: [PATCH] --- base/src/org/compiere/print/CPaper.java | 71 ++++++++++++++++---- base/src/org/compiere/print/MPrintPaper.java | 18 ++++- 2 files changed, 74 insertions(+), 15 deletions(-) diff --git a/base/src/org/compiere/print/CPaper.java b/base/src/org/compiere/print/CPaper.java index e601b8e925..7819430cfd 100644 --- a/base/src/org/compiere/print/CPaper.java +++ b/base/src/org/compiere/print/CPaper.java @@ -37,6 +37,11 @@ import org.compiere.util.Msg; /** * Adempiere Paper * + * Change log: + * + * * @author Jorg Janke * @version $Id: CPaper.java,v 1.2 2006/07/30 00:53:02 jjanke Exp $ */ @@ -142,12 +147,45 @@ public class CPaper extends Paper log.fine(mediaSize.getMediaSizeName() + ": " + m_mediaSize + " - Landscape=" + m_landscape); } // setMediaSize + /** + * Get Media Size + * @return media size + */ + //AA Goodwill : Custom Paper Support + public CPaper (double x, double y, boolean landscape, + double left, double top, double right, double bottom) + { + super(); + setMediaSize (x,y, landscape); + setImageableArea(left, top, getWidth()-left-right, getHeight()-top-bottom); + } + + public void setMediaSize (double x, double y, boolean landscape) + { + if (x == 0 || y == 0) + throw new IllegalArgumentException("MediaSize is null"); + + m_landscape = landscape; + + // Get Sise in Inch * 72 + double width = x * 72; + double height = y * 72; + // Set Size + setSize (width, height); + log.fine("Width & Height" + ": " + String.valueOf(x) + "/" + String.valueOf(y) + " - Landscape=" + m_landscape); + } // setMediaSize + //End Of AA Goodwill + /** * Get Media Size * @return media size */ public MediaSizeName getMediaSizeName() { + //AA Goodwill: Custom Paper Support + if(m_mediaSize == null) + return MediaSizeName.ISO_A4; + //End Of AA Goodwill return m_mediaSize.getMediaSizeName(); } // getMediaSizeName @@ -224,7 +262,9 @@ public class CPaper extends Paper else pratts.add(OrientationRequested.PORTRAIT); // media = na-legal - pratts.add(getMediaSizeName()); + //Commented Lines By AA Goodwill: Custom Paper Support + //pratts.add(getMediaSizeName()); + //End Of AA Goodwill return pratts; } // getPrintRequestAttributes @@ -313,18 +353,23 @@ public class CPaper extends Paper { StringBuffer sb = new StringBuffer(); // Print Media size - sb.append(m_mediaSize.getMediaSizeName()); - // Print dimension - 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")); - // Print Orientation - sb.append(") - ") - .append(Msg.getMsg(ctx, m_landscape ? "Landscape" : "Portrait")); + //AA Goodwill : Custom Paper Support + if (m_mediaSize != null){ + sb.append(m_mediaSize.getMediaSizeName()); + // Print dimension + 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")); + // Print Orientation + sb.append(") - ") + .append(Msg.getMsg(ctx, m_landscape ? "Landscape" : "Portrait")); + } + else sb.append("Custom - ").append(toString()); + //End Of AA Goodwill return sb.toString(); } // toString diff --git a/base/src/org/compiere/print/MPrintPaper.java b/base/src/org/compiere/print/MPrintPaper.java index d3c58510ac..42f322f176 100644 --- a/base/src/org/compiere/print/MPrintPaper.java +++ b/base/src/org/compiere/print/MPrintPaper.java @@ -34,6 +34,11 @@ import org.compiere.util.Language; /** * AD_PrintPaper Print Paper Model * + * Change log: + * + * * @author Jorg Janke * @version $Id: MPrintPaper.java,v 1.3 2006/07/30 00:53:02 jjanke Exp $ */ @@ -198,8 +203,17 @@ public class MPrintPaper extends X_AD_PrintPaper */ public CPaper getCPaper() { - CPaper retValue = new CPaper (getMediaSize(), isLandscape(), - getMarginLeft(), getMarginTop(), getMarginRight(), getMarginBottom()); + //Modify Lines By AA Goodwill : Custom Paper Support + CPaper retValue; + if (getCode().toLowerCase().startsWith("custom")){ + retValue = new CPaper (getSizeX().doubleValue(), getSizeY().doubleValue(), isLandscape(), + getMarginLeft(), getMarginTop(), getMarginRight(), getMarginBottom()); + } + else{ + retValue = new CPaper (getMediaSize(), isLandscape(), + getMarginLeft(), getMarginTop(), getMarginRight(), getMarginBottom()); + } + //End Of AA Goodwill return retValue; } // getCPaper