annotate src/name/blackcap/clipman/Pasteboard.kt @ 39:2a5808156f99

Remove more deadwood, add non-Mac About dialog.
author David Barts <n5jrn@me.com>
date Fri, 31 Jan 2020 00:06:59 -0800
parents 9890445e4cc4
children 33fbe3a78d84
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 CHARSET = Charset.forName(CHARSET_NAME)
9890445e4cc4 Didn't like eating its own dog food. Fixed.
David Barts <n5jrn@me.com>
parents: 31
diff changeset
23 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
24
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
25 /**
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
26 * 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
27 * write it.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
28 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
29 sealed class PasteboardItem {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
30 /* 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
31
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
32 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
33
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
34 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
35
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
36 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
37 private var failed = false
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
38
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
39 /* lazy conversion to HTML */
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
40 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
41 val html: String?
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
42 get() {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
43 if (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 _html = htmlFromRTF()
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
47 failed = _html == null
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
48 return _html
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
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
51 private fun htmlFromRTF(): String? {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
52 ByteArrayInputStream(rtf).use {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
53 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
54 if (errors != null) {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
55 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
56 return null
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 return html
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
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
63 /* 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
64
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
65 private class PasteboardData(val item: PasteboardItem):
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
66 Transferable, ClipboardOwner {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
67 private val _data: HashMap<DataFlavor, Any>
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
68 private val flavors: Array<DataFlavor>
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
69
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
70 init {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
71 _data = HashMap<DataFlavor, Any>().apply {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
72 when (item) {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
73 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
74 is HTML -> {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
75 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
76 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
77 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
78 is RTF -> {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
79 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
80 if (item.html != null) {
18
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
81 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
82 }
0
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 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
86 _data.keys.asIterable().run {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
87 flavors = Array<DataFlavor>(count()) { elementAt(it) }
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
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
91 override fun getTransferData(flavor: DataFlavor): Any {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
92 return _data.get(flavor) ?: throw UnsupportedFlavorException(flavor)
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
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
95 override fun getTransferDataFlavors(): Array<DataFlavor> = flavors
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
96 override fun isDataFlavorSupported(flavor: DataFlavor) = _data.containsKey(flavor)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
97 override fun lostOwnership(clipboard: Clipboard, contents: Transferable) {}
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
98 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
99
18
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
100 /**
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
101 * Compare this PasteboardItem with another object.
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
102 * @param other object
96cc73ae2904 Make it more fail-safe.
David Barts <n5jrn@me.com>
parents: 17
diff changeset
103 * @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
104 */
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
105 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
106 return when (this) {
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
107 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
108 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
109 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
110 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
111 }
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
112
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
113 companion object {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
114 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
115 private val CLIPBOARD = Toolkit.getDefaultToolkit().systemClipboard
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 /**
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
118 * Read the item in the pasteboard.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
119 * @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
120 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
121 fun read() : PasteboardItem? {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
122 check()
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
123 val plain = getClipboardData(DataFlavor.stringFlavor) as String?
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
124 if (plain == null) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
125 return null
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
126 }
37
9890445e4cc4 Didn't like eating its own dog food. Fixed.
David Barts <n5jrn@me.com>
parents: 31
diff changeset
127 val html = getClipboardData(HTML_FLAVOR) as ByteArray?
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
128 if (html == null) {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
129 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
130 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
131 } else {
37
9890445e4cc4 Didn't like eating its own dog food. Fixed.
David Barts <n5jrn@me.com>
parents: 31
diff changeset
132 return HTML(plain, html.toString(CHARSET))
0
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 /**
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
137 * Write an item to the pasteboard.
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
138 * @param item a PasteboardItem to write
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
139 */
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
140 fun write(item: PasteboardItem) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
141 check()
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
142 val pbdata = PasteboardData(item)
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
143 CLIPBOARD.setContents(pbdata, pbdata)
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
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
146 private fun check() {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
147 if (CLIPBOARD == null) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
148 throw RuntimeException("no clipboard available!")
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 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
151
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
152 private fun getClipboardData(flavor: DataFlavor): Any? {
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
153 try {
17
9dd58db4d15a Only convert RTF to HTML if needed. Much more efficient.
David Barts <n5jrn@me.com>
parents: 0
diff changeset
154 return CLIPBOARD.getData(flavor)
0
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
155 } catch (e: IOException) {
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 } catch (e: UnsupportedFlavorException) {
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
158 return null
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 }
be282c48010a Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff changeset
162 }