VirtualBox

Ignore:
Timestamp:
Jul 27, 2007 7:17:56 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
23276
Message:

Removed support for Latin1 from the Linux clipboard code, except as a fallback for bad Utf8. Plain text now means Utf8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/xclient/clipboard.cpp

    r3332 r3895  
    2626#define USE_UTF8
    2727#define USE_CTEXT
    28 #define USE_LATIN1
    2928
    3029#define LOG_GROUP LOG_GROUP_HGCM
     
    8180    INVALID = 0,
    8281    TARGETS,
    83     LATIN1,
    8482    CTEXT,
    8583    UTF8,
     
    660658        break;
    661659    case UTF8:
    662     case LATIN1:
    663660    {
    664661        /* If we are given broken Utf-8, we treat it as Latin1.  Is this acceptable? */
     
    12421239    *pcLenReturn = property.nitems;
    12431240    *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 returning
    1254  * @param pValReturn     A pointer to the data we are returning.  This should be to memory
    1255  *                       allocated by XtMalloc, which will be freed by the toolkit later
    1256  * @param pcLenReturn    The length of the data we are returning
    1257  * @param piFormatReturn The format (8bit, 16bit, 32bit) of the data we are returning
    1258  */
    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         else
    1297             /* 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;
    13091241    LogFlowFunc(("rc = true\n"));
    13101242    return true;
     
    13801312    case CTEXT:
    13811313        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);
    13861314        LogFlowFunc(("rc=%d\n", rc));
    13871315        return rc;
     
    17201648    vboxClipboardAddFormat("text/plain;charset=utf-8", UTF8,
    17211649                           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);
    17221656#endif
    17231657#ifdef USE_CTEXT
    17241658    vboxClipboardAddFormat("COMPOUND_TEXT", CTEXT,
    1725                            VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1726 #endif
    1727 #ifdef USE_LATIN1
    1728     vboxClipboardAddFormat("STRING", LATIN1,
    1729                            VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1730     vboxClipboardAddFormat("TEXT", LATIN1,
    1731                            VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    1732     vboxClipboardAddFormat("text/plain", LATIN1,
    17331659                           VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT);
    17341660#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette