001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * StreamExcelOutputProcessor.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.output.table.xls;
030:
031: import java.io.InputStream;
032: import java.io.OutputStream;
033:
034: import org.jfree.report.layout.model.LogicalPageBox;
035: import org.jfree.report.layout.output.ContentProcessingException;
036: import org.jfree.report.layout.output.DisplayAllFlowSelector;
037: import org.jfree.report.layout.output.FlowSelector;
038: import org.jfree.report.layout.output.LogicalPageKey;
039: import org.jfree.report.layout.output.OutputProcessorMetaData;
040: import org.jfree.report.modules.output.table.base.AbstractTableOutputProcessor;
041: import org.jfree.report.modules.output.table.base.TableContentProducer;
042: import org.jfree.report.modules.output.table.xls.helper.ExcelOutputProcessorMetaData;
043: import org.jfree.report.modules.output.table.xls.helper.ExcelPrinter;
044: import org.jfree.util.Configuration;
045:
046: /**
047: * Creation-Date: 09.05.2007, 14:36:28
048: *
049: * @author Thomas Morgner
050: */
051: public class StreamExcelOutputProcessor extends
052: AbstractTableOutputProcessor {
053: private OutputProcessorMetaData metaData;
054: private FlowSelector flowSelector;
055: private ExcelPrinter printer;
056:
057: public StreamExcelOutputProcessor(final Configuration config,
058: final OutputStream outputStream) {
059: this .metaData = new ExcelOutputProcessorMetaData(config,
060: ExcelOutputProcessorMetaData.PAGINATION_NONE);
061: this .flowSelector = new DisplayAllFlowSelector();
062:
063: this .printer = new ExcelPrinter();
064: this .printer.init(config, metaData, outputStream);
065: }
066:
067: public InputStream getTemplateInputStream() {
068: return printer.getTemplateInputStream();
069: }
070:
071: public void setTemplateInputStream(
072: final InputStream templateInputStream) {
073: printer.setTemplateInputStream(templateInputStream);
074: }
075:
076: public OutputProcessorMetaData getMetaData() {
077: return metaData;
078: }
079:
080: protected FlowSelector getFlowSelector() {
081: return flowSelector;
082: }
083:
084: protected void processTableContent(
085: final LogicalPageKey logicalPageKey,
086: final LogicalPageBox logicalPage,
087: final TableContentProducer contentProducer)
088: throws ContentProcessingException {
089: printer.print(logicalPageKey, logicalPage, contentProducer,
090: false);
091: }
092:
093: protected void updateTableContent(
094: final LogicalPageKey logicalPageKey,
095: final LogicalPageBox logicalPageBox,
096: final TableContentProducer tableContentProducer,
097: final boolean performOutput)
098: throws ContentProcessingException {
099: printer.print(logicalPageKey, logicalPageBox,
100: tableContentProducer, true);
101: }
102:
103: protected void processingContentFinished() {
104: if (isContentGeneratable() == false) {
105: return;
106: }
107:
108: this.printer.close();
109: }
110:
111: }
|