diff options
author | Robert Schuster <theBohemian@gmx.net> | 2006-03-06 10:51:19 +0000 |
---|---|---|
committer | Robert Schuster <theBohemian@gmx.net> | 2006-03-06 10:51:19 +0000 |
commit | c018813152f30603187b5e65b1dc83b5bf96d080 (patch) | |
tree | aae70b2c4595a34d275169ebac6ec43b12ec689e | |
parent | 7418f4b042fb641277697611d834cf70dcd5590c (diff) | |
download | classpath-c018813152f30603187b5e65b1dc83b5bf96d080.tar.gz |
2006-03-06 Robert Schuster <robertschuster@fsfe.org>
* javax/swing/text/PlainDocument.java: Fix copyright header,
added author tags.
(insertUpdate): Do not copy the whole document any more, added some
more variables to prevent needless method calls.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | javax/swing/text/PlainDocument.java | 27 |
2 files changed, 26 insertions, 8 deletions
@@ -1,3 +1,10 @@ +2006-03-06 Robert Schuster <robertschuster@fsfe.org> + + * javax/swing/text/PlainDocument.java: Fix copyright header, + added author tags. + (insertUpdate): Do not copy the whole document any more, added some + more variables to prevent needless method calls. + 2006-03-06 Christian Thalinger <twisti@complang.tuwien.ac.at> * configure.ac: Check for FREETYPE2. This is a reverted patch and diff --git a/javax/swing/text/PlainDocument.java b/javax/swing/text/PlainDocument.java index fd7ef92a0..c699dcad2 100644 --- a/javax/swing/text/PlainDocument.java +++ b/javax/swing/text/PlainDocument.java @@ -1,5 +1,5 @@ /* PlainDocument.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,6 +40,15 @@ package javax.swing.text; import java.util.ArrayList; +/** + * A simple document class which maps lines to {@link Element}s. + * + * @author Anthony Balkissoon (abalkiss@redhat.com) + * @author Graydon Hoare (graydon@redhat.com) + * @author Roman Kennke (roman@kennke.org) + * @author Michael Koch (konqueror@gmx.de) + * @author Robert Schuster (robertschuster@fsfe.org) + */ public class PlainDocument extends AbstractDocument { private static final long serialVersionUID = 4758290289196893664L; @@ -109,6 +118,7 @@ public class PlainDocument extends AbstractDocument AttributeSet attributes) { int offset = event.getOffset(); + int eventLength = event.getLength(); int end = offset + event.getLength(); int oldElementIndex, elementIndex = rootElement.getElementIndex(offset); Element firstElement = rootElement.getElement(elementIndex); @@ -161,24 +171,25 @@ public class PlainDocument extends AbstractDocument Element[] added; try { - String str = content.getString(0, content.length()); + String str = content.getString(offset, eventLength); ArrayList elts = new ArrayList(); // Determine how many NEW lines were added by finding the newline // characters within the newly inserted text int j = firstElement.getStartOffset(); - int i = str.indexOf('\n', offset); + int i = str.indexOf('\n', 0); + int contentLength = content.length(); - while (i != -1 && i <= end) + while (i != -1 && i <= eventLength) { // For each new line, create a new element elts.add(createLeafElement(rootElement, SimpleAttributeSet.EMPTY, - j, i + 1)); + j, offset + i + 1)); - j = i + 1; - if (j >= str.length()) + j = offset + i + 1; + if (j >= contentLength) break; - i = str.indexOf('\n', j); + i = str.indexOf('\n', i + 1); } // If there were new lines added we have to add an ElementEdit to |