1 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 Header { 38 private Document _document; 39 private String _product; 40 private String _version; 41 private String _title; 42 private String _author; 43 private String _date; 44 private Section _description; 45 private Keywords _keywords; 46 private String _tutorial; 47 48 public Header(Document document) 49 { 50 _document = document; 51 } 52 53 public void setProduct(String product) 54 { 55 _product = product; 56 } 57 58 public void setVersion(String version) 59 { 60 _version = version; 61 } 62 63 public void setTitle(String title) 64 { 65 _title = title; 66 } 67 68 public String getTitle() 69 { 70 return _title; 71 } 72 73 public void setDate(String date) 74 { 75 _date = date; 76 } 77 78 public void setAuthor(String author) 79 { 80 _author = author; 81 } 82 83 public void setResin2_0(String resin2_0) 84 { 85 } 86 87 public void setType(String type) 88 { 89 } 90 91 public void setTutorialStartPage(String startPage) 92 { 93 _tutorial = startPage; 94 } 95 96 public String getTutorialStartPage() 97 { 98 return _tutorial; 99 } 100 101 public void setLevel(String level) 102 { 103 } 104 105 public void setKeywords(Keywords keywords) 106 { 107 _keywords = keywords; 108 } 109 110 public ContentItem getDescription() 111 { 112 return _description; 113 } 114 115 public Section createDescription() 116 { 117 _description = new S1(_document); 118 return _description; 119 } 120 121 public void writeHtml(XMLStreamWriter out) 122 throws XMLStreamException 123 { 124 out.writeStartElement("head"); 125 126 out.writeEmptyElement("meta"); 127 out.writeAttribute("http-equiv", "Content-Type"); 128 out.writeAttribute("content", "text/html; charset=utf-8"); 129 130 if (_product != null) { 131 out.writeEmptyElement("meta"); 132 out.writeAttribute("name", "product"); 133 out.writeAttribute("content", _product); 134 } 135 136 if (_version != null) { 137 out.writeEmptyElement("meta"); 138 out.writeAttribute("name", "version"); 139 out.writeAttribute("content", _version); 140 } 141 142 if (_keywords != null) { 143 out.writeEmptyElement("meta"); 144 out.writeAttribute("name", "keywords"); 145 out.writeAttribute("content", _keywords.toString()); 146 } 147 148 out.writeEmptyElement("link"); 149 out.writeAttribute("rel", "STYLESHEET"); 150 out.writeAttribute("type", "text/css"); 151 out.writeAttribute("href", _document.getContextPath() + "/css/default.css"); 152 153 out.writeStartElement("title"); 154 155 NavigationItem nav = _document.getNavigation(); 156 157 if (nav != null 158 && nav.getNavigation() != null 159 && nav.getNavigation().getSection() != null) 160 out.writeCharacters(nav.getNavigation().getSection()); 161 162 out.writeCharacters(_title); 163 out.writeEndElement(); 165 out.writeEndElement(); } 167 168 public void writeLaTeXTop(PrintWriter out) 169 throws IOException 170 { 171 out.println("\\usepackage[margin=1in]{geometry}"); 172 out.println("\\usepackage{url}"); 173 out.println("\\usepackage{hyperref}"); 174 out.println("\\usepackage{graphicx}"); 175 out.println("\\usepackage{color}"); 176 out.println("\\usepackage{colortbl}"); 177 out.println("\\usepackage{fancyvrb}"); 178 out.println("\\usepackage{listings}"); 179 out.println(); 180 out.println("\\definecolor{example-gray}{gray}{0.8}"); 181 out.println("\\definecolor{results-gray}{gray}{0.6}"); 182 out.println(); 183 out.println("\\title{" + _title + "}"); 184 } 186 187 public void writeLaTeX(PrintWriter out) 188 throws IOException 189 { 190 out.println("\\section{" + _title + "}"); 191 192 out.println("\\label{" + _document.getName() + "}"); 193 out.println("\\hypertarget{" + _document.getName() + "}{}"); 194 } 195 196 public void writeLaTeXEnclosed(PrintWriter out) 197 throws IOException 198 { 199 out.println("\\subsection{" + _title + "}"); 200 201 out.println("\\label{" + _document.getName() + "}"); 202 out.println("\\hypertarget{" + _document.getName() + "}{}"); 203 } 204 } 205 | Popular Tags |