Hi,

I implemented the method setParagraphAttributes in
javax.swing.text.DefaultStyledDocument. Also I check in a little fix to
avoid an NPE in this class.

2005-09-20  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/text/DefaultStyledDocument.java
        (setParagraphAttributes): Implemented this method.
        (insertUpdate): Fixed attribute comparison to avoid NPE.

/Roman
Index: javax/swing/text/DefaultStyledDocument.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.11
diff -u -r1.11 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	14 Sep 2005 22:00:38 -0000	1.11
+++ javax/swing/text/DefaultStyledDocument.java	20 Sep 2005 08:49:02 -0000
@@ -1025,11 +1025,19 @@
    *     selection are overridden, otherwise they are merged
    */
   public void setParagraphAttributes(int offset, int length,
-				     AttributeSet attributes,
-				     boolean replace)
+                                     AttributeSet attributes,
+                                     boolean replace)
   {
-    // FIXME: Implement me.
-    throw new Error("not implemented");
+    int index = offset;
+    while (index < offset + length)
+      {
+        AbstractElement par = (AbstractElement) getParagraphElement(index);
+        AttributeContext ctx = getAttributeContext();
+        if (replace)
+          par.removeAttributes(par);
+        par.addAttributes(attributes);
+        index = par.getElementCount();
+      }
   }
 
   /**
@@ -1081,7 +1089,7 @@
             // joined with the previous element.
             else if (specs.size() == 0)
               {
-                if (attr.isEqual(prev.getAttributes()))
+                if (prev.getAttributes().isEqual(attr))
                     spec.setDirection(ElementSpec.JoinPreviousDirection);
               }
 
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to