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.LineNumberReader ; 36 import java.io.PrintWriter ; 37 import java.io.StringReader ; 38 import java.util.logging.Logger ; 39 40 public class VerboseText implements ContentItem { 41 private Logger log = Logger.getLogger(VerboseText.class.getName()); 42 private String _text; 43 private Document _document; 44 45 public VerboseText(String text, Document document) 46 { 47 _text = text; 48 _document = document; 49 } 50 51 public void writeHtml(XMLStreamWriter out) 52 throws XMLStreamException 53 { 54 out.writeCharacters(_text); 55 } 56 57 public void writeLaTeX(PrintWriter out) 58 throws IOException 59 { 60 StringReader stringReader = new StringReader (_text); 61 LineNumberReader lineReader = new LineNumberReader (stringReader); 62 63 for (String line = lineReader.readLine(); 64 line != null; 65 line = lineReader.readLine()) { 66 if (line.length() > 70) { 67 log.warning("lines longer than 70 characters will not work in LaTeX"); 68 log.warning(line); 69 log.warning("document: " + _document.getDocumentPath()); 70 } 71 } 72 73 out.print(_text); 74 } 75 76 public void writeLaTeXEnclosed(PrintWriter out) 77 throws IOException 78 { 79 writeLaTeX(out); 80 } 81 82 public void writeLaTeXTop(PrintWriter out) 83 throws IOException 84 { 85 writeLaTeX(out); 86 } 87 } 88 | Popular Tags |