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: * FlowExcelOutputProcessor.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 FlowExcelOutputProcessor extends
052: AbstractTableOutputProcessor {
053: private OutputProcessorMetaData metaData;
054: private FlowSelector flowSelector;
055: private ExcelPrinter printer;
056:
057: public FlowExcelOutputProcessor(final Configuration config,
058: final OutputStream outputStream) {
059: this .metaData = new ExcelOutputProcessorMetaData(config,
060: ExcelOutputProcessorMetaData.PAGINATION_MANUAL);
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: public void setFlowSelector(final FlowSelector flowSelector) {
081: this .flowSelector = flowSelector;
082: }
083:
084: public FlowSelector getFlowSelector() {
085: return flowSelector;
086: }
087:
088: protected void processTableContent(
089: final LogicalPageKey logicalPageKey,
090: final LogicalPageBox logicalPage,
091: final TableContentProducer contentProducer)
092: throws ContentProcessingException {
093: printer.print(logicalPageKey, logicalPage, contentProducer,
094: false);
095: }
096:
097: protected void updateTableContent(
098: final LogicalPageKey logicalPageKey,
099: final LogicalPageBox logicalPageBox,
100: final TableContentProducer tableContentProducer,
101: final boolean performOutput)
102: throws ContentProcessingException {
103: printer.print(logicalPageKey, logicalPageBox,
104: tableContentProducer, true);
105: }
106:
107: protected void processingContentFinished() {
108: if (isContentGeneratable() == false) {
109: return;
110: }
111:
112: this.printer.close();
113: }
114: }
|