Mercurial > projects > dwt-win
comparison dwt/dnd/HTMLTransfer.d @ 246:fd9c62a2998e
Updater SWT 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 01 Jul 2008 10:15:59 +0200 |
parents | e2affbeb686d |
children | fbb9174f2a2c |
comparison
equal
deleted
inserted
replaced
245:d8c3d4a4f2b0 | 246:fd9c62a2998e |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
25 alias tango.text.Text.Text!(char) StringBuffer; | 25 alias tango.text.Text.Text!(char) StringBuffer; |
26 | 26 |
27 /** | 27 /** |
28 * The class <code>HTMLTransfer</code> provides a platform specific mechanism | 28 * The class <code>HTMLTransfer</code> provides a platform specific mechanism |
29 * for converting text in HTML format represented as a java <code>String</code> | 29 * for converting text in HTML format represented as a java <code>String</code> |
30 * to a platform specific representation of the data and vice versa. See | 30 * to a platform specific representation of the data and vice versa. |
31 * <code>Transfer</code> for additional information. | |
32 * | 31 * |
33 * <p>An example of a java <code>String</code> containing HTML text is shown | 32 * <p>An example of a java <code>String</code> containing HTML text is shown |
34 * below:</p> | 33 * below:</p> |
35 * | 34 * |
36 * <code><pre> | 35 * <code><pre> |
37 * String htmlData = "<p>This is a paragraph of text.</p>"; | 36 * String htmlData = "<p>This is a paragraph of text.</p>"; |
38 * </code></pre> | 37 * </code></pre> |
38 * | |
39 * @see Transfer | |
39 */ | 40 */ |
40 public class HTMLTransfer : ByteArrayTransfer { | 41 public class HTMLTransfer : ByteArrayTransfer { |
41 | 42 |
42 static HTMLTransfer _instance; | 43 static HTMLTransfer _instance; |
43 static const String HTML_FORMAT = "HTML Format"; //$NON-NLS-1$ | 44 static const String HTML_FORMAT = "HTML Format"; //$NON-NLS-1$ |
72 } | 73 } |
73 | 74 |
74 /** | 75 /** |
75 * This implementation of <code>javaToNative</code> converts HTML-formatted text | 76 * This implementation of <code>javaToNative</code> converts HTML-formatted text |
76 * represented by a java <code>String</code> to a platform specific representation. | 77 * represented by a java <code>String</code> to a platform specific representation. |
77 * For additional information see <code>Transfer#javaToNative</code>. | |
78 * | 78 * |
79 * @param object a java <code>String</code> containing HTML text | 79 * @param object a java <code>String</code> containing HTML text |
80 * @param transferData an empty <code>TransferData</code> object; this | 80 * @param transferData an empty <code>TransferData</code> object that will |
81 * object will be filled in on return with the platform specific format of the data | 81 * be filled in on return with the platform specific format of the data |
82 * | |
83 * @see Transfer#nativeToJava | |
82 */ | 84 */ |
83 public void javaToNative (Object object, TransferData transferData){ | 85 public void javaToNative (Object object, TransferData transferData){ |
84 if (!checkHTML(object) || !isSupportedType(transferData)) { | 86 if (!checkHTML(object) || !isSupportedType(transferData)) { |
85 DND.error(DND.ERROR_INVALID_DATA); | 87 DND.error(DND.ERROR_INVALID_DATA); |
86 } | 88 } |
143 } | 145 } |
144 | 146 |
145 /** | 147 /** |
146 * This implementation of <code>nativeToJava</code> converts a platform specific | 148 * This implementation of <code>nativeToJava</code> converts a platform specific |
147 * representation of HTML text to a java <code>String</code>. | 149 * representation of HTML text to a java <code>String</code>. |
148 * For additional information see <code>Transfer#nativeToJava</code>. | 150 * |
149 * | 151 * @param transferData the platform specific representation of the data to be converted |
150 * @param transferData the platform specific representation of the data to be | 152 * @return a java <code>String</code> containing HTML text if the conversion was successful; |
151 * been converted | 153 * otherwise null |
152 * @return a java <code>String</code> containing HTML text if the | 154 * |
153 * conversion was successful; otherwise null | 155 * @see Transfer#javaToNative |
154 */ | 156 */ |
155 public Object nativeToJava(TransferData transferData){ | 157 public Object nativeToJava(TransferData transferData){ |
156 if (!isSupportedType(transferData) || transferData.pIDataObject is null) return null; | 158 if (!isSupportedType(transferData) || transferData.pIDataObject is null) return null; |
157 IDataObject data = transferData.pIDataObject; | 159 IDataObject data = transferData.pIDataObject; |
158 data.AddRef(); | 160 data.AddRef(); |