01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: RtfFootnote.java 426576 2006-07-28 15:44:37Z jeremias $ */
19:
20: package org.apache.fop.render.rtf.rtflib.rtfdoc;
21:
22: //Java
23: import java.io.Writer;
24: import java.io.IOException;
25:
26: //FOP
27: import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;
28:
29: /** Model of an RTF footnote
30: * @author Peter Herweg, pherweg@web.de
31: * @author Marc Wilhelm Kuester
32: */
33: public class RtfFootnote extends RtfContainer implements
34: IRtfTextrunContainer, IRtfListContainer {
35: RtfTextrun textrunInline = null;
36: RtfContainer body = null;
37: RtfList list = null;
38: boolean bBody = false;
39:
40: /** Create an RTF list item as a child of given container with default attributes */
41: RtfFootnote(RtfContainer parent, Writer w) throws IOException {
42: super (parent, w);
43: textrunInline = new RtfTextrun(this , writer, null);
44: body = new RtfContainer(this , writer);
45: }
46:
47: public RtfTextrun getTextrun() throws IOException {
48: if (bBody) {
49: RtfTextrun textrun = RtfTextrun.getTextrun(body, writer,
50: null);
51: textrun.setSuppressLastPar(true);
52:
53: return textrun;
54: } else {
55: return textrunInline;
56: }
57: }
58:
59: /**
60: * write RTF code of all our children
61: * @throws IOException for I/O problems
62: */
63: protected void writeRtfContent() throws IOException {
64: textrunInline.writeRtfContent();
65:
66: writeGroupMark(true);
67: writeControlWord("footnote");
68: writeControlWord("ftnalt");
69:
70: body.writeRtfContent();
71:
72: writeGroupMark(false);
73: }
74:
75: public RtfList newList(RtfAttributes attrs) throws IOException {
76: if (list != null) {
77: list.close();
78: }
79:
80: list = new RtfList(body, writer, attrs);
81:
82: return list;
83: }
84:
85: public void startBody() {
86: bBody = true;
87: }
88:
89: public void endBody() {
90: bBody = false;
91: }
92: }
|