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.layoutprocessor;
24 
25 import com.sun.star.report.pentaho.model.FixedTextElement;
26 
27 import org.jfree.report.DataSourceException;
28 import org.jfree.report.ReportDataFactoryException;
29 import org.jfree.report.ReportProcessingException;
30 import org.jfree.report.data.GlobalMasterRow;
31 import org.jfree.report.data.ReportDataRow;
32 import org.jfree.report.flow.FlowController;
33 import org.jfree.report.flow.ReportContext;
34 import org.jfree.report.flow.ReportTarget;
35 import org.jfree.report.flow.layoutprocessor.LayoutController;
36 import org.jfree.report.flow.layoutprocessor.LayoutControllerFactory;
37 import org.jfree.report.structure.Section;
38 
39 /**
40  * Processes a fixed-text element of the OpenOffice reporting specifciation.
41  * The element itself contains a single paragraph which contains the content.
42  * After checking, whether this element should be printed, this layout
43  * controller simply delegates the dirty work to a suitable handler.
44  *
45  * @author Thomas Morgner
46  * @noinspection CloneableClassWithoutClone
47  * @since 05.03.2007
48  */
49 public class FixedTextLayoutController
50         extends AbstractReportElementLayoutController
51 {
52 
FixedTextLayoutController()53     public FixedTextLayoutController()
54     {
55     }
56 
isValueChanged()57     protected boolean isValueChanged()
58     {
59         final FlowController controller = getFlowController();
60         final GlobalMasterRow masterRow = controller.getMasterRow();
61         final ReportDataRow reportDataRow = masterRow.getReportDataRow();
62         return reportDataRow.getCursor() == 0;
63     }
64 
delegateContentGeneration(final ReportTarget target)65     protected LayoutController delegateContentGeneration(final ReportTarget target)
66             throws ReportProcessingException, ReportDataFactoryException,
67             DataSourceException
68     {
69         final FixedTextElement fte = (FixedTextElement) getNode();
70         final Section content = fte.getContent();
71 
72         final FlowController flowController = getFlowController();
73         final ReportContext reportContext = flowController.getReportContext();
74         final LayoutControllerFactory layoutControllerFactory =
75                 reportContext.getLayoutControllerFactory();
76 
77         final FixedTextLayoutController flc = (FixedTextLayoutController) clone();
78         flc.setState(AbstractReportElementLayoutController.FINISHED);
79         return layoutControllerFactory.create(flowController, content, flc);
80     }
81 }
82