Ugh! Attached wrong patch.. here is the correct one.

Lillian



On Fri, 2006-01-13 at 11:21 -0500, Lillian Angel wrote:
> Cleaned up the code in DefaultStyledDocument.
> 
> 2006-01-13  Lillian Angel  <[EMAIL PROTECTED]>
> 
>         * javax/swing/text/DefaultStyledDocument.java:
>         Removed unused fields.
>         (insert): Removed unused fields.
>         (endEdit): Removed, not needed.
>         (insertUpdate): Removed call to endEdit.
>         (prepareContentInsertion): Removed, not needed.
>         (insertContentTag): Removed call to prepareContentInsertion.
>         (printElements): Removed, not needed.
>         (attributeSetsAreSame): Removed, not needed.
> 
Index: javax/swing/text/DefaultStyledDocument.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.35
diff -u -r1.35 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	12 Jan 2006 22:53:25 -0000	1.35
+++ javax/swing/text/DefaultStyledDocument.java	13 Jan 2006 16:19:49 -0000
@@ -433,34 +433,12 @@
     private int endOffset;
 
     /**
-     * The number of inserted end tags. This is a counter which always gets
-     * incremented when an end tag is inserted. This is evaluated before
-     * content insertion to go up the element stack.
-     */
-    private int numEndTags;
-
-    /**
-     * The number of inserted start tags. This is a counter which always gets
-     * incremented when an end tag is inserted. This is evaluated before
-     * content insertion to go up the element stack.
-     */
-    private int numStartTags;
-
-    /**
      * The current position in the element tree. This is used for bulk inserts
      * using ElementSpecs.
      */
     private Stack elementStack;
 
     /**
-     * Holds fractured elements during insertion of end and start tags.
-     * Inserting an end tag may lead to fracturing of the current paragraph
-     * element. The elements that have been cut off may be added to the
-     * next paragraph that is created in the next start tag.
-     */
-    Element[] fracture;
-
-    /**
      * The ElementChange that describes the latest changes.
      */
     DefaultDocumentEvent documentEvent;
@@ -767,8 +745,6 @@
       elementStack.clear();
       elementStack.push(root);
       elementStack.push(root.getElement(root.getElementIndex(offset)));
-      numEndTags = 0;
-      numStartTags = 0;
       insertUpdate(data);
     }
 
@@ -851,40 +827,6 @@
               break;
             }
         }
-      endEdit();
-    }
-
-    /**
-     * Finishes an insertion by possibly evaluating the outstanding start and
-     * end tags. However, this is only performed if the event has received any
-     * modifications.
-     */
-    private void endEdit()
-    {
-      if (documentEvent.modified)
-        prepareContentInsertion();
-    }
-
-    /**
-     * Evaluates the number of inserted end tags and performs the corresponding
-     * structural changes.
-     */
-    private void prepareContentInsertion()
-    {
-      while (numEndTags > 0)
-        {
-          elementStack.pop();
-          numEndTags--;
-        }
-
-      while (numStartTags > 0)
-        {
-          Element current = (Element) elementStack.peek();
-          Element newParagraph =
-            insertParagraph((BranchElement) current, offset);
-          elementStack.push(newParagraph);
-          numStartTags--;
-        }
     }
 
     private Element insertParagraph(BranchElement par, int offset)
@@ -1025,7 +967,6 @@
      */
     private void insertContentTag(ElementSpec tag)
     {
-      prepareContentInsertion();
       int len = tag.getLength();
       int dir = tag.getDirection();
       AttributeSet tagAtts = tag.getAttributes();
@@ -1921,35 +1862,6 @@
   {
     // Nothing to do here. This is intended to be overridden by subclasses.
   }
-
-  void printElements (Element start, int pad)
-  {
-    for (int i = 0; i < pad; i++)
-      System.out.print(" ");
-    if (pad == 0)
-      System.out.println ("ROOT ELEMENT ("+start.getStartOffset()+", "+start.getEndOffset()+")");
-    else if (start instanceof AbstractDocument.BranchElement)
-      System.out.println ("BranchElement ("+start.getStartOffset()+", "+start.getEndOffset()+")");
-    else
-      {
-        {
-          try
-            {
-              System.out.println ("LeafElement ("+start.getStartOffset()+", "
-                                  + start.getEndOffset()+"): "+ 
-                                  start.getDocument().
-                                  getText(start.getStartOffset(), 
-                                          start.getEndOffset() - 
-                                          start.getStartOffset()));
-            }
-          catch (BadLocationException ble)
-            {
-            }
-        }
-      }
-    for (int i = 0; i < start.getElementCount(); i ++)
-      printElements (start.getElement(i), pad+3);
-  }
   
   /**
    * Inserts a bulk of structured content at once.
@@ -2034,9 +1946,4 @@
         throw err;
       }
   }
-  
-  static boolean attributeSetsAreSame (AttributeSet a, AttributeSet b)
-  {
-    return (a == null && b == null) || (a != null && a.isEqual(b));
-  }
 }
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to