annotate src/name/blackcap/clipman/Pasteboard.kt @ 42:99220aa136d9

Add default.properties.
author David Barts <n5jrn@me.com>
date Sat, 08 Feb 2020 23:05:39 -0700
parents 33fbe3a78d84
children
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
37
9890445e4cc4 Didn't like eating its own dog food. Fixed.
David Barts <n5jrn@me.com>
parents: 31
diff changeset
21 /* Kotlin bug: compaion class fails to see these unless they are out here. */
9890445e4cc4 Didn't like eating its own dog food. Fixed.
David Barts <n5jrn@me.com>
parents: 31
diff changeset
22 private val HTML_FLAVOR = DataFlavor("text/html; document=all; class=\"[B\"; charset=" + CHARSET_NAME)
9890445e4cc4 Didn't like eating its own dog food. Fixed.
David Barts <n5jrn@me.com>
parents: 31
diff changeset
23
0
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 * 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
26 * write it.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
27 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
28 sealed class PasteboardItem {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
29 /* 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
30
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
31 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
32
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
33 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
34
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
35 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
36 private var failed = false
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
37
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
38 /* lazy conversion to HTML */
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
39 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
40 val html: String?
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
41 get() {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
42 if (failed || _html != null) {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
43 return _html
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
44 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
45 _html = htmlFromRTF()
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
46 failed = _html == null
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
47 return _html
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
48 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
49
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
50 private fun htmlFromRTF(): String? {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
51 ByteArrayInputStream(rtf).use {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
52 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
53 if (errors != null) {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
54 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
55 return null
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 return html
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 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
60 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
61
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
62 /* 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
63
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
64 private class PasteboardData(val item: PasteboardItem):
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
65 Transferable, ClipboardOwner {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
66 private val _data: HashMap<DataFlavor, Any>
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
67 private val flavors: Array<DataFlavor>
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
68
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
69 init {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
70 _data = HashMap<DataFlavor, Any>().apply {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
71 when (item) {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
72 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
73 is HTML -> {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
74 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
75 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
76 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
77 is RTF -> {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
78 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
79 if (item.html != null) {
18
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
80 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
81 }
0
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 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
85 _data.keys.asIterable().run {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
86 flavors = Array<DataFlavor>(count()) { elementAt(it) }
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
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
90 override fun getTransferData(flavor: DataFlavor): Any {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
91 return _data.get(flavor) ?: throw UnsupportedFlavorException(flavor)
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
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
94 override fun getTransferDataFlavors(): Array<DataFlavor> = flavors
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
95 override fun isDataFlavorSupported(flavor: DataFlavor) = _data.containsKey(flavor)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
96 override fun lostOwnership(clipboard: Clipboard, contents: Transferable) {}
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
97 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
98
18
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
99 /**
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
100 * Compare this PasteboardItem with another object.
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
101 * @param other object
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
102 * @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
103 */
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
104 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
105 return when (this) {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
106 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
107 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
108 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
109 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
110 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
111
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
112 companion object {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
113 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
114 private val CLIPBOARD = Toolkit.getDefaultToolkit().systemClipboard
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 /**
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
117 * Read the item in the pasteboard.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
118 * @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
119 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
120 fun read() : PasteboardItem? {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
121 check()
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
122 val plain = getClipboardData(DataFlavor.stringFlavor) as String?
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
123 if (plain == null) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
124 return null
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
125 }
37
9890445e4cc4 Didn't like eating its own dog food. Fixed.
David Barts <n5jrn@me.com>
parents: 31
diff changeset
126 val html = getClipboardData(HTML_FLAVOR) as ByteArray?
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
127 if (html == null) {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
128 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
129 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
130 } else {
37
9890445e4cc4 Didn't like eating its own dog food. Fixed.
David Barts <n5jrn@me.com>
parents: 31
diff changeset
131 return HTML(plain, html.toString(CHARSET))
0
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 /**
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
136 * Write an item to the pasteboard.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
137 * @param item a PasteboardItem to write
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
138 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
139 fun write(item: PasteboardItem) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
140 check()
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
141 val pbdata = PasteboardData(item)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
142 CLIPBOARD.setContents(pbdata, pbdata)
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
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
145 private fun check() {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
146 if (CLIPBOARD == null) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
147 throw RuntimeException("no clipboard available!")
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 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
150
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
151 private fun getClipboardData(flavor: DataFlavor): Any? {
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
152 try {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
153 return CLIPBOARD.getData(flavor)
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
154 } catch (e: IOException) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
155 return null
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
156 } catch (e: UnsupportedFlavorException) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
157 return null
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 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
161 }