01: /*
02: * Copyright (c) 1998-2000 Caucho Technology -- all rights reserved
03: *
04: * This file is part of Resin(R) Open Source
05: *
06: * Each copy or derived work must preserve the copyright notice and this
07: * notice unmodified.
08: *
09: * Resin Open Source is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU General Public License as published by
11: * the Free Software Foundation; either version 2 of the License, or
12: * (at your option) any later version.
13: *
14: * Resin Open Source is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17: * of NON-INFRINGEMENT. See the GNU General Public License for more
18: * details.
19: *
20: * You should have received a copy of the GNU General Public License
21: * along with Resin Open Source; if not, write to the
22: *
23: * Free Software Foundation, Inc.
24: * 59 Temple Place, Suite 330
25: * Boston, MA 02111-1307 USA
26: *
27: * @author Emil Ong
28: */
29:
30: package com.caucho.xtpdoc;
31:
32: import java.io.IOException;
33: import java.io.PrintWriter;
34:
35: import javax.xml.stream.XMLStreamException;
36: import javax.xml.stream.XMLStreamWriter;
37:
38: public class S4 extends Section {
39: public S4(Document document, String parentHref) {
40: super (document, parentHref);
41: }
42:
43: public void writeLaTeXTop(PrintWriter out) throws IOException {
44: if (_type != null && _type.equals("defun"))
45: out.println("\\newpage");
46:
47: if (_title != null)
48: out.println("\\paragraph{"
49: + LaTeXUtil.escapeForLaTeX(_title) + "}");
50:
51: super .writeLaTeX(out);
52: }
53:
54: public void writeHtml(XMLStreamWriter out)
55: throws XMLStreamException {
56: out.writeCharacters("\n");
57: out.writeStartElement("div");
58: out.writeAttribute("class", "s4");
59:
60: out.writeStartElement("a");
61: out.writeAttribute("name", getHref());
62: out.writeEndElement();
63:
64: if (_title != null) {
65: out.writeStartElement("h4");
66: out.writeCharacters(_title);
67: out.writeEndElement();
68: }
69:
70: for (ContentItem item : getItems())
71: item.writeHtml(out);
72:
73: out.writeEndElement();
74: }
75:
76: public void writeLaTeX(PrintWriter out) throws IOException {
77: if (_type != null && _type.equals("defun"))
78: out.println("\\newpage");
79:
80: if (_title != null)
81: out.println("\\textbf{" + LaTeXUtil.escapeForLaTeX(_title)
82: + "}");
83:
84: super .writeLaTeX(out);
85: }
86:
87: public void writeLaTeXEnclosed(PrintWriter out) throws IOException {
88: if (_type != null && _type.equals("defun"))
89: out.println("\\newpage");
90:
91: if (_title != null)
92: out.println("{" + LaTeXUtil.escapeForLaTeX(_title) + ": }");
93:
94: super.writeLaTeX(out);
95: }
96: }
|