diff options
Diffstat (limited to 'libjava/classpath/javax/swing/text/html/HTMLDocument.java')
-rw-r--r-- | libjava/classpath/javax/swing/text/html/HTMLDocument.java | 154 |
1 files changed, 17 insertions, 137 deletions
diff --git a/libjava/classpath/javax/swing/text/html/HTMLDocument.java b/libjava/classpath/javax/swing/text/html/HTMLDocument.java index fba6cad12e9..b7a706904a4 100644 --- a/libjava/classpath/javax/swing/text/html/HTMLDocument.java +++ b/libjava/classpath/javax/swing/text/html/HTMLDocument.java @@ -40,14 +40,12 @@ package javax.swing.text.html; import gnu.classpath.NotImplementedException; +import gnu.javax.swing.text.html.CharacterAttributeTranslator; import java.io.IOException; import java.net.URL; import java.util.HashMap; import java.util.Stack; import java.util.Vector; - -import javax.swing.event.DocumentEvent; -import javax.swing.event.UndoableEditEvent; import javax.swing.text.AbstractDocument; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; @@ -131,21 +129,6 @@ public class HTMLDocument extends DefaultStyledDocument } /** - * Replaces the contents of the document with the given element - * specifications. This is called before insert if the loading is done - * in bursts. This is the only method called if loading the document - * entirely in one burst. - * - * @param data - the date that replaces the content of the document - */ - protected void create(DefaultStyledDocument.ElementSpec[] data) - { - // Once the super behaviour is properly implemented it should be sufficient - // to simply call super.create(data). - super.create(data); - } - - /** * This method creates a root element for the new document. * * @return the new default root @@ -216,41 +199,6 @@ public class HTMLDocument extends DefaultStyledDocument } /** - * Inserts new elements in bulk. This is how elements get created in the - * document. The parsing determines what structure is needed and creates the - * specification as a set of tokens that describe the edit while leaving the - * document free of a write-lock. This method can then be called in bursts by - * the reader to acquire a write-lock for a shorter duration (i.e. while the - * document is actually being altered). - * - * @param offset - the starting offset - * @param data - the element data - * @throws BadLocationException - if the given position does not - * represent a valid location in the associated document. - */ - protected void insert(int offset, DefaultStyledDocument.ElementSpec[] data) - throws BadLocationException - { - super.insert(offset, data); - } - - /** - * Updates document structure as a result of text insertion. This will happen - * within a write lock. This implementation simply parses the inserted content - * for line breaks and builds up a set of instructions for the element buffer. - * - * @param chng - a description of the document change - * @param attr - the attributes - */ - protected void insertUpdate(AbstractDocument.DefaultDocumentEvent chng, - AttributeSet attr) - { - // FIXME: Not implemented - System.out.println("insertUpdate not implemented"); - super.insertUpdate(chng, attr); - } - - /** * Returns the parser used by this HTMLDocument to insert HTML. * * @return the parser used by this HTMLDocument to insert HTML. @@ -414,6 +362,7 @@ public class HTMLDocument extends DefaultStyledDocument } public void processHTMLFrameHyperlinkEvent(HTMLFrameHyperlinkEvent event) + throws NotImplementedException { // TODO: Implement this properly. } @@ -646,12 +595,16 @@ public class HTMLDocument extends DefaultStyledDocument { // Put the old attribute set on the stack. pushCharacterStyle(); - - // And create the new one by adding the attributes in <code>a</code>. - if (a != null) - charAttr.addAttribute(t, a.copyAttributes()); + + // Translate tag.. return if succesful. + if(CharacterAttributeTranslator.translateTag(charAttr, t, a)) + return; + + // Just add the attributes in <code>a</code>. + if (a != null) + charAttr.addAttribute(t, a.copyAttributes()); } - + /** * Called when an end tag is seen for one of the types of tags associated * with this Action. @@ -724,17 +677,6 @@ public class HTMLDocument extends DefaultStyledDocument // FIXME: Implement. print ("IsindexAction.start not implemented"); } - - /** - * Called when an end tag is seen for one of the types of tags associated - * with this Action. - */ - public void end(HTML.Tag t) - throws NotImplementedException - { - // FIXME: Implement. - print ("IsindexAction.end not implemented"); - } } public class ParagraphAction extends BlockAction @@ -745,7 +687,6 @@ public class HTMLDocument extends DefaultStyledDocument */ public void start(HTML.Tag t, MutableAttributeSet a) { - // FIXME: What else must be done here? blockOpen(t, a); } @@ -755,7 +696,6 @@ public class HTMLDocument extends DefaultStyledDocument */ public void end(HTML.Tag t) { - // FIXME: What else must be done here? blockClose(t); } } @@ -771,6 +711,7 @@ public class HTMLDocument extends DefaultStyledDocument { // FIXME: Implement. print ("PreAction.start not implemented"); + super.start(t, a); } /** @@ -782,6 +723,7 @@ public class HTMLDocument extends DefaultStyledDocument { // FIXME: Implement. print ("PreAction.end not implemented"); + super.end(t); } } @@ -792,22 +734,9 @@ public class HTMLDocument extends DefaultStyledDocument * of tags associated with this Action. */ public void start(HTML.Tag t, MutableAttributeSet a) - throws NotImplementedException { - // FIXME: Implement. - print ("SpecialAction.start not implemented"); + addSpecialElement(t, a); } - - /** - * Called when an end tag is seen for one of the types of tags associated - * with this Action. - */ - public void end(HTML.Tag t) - throws NotImplementedException - { - // FIXME: Implement. - print ("SpecialAction.end not implemented"); - } } class AreaAction extends TagAction @@ -1131,7 +1060,7 @@ public class HTMLDocument extends DefaultStyledDocument */ protected void pushCharacterStyle() { - charAttrStack.push(charAttr); + charAttrStack.push(charAttr.copyAttributes()); } /** @@ -1565,8 +1494,8 @@ public class HTMLDocument extends DefaultStyledDocument */ public Element getElement(String attrId) { - Element root = getDefaultRootElement(); - return getElement(root, HTML.getAttributeKey(attrId) , attrId); + return getElement(getDefaultRootElement(), HTML.getAttributeKey(attrId), + attrId); } /** @@ -1690,53 +1619,4 @@ public class HTMLDocument extends DefaultStyledDocument // FIXME: Not implemented fully, use InsertHTML* in HTMLEditorKit? System.out.println("insertAfterStart not implemented"); } - - /** - * This method sets the attributes associated with the paragraph containing - * offset. If replace is false, s is merged with existing attributes. The - * length argument determines how many characters are affected by the new - * attributes. This is often the entire paragraph. - * - * @param offset - - * the offset into the paragraph (must be at least 0) - * @param length - - * the number of characters affected (must be at least 0) - * @param s - - * the attributes - * @param replace - - * whether to replace existing attributes, or merge them - */ - public void setParagraphAttributes(int offset, int length, AttributeSet s, - boolean replace) - throws NotImplementedException - { - // FIXME: Not implemented. - System.out.println("setParagraphAttributes not implemented"); - super.setParagraphAttributes(offset, length, s, replace); - } - - /** - * This method flags a change in the document. - * - * @param e - the Document event - */ - protected void fireChangedUpdate(DocumentEvent e) - throws NotImplementedException - { - // FIXME: Not implemented. - System.out.println("fireChangedUpdate not implemented"); - super.fireChangedUpdate(e); - } - - /** - * This method fires an event intended to be caught by Undo listeners. It - * simply calls the super version inherited from DefaultStyledDocument. With - * this method, an HTML editor could easily provide undo support. - * - * @param e - the UndoableEditEvent - */ - protected void fireUndoableEditUpdate(UndoableEditEvent e) - { - super.fireUndoableEditUpdate(e); - } } |