This makes some mauve test quiet. It sets a document property that we
should make use of one day, and it checks the bounds in removeImpl().

2006-06-22  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/text/AbstractDocument.java
        (AbstractDocument): Set the i18n document property.
        (removeImpl): Added checks for correct boundaries.

/Roman
-- 
“Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.” - William Blake
Index: javax/swing/text/AbstractDocument.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/AbstractDocument.java,v
retrieving revision 1.58
diff -u -2 -0 -r1.58 AbstractDocument.java
--- javax/swing/text/AbstractDocument.java	21 Jun 2006 17:04:41 -0000	1.58
+++ javax/swing/text/AbstractDocument.java	22 Jun 2006 15:12:59 -0000
@@ -168,40 +168,44 @@
   protected AbstractDocument(Content doc)
   {
     this(doc, StyleContext.getDefaultStyleContext());
   }
 
   /**
    * Creates a new <code>AbstractDocument</code> with the specified
    * [EMAIL PROTECTED] Content} model and [EMAIL PROTECTED] AttributeContext}.
    *
    * @param doc the <code>Content</code> model to be used in this
    *        <code>Document<code>
    * @param ctx the <code>AttributeContext</code> to use
    *
    * @see GapContent
    * @see StringContent
    */
   protected AbstractDocument(Content doc, AttributeContext ctx)
   {
     content = doc;
     context = ctx;
+
+    // FIXME: This is determined using a Mauve test. Make the document
+    // actually use this.
+    putProperty("i18n", Boolean.FALSE);
   }
   
   /** Returns the DocumentFilter.FilterBypass instance for this
    * document and create it if it does not exist yet.
    *  
    * @return This document's DocumentFilter.FilterBypass instance.
    */
   private DocumentFilter.FilterBypass getBypass()
   {
     if (bypass == null)
       bypass = new Bypass();
     
     return bypass;
   }
 
   /**
    * Returns the paragraph [EMAIL PROTECTED] Element} that holds the specified position.
    *
    * @param pos the position for which to get the paragraph element
    *
@@ -722,44 +726,50 @@
    * forwarded to the underlying [EMAIL PROTECTED] AbstractDocument.Content} instance
    * of this document and no exception is thrown.</p>
    * 
    * @param offset the start offset of the fragment to be removed
    * @param length the length of the fragment to be removed
    *
    * @throws BadLocationException if <code>offset</code> or
    *         <code>offset + length</code> or invalid locations within this
    *         document
    */
   public void remove(int offset, int length) throws BadLocationException
   {
     if (documentFilter == null)
       removeImpl(offset, length);
     else
       documentFilter.remove(getBypass(), offset, length);
   }
   
   void removeImpl(int offset, int length) throws BadLocationException
   {
+    if (offset < 0 || offset > getLength())
+      throw new BadLocationException("Invalid remove position", offset);
+
+    if (offset + length > getLength())
+      throw new BadLocationException("Invalid remove length", offset);
+
     // Prevent some unneccessary method invocation (observed in the RI). 
-    if (length <= 0)
+    if (length == 0)
       return;
-    
+
     DefaultDocumentEvent event =
       new DefaultDocumentEvent(offset, length,
 			       DocumentEvent.EventType.REMOVE);
     
     try
       {
         writeLock();
         
         // The order of the operations below is critical!        
         removeUpdate(event);
         UndoableEdit temp = content.remove(offset, length);
         
         postRemoveUpdate(event);
         fireRemoveUpdate(event);
       }
     finally
       {
         writeUnlock();
       } 
   }

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to