net.sf.jasperreports.engine.export.oasis
Class JROdtFrameExporter
java.lang.Object
net.sf.jasperreports.engine.JRAbstractExporter
net.sf.jasperreports.engine.export.oasis.JROdtFrameExporter
- All Implemented Interfaces:
- JRExporter
public class JROdtFrameExporter
- extends JRAbstractExporter
Exports a JasperReports document to ODF format. It has character output type and exports the document to a
grid-based layout.
- Version:
- $Id: JROdtFrameExporter.java 2072 2008-02-01 16:55:47Z teodord $
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
Fields inherited from class net.sf.jasperreports.engine.JRAbstractExporter |
classLoader, classLoaderSet, dateFormatCache, endPageIndex, fileResolver, fileResolverSet, filter, globalOffsetX, globalOffsetY, isModeBatch, jasperPrint, jasperPrintList, numberFormatCache, parameters, startPageIndex, urlHandlerFactory, urlHandlerFactorySet |
Method Summary |
protected void |
exportElements(java.util.Collection elements)
|
protected void |
exportEllipse(JRPrintEllipse ellipse)
|
protected void |
exportLine(JRPrintLine line)
|
protected void |
exportPage(JRPrintPage page)
|
protected void |
exportRectangle(JRPrintRectangle rectangle)
|
void |
exportReport()
Actually starts the export process. |
protected void |
exportReportToOasisZip(java.io.OutputStream os)
public static JRPrintImage getImage(List jasperPrintList, String imageName)
{
return getImage(jasperPrintList, getPrintElementIndex(imageName));
}
public static JRPrintImage getImage(List jasperPrintList, JRPrintElementIndex imageIndex)
{
JasperPrint report = (JasperPrint)jasperPrintList.get(imageIndex.getReportIndex());
JRPrintPage page = (JRPrintPage)report.getPages().get(imageIndex.getPageIndex());
Integer[] elementIndexes = imageIndex.getElementIndexes();
Object element = page.getElements().get(elementIndexes[0].intValue());
for (int i = 1; i < elementIndexes.length; ++i)
{
JRPrintFrame frame = (JRPrintFrame) element;
element = frame.getElements().get(elementIndexes[i].intValue());
}
return (JRPrintImage) element;
}
/** |
protected void |
exportStyledText(JRStyledText styledText)
protected void exportText(TableBuilder tableBuilder, JRPrintText text, JRExporterGridCell gridCell) throws IOException
{
tableBuilder.buildCellStyleHeader(text);
tableBuilder.buildCellBackcolorStyle(text);
tableBuilder.buildCellBorderStyle(text, text);
tableBuilder.buildCellAlignmentStyle(text);
tableBuilder.buildCellStyleFooter();
tableBuilder.buildCellHeader(gridCell.colSpan, gridCell.rowSpan);
JRStyledText styledText = getStyledText(text);
int textLength = 0;
if (styledText != null)
{
textLength = styledText.length();
}
StringBuffer paragraphStyleIdBuffer = new StringBuffer();
String verticalAlignment = VERTICAL_ALIGN_TOP;
switch (text.getVerticalAlignment())
{
case JRAlignment.VERTICAL_ALIGN_BOTTOM :
{
verticalAlignment = VERTICAL_ALIGN_BOTTOM;
break;
}
case JRAlignment.VERTICAL_ALIGN_MIDDLE :
{
verticalAlignment = VERTICAL_ALIGN_MIDDLE;
break;
}
case JRAlignment.VERTICAL_ALIGN_TOP :
default :
{
verticalAlignment = VERTICAL_ALIGN_TOP;
}
}
paragraphStyleIdBuffer.append(verticalAlignment);
String runDirection = null;
if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_RTL)
{
runDirection = "rl";
}
paragraphStyleIdBuffer.append(runDirection);
String horizontalAlignment = HORIZONTAL_ALIGN_LEFT;
switch (text.getHorizontalAlignment())
{
case JRAlignment.HORIZONTAL_ALIGN_RIGHT :
{
horizontalAlignment = HORIZONTAL_ALIGN_RIGHT;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_CENTER :
{
horizontalAlignment = HORIZONTAL_ALIGN_CENTER;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_JUSTIFIED :
{
horizontalAlignment = HORIZONTAL_ALIGN_JUSTIFY;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_LEFT :
default :
{
horizontalAlignment = HORIZONTAL_ALIGN_LEFT;
}
}
paragraphStyleIdBuffer.append(horizontalAlignment);
// if (isWrapBreakWord)
// {
// styleBuffer.append("width: " + gridCell.width + "; ");
// styleBuffer.append("word-wrap: break-word; ");
// }
// if (text.getLineSpacing() != JRTextElement.LINE_SPACING_SINGLE)
// {
// styleBuffer.append("line-height: " + text.getLineSpacingFactor() + "; ");
// }
// if (styleBuffer.length() > 0)
// {
// writer.write(" style=\"");
// writer.write(styleBuffer.toString());
// writer.write("\"");
// }
//
// writer.write(">");
// if (text.getAnchorName() != null)
// {
// writer.write("");
// }
// boolean startedHyperlink = startHyperlink(text);
String paragraphStyleId = paragraphStyleIdBuffer.toString();
String paragraphStyleName = (String)paragraphStyles.get(paragraphStyleId);
if (paragraphStyleName == null)
{
paragraphStyleName = "P" + paragraphStylesCounter++;
paragraphStyles.put(paragraphStyleId, paragraphStyleName);
tempStyleWriter.write("\n");
tempStyleWriter.write(" \r\n");
tempStyleWriter.write("\n");
tempStyleWriter.write("\n");
}
tempBodyWriter.write("");
if (textLength > 0)
{
exportStyledText(styledText);
}
// if (startedHyperlink)
// {
// endHyperlink();
// }
tempBodyWriter.write("\n");
tableBuilder.buildCellFooter();
}
/** |
protected void |
exportStyledTextRun(java.util.Map attributes,
java.lang.String text)
|
protected void |
exportText(JRPrintText text)
|
protected void |
setHyperlinkProducerFactory()
|
Methods inherited from class net.sf.jasperreports.engine.JRAbstractExporter |
defaultParseNumber, getBooleanCellValue, getBooleanParameter, getDateCellValue, getDateFormat, getIntegerParameter, getNumberCellValue, getNumberFormat, getOffsetX, getOffsetY, getParameter, getParameterResolver, getParameters, getStringParameter, getStringParameterOrDefault, getStyledText, getStyledText, getTextFormatFactoryClass, getTextLocale, getTextTimeZone, getTextValue, getTextValueString, reset, resetClassLoader, resetExportContext, restoreElementOffsets, setClassLoader, setExportContext, setFrameElementsOffset, setInput, setOffset, setOffset, setOutput, setPageRange, setParameter, setParameters |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
VERSION
public static final java.lang.String VERSION
- See Also:
- Constant Field Values
JR_PAGE_ANCHOR_PREFIX
protected static final java.lang.String JR_PAGE_ANCHOR_PREFIX
- See Also:
- Constant Field Values
IMAGE_NAME_PREFIX
public static final java.lang.String IMAGE_NAME_PREFIX
- See Also:
- Constant Field Values
IMAGE_NAME_PREFIX_LEGTH
protected static final int IMAGE_NAME_PREFIX_LEGTH
tempBodyWriter
protected java.io.Writer tempBodyWriter
tempStyleWriter
protected java.io.Writer tempStyleWriter
progressMonitor
protected JRExportProgressMonitor progressMonitor
rendererToImagePathMap
protected java.util.Map rendererToImagePathMap
imageMaps
protected java.util.Map imageMaps
imagesToProcess
protected java.util.List imagesToProcess
reportIndex
protected int reportIndex
pageIndex
protected int pageIndex
tableIndex
protected int tableIndex
encoding
protected java.lang.String encoding
isWrapBreakWord
protected boolean isWrapBreakWord
fontMap
protected java.util.Map fontMap
hyperlinkProducerFactory
protected JRHyperlinkProducerFactory hyperlinkProducerFactory
JROdtFrameExporter
public JROdtFrameExporter()
exportReport
public void exportReport()
throws JRException
- Description copied from interface:
JRExporter
- Actually starts the export process.
- Specified by:
exportReport
in interface JRExporter
- Specified by:
exportReport
in class JRAbstractExporter
- Throws:
JRException
setHyperlinkProducerFactory
protected void setHyperlinkProducerFactory()
exportReportToOasisZip
protected void exportReportToOasisZip(java.io.OutputStream os)
throws JRException,
java.io.IOException
- public static JRPrintImage getImage(List jasperPrintList, String imageName)
{
return getImage(jasperPrintList, getPrintElementIndex(imageName));
}
public static JRPrintImage getImage(List jasperPrintList, JRPrintElementIndex imageIndex)
{
JasperPrint report = (JasperPrint)jasperPrintList.get(imageIndex.getReportIndex());
JRPrintPage page = (JRPrintPage)report.getPages().get(imageIndex.getPageIndex());
Integer[] elementIndexes = imageIndex.getElementIndexes();
Object element = page.getElements().get(elementIndexes[0].intValue());
for (int i = 1; i < elementIndexes.length; ++i)
{
JRPrintFrame frame = (JRPrintFrame) element;
element = frame.getElements().get(elementIndexes[i].intValue());
}
return (JRPrintImage) element;
}
/**
- Throws:
JRException
java.io.IOException
exportPage
protected void exportPage(JRPrintPage page)
throws JRException,
java.io.IOException
- Throws:
JRException
java.io.IOException
exportElements
protected void exportElements(java.util.Collection elements)
throws java.io.IOException,
JRException
- Throws:
java.io.IOException
JRException
exportLine
protected void exportLine(JRPrintLine line)
throws java.io.IOException
- Throws:
java.io.IOException
exportRectangle
protected void exportRectangle(JRPrintRectangle rectangle)
throws java.io.IOException
- Throws:
java.io.IOException
exportEllipse
protected void exportEllipse(JRPrintEllipse ellipse)
throws java.io.IOException
- Throws:
java.io.IOException
exportText
protected void exportText(JRPrintText text)
throws java.io.IOException
- Throws:
java.io.IOException
exportStyledText
protected void exportStyledText(JRStyledText styledText)
throws java.io.IOException
- protected void exportText(TableBuilder tableBuilder, JRPrintText text, JRExporterGridCell gridCell) throws IOException
{
tableBuilder.buildCellStyleHeader(text);
tableBuilder.buildCellBackcolorStyle(text);
tableBuilder.buildCellBorderStyle(text, text);
tableBuilder.buildCellAlignmentStyle(text);
tableBuilder.buildCellStyleFooter();
tableBuilder.buildCellHeader(gridCell.colSpan, gridCell.rowSpan);
JRStyledText styledText = getStyledText(text);
int textLength = 0;
if (styledText != null)
{
textLength = styledText.length();
}
StringBuffer paragraphStyleIdBuffer = new StringBuffer();
String verticalAlignment = VERTICAL_ALIGN_TOP;
switch (text.getVerticalAlignment())
{
case JRAlignment.VERTICAL_ALIGN_BOTTOM :
{
verticalAlignment = VERTICAL_ALIGN_BOTTOM;
break;
}
case JRAlignment.VERTICAL_ALIGN_MIDDLE :
{
verticalAlignment = VERTICAL_ALIGN_MIDDLE;
break;
}
case JRAlignment.VERTICAL_ALIGN_TOP :
default :
{
verticalAlignment = VERTICAL_ALIGN_TOP;
}
}
paragraphStyleIdBuffer.append(verticalAlignment);
String runDirection = null;
if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_RTL)
{
runDirection = "rl";
}
paragraphStyleIdBuffer.append(runDirection);
String horizontalAlignment = HORIZONTAL_ALIGN_LEFT;
switch (text.getHorizontalAlignment())
{
case JRAlignment.HORIZONTAL_ALIGN_RIGHT :
{
horizontalAlignment = HORIZONTAL_ALIGN_RIGHT;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_CENTER :
{
horizontalAlignment = HORIZONTAL_ALIGN_CENTER;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_JUSTIFIED :
{
horizontalAlignment = HORIZONTAL_ALIGN_JUSTIFY;
break;
}
case JRAlignment.HORIZONTAL_ALIGN_LEFT :
default :
{
horizontalAlignment = HORIZONTAL_ALIGN_LEFT;
}
}
paragraphStyleIdBuffer.append(horizontalAlignment);
// if (isWrapBreakWord)
// {
// styleBuffer.append("width: " + gridCell.width + "; ");
// styleBuffer.append("word-wrap: break-word; ");
// }
// if (text.getLineSpacing() != JRTextElement.LINE_SPACING_SINGLE)
// {
// styleBuffer.append("line-height: " + text.getLineSpacingFactor() + "; ");
// }
// if (styleBuffer.length() > 0)
// {
// writer.write(" style=\"");
// writer.write(styleBuffer.toString());
// writer.write("\"");
// }
//
// writer.write(">");
// if (text.getAnchorName() != null)
// {
// writer.write("");
// }
// boolean startedHyperlink = startHyperlink(text);
String paragraphStyleId = paragraphStyleIdBuffer.toString();
String paragraphStyleName = (String)paragraphStyles.get(paragraphStyleId);
if (paragraphStyleName == null)
{
paragraphStyleName = "P" + paragraphStylesCounter++;
paragraphStyles.put(paragraphStyleId, paragraphStyleName);
tempStyleWriter.write("\n");
tempStyleWriter.write(" \r\n");
tempStyleWriter.write("\n");
tempStyleWriter.write("\n");
}
tempBodyWriter.write("");
if (textLength > 0)
{
exportStyledText(styledText);
}
// if (startedHyperlink)
// {
// endHyperlink();
// }
tempBodyWriter.write("\n");
tableBuilder.buildCellFooter();
}
/**
- Throws:
java.io.IOException
exportStyledTextRun
protected void exportStyledTextRun(java.util.Map attributes,
java.lang.String text)
throws java.io.IOException
- Throws:
java.io.IOException
© 2001-2006 JasperSoft Corporation www.jaspersoft.com