IDEMPIERE-2479 fix a problem with switching from columnnary reports to form back and forth - index out of bounds - suppresscolumns is just intended for columnnary reports
This commit is contained in:
parent
c4d6e259b2
commit
ba13d8584e
|
@ -21,6 +21,7 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MSysConfig;
|
||||
|
||||
import com.itextpdf.text.FontFactory;
|
||||
|
@ -86,7 +87,7 @@ public class Document {
|
|||
document.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +97,7 @@ public class Document {
|
|||
try {
|
||||
writePDF(pageable, new FileOutputStream(result));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -60,6 +60,7 @@ import javax.print.event.PrintServiceAttributeEvent;
|
|||
import javax.print.event.PrintServiceAttributeListener;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.pdf.Document;
|
||||
import org.adempiere.print.export.PrintDataExcelExporter;
|
||||
import org.apache.ecs.XhtmlDocument;
|
||||
|
@ -578,6 +579,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
|||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "(f)", e);
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
return false;
|
||||
} // createHTML
|
||||
|
@ -674,7 +676,11 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
|||
tbody.setNeedClosingTag(false);
|
||||
|
||||
Boolean [] colSuppressRepeats = m_layout == null || m_layout.colSuppressRepeats == null? LayoutEngine.getColSuppressRepeats(m_printFormat):m_layout.colSuppressRepeats;
|
||||
Object [] preValues = new Object [colSuppressRepeats.length];
|
||||
Object [] preValues = null;
|
||||
if (colSuppressRepeats != null){
|
||||
preValues = new Object [colSuppressRepeats.length];
|
||||
}
|
||||
|
||||
int printColIndex = -1;
|
||||
// for all rows (-1 = header row)
|
||||
for (int row = -1; row < m_printData.getRowCount(); row++)
|
||||
|
@ -732,7 +738,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
|||
Object obj = m_printData.getNode(Integer.valueOf(item.getAD_Column_ID()));
|
||||
if (obj == null){
|
||||
td.addElement(" ");
|
||||
if (colSuppressRepeats[printColIndex]){
|
||||
if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){
|
||||
preValues[printColIndex] = null;
|
||||
}
|
||||
}
|
||||
|
@ -741,7 +747,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
|||
PrintDataElement pde = (PrintDataElement) obj;
|
||||
String value = pde.getValueDisplay(language); // formatted
|
||||
|
||||
if (colSuppressRepeats[printColIndex]){
|
||||
if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){
|
||||
if (value.equals(preValues[printColIndex])){
|
||||
td.addElement(" ");
|
||||
continue;
|
||||
|
@ -858,6 +864,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
|||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "(w)", e);
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
return false;
|
||||
} // createHTML
|
||||
|
@ -916,7 +923,10 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
|||
try
|
||||
{
|
||||
Boolean [] colSuppressRepeats = m_layout == null || m_layout.colSuppressRepeats == null? LayoutEngine.getColSuppressRepeats(m_printFormat):m_layout.colSuppressRepeats;
|
||||
Object [] preValues = new Object [colSuppressRepeats.length];
|
||||
Object [] preValues = null;
|
||||
if (colSuppressRepeats != null){
|
||||
preValues = new Object [colSuppressRepeats.length];
|
||||
}
|
||||
int printColIndex = -1;
|
||||
// for all rows (-1 = header row)
|
||||
for (int row = -1; row < m_printData.getRowCount(); row++)
|
||||
|
@ -948,7 +958,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
|||
Object obj = m_printData.getNode(Integer.valueOf(item.getAD_Column_ID()));
|
||||
String data = "";
|
||||
if (obj == null){
|
||||
if (colSuppressRepeats[printColIndex]){
|
||||
if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){
|
||||
preValues[printColIndex] = null;
|
||||
}
|
||||
}
|
||||
|
@ -960,7 +970,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
|||
else
|
||||
data = pde.getValueDisplay(language); // formatted
|
||||
|
||||
if (colSuppressRepeats[printColIndex]){
|
||||
if (colSuppressRepeats != null && colSuppressRepeats[printColIndex]){
|
||||
if (data.equals(preValues[printColIndex])){
|
||||
continue;
|
||||
}else{
|
||||
|
@ -1149,7 +1159,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
|||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "PDF", e);
|
||||
return false;
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
|
||||
File file2 = new File(fileName);
|
||||
|
|
|
@ -250,6 +250,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
|||
public void setPrintFormat (MPrintFormat format, boolean doLayout)
|
||||
{
|
||||
m_format = format;
|
||||
this.colSuppressRepeats = null;
|
||||
// Initial & Default Settings
|
||||
m_printCtx = new Properties(format.getCtx());
|
||||
|
||||
|
@ -1980,6 +1981,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
|||
}
|
||||
|
||||
public static Boolean [] getColSuppressRepeats (MPrintFormat format){
|
||||
if (format.isForm())
|
||||
return null;
|
||||
List<Boolean> colSuppressRepeats = new ArrayList<>();
|
||||
for (int c = 0; c < format.getItemCount(); c++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue