annotate src/name/blackcap/clipman/Pasteboard.kt @ 31:0c6c18a733b7

Compiles, new menu still a mess.
author David Barts <n5jrn@me.com>
date Thu, 30 Jan 2020 16:01:51 -0800
parents 8aa2dfac27eb
children 9890445e4cc4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
1 /*
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
2 * We call the clipboard a "pasteboard" for our internal class name, not
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
3 * because I prefer that term (I don't) but so as to not clash with the
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
4 * AWT's Clipboard class.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
5 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
6 package name.blackcap.clipman
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
7
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
8 import java.awt.Toolkit
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
9 import java.awt.datatransfer.Clipboard
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
10 import java.awt.datatransfer.ClipboardOwner
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
11 import java.awt.datatransfer.DataFlavor
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
12 import java.awt.datatransfer.Transferable
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
13 import java.awt.datatransfer.UnsupportedFlavorException
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
14 import java.io.IOException
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
15 import java.io.ByteArrayInputStream
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
16 import java.nio.charset.Charset
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
17 import java.util.logging.Level
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
18 import java.util.logging.Logger
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
19 import kotlin.collections.HashMap
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
20
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
21 /**
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
22 * Represents an item of data in the clipboard and how to read and
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
23 * write it.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
24 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
25 sealed class PasteboardItem {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
26 /* the three possibilities for this class */
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
27
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
28 class Plain(val plain: String): PasteboardItem()
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
29
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
30 class HTML(val plain: String, val html: String): PasteboardItem()
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
31
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
32 class RTF(val plain: String, val rtf: ByteArray): PasteboardItem() {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
33 private var failed = false
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
34
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
35 /* lazy conversion to HTML */
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
36 private var _html: String? = null
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
37 val html: String?
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
38 get() {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
39 if (failed || _html != null) {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
40 return _html
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
41 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
42 _html = htmlFromRTF()
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
43 failed = _html == null
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
44 return _html
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
45 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
46
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
47 private fun htmlFromRTF(): String? {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
48 ByteArrayInputStream(rtf).use {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
49 val (html, errors) = rtfToHtml(it)
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
50 if (errors != null) {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
51 LOGGER.log(Level.WARNING, errors)
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
52 return null
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
53 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
54 return html
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
55 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
56 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
57 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
58
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
59 /* we use this when writing data back to the clipboard */
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
60
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
61 private class PasteboardData(val item: PasteboardItem):
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
62 Transferable, ClipboardOwner {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
63 private val CHARSET = Charset.forName(CHARSET_NAME)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
64 private val HTML_FLAVOR = DataFlavor("text/html; document=all; class=\"[B\"; charset=" + CHARSET_NAME)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
65 private val _data: HashMap<DataFlavor, Any>
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
66 private val flavors: Array<DataFlavor>
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
67
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
68 init {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
69 _data = HashMap<DataFlavor, Any>().apply {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
70 when (item) {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
71 is Plain -> put(DataFlavor.stringFlavor, item.plain as Any)
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
72 is HTML -> {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
73 put(DataFlavor.stringFlavor, item.plain as Any)
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
74 put(HTML_FLAVOR, item.html.toByteArray(CHARSET) as Any)
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
75 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
76 is RTF -> {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
77 put(DataFlavor.stringFlavor, item.plain as Any)
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
78 if (item.html != null) {
18
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
79 put(HTML_FLAVOR, item.html!!.toByteArray(CHARSET) as Any)
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
80 }
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
81 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
82 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
83 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
84 _data.keys.asIterable().run {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
85 flavors = Array<DataFlavor>(count()) { elementAt(it) }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
86 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
87 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
88
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
89 override fun getTransferData(flavor: DataFlavor): Any {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
90 return _data.get(flavor) ?: throw UnsupportedFlavorException(flavor)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
91 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
92
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
93 override fun getTransferDataFlavors(): Array<DataFlavor> = flavors
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
94 override fun isDataFlavorSupported(flavor: DataFlavor) = _data.containsKey(flavor)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
95 override fun lostOwnership(clipboard: Clipboard, contents: Transferable) {}
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
96 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
97
18
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
98 /**
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
99 * Compare this PasteboardItem with another object.
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
100 * @param other object
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
101 * @return true iff this item's type and native content match the other's
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
102 */
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
103 override operator fun equals(other: Any?): Boolean {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
104 return when (this) {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
105 is Plain -> (other is Plain) && (this.plain == other.plain)
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
106 is HTML -> (other is HTML) && (this.html == other.html)
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
107 is RTF -> (other is RTF) && (this.rtf contentEquals other.rtf)
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
108 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
109 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
110
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
111 companion object {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
112 private val RTF_FLAVOR = DataFlavor("text/rtf; class=\"[B\"")
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
113 private val CLIPBOARD = Toolkit.getDefaultToolkit().systemClipboard
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
114
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
115 /**
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
116 * Read the item in the pasteboard.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
117 * @return a PasteboardItem? object, null if nothing could be read
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
118 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
119 fun read() : PasteboardItem? {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
120 check()
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
121 val plain = getClipboardData(DataFlavor.stringFlavor) as String?
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
122 if (plain == null) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
123 return null
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
124 }
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
125 val html = getClipboardData(DataFlavor.allHtmlFlavor) as String?
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
126 if (html == null) {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
127 val rtf = getClipboardData(RTF_FLAVOR) as ByteArray?
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
128 return if (rtf == null) { Plain(plain) } else { RTF(plain, rtf) }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
129 } else {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
130 return HTML(plain, html)
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
131 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
132 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
133
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
134 /**
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
135 * Write an item to the pasteboard.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
136 * @param item a PasteboardItem to write
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
137 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
138 fun write(item: PasteboardItem) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
139 check()
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
140 val pbdata = PasteboardData(item)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
141 CLIPBOARD.setContents(pbdata, pbdata)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
142 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
143
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
144 private fun check() {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
145 if (CLIPBOARD == null) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
146 throw RuntimeException("no clipboard available!")
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
147 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
148 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
149
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
150 private fun getClipboardData(flavor: DataFlavor): Any? {
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
151 try {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
152 return CLIPBOARD.getData(flavor)
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
153 } catch (e: IOException) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
154 return null
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
155 } catch (e: UnsupportedFlavorException) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
156 return null
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
157 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
158 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
159 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
160 }