comparison dwt/dnd/RTFTransfer.d @ 267:6383fb4cdfc3

Fix: missing .dup
author Frank Benoit <benoit@tionex.de>
date Sun, 06 Jul 2008 15:35:34 +0200
parents c0d810de7093
children 58ef057b3e9d
comparison
equal deleted inserted replaced
266:b302f82224e1 267:6383fb4cdfc3
68 * represented by a java <code>String</code> to a platform specific representation. 68 * represented by a java <code>String</code> to a platform specific representation.
69 * 69 *
70 * @param object a java <code>String</code> containing RTF text 70 * @param object a java <code>String</code> containing RTF text
71 * @param transferData an empty <code>TransferData</code> object that will 71 * @param transferData an empty <code>TransferData</code> object that will
72 * be filled in on return with the platform specific format of the data 72 * be filled in on return with the platform specific format of the data
73 * 73 *
74 * @see Transfer#nativeToJava 74 * @see Transfer#nativeToJava
75 */ 75 */
76 public override void javaToNative (Object object, TransferData transferData){ 76 public override void javaToNative (Object object, TransferData transferData){
77 transferData.result = 0; 77 transferData.result = 0;
78 if (!checkRTF(object) || !isSupportedType(transferData)) { 78 if (!checkRTF(object) || !isSupportedType(transferData)) {
94 * representation of RTF text to a java <code>String</code>. 94 * representation of RTF text to a java <code>String</code>.
95 * 95 *
96 * @param transferData the platform specific representation of the data to be converted 96 * @param transferData the platform specific representation of the data to be converted
97 * @return a java <code>String</code> containing RTF text if the conversion was successful; 97 * @return a java <code>String</code> containing RTF text if the conversion was successful;
98 * otherwise null 98 * otherwise null
99 * 99 *
100 * @see Transfer#javaToNative 100 * @see Transfer#javaToNative
101 */ 101 */
102 public override Object nativeToJava(TransferData transferData){ 102 public override Object nativeToJava(TransferData transferData){
103 if ( !isSupportedType(transferData) || transferData.pValue is null ) return null; 103 if ( !isSupportedType(transferData) || transferData.pValue is null ) return null;
104 int size = transferData.format * transferData.length / 8; 104 int size = transferData.format * transferData.length / 8;
105 if (size is 0) return null; 105 if (size is 0) return null;
106 byte[] buffer = new byte[size];
107 char [] chars = transferData.pValue[ 0 .. size]; 106 char [] chars = transferData.pValue[ 0 .. size];
108 return new ArrayWrapperString( chars[ 0 .. tango.text.Util.locate( chars, '\0' ) ] ); 107 return new ArrayWrapperString( chars[ 0 .. tango.text.Util.locate( chars, '\0' ) ].dup );
109 } 108 }
110 109
111 protected override int[] getTypeIds() { 110 protected override int[] getTypeIds() {
112 return [TEXT_RTF_ID, TEXT_RTF2_ID, APPLICATION_RTF_ID]; 111 return [TEXT_RTF_ID, TEXT_RTF2_ID, APPLICATION_RTF_ID];
113 } 112 }