reorganized file layout (part 2: edits)
[org.ibex.core.git] / src / org / ibex / util / Doc.java
1
2 // FEATURE:   <code type="c++"/>          -- syntax highlighting
3 // FEATURE:   <code linenumbers="true"/>  -- LaTeX moreverb package can help
4 // FIXME: nest TextNodes within each other for bold+italic
5 // FEATURE: property tree
6
7 package org.ibex.util;
8 import java.util.*;
9 import java.io.*;
10 import org.ibex.util.*;
11
12 public class Doc extends XML {
13     
14     public static boolean slides = false;
15     Root root = null;
16     int skip = 0;
17     Vec nodeStack = new Vec();
18     String pending = "";
19     char[] buffer = new char[1024 * 1024];
20     int preStart = -1;
21     
22     public Doc() { }
23
24     public static void main(String[] s) throws Exception {
25         if (s.length > 0 && "slides".equals(s[0])) slides = true;
26         Doc d = new Doc();
27         Reader r = new InputStreamReader(System.in);
28         int len = 0;
29         while(true) {
30             int numread = r.read(d.buffer, len, d.buffer.length - len);
31             if (numread == -1) break;
32             len += numread;
33             if (len >= d.buffer.length) {
34                 char[] newbuffer = new char[d.buffer.length * 2];
35                 System.arraycopy(d.buffer, 0, newbuffer, 0, d.buffer.length);
36                 d.buffer = newbuffer;
37             }
38         }
39         d.parse(new CharArrayReader(d.buffer));
40         StringBuffer sb = new StringBuffer();
41         d.root.dumpLatex(sb);
42         System.out.println(sb);
43     }
44
45     public void startElement(Element e) throws Exn {
46         if (preStart != -1) return;
47
48         Node target = (Node)nodeStack.lastElement();
49         if (target == null) target = (Node)victim;
50         if (target != null) {
51             if (pending.length() > 0) target.addText(pending);
52             pending = "";
53         }
54
55         String name = e.getLocalName();
56         Node newGuy = null;
57         if (name.equals("ibex-doc")) {            newGuy = new Root(e);
58         } else if (name.equals("section")) {      newGuy = new Section(e);
59         } else if (name.equals("heading")) {      newGuy = new Heading(e);
60         } else if (name.equals("appendix")) {     newGuy = new Appendix(e);
61         } else if (name.equals("list")) {         newGuy = new List();
62
63         } else if (name.equals("pre")) {          preStart = getGlobalOffset();
64
65         } else if (name.equals("definition")) {   newGuy = new Definition(e);
66         } else if (name.equals("math")) {         newGuy = new Math(e);
67         } else if (name.equals("property")) {     newGuy = new Property(e);
68
69         } else if (name.equals("link")) {         newGuy = new Link(e);
70         } else if (name.equals("image")) {        newGuy = new Image(e);
71
72         } else {
73             System.err.println("warning: unknown tag " + name);
74             skip++;
75         }
76         if (newGuy != null) {
77             Node parent = (Node)nodeStack.lastElement();
78             if (parent != null) parent.addChild(newGuy);
79             nodeStack.addElement(newGuy);
80         }
81     }
82
83     static Object victim = null;
84
85     public void whitespace(char[] ch, int start, int length) throws Exn, IOException { characters(ch, start, length); }
86     public void endElement(Element e) throws Exn, IOException {
87
88         Node target = (Node)nodeStack.lastElement();
89         if (target == null) target = (Node)victim;
90         if (preStart != -1) {
91             if (!e.getLocalName().equals("pre")) return;
92             target.addChild(new PRE(preStart, getGlobalOffset()));
93             preStart = -1;
94         } else if (skip > 0) {
95             skip--;
96             return;
97         } else {
98             if (target != null) {
99                 if (pending.length() > 0) target.addText(pending);
100                 pending = "";
101             }
102             if (nodeStack.lastElement() instanceof Section) victim = nodeStack.lastElement();
103             nodeStack.setSize(nodeStack.size() - 1);
104         }
105     }
106
107     public void characters(char[] ch, int start, int length) throws Exn, IOException {
108         if (preStart != -1) return;
109         pending += new String(ch, start, length);
110     }
111
112     abstract class Node {
113         public Node parent = null;
114         public abstract void addText(String s);
115         public abstract void addChild(Node s);
116         public abstract void dumpLatex(StringBuffer sb);
117         final String fixLatex(String s) {
118             if (s == null) return "";
119             s = s.replaceAll("\\\\", "\\$\\\\backslash\\$");
120             s = s.replaceAll("\\$", "\\\\\\$");
121             s = s.replaceAll("\\\\\\$\\\\backslash\\\\\\$", "\\$\\\\backslash\\$");
122             s = s.replaceAll("\\{", "\\\\{");
123             s = s.replaceAll("\\}", "\\\\}");
124             s = s.replaceAll("\\*\\*([^\n]+?)\\*\\*", "{\\\\it{$1}}");
125             s = s.replaceAll("__([^\n]+?)__", "{\\\\textbf{$1}}");
126             s = s.replaceAll("\\[\\[([^\n]+?)\\]\\]", "{\\\\texttt{$1}}");
127             s = s.replaceAll("LaTeX", "\\\\LaTeX");
128             s = s.replaceAll("\\%", "\\\\% ");
129             s = s.replaceAll("#", "\\\\#");
130             s = s.replaceAll("\\&", "\\\\&");
131             s = s.replaceAll("\\~", "\\\\~");
132             s = s.replaceAll("_", "\\\\_");
133             s = s.replaceAll(" \"", " ``");
134             s = s.replaceAll("\"", "''");
135             return s;
136         }
137     }
138
139
140     // Empty Nodes //////////////////////////////////////////////////////////////////////////////
141
142     class EmptyNode extends Node {
143         public EmptyNode() { }
144         public void addChild(Node o) { throw new RuntimeException(this.getClass().getName() + " cannot have children"); }
145         public void addText(String o) { throw new RuntimeException(this.getClass().getName() + " cannot have content"); }
146         public void dumpLatex(StringBuffer sb) { }
147     }
148
149     class Image extends EmptyNode {
150         public String url;
151         public String caption;
152         public String width;
153         public String align;
154         public Image(XML.Element e) {
155             url = e.getAttrVal("url"); caption = e.getAttrVal("caption"); width = e.getAttrVal("width");
156             align = e.getAttrVal("align");
157         }
158         public void dumpLatex(StringBuffer sb) {
159             if (url.endsWith(".pdf")) {
160                 if (width == null) {
161                     sb.append("\\begin{figure}[H]\n");
162                     sb.append("\\begin{center}\n");
163                     sb.append("\\epsfig{file="+url.substring(0, url.length() - 4)+",width=\\textwidth}\n");
164                     if (caption != null)
165                         sb.append("\\caption{"+fixLatex(caption)+"}\n");
166                     sb.append("\\end{center}\n");
167                     sb.append("\\end{figure}\n");
168                 } else {
169                     if ("left".equals(align)) {
170                         sb.append("\\begin{wrapfigure}{l}{"+width+"}\n");
171                     } else {
172                         sb.append("\\begin{wrapfigure}{r}{"+width+"}\n");
173                     }
174                     sb.append("\\epsfig{file="+url.substring(0, url.length() - 4)+",width="+width+"}%\n");
175                     if (caption != null)
176                         sb.append("\\caption{"+fixLatex(caption)+"}\n");
177                     sb.append("\\end{wrapfigure}\n");
178                 }
179             } else {
180                 sb.append("\\hyperimage{" + url + "}");
181             }
182         }
183     }
184
185     class Heading extends EmptyNode {
186         public String text;
187         public Heading(XML.Element e) { text = e.getAttrVal("title"); }
188         public void dumpLatex(StringBuffer sb) { sb.append("\\vspace{.6cm}\\hypertarget{" +
189                                                            fixLatex(text) + "}{\\textbf{\\textsf{" +
190                                                            fixLatex(text) + "}}}"); }
191     }
192
193     class LineBreak extends EmptyNode {
194         public LineBreak() { }
195         public void dumpLatex(StringBuffer sb) { sb.append("\\\n"); }
196     }
197
198     class ParagraphBreak extends EmptyNode {
199         public ParagraphBreak() { }
200         public void dumpLatex(StringBuffer sb) { sb.append("\n\n"); }
201     }
202
203
204
205     // Non-Paragraph Nodes //////////////////////////////////////////////////////////////////////////////
206
207     /** Nodes which contain only text; they split themselves if anything else is added */
208     class TextNode extends Node implements Cloneable {
209         public String mytext = "";
210         private boolean canAcceptMoreText = true;
211         public void dumpLatex(StringBuffer sb) { sb.append(fixLatex(mytext)); }
212         public void addChild(Node o) { canAcceptMoreText = false; parent.addChild(o); }
213         public void addText(String o) {
214             if (canAcceptMoreText) {
215                 mytext += (String)o;
216                 String[] split = mytext.split("\\n\\s*\\n");
217                 if (split.length <= 1) return;
218                 canAcceptMoreText = false;
219                 mytext = split[0];
220                 parent.addChild(new ParagraphBreak());
221                 o = "";
222                 for(int i=1; i<split.length; i++) o += split[i] + "\n\n";
223             }
224             try {
225                 TextNode clone = (TextNode)clone();
226                 clone.mytext = "";
227                 clone.canAcceptMoreText = true;
228                 parent.addChild(clone);
229                 clone.addText(o);
230             } catch (CloneNotSupportedException cnse) {
231                 throw new RuntimeException(cnse);
232             }
233         }
234     }
235
236     class Link extends TextNode {
237         public String url;
238         public String section;
239         public String appendix;
240         public String text;
241         public Link(XML.Element e) {
242             url = e.getAttrVal("url");            if ("".equals(url)) url = null;
243             appendix = e.getAttrVal("appendix");  if ("".equals(appendix)) appendix = null;
244             section = e.getAttrVal("section");    if ("".equals(section)) section = null;
245             text = e.getAttrVal("text");          if ("".equals(url)) text = null;
246             if (text == null) text = url;
247             if (text == null) text = section;
248             if (text == null) text = appendix;
249         }
250         public void dumpLatex(StringBuffer sb) {
251             // FIXME: dotted underline for section/appendix, solid underline for url
252             String text = fixLatex(this.text);
253             if (text == null) text = "\\tt " + (url != null ? url : section != null ? section : appendix);
254             if (url != null) {             sb.append("\\href{" + url + "}{\\uline{" + text + "}} ");
255             } else if (section != null) {  sb.append("\\hyperlink{" + section + "}{" + text + "} ");
256             } else if (appendix != null) { sb.append("\\hyperlink{" + appendix + "}{" + text + "} ");
257             }
258         }
259     }
260
261     class PRE extends TextNode {
262         int gobble = 0;
263         public PRE(int start, int end) {
264             while(Character.isWhitespace(buffer[start])) start++;
265             while(buffer[start] != '\n') start--;
266             start++;
267             end -= 6; // ugly hack since </pre> is 6 chars long...
268             if (Character.isWhitespace(buffer[end])) {
269                 while(Character.isWhitespace(buffer[end])) end--;
270                 end++;
271             }
272             mytext = new String(buffer, start, end - start);
273             gobble = 9999;
274             int i = 0;
275             while(true) {
276                 int start2 = i;
277                 while(i<mytext.length() && mytext.charAt(i) == ' ') i++;
278                 if (i==mytext.length()) break;
279                 gobble = java.lang.Math.min(gobble, i - start2);
280                 i = mytext.indexOf('\n', i);
281                 if (i == -1) break;
282                 i++;
283             }
284         }
285         public void dumpLatex(StringBuffer sb) {
286             sb.append("\n\n\\begin{Verbatim}[fontfamily=courier,fontsize=\\tiny,frame=single,rulecolor=\\color{CodeBorder},resetmargins=true,gobble="+gobble+"]\n");
287             sb.append(mytext);
288             sb.append("\\end{Verbatim}\n\n");
289         }
290     }
291
292
293     // Paragraph Nodes //////////////////////////////////////////////////////////////////////////////
294
295     class ParagraphNode extends Node {
296         protected Vec children = new Vec();
297         public void addChild(Node n) { children.addElement(n); n.parent = this; }
298         public void addText(String s) {
299             if (children.size() == 0 || !(children.lastElement() instanceof String))
300                 children.addElement(s);
301             else
302                 children.setElementAt(children.lastElement() + s, children.size() - 1);
303         }
304         public void dumpLatex(StringBuffer sb) {
305             for(int i=0; i<children.size(); i++) {
306                 if (children.elementAt(i) instanceof String) sb.append(fixLatex(children.elementAt(i).toString()));
307                 else ((Node)children.elementAt(i)).dumpLatex(sb);
308             }
309         }
310     }
311
312     class Property extends ParagraphNode {
313         String name = "";
314         String type = "";
315         String default_ = null;
316         public Property(XML.Element e) {
317             name = e.getAttrVal("name");
318             if (name == null || name.equals("")) name = "ERROR";
319             type = e.getAttrVal("type");
320             default_ = e.getAttrVal("default");
321             if (default_ != null && default_.trim().length() == 0) default_ = null;
322         }
323         public void dumpLatex(StringBuffer sb) {
324             StringBuffer sb2 = new StringBuffer();
325             super.dumpLatex(sb2);
326             String s = sb2.toString();
327             while(Character.isSpace(s.charAt(0))) s = s.substring(1);
328             String fname = fixLatex(name);
329             type = type == null || type.equals("") ? "" : "({\\it{" + fixLatex(type) + "}})";
330             if (name.trim().length() > 13 && name.trim().indexOf(' ') == -1) {
331                 sb.append("\n\n{\\color{CodeBorder}\\hspace{-2cm}\\dotfill\\\\\\color{black}}");
332                 sb.append("\\marginpar{\\raggedleft{\\texttt{\\textbf{\\footnotesize{"+fname+"}}}}\\\\"+type+" }");
333                 sb.append("\\\\");
334                 sb.append(s);
335             } else {
336                 sb.append("\n\n{\\color{CodeBorder}\\hspace{-2cm}\\dotfill\\\\\\color{black}}");
337                 sb.append(s.substring(0, s.indexOf(' ')));
338                 sb.append("\\marginpar{\\raggedleft{\\texttt{\\textbf{\\footnotesize{"+fname+"}}}}\\\\"+type+" }");
339                 sb.append(s.substring(s.indexOf(' ')));
340             }
341             if (default_ != null) {
342                 String fd = fixLatex(default_);
343                 fd = fd.replaceAll(" ``", " \"");
344                 fd = fd.replaceAll("''", "\"");
345                 sb.append("\\\\{\\it default: }{\\texttt{" + fd + "}}\n\n");
346             } else {
347                 sb.append("\n\n");
348             }
349         }
350     }
351
352     class Definition extends ParagraphNode {
353         String name = "";
354         public Definition(XML.Element e) { name = e.getAttrVal("term"); }
355         public void dumpLatex(StringBuffer sb) {
356             StringBuffer sb2 = new StringBuffer();
357             super.dumpLatex(sb2);
358             String s = sb2.toString();
359             while(Character.isSpace(s.charAt(0))) s = s.substring(1);
360             sb.append(s.substring(0, s.indexOf(' ')));
361             sb.append("\\marginpar{\\raggedleft{\\textbf{"+fixLatex(name)+"}}}");
362             sb.append(s.substring(s.indexOf(' ')));
363         }
364     }
365
366     class Math extends ParagraphNode {
367         String tex = "";
368         public Math(XML.Element e) { tex = e.getAttrVal("tex"); if (tex == null) tex = ""; }
369         public void addText(String s) { tex += s; }
370         public void dumpLatex(StringBuffer sb) { sb.append("\n\n$$\n" + tex.replaceAll("\n", " ") + "\n$$\n\n"); }
371     }
372
373     class Section extends ParagraphNode {
374         String name;
375         public Section(XML.Element e) {
376             name = e.getAttrVal("title");
377             if (slides) super.addChild(new List());
378         }
379         public void addText(String s) {
380             if (slides) ((List)children.elementAt(0)).addText(s);
381             else super.addText(s);
382         }
383         public void addChild(Node n) {
384             /*            if (slides) ((List)children.elementAt(0)).addChild(n);
385                           else*/ super.addChild(n);
386         }
387         public void dumpLatex(StringBuffer sb) {
388             String secs = "";
389             String base = "section";
390             int count = 0;
391             String pile = "";
392             for(Node n = parent; n != null; n = n.parent)
393                 if (n instanceof Section || n instanceof Appendix) {
394                     base = "section";
395                     secs += "sub";
396                     for (int i=0; i<count; i++) pile += "\\hspace{1cm}";
397                     pile += ((Section)n).name + "\\\\\n";
398                     count++;
399                 }
400             if (slides) {
401                 sb.append(pile);
402                 sb.append("\n\n\\begin{slide}\n");
403                 sb.append("\\slideheading{"+fixLatex(name)+"}\n");
404                 for(int i=0; i<children.size(); i++)
405                     if (children.elementAt(i) instanceof String)
406                         sb.append(fixLatex(children.elementAt(i).toString()));
407                 sb.append("\n\n\\end{slide}\n");
408                 for(int i=0; i<children.size(); i++)
409                     if (children.elementAt(i) instanceof String)
410                      ((Node)children.elementAt(i)).dumpLatex(sb);
411             } else {
412                 if (secs.length() == 0)
413                     sb.append("\\newpage\n\n");
414                 sb.append("\n\n\\hypertarget{" + name + "}{\\" + secs + base + "{" + name + "}}\n\n");
415                 super.dumpLatex(sb);
416             }
417         }
418     }
419
420     static boolean hitAppendix = false;
421     class Appendix extends Section {
422         public Appendix(XML.Element e) { super(e); }
423         public void dumpLatex(StringBuffer sb) {
424             if (!hitAppendix) sb.append("\\appendix\n");
425             hitAppendix = true;
426             super.dumpLatex(sb);
427         }
428     }
429
430     class List extends ParagraphNode {
431         TextNode textnode = null;
432         public List() { }
433         public void addChild(Node n) {
434             if (n != textnode) textnode = null;
435             super.addChild(n);
436         }
437         public void addText(String s) {
438             if (!(children.lastElement() == textnode) || (textnode == null && children.lastElement() == null))
439                 addChild(textnode = new TextNode());
440             s = s.replaceAll("\n( +)\\- ", "\n\n$1 ");
441             textnode.addText(s);
442         }
443         public int indentof(String s) {
444             for(int i=0; i<s.length(); i++)
445                 if (!Character.isWhitespace(s.charAt(i)))
446                     return i;
447             return s.length();
448         }
449         public void dumpLatex(StringBuffer sb0) {
450             StringBuffer sb = new StringBuffer();
451             boolean began = false;
452             boolean unusedItem = false;
453             List spawn = null;
454             int indentation = -1;
455             for(int i=0; i<children.size(); i++) {
456                 Object kid = children.elementAt(i);
457                 if (kid instanceof ParagraphBreak) { unusedItem = false; continue; }
458                 if (kid instanceof List) unusedItem = true;
459                 String txt = null;
460                 if (kid instanceof String) {
461                     if (kid.toString().trim().length() == 0) continue;
462                     txt = (String)children.elementAt(i);
463                 } else if (kid instanceof TextNode) {
464                     if (((TextNode)kid).mytext.trim().length() == 0) continue;
465                     txt = ((TextNode)kid).mytext;
466                 } else {
467                     if (spawn != null) {
468                         spawn.dumpLatex(sb);
469                         unusedItem = false;
470                         spawn = null;
471                     }
472                     ((Node)kid).dumpLatex(sb);
473                     continue;
474                 }
475                 if (txt.trim().length() == 0) continue;
476                 if (indentation == -1) indentation = indentof(txt);
477                 if (indentof(txt) > indentation) {
478                     if (spawn == null) spawn = new List();
479                     spawn.addText(txt);
480                     spawn.addChild(new ParagraphBreak());
481                     continue;
482                 }
483                 if (spawn != null) {
484                     spawn.dumpLatex(sb);
485                     unusedItem = false;
486                     spawn = null;
487                 }
488                 if (!unusedItem) { unusedItem = true; sb.append("\n\n\\item\n"); }
489                 sb.append(fixLatex(txt));
490             }
491             if (spawn != null) {
492                 spawn.dumpLatex(sb);
493                 spawn = null;
494             }
495             if (sb.toString().replaceAll("\\[.+\\]", "").trim().length() > 0) {
496                 sb0.append("\n\\begin{itemize}\n");
497                 sb0.append(sb.toString());
498                 sb0.append("\n\\end{itemize}\n");
499             }
500         }
501     }
502
503     class Root extends ParagraphNode {
504         String title = "You forgot the title, you idiot!";
505         String author = "Your Mom";
506         String email = null;
507         String subtitle = null;
508         public Root(XML.Element e) {
509             root = this;
510             title = e.getAttrVal("title");
511             author = e.getAttrVal("author");
512             email = e.getAttrVal("email");
513             subtitle = e.getAttrVal("subtitle");
514         }
515         public void addText(String s) {
516             if (victim != null) ((Node)victim).addText(s);
517         }
518         public void addChild(Node n) {
519             if (!(n instanceof Section))
520                 ((Section)victim).addChild(n);
521             else
522                 super.addChild(n);
523         }
524         public void dumpLatex(StringBuffer sb) {
525             if (slides) {
526                 sb.append("\\documentclass[letter]{seminar}\n");
527                 sb.append("\\usepackage{calc}               % Simple computations with LaTeX variables\n");
528                 sb.append("\\usepackage[hang]{caption2}     % Improved captions\n");
529                 sb.append("\\usepackage{fancybox}           % To have several backgrounds\n");
530                 sb.append("                                % (must be loaded before `fancyvrb')\n");
531                 sb.append("\\usepackage{fancyhdr}           % Headers and footers definitions\n");
532                 sb.append("\\usepackage{fancyvrb}           % Fancy verbatim environments\n");
533                 sb.append("\\usepackage{wrapfig}\n");
534                 sb.append("\\usepackage{float}\n");
535                 sb.append("\\usepackage{amsmath}\n");
536                 sb.append("\\usepackage{amssymb}\n");
537                 sb.append("\\usepackage{pdftricks}\n");
538                 sb.append("\\begin{psinputs}\n");
539                 sb.append("  \\usepackage{pstcol}             % PSTricks with the standard color package\n");
540                 sb.append("                                  % (before `graphicx' for the \\scalebox macro)\n");
541                 sb.append("  \\usepackage{graphicx}           % Standard graphics package\n");
542                 sb.append("  \\usepackage{multido}            % General loop macro\n");
543                 sb.append("  \\usepackage{pifont}             % Ding symbols (mainly for lists)\n");
544                 sb.append("  \\usepackage{pst-fr3d}           % PSTricks 3D framed boxes\n");
545                 sb.append("  \\usepackage{pst-grad}           % PSTricks gradient mode\n");
546                 sb.append("  \\usepackage{pst-node}           % PSTricks nodes\n");
547                 sb.append("  \\usepackage{pst-slpe}           % Improved PSTricks gradients\n");
548                 sb.append("\\end{psinputs}\n");
549                 sb.append("\\usepackage{color}\n");
550                 sb.append("\\definecolor{CodeBorder}{rgb}{0.6,0.6,0.6}\n");
551                 sb.append("\\definecolor{CodeBackground}{rgb}{0.93,0.93,0.93}\n");
552                 sb.append("\\usepackage{graphicx}\n");
553                 sb.append("\\usepackage{courier}\n");
554                 sb.append("\\usepackage{fancyvrb}\n");
555                 sb.append("\\usepackage{float}\n");
556                 sb.append("\\usepackage{fvrb-ex}\n");
557                 sb.append("\\usepackage{bold-extra}\n");
558                 sb.append("\\usepackage{ulem}\n");
559                 sb.append("\\usepackage{amssymb,amsmath,epsfig,alltt}\n");
560                 sb.append("\\usepackage{semcolor}           % Seminar colored slides\n");
561                 sb.append("\\usepackage{semhelv}            % Seminar helvetica fonts\n");
562                 sb.append("\\usepackage{semlayer}           % Seminar overlays\n");
563                 sb.append("\\usepackage{slidesec}           % Seminar sections and list of slides\n");
564                 sb.append("\\usepackage{url}                % Convenient URL typesetting\n");
565                 sb.append("\\usepackage[pdftex,letterpaper,pdffitwindow=true,colorlinks=true,pdfpagemode=UseNone,\n");
566                 sb.append("            bookmarks=true]{hyperref} % Hyperlinks for PDF versions\n");
567                 sb.append("\\usepackage{hcolor}\n");
568                 sb.append("\\slidepagestyle{fancy}\n");
569                 sb.append("\n");
570                 sb.append("\\slidesmag{4}     % Set magnification of slide\n");
571                 sb.append("\\def\\SeminarPaperWidth{\\paperwidth / 2}\n");
572                 sb.append("\\def\\SeminarPaperHeight{\\paperheight / 2}\n");
573                 sb.append("\\slideframe{none} % No default frame\n");
574                 sb.append("\n");
575                 sb.append("  \n");
576                 sb.append("\n");
577                 sb.append("  % General size parameters\n");
578                 sb.append("\\renewcommand{\\slideparindent}{5mm}\n");
579                 sb.append("\\raggedslides[0mm]\n");
580                 sb.append("%  \\renewcommand{\\slidetopmargin}{15.5mm}\n");
581                 sb.append("%  \\renewcommand{\\slidebottommargin}{13mm}\n");
582                 sb.append("%  \\renewcommand{\\slideleftmargin}{4mm}\n");
583                 sb.append("%  \\renewcommand{\\sliderightmargin}{4mm}\n");
584                 sb.append("  % To adjust the frame length to the header and footer ones\n");
585                 sb.append("%  \\autoslidemarginstrue\n");
586                 sb.append("  % We suppress the header and footer `fancyhdr' rules\n");
587                 sb.append("\\fancyhf{} % Clear all fields\n");
588                 sb.append("\\renewcommand{\\headrule}{}\n");
589                 sb.append("\\renewcommand{\\footrule}{}\n");
590                 sb.append("\n");
591                 sb.append("%  \\usepackage{nohyperref}       % To deactivate the `hyperref' features\n");
592                 sb.append("%  \\overlaysfalse                % To suppress overlays\n");
593                 sb.append("%  \\def\\special@paper{}% Needed to avoid `hyperref' to collapse with ``dvips''\n");
594                 sb.append("\\newslideframe{IMAGE}{%\n");
595                 sb.append("  \\boxput{\\rput(0,0){%\n");
596                 sb.append("      \\includegraphics[width=\\SeminarPaperHeight,height=\\SeminarPaperWidth]{background.pdf}}}{#1}}\n");
597                 sb.append("\\slideframe*{IMAGE}\n");
598                 sb.append("%\\renewcommand{\\slideleftmargin}{3cm}\n");
599                 sb.append("%\\addtolength{\\slidewidth}{-\\slideleftmargin}\n");
600                 sb.append("\\RequirePackage[T1]{fontenc}\n");
601                 sb.append("\\RequirePackage{textcomp}\n");
602                 sb.append("\\renewcommand{\\rmdefault}{trebuchet}\n");
603                 sb.append("\\renewcommand{\\slidefonts}{%\n");
604                 sb.append("  \\renewcommand{\\rmdefault}{trebuchet}%\n");
605                 sb.append("  \\renewcommand{\\ttdefault}{courier}}%\n");
606                 sb.append("  \\newcommand{\\ParagraphTitle}[2][black]{%\n");
607                 sb.append("  \\noindent\\psshadowbox[fillstyle=solid,fillcolor=#1]{\\large{#2}}}\n");
608                 sb.append("  \\newcommand{\\CenteredParagraphTitle}[2][black]{%\n");
609                 sb.append("  \\centerline{\\psshadowbox[fillstyle=solid,fillcolor=#1]{\\large{#2}}}}\n");
610                 sb.append("  \\renewcommand{\\makeslideheading}[1]{%\n");
611                 sb.append("  \\CenteredParagraphTitle[black]{%\n");
612                 sb.append("    \\textcolor{black}{\\huge\\textbf{#1}}}}\n");
613                 sb.append("  \\renewcommand{\\makeslidesubheading}[1]{%\n");
614                 sb.append("    \\CenteredParagraphTitle{\\Large\\theslidesubsection{} -- #1}}\n");
615                 sb.append("  \\renewenvironment{dinglist}[2][black]\n");
616                 sb.append("  {\\begin{list}{\\ding{#2}}{}}{\\end{list}}\n");
617                 sb.append("  \\newcommand{\\DingListSymbolA}{43}\n");
618                 sb.append("  \\newcommand{\\DingListSymbolB}{243}\n");
619                 sb.append("  \\newcommand{\\DingListSymbolC}{224}\n");
620                 sb.append("  \\newcommand{\\DingListSymbolD}{219}\n");
621                 sb.append("  \\newcommand{\\eqbox}[2][0.6]{%\n");
622                 sb.append("  \\centerline{\\psshadowbox[fillstyle=solid,fillcolor=gray]{%\n");
623                 sb.append("  \\parbox{#1\\hsize}{%\n");
624                 sb.append("      \\[\n");
625                 sb.append("        \\textcolor{black} {#2}\n");
626                 sb.append("      \\]}}}}\n");
627                 sb.append("\\begin{document}\n");
628                 sb.append("\\begin{slide}\n");
629                 sb.append("\\begin{center}\n");
630                 sb.append("\\ParagraphTitle{\\bf \\Large "+title+"}\n");
631                 sb.append("\\vspace{5mm} \\\n");
632                 sb.append("\\textit{\\large "+subtitle+"} \\\\\n");
633                 sb.append("\\vspace{5mm} \\\n");
634                 sb.append("\\textit{"+author+"} \\\n");
635                 sb.append("\\end{center}\n");
636                 sb.append("\\end{slide}\n\n");
637                 super.dumpLatex(sb);
638                 sb.append("\\end{document}");
639             } else {
640                 sb.append("\\documentclass{article}\n");
641                 sb.append("\\def\\ninept{\\def\\baselinestretch{.95}\\let\\normalsize\\small\\normalsize}\n");
642                 sb.append("\\ninept\n");
643                 sb.append("\\usepackage{color}\n");
644                 sb.append("\\definecolor{CodeBorder}{rgb}{0.6,0.6,0.6}\n");
645                 sb.append("\\definecolor{CodeBackground}{rgb}{0.93,0.93,0.93}\n");
646                 sb.append("\\usepackage{graphicx}\n");
647                 sb.append("\\usepackage{courier}\n");
648                 sb.append("\\usepackage{fancyvrb}\n");
649                 sb.append("\\usepackage{float}\n");
650                 sb.append("\\usepackage{wrapfig}\n");
651                 sb.append("\\usepackage{fvrb-ex}\n");
652                 sb.append("\\usepackage{bold-extra}\n");
653                 sb.append("\\usepackage{ulem}\n");
654                 sb.append("\\usepackage{amssymb,amsmath,epsfig,alltt}\n");
655                 sb.append("\\sloppy\n");
656                 sb.append("\\usepackage{palatino}\n");
657                 sb.append("\\usepackage{sectsty}\n");
658                 sb.append("\\allsectionsfont{\\sffamily}\n");
659                 sb.append("\\sectionfont{\\color{black}\\leftskip=-2cm");
660                 sb.append("\\hrulefill\\\\\\sffamily\\bfseries\\raggedleft\\vspace{1cm}}\n");
661                 sb.append("\\subsectionfont{\\color{black}\\dotfill\\\\\\sffamily\\raggedright\\hspace{-4cm}}\n");
662                 sb.append("\\newdimen\\sectskip\n");
663                 sb.append("\\newdimen\\subsectskip\n");
664                 sb.append("\\newdimen\\saveskip\n");
665                 sb.append("\\saveskip=\\leftskip\n");
666                 sb.append("\\sectskip=-2cm\n");
667                 sb.append("\\subsectskip=0cm\n");
668                 sb.append("\\let\\oldsection\\section\n");
669                 sb.append("\\let\\oldsubsection\\subsection\n");
670                 sb.append("\\def\\subsection#1{\\leftskip=\\sectskip\\oldsubsection{#1}\\leftskip=0cm}\n");
671                 sb.append("\\usepackage{parskip}\n");
672                 sb.append("\\usepackage{tabularx}\n");
673                 sb.append("\\usepackage{alltt}\n");
674                 sb.append("\\usepackage[pdftex,colorlinks=true,urlcolor=blue,linkcolor=blue,bookmarks=true]{hyperref}\n");
675                 // FIXME: pdfauthor, pdftitle, pdfsubject, pdfkeywords?
676                 sb.append("\n");
677                 sb.append("\\begin{document}\n");
678                 sb.append("\\reversemarginpar\n");
679                 sb.append("\n");
680                 sb.append("\\title{\\textbf{\\textsf{\n");
681                 sb.append(title);
682                 if (subtitle != null) sb.append("\\\\{\\large " + subtitle + "}\n");
683                 sb.append("}}}\n");
684                 if (author != null) {
685                     sb.append("\\author{\n");
686                     sb.append(author);
687                     if (email != null) sb.append("\\\\{\\tt " + email + "}\n");
688                     sb.append("}\n");
689                 }
690                 sb.append("\n");
691                 sb.append("\\maketitle\n");
692                 sb.append("\\clearpage\n");
693                 sb.append("\\tableofcontents\n");
694                 sb.append("\\clearpage\n");
695                 sb.append("\\onecolumn\n");
696                 super.dumpLatex(sb);
697                 sb.append("\\end{document}");
698             }
699         }
700     }
701 }
702