diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
commit | 8f523f3a1047919d3563daf1ef47ba87336ebe89 (patch) | |
tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/javax/swing/text/PlainDocument.java | |
parent | 02e549bfaaec38f68307e7f34e46ea57ea1809af (diff) | |
download | gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.gz |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
From-SVN: r107049
Diffstat (limited to 'libjava/classpath/javax/swing/text/PlainDocument.java')
-rw-r--r-- | libjava/classpath/javax/swing/text/PlainDocument.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/libjava/classpath/javax/swing/text/PlainDocument.java b/libjava/classpath/javax/swing/text/PlainDocument.java index 71070e92da7..9e600c4c908 100644 --- a/libjava/classpath/javax/swing/text/PlainDocument.java +++ b/libjava/classpath/javax/swing/text/PlainDocument.java @@ -132,8 +132,8 @@ public class PlainDocument extends AbstractDocument // collapse elements if the removal spans more than 1 line Element newEl = createLeafElement(rootElement, SimpleAttributeSet.EMPTY, - start, end - len); - rootElement.replace(i1, i2 - i1, new Element[]{ newEl }); + start, end); + rootElement.replace(i1, i2 - i1 + 1, new Element[]{ newEl }); } } @@ -147,4 +147,28 @@ public class PlainDocument extends AbstractDocument Element root = getDefaultRootElement(); return root.getElement(root.getElementIndex(pos)); } + + /** + * Inserts a string into the document. If the document property + * '<code>filterNewLines</code>' is set to <code>Boolean.TRUE</code>, then + * all newlines in the inserted string are replaced by space characters, + * otherwise the superclasses behaviour is executed. + * + * Inserting content causes a write lock to be acquired during this method + * call. + * + * @param offs the offset at which to insert the string + * @param str the string to be inserted + * @param atts the text attributes of the string to be inserted + * + * @throws BadLocationException + */ + public void insertString(int offs, String str, AttributeSet atts) + throws BadLocationException + { + String string = str; + if (Boolean.TRUE.equals(getProperty("filterNewlines"))) + string = str.replaceAll("\n", " "); + super.insertString(offs, string, atts); + } } |