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 javax.xml.stream.XMLStreamException;
33: import javax.xml.stream.XMLStreamWriter;
34: import java.io.IOException;
35: import java.io.PrintWriter;
36:
37: public class Defun extends Section {
38: public Defun(Document document) {
39: super (document);
40: }
41:
42: public S2 createS2() {
43: S2 s2 = new S2(getDocument(), getHref());
44: addItem(s2);
45: return s2;
46: }
47:
48: public void writeHtml(XMLStreamWriter out)
49: throws XMLStreamException {
50: out.writeCharacters("\n");
51: out.writeStartElement("div");
52: out.writeAttribute("class", "s1");
53:
54: out.writeStartElement("a");
55: out.writeAttribute("name", getHref());
56: out.writeEndElement();
57:
58: if (_title != null) {
59: out.writeStartElement("h1");
60: out.writeAttribute("class", "section");
61: out.writeCharacters(_title);
62: out.writeEndElement();
63: }
64:
65: out.writeEndElement();
66:
67: super .writeHtml(out);
68: }
69:
70: public void writeLaTeXTop(PrintWriter out) throws IOException {
71: out.println("\\subsection{" + LaTeXUtil.escapeForLaTeX(_title)
72: + "}");
73:
74: super .writeLaTeX(out);
75: }
76:
77: public void writeLaTeX(PrintWriter out) throws IOException {
78: out.println("\\subsection{" + LaTeXUtil.escapeForLaTeX(_title)
79: + "}");
80:
81: super .writeLaTeX(out);
82: }
83:
84: public void writeLaTeXEnclosed(PrintWriter out) throws IOException {
85: if (_type != null && _type.equals("defun"))
86: out.println("\\newpage");
87:
88: if (_title != null)
89: out.println("\\subsubsection{"
90: + LaTeXUtil.escapeForLaTeX(_title) + "}");
91:
92: super.writeLaTeX(out);
93: }
94: }
|