This wires the fresh HTMLWriter and the already-existing
MinimalHTMLWriter into the HTMLEditorKit to allow writing of
HTMLDocuments and StyledDocuments as HTML.

2006-10-31  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/text/html/HTMLEditorKit.java
        (write): Use HTMLWriter or MinimalHTMLWriter for writing
        HTML or Styled documents.

/Roman

Index: javax/swing/text/html/HTMLEditorKit.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/HTMLEditorKit.java,v
retrieving revision 1.34
diff -u -1 -5 -r1.34 HTMLEditorKit.java
--- javax/swing/text/html/HTMLEditorKit.java	17 Sep 2006 23:13:54 -0000	1.34
+++ javax/swing/text/html/HTMLEditorKit.java	31 Oct 2006 11:56:07 -0000
@@ -54,30 +54,31 @@
 import java.io.Serializable;
 import java.io.StringReader;
 import java.io.Writer;
 
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 
 import javax.swing.Action;
 import javax.swing.JEditorPane;
 import javax.swing.text.BadLocationException;
 import javax.swing.text.Document;
 import javax.swing.text.EditorKit;
 import javax.swing.text.Element;
 import javax.swing.text.MutableAttributeSet;
 import javax.swing.text.StyleConstants;
+import javax.swing.text.StyledDocument;
 import javax.swing.text.StyledEditorKit;
 import javax.swing.text.TextAction;
 import javax.swing.text.View;
 import javax.swing.text.ViewFactory;
 import javax.swing.text.html.parser.ParserDelegator;
 
 /* Move these imports here after javax.swing.text.html to make it compile
    with jikes.  */
 import gnu.javax.swing.text.html.parser.GnuParserDelegator;
 import gnu.javax.swing.text.html.parser.HTML_401Swing;
 
 /**
  * @author Lillian Angel (langel at redhat dot com)
  */
 public class HTMLEditorKit
@@ -970,32 +971,39 @@
    * an appropriate format.
    * 
    * @param out - the stream to write to
    * @param doc - the source for the write
    * @param pos - the location in the document to get the content.
    * @param len - the amount to write out
    * @throws IOException - on any I/O error
    * @throws BadLocationException - if pos represents an invalid location
    * within the document
    */
   public void write(Writer out, Document doc, int pos, int len)
       throws IOException, BadLocationException
   {
     if (doc instanceof HTMLDocument)
       {
-        // FIXME: Not implemented. Use HTMLWriter.
-        out.write(doc.getText(pos, len));
+        HTMLWriter writer = new HTMLWriter(out, (HTMLDocument) doc, pos, len);
+        writer.write();
+      }
+    else if (doc instanceof StyledDocument)
+      {
+        MinimalHTMLWriter writer = new MinimalHTMLWriter(out,
+                                                         (StyledDocument) doc,
+                                                         pos, len);
+        writer.write();
       }
     else
       super.write(out, doc, pos, len);
   }
   
   /**
    * Gets the content type that the kit supports.
    * This kit supports the type text/html.
    * 
    * @returns the content type supported.
    */
   public String getContentType()
   {
     return contentType;
   } 

Reply via email to