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 */
private HashMap<String, HSSFCellStyle> m_styles = new HashMap<String, HSSFCellStyle>();
protected boolean[] colSuppressRepeats;
protected Boolean[] colSuppressRepeats;
public AbstractExcelExporter() {
m_workbook = new HSSFWorkbook();

View File

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

View File

@ -629,7 +629,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
thead thead = new thead();
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;
// for all rows (-1 = header 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()));
if (obj == null){
td.addElement("&nbsp;");
if (m_layout.colSuppressRepeats[printColIndex]){
if (colSuppressRepeats[printColIndex]){
preValues[printColIndex] = null;
}
}
@ -696,7 +697,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
PrintDataElement pde = (PrintDataElement) obj;
String value = pde.getValueDisplay(language); // formatted
if (m_layout.colSuppressRepeats[printColIndex]){
if (colSuppressRepeats[printColIndex]){
if (value.equals(preValues[printColIndex])){
td.addElement("&nbsp;");
continue;
@ -898,7 +899,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
delimiter = '\t';
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;
// for all rows (-1 = header 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()));
String data = "";
if (obj == null){
if (m_layout.colSuppressRepeats[printColIndex]){
if (colSuppressRepeats[printColIndex]){
preValues[printColIndex] = null;
}
}
@ -942,7 +944,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
else
data = pde.getValueDisplay(language); // formatted
if (m_layout.colSuppressRepeats[printColIndex]){
if (colSuppressRepeats[printColIndex]){
if (data.equals(preValues[printColIndex])){
continue;
}else{
@ -1229,7 +1231,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
public void createXLS(File outFile, Language language)
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);
}

View File

@ -40,6 +40,7 @@ import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -225,7 +226,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
/** Image Size */
public static Dimension IMAGE_SIZE = new Dimension(10,10);
public boolean[] colSuppressRepeats;
public Boolean[] colSuppressRepeats;
static {
Toolkit tk = Toolkit.getDefaultToolkit();
@ -1605,7 +1606,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
int[] columnMaxWidth = new int[columnCount];
int[] columnMaxHeight = new int[columnCount];
boolean[] fixedWidth = new boolean [columnCount];
colSuppressRepeats = new boolean[columnCount];
colSuppressRepeats = new Boolean[columnCount];
String[] columnJustification = new String[columnCount];
HashMap<Integer,Integer> additionalLines = new HashMap<Integer,Integer>();
@ -1973,4 +1974,16 @@ public class LayoutEngine implements Pageable, Printable, Doc
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

View File

@ -120,7 +120,7 @@ public class TableElement extends PrintElement
SerializableMatrix<Serializable> data, KeyNamePair[] pk, String pkColumnName,
int pageNoStart, Rectangle firstPage, Rectangle nextPages, int repeatedColumns, HashMap<Integer,Integer> additionalLines,
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();
if (log.isLoggable(Level.FINE))
@ -212,7 +212,7 @@ public class TableElement extends PrintElement
/** Bounds of next Pages */
private Rectangle m_nextPages;
private boolean[] m_colSuppressRepeats;
private Boolean[] m_colSuppressRepeats;
/** repeat first x columns on - X Axis follow pages */
private int m_repeatedColumns;