KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > plugin > jfreereport > outputs > JFreeReportRTFComponent


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  */

13 package org.pentaho.plugin.jfreereport.outputs;
14
15 import java.io.IOException JavaDoc;
16 import java.io.OutputStream JavaDoc;
17
18 import org.jfree.report.JFreeReport;
19 import org.jfree.report.ReportProcessingException;
20 import org.jfree.report.modules.output.table.rtf.RTFProcessor;
21 import org.pentaho.plugin.jfreereport.helper.YieldReportListener;
22
23 /**
24  * Creation-Date: 07.07.2006, 20:42:17
25  *
26  * @author Thomas Morgner
27  */

28 public class JFreeReportRTFComponent extends AbstractGenerateStreamContentComponent {
29     private static final long serialVersionUID = -4095237855917616138L;
30
31     public JFreeReportRTFComponent() {
32     }
33
34     protected String JavaDoc getMimeType() {
35         return "application/rtf"; //$NON-NLS-1$
36
}
37
38     protected String JavaDoc getExtension() {
39         return ".rtf"; //$NON-NLS-1$
40
}
41
42     protected boolean performExport(final JFreeReport report, final OutputStream JavaDoc outputStream) {
43         try {
44             RTFProcessor processor = new RTFProcessor(report);
45             processor.setOutputStream(outputStream);
46             final int yieldRate = getYieldRate();
47             if (yieldRate > 0) {
48                 processor.addRepaginationListener(new YieldReportListener(yieldRate));
49             }
50             processor.processReport();
51             outputStream.close();
52             return true;
53         } catch (ReportProcessingException e) {
54             return false;
55         } catch (IOException JavaDoc e) {
56             return false;
57         }
58     }
59 }
60
Popular Tags