Changeset 3895 in vbox for trunk/src/VBox/Additions/linux/xclient
- Timestamp:
- Jul 27, 2007 7:17:56 AM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 23276
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/xclient/clipboard.cpp
r3332 r3895 26 26 #define USE_UTF8 27 27 #define USE_CTEXT 28 #define USE_LATIN129 28 30 29 #define LOG_GROUP LOG_GROUP_HGCM … … 81 80 INVALID = 0, 82 81 TARGETS, 83 LATIN1,84 82 CTEXT, 85 83 UTF8, … … 660 658 break; 661 659 case UTF8: 662 case LATIN1:663 660 { 664 661 /* If we are given broken Utf-8, we treat it as Latin1. Is this acceptable? */ … … 1242 1239 *pcLenReturn = property.nitems; 1243 1240 *piFormatReturn = property.format; 1244 LogFlowFunc(("rc = true\n"));1245 return true;1246 }1247 1248 /**1249 * Satisfy a request from the guest to convert the clipboard text to Latin1.1250 *1251 * @returns true if we successfully convert the data to the format requested, false otherwise.1252 *1253 * @param atomTypeReturn The type of the data we are returning1254 * @param pValReturn A pointer to the data we are returning. This should be to memory1255 * allocated by XtMalloc, which will be freed by the toolkit later1256 * @param pcLenReturn The length of the data we are returning1257 * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning1258 */1259 static Boolean vboxClipboardConvertLatin1(Atom *atomTypeReturn, XtPointer *pValReturn,1260 unsigned long *pcLenReturn, int *piFormatReturn)1261 {1262 enum { LINEFEED = 0xa, CARRIAGERETURN = 0xd };1263 PRTUTF16 pu16HostText;1264 unsigned cbHostText, cwHostText, cbGuestPos = 0, cbGuestText;1265 unsigned char *pcGuestText;1266 int rc;1267 1268 LogFlowFunc(("\n"));1269 /* Get the host UTF16 data */1270 rc = vboxClipboardReadHostData(VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT,1271 reinterpret_cast<void **>(&pu16HostText), &cbHostText);1272 if ((rc != VINF_SUCCESS) || cbHostText == 0)1273 {1274 Log (("vboxClipboardConvertUtf16: vboxClipboardReadHostData returned %Vrc, %d bytes of data\n", rc, cbGuestText));1275 g_ctx.hostFormats = 0;1276 LogFlowFunc(("rc = false\n"));1277 return false;1278 }1279 cwHostText = cbHostText / 2;1280 cbGuestText = cwHostText;1281 pcGuestText = reinterpret_cast<unsigned char *>(XtMalloc(cbGuestText));1282 if (pcGuestText == 0)1283 {1284 RTMemFree(reinterpret_cast<void *>(pu16HostText));1285 LogFlowFunc(("rc = false\n"));1286 return false;1287 }1288 for (unsigned i = 0; i < cwHostText; ++i, ++cbGuestPos)1289 {1290 if ( (i + 1 < cwHostText)1291 && (pu16HostText[i] == CARRIAGERETURN)1292 && (pu16HostText[i + 1] == LINEFEED))1293 ++i;1294 if (pu16HostText[i] < 256)1295 pcGuestText[cbGuestPos] = pu16HostText[i];1296 else1297 /* Any better ideas as to how to do this? */1298 pcGuestText[cbGuestPos] = '.';1299 }1300 Log (("vboxClipboardConvertLatin1: returning Latin-1, original text is %.*ls\n", cwHostText,1301 pu16HostText));1302 Log (("vboxClipboardConvertLatin1: converted text is %.*s\n", cbGuestPos,1303 pcGuestText));1304 RTMemFree(reinterpret_cast<void *>(pu16HostText));1305 *atomTypeReturn = XA_STRING;1306 *pValReturn = reinterpret_cast<XtPointer>(pcGuestText);1307 *pcLenReturn = cbGuestPos;1308 *piFormatReturn = 8;1309 1241 LogFlowFunc(("rc = true\n")); 1310 1242 return true; … … 1380 1312 case CTEXT: 1381 1313 rc = vboxClipboardConvertCText(atomTypeReturn, pValReturn, pcLenReturn, piFormatReturn); 1382 LogFlowFunc(("rc=%d\n", rc));1383 return rc;1384 case LATIN1:1385 rc = vboxClipboardConvertLatin1(atomTypeReturn, pValReturn, pcLenReturn, piFormatReturn);1386 1314 LogFlowFunc(("rc=%d\n", rc)); 1387 1315 return rc; … … 1720 1648 vboxClipboardAddFormat("text/plain;charset=utf-8", UTF8, 1721 1649 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT); 1650 vboxClipboardAddFormat("STRING", UTF8, 1651 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT); 1652 vboxClipboardAddFormat("TEXT", UTF8, 1653 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT); 1654 vboxClipboardAddFormat("text/plain", UTF8, 1655 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT); 1722 1656 #endif 1723 1657 #ifdef USE_CTEXT 1724 1658 vboxClipboardAddFormat("COMPOUND_TEXT", CTEXT, 1725 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);1726 #endif1727 #ifdef USE_LATIN11728 vboxClipboardAddFormat("STRING", LATIN1,1729 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);1730 vboxClipboardAddFormat("TEXT", LATIN1,1731 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);1732 vboxClipboardAddFormat("text/plain", LATIN1,1733 1659 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT); 1734 1660 #endif
Note:
See TracChangeset
for help on using the changeset viewer.