-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextTransferable.java
More file actions
41 lines (26 loc) · 1.02 KB
/
Copy pathTextTransferable.java
File metadata and controls
41 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// TextTransferable.java
// Andrew Davison, ad@fivedots.coe.psu.ac.th, July 2016
// An Office transferable for unicode text
import com.sun.star.datatransfer.*;
import com.sun.star.uno.Type;
public class TextTransferable implements XTransferable
{
private final String UNICODE_MIMETYPE = "text/plain;charset=utf-16";
private String text;
public TextTransferable(String s)
{ text = s; }
public Object getTransferData(DataFlavor df)
throws UnsupportedFlavorException
{ if (!df.MimeType.equalsIgnoreCase(UNICODE_MIMETYPE))
throw new UnsupportedFlavorException();
return text;
}
public DataFlavor[] getTransferDataFlavors()
{ DataFlavor[] dfs = new DataFlavor[1];
dfs[0] = new DataFlavor(UNICODE_MIMETYPE, "Unicode Text",
new Type(String.class));
return dfs;
}
public boolean isDataFlavorSupported(DataFlavor df)
{ return df.MimeType.equalsIgnoreCase(UNICODE_MIMETYPE); }
} // end of TextTransferable class