net.sf.jasperreports.engine.export.oasis.TableBuilder Maven / Gradle / Ivy
/*
* JasperReports - Free Java Reporting Library.
* Copyright (C) 2001 - 2011 Jaspersoft Corporation. All rights reserved.
* http://www.jaspersoft.com
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is part of JasperReports.
*
* JasperReports is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* JasperReports is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JasperReports. If not, see .
*/
/*
* Special thanks to Google 'Summer of Code 2005' program for supporting this development
*
* Contributors:
* Majid Ali Khan - [email protected]
* Frank Sch�nheit - [email protected]
*/
package net.sf.jasperreports.engine.export.oasis;
import java.io.IOException;
import java.io.Writer;
import net.sf.jasperreports.engine.export.LengthUtil;
/**
* @author Teodor Danciu ([email protected])
* @version $Id: TableBuilder.java 5180 2012-03-29 13:23:12Z teodord $
*/
public class TableBuilder
{
private String tableName;
private int reportIndex;
private Writer bodyWriter;
private Writer styleWriter;
private boolean isFrame;
private boolean isPageBreak;
protected TableBuilder(
String name,
Writer bodyWriter,
Writer styleWriter
)
{
isFrame = true;
isPageBreak = false;
this.bodyWriter = bodyWriter;
this.styleWriter = styleWriter;
this.tableName = "TBL_" + name;
}
protected TableBuilder(
int reportIndex,
int pageIndex,
Writer bodyWriter,
Writer styleWriter
)
{
isFrame = false;
isPageBreak = (reportIndex != 0 || pageIndex != 0);
this.reportIndex = reportIndex;
this.bodyWriter = bodyWriter;
this.styleWriter = styleWriter;
this.tableName = "TBL_" + reportIndex + "_" + pageIndex;
}
public void buildTableStyle(int width) throws IOException
{
styleWriter.write(" \n");
styleWriter.write(" \n");
styleWriter.write(" \n");
}
public void buildTableHeader() throws IOException
{
bodyWriter.write("\n");
}
public void buildTableFooter() throws IOException
{
bodyWriter.write(" \n");
}
public void buildRowStyle(int rowIndex, int rowHeight) throws IOException
{
String rowName = tableName + "_row_" + rowIndex;
styleWriter.write(" \n");
styleWriter.write(" \n");
styleWriter.write(" \n");
}
public void buildRowHeader(int rowIndex) throws IOException
{
String rowName = tableName + "_row_" + rowIndex;
bodyWriter.write("\n");
}
public void buildRowFooter() throws IOException
{
bodyWriter.write(" \n");
}
public void buildColumnStyle(int colIndex, int colWidth) throws IOException
{
String columnName = tableName + "_col_" + colIndex;
styleWriter.write(" \n");
styleWriter.write(" \n");
styleWriter.write(" \n");
}
public void buildColumnHeader(int colIndex) throws IOException
{
String columnName = tableName + "_col_" + colIndex;
bodyWriter.write("\n");
}
public void buildColumnFooter() throws IOException
{
bodyWriter.write(" \n");
}
public void buildCellHeader(String cellStyleName, int colSpan, int rowSpan) throws IOException
{
//FIXMEODT officevalue bodyWriter.write(" 1)
{
bodyWriter.write(" table:number-columns-spanned=\"" + colSpan + "\"");
}
if (rowSpan > 1)
{
bodyWriter.write(" table:number-rows-spanned=\"" + rowSpan + "\"");
}
bodyWriter.write(">\n");
}
public void buildCellFooter() throws IOException {
bodyWriter.write(" \n");
}
}