IDEMPIERE-2479:Printformat, Surpress Repeats doesnt works for HTML and XLS

some time m_layout is null example when call report from report button at standart window
This commit is contained in:
hieplq 2015-07-07 22:06:23 +07:00
parent 931ede8620
commit 6aa16930d2
5 changed files with 29 additions and 13 deletions

View File

@ -131,7 +131,7 @@ public abstract class AbstractExcelExporter
/** Styles cache */ /** Styles cache */
private HashMap<String, HSSFCellStyle> m_styles = new HashMap<String, HSSFCellStyle>(); private HashMap<String, HSSFCellStyle> m_styles = new HashMap<String, HSSFCellStyle>();
protected boolean[] colSuppressRepeats; protected Boolean[] colSuppressRepeats;
public AbstractExcelExporter() { public AbstractExcelExporter() {
m_workbook = new HSSFWorkbook(); m_workbook = new HSSFWorkbook();

View File

@ -39,7 +39,7 @@ extends AbstractExcelExporter
private PrintData m_printData; private PrintData m_printData;
private MPrintFormat m_printFormat; private MPrintFormat m_printFormat;
public PrintDataExcelExporter(PrintData printData, MPrintFormat printFormat, boolean[] colSuppressRepeats) { public PrintDataExcelExporter(PrintData printData, MPrintFormat printFormat, Boolean[] colSuppressRepeats) {
super(); super();
this.m_printData = printData; this.m_printData = printData;
this.m_printFormat = printFormat; this.m_printFormat = printFormat;

View File

@ -629,7 +629,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
thead thead = new thead(); thead thead = new thead();
tbody tbody = new tbody(); tbody tbody = new tbody();
Object [] preValues = new Object [m_layout.colSuppressRepeats.length]; Boolean [] colSuppressRepeats = m_layout == null ? LayoutEngine.getColSuppressRepeats(m_printFormat):m_layout.colSuppressRepeats;
Object [] preValues = new Object [colSuppressRepeats.length];
int printColIndex = -1; int printColIndex = -1;
// for all rows (-1 = header row) // for all rows (-1 = header row)
for (int row = -1; row < m_printData.getRowCount(); row++) for (int row = -1; row < m_printData.getRowCount(); row++)
@ -687,7 +688,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
Object obj = m_printData.getNode(new Integer(item.getAD_Column_ID())); Object obj = m_printData.getNode(new Integer(item.getAD_Column_ID()));
if (obj == null){ if (obj == null){
td.addElement("&nbsp;"); td.addElement("&nbsp;");
if (m_layout.colSuppressRepeats[printColIndex]){ if (colSuppressRepeats[printColIndex]){
preValues[printColIndex] = null; preValues[printColIndex] = null;
} }
} }
@ -696,7 +697,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
PrintDataElement pde = (PrintDataElement) obj; PrintDataElement pde = (PrintDataElement) obj;
String value = pde.getValueDisplay(language); // formatted String value = pde.getValueDisplay(language); // formatted
if (m_layout.colSuppressRepeats[printColIndex]){ if (colSuppressRepeats[printColIndex]){
if (value.equals(preValues[printColIndex])){ if (value.equals(preValues[printColIndex])){
td.addElement("&nbsp;"); td.addElement("&nbsp;");
continue; continue;
@ -898,7 +899,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
delimiter = '\t'; delimiter = '\t';
try try
{ {
Object [] preValues = new Object [m_layout.colSuppressRepeats.length]; Boolean [] colSuppressRepeats = m_layout == null ? LayoutEngine.getColSuppressRepeats(m_printFormat):m_layout.colSuppressRepeats;
Object [] preValues = new Object [colSuppressRepeats.length];
int printColIndex = -1; int printColIndex = -1;
// for all rows (-1 = header row) // for all rows (-1 = header row)
for (int row = -1; row < m_printData.getRowCount(); row++) for (int row = -1; row < m_printData.getRowCount(); row++)
@ -930,7 +932,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
Object obj = m_printData.getNode(new Integer(item.getAD_Column_ID())); Object obj = m_printData.getNode(new Integer(item.getAD_Column_ID()));
String data = ""; String data = "";
if (obj == null){ if (obj == null){
if (m_layout.colSuppressRepeats[printColIndex]){ if (colSuppressRepeats[printColIndex]){
preValues[printColIndex] = null; preValues[printColIndex] = null;
} }
} }
@ -942,7 +944,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
else else
data = pde.getValueDisplay(language); // formatted data = pde.getValueDisplay(language); // formatted
if (m_layout.colSuppressRepeats[printColIndex]){ if (colSuppressRepeats[printColIndex]){
if (data.equals(preValues[printColIndex])){ if (data.equals(preValues[printColIndex])){
continue; continue;
}else{ }else{
@ -1229,7 +1231,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
public void createXLS(File outFile, Language language) public void createXLS(File outFile, Language language)
throws Exception throws Exception
{ {
PrintDataExcelExporter exp = new PrintDataExcelExporter(getPrintData(), getPrintFormat(), m_layout.colSuppressRepeats); Boolean [] colSuppressRepeats = m_layout == null ? LayoutEngine.getColSuppressRepeats(m_printFormat):m_layout.colSuppressRepeats;
PrintDataExcelExporter exp = new PrintDataExcelExporter(getPrintData(), getPrintFormat(), colSuppressRepeats);
exp.export(outFile, language); exp.export(outFile, language);
} }

View File

@ -40,6 +40,7 @@ import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -225,7 +226,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
/** Image Size */ /** Image Size */
public static Dimension IMAGE_SIZE = new Dimension(10,10); public static Dimension IMAGE_SIZE = new Dimension(10,10);
public boolean[] colSuppressRepeats; public Boolean[] colSuppressRepeats;
static { static {
Toolkit tk = Toolkit.getDefaultToolkit(); Toolkit tk = Toolkit.getDefaultToolkit();
@ -1605,7 +1606,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
int[] columnMaxWidth = new int[columnCount]; int[] columnMaxWidth = new int[columnCount];
int[] columnMaxHeight = new int[columnCount]; int[] columnMaxHeight = new int[columnCount];
boolean[] fixedWidth = new boolean [columnCount]; boolean[] fixedWidth = new boolean [columnCount];
colSuppressRepeats = new boolean[columnCount]; colSuppressRepeats = new Boolean[columnCount];
String[] columnJustification = new String[columnCount]; String[] columnJustification = new String[columnCount];
HashMap<Integer,Integer> additionalLines = new HashMap<Integer,Integer>(); HashMap<Integer,Integer> additionalLines = new HashMap<Integer,Integer>();
@ -1973,4 +1974,16 @@ public class LayoutEngine implements Pageable, Printable, Doc
return m_PrintInfo; return m_PrintInfo;
} }
public static Boolean [] getColSuppressRepeats (MPrintFormat format){
List<Boolean> colSuppressRepeats = new ArrayList<>();
for (int c = 0; c < format.getItemCount(); c++)
{
MPrintFormatItem item = format.getItem(c);
if (item.isPrinted())
{
colSuppressRepeats.add(item.isSuppressRepeats());
}
}
return colSuppressRepeats.toArray(new Boolean[0]);
}
} // LayoutEngine } // LayoutEngine

View File

@ -120,7 +120,7 @@ public class TableElement extends PrintElement
SerializableMatrix<Serializable> data, KeyNamePair[] pk, String pkColumnName, SerializableMatrix<Serializable> data, KeyNamePair[] pk, String pkColumnName,
int pageNoStart, Rectangle firstPage, Rectangle nextPages, int repeatedColumns, HashMap<Integer,Integer> additionalLines, int pageNoStart, Rectangle firstPage, Rectangle nextPages, int repeatedColumns, HashMap<Integer,Integer> additionalLines,
HashMap<Point,Font> rowColFont, HashMap<Point,Color> rowColColor, HashMap<Point,Color> rowColBackground, HashMap<Point,Font> rowColFont, HashMap<Point,Color> rowColColor, HashMap<Point,Color> rowColBackground,
MPrintTableFormat tFormat, ArrayList<Integer> pageBreak, boolean[] colSuppressRepeats) MPrintTableFormat tFormat, ArrayList<Integer> pageBreak, Boolean[] colSuppressRepeats)
{ {
super(); super();
if (log.isLoggable(Level.FINE)) if (log.isLoggable(Level.FINE))
@ -212,7 +212,7 @@ public class TableElement extends PrintElement
/** Bounds of next Pages */ /** Bounds of next Pages */
private Rectangle m_nextPages; private Rectangle m_nextPages;
private boolean[] m_colSuppressRepeats; private Boolean[] m_colSuppressRepeats;
/** repeat first x columns on - X Axis follow pages */ /** repeat first x columns on - X Axis follow pages */
private int m_repeatedColumns; private int m_repeatedColumns;