1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 package com.sun.star.report.pentaho.output.text;
24 
25 import com.sun.star.report.DataSourceFactory;
26 import com.sun.star.report.ImageService;
27 import com.sun.star.report.InputRepository;
28 import com.sun.star.report.OutputRepository;
29 import com.sun.star.report.pentaho.PentahoFormulaContext;
30 
31 import org.jfree.report.ReportProcessingException;
32 import org.jfree.report.data.ReportContextImpl;
33 import org.jfree.report.flow.ReportContext;
34 import org.jfree.report.flow.ReportJob;
35 import org.jfree.report.flow.ReportStructureRoot;
36 import org.jfree.report.flow.ReportTarget;
37 import org.jfree.report.flow.SinglePassReportProcessor;
38 
39 import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
40 
41 /**
42  * Creation-Date: 03.07.2006, 17:08:25
43  *
44  * @author Thomas Morgner
45  */
46 public class TextRawReportProcessor extends SinglePassReportProcessor
47 {
48 
49     private final OutputRepository outputRepository;
50     private final String targetName;
51     private final InputRepository inputRepository;
52     private final ImageService imageService;
53     private final DataSourceFactory dataSourceFactory;
54 
TextRawReportProcessor(final InputRepository inputRepository, final OutputRepository outputRepository, final String targetName, final ImageService imageService, final DataSourceFactory dataSourceFactory)55     public TextRawReportProcessor(final InputRepository inputRepository,
56             final OutputRepository outputRepository,
57             final String targetName,
58             final ImageService imageService,
59             final DataSourceFactory dataSourceFactory)
60     {
61         if (inputRepository == null)
62         {
63             throw new NullPointerException();
64         }
65         if (outputRepository == null)
66         {
67             throw new NullPointerException();
68         }
69         if (targetName == null)
70         {
71             throw new NullPointerException();
72         }
73         if (imageService == null)
74         {
75             throw new NullPointerException();
76         }
77         if (dataSourceFactory == null)
78         {
79             throw new NullPointerException();
80         }
81 
82         this.targetName = targetName;
83         this.inputRepository = inputRepository;
84         this.outputRepository = outputRepository;
85         this.imageService = imageService;
86         this.dataSourceFactory = dataSourceFactory;
87     }
88 
createReportTarget(final ReportJob job)89     protected ReportTarget createReportTarget(final ReportJob job)
90             throws ReportProcessingException
91     {
92         final ReportStructureRoot report = job.getReportStructureRoot();
93         final ResourceManager resourceManager = report.getResourceManager();
94 
95         return new TextRawReportTarget(job, resourceManager, report.getBaseResource(),
96                 inputRepository, outputRepository, targetName, imageService, dataSourceFactory);
97     }
98 
createReportContext(final ReportJob job, final ReportTarget target)99     protected ReportContext createReportContext(final ReportJob job,
100             final ReportTarget target)
101     {
102         final ReportContext context = super.createReportContext(job, target);
103         if (context instanceof ReportContextImpl)
104         {
105             final ReportContextImpl impl = (ReportContextImpl) context;
106             impl.setFormulaContext(new PentahoFormulaContext(impl.getFormulaContext(), job.getConfiguration()));
107         }
108         return context;
109     }
110 }
111 
112 
113