1 7 package javax.swing.text.rtf; 8 9 import java.awt.*; 10 import java.io.*; 11 import java.net.MalformedURLException ; 12 import java.net.URL ; 13 import javax.swing.Action ; 14 import javax.swing.text.*; 15 import javax.swing.*; 16 17 26 public class RTFEditorKit extends StyledEditorKit { 27 28 31 public RTFEditorKit() { 32 super(); 33 } 34 35 42 public String getContentType() { 43 return "text/rtf"; 44 } 45 46 59 public void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException { 60 61 if (doc instanceof StyledDocument) { 62 RTFReader rdr = new RTFReader ((StyledDocument) doc); 65 rdr.readFromStream(in); 66 rdr.close(); 67 } else { 68 super.read(in, doc, pos); 70 } 71 } 72 73 86 public void write(OutputStream out, Document doc, int pos, int len) 87 throws IOException, BadLocationException { 88 89 RTFGenerator.writeDocument(doc, out); 92 } 93 94 106 public void read(Reader in, Document doc, int pos) 107 throws IOException, BadLocationException { 108 109 if (doc instanceof StyledDocument) { 110 RTFReader rdr = new RTFReader ((StyledDocument) doc); 111 rdr.readFromReader(in); 112 rdr.close(); 113 } else { 114 super.read(in, doc, pos); 116 } 117 } 118 119 132 public void write(Writer out, Document doc, int pos, int len) 133 throws IOException, BadLocationException { 134 135 throw new IOException("RTF is an 8-bit format"); 136 } 137 138 } 139
| Popular Tags
|