This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix for 'paste'


Currently, you cut 'asdfg' and paste 'java.io.StringBufferInputStream@879d060' if your DataFlavor is stringFlavor. To reproduce, use the Acunia test Datatransfer.TrivialApplication 'Clipboard vb'.

This patch fixes it by returning the object accordingly to the DataFlavor specified by the caller.


2003-12-02 Fernando Nasser <fnasser@redhat.com>


        * java/awt/datatransfer/StringSelection.java (getTransferData): Return
        object of type expected by specified DataFlavor.
Index: java/awt/datatransfer/StringSelection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/datatransfer/StringSelection.java,v
retrieving revision 1.2
diff -c -p -u -r1.2 StringSelection.java
--- java/awt/datatransfer/StringSelection.java	24 Jun 2003 10:50:21 -0000	1.2
+++ java/awt/datatransfer/StringSelection.java	8 Dec 2003 21:53:16 -0000
@@ -140,7 +140,10 @@ getTransferData(DataFlavor flavor) throw
   if (!isDataFlavorSupported(flavor))
     throw new UnsupportedFlavorException(flavor);
 
-  return(new StringBufferInputStream(data));
+  if (DataFlavor.plainTextFlavor == flavor)
+      return(new StringBufferInputStream(data));
+  else // DataFlavor.stringFlavor
+      return data;
 }
 
 /*************************************************************************/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]