KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > rtf > rtflib > rtfdoc > RtfTemplate


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: RtfTemplate.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20
21 /*
22  * This file is part of the RTF library of the FOP project, which was originally
23  * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
24  * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
25  * the FOP project.
26  */

27
28 package org.apache.fop.render.rtf.rtflib.rtfdoc;
29
30 import java.io.IOException JavaDoc;
31
32 /**
33  * Singelton of the RTF style template
34  * This class belongs to the <jfor:style-template> tag processing.
35  */

36
37 public class RtfTemplate {
38
39     /** Singelton instance */
40     private static RtfTemplate instance = null;
41
42     private String JavaDoc templateFilePath = null;
43
44     /**
45      * Constructor.
46      */

47     private RtfTemplate () {
48
49     }
50
51
52     /**
53      * Singelton.
54      *
55      * @return The instance of RtfTemplate
56      */

57     public static RtfTemplate getInstance () {
58         if (instance == null) {
59             instance = new RtfTemplate();
60         }
61
62         return instance;
63     }
64
65
66     /**
67      * Set the template file and adjust tha path separator
68      * @param templateFilePath The full path of the template
69      * @throws IOException for I/O problems
70      **/

71     public void setTemplateFilePath(String JavaDoc templateFilePath) throws IOException JavaDoc {
72         // no validity checks here - leave this to the RTF client
73
if (templateFilePath == null) {
74             this.templateFilePath = null;
75         } else {
76             this.templateFilePath = templateFilePath.trim();
77         }
78     }
79
80     /**
81      * Write the rtf template
82      * @param header Rtf header is the parent
83      * @throws IOException On write error
84      */

85     public void writeTemplate (RtfHeader header) throws IOException JavaDoc {
86         if (templateFilePath == null || templateFilePath.length() == 0) {
87             return;
88         }
89
90         header.writeGroupMark (true);
91         header.writeControlWord ("template");
92         header.writeRtfString(this.templateFilePath);
93         header.writeGroupMark (false);
94
95         header.writeGroupMark (true);
96         header.writeControlWord ("linkstyles");
97         header.writeGroupMark (false);
98     }
99 }
100
101
102
Popular Tags