| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbmime.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | QXcbMime::QXcbMime() | - | ||||||||||||||||||||||||
| 13 | : QInternalMimeData() | - | ||||||||||||||||||||||||
| 14 | { } executed 140 times by 9 tests: end of blockExecuted by:
| 140 | ||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | QXcbMime::~QXcbMime() | - | ||||||||||||||||||||||||
| 17 | {} | - | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | QString QXcbMime::mimeAtomToString(QXcbConnection *connection, xcb_atom_t a) | - | ||||||||||||||||||||||||
| 22 | { | - | ||||||||||||||||||||||||
| 23 | if (a == 0L
| 0-59 | ||||||||||||||||||||||||
| 24 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||
| 27 | if (a == XCB_ATOM_STRING
| 7-52 | ||||||||||||||||||||||||
| 28 | || a == connection->atom(QXcbAtom::UTF8_STRING)
| 9-43 | ||||||||||||||||||||||||
| 29 | || a == connection->atom(QXcbAtom::TEXT)
| 7-36 | ||||||||||||||||||||||||
| 30 | return executed 23 times by 6 tests: QLatin1String("text/plain");return QLatin1String("text/plain");Executed by:
executed 23 times by 6 tests: return QLatin1String("text/plain");Executed by:
| 23 | ||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||
| 33 | if (a == XCB_ATOM_PIXMAP
| 0-36 | ||||||||||||||||||||||||
| 34 | return never executed: QLatin1String("image/ppm");return QLatin1String("image/ppm");never executed: return QLatin1String("image/ppm"); | 0 | ||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||
| 36 | QByteArray atomName = connection->atomName(a); | - | ||||||||||||||||||||||||
| 37 | - | |||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||
| 39 | if (atomName == "text/x-moz-url"
| 0-36 | ||||||||||||||||||||||||
| 40 | atomName = "text/uri-list"; never executed: atomName = "text/uri-list"; | 0 | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | return executed 36 times by 6 tests: QString::fromLatin1(atomName.constData());return QString::fromLatin1(atomName.constData());Executed by:
executed 36 times by 6 tests: return QString::fromLatin1(atomName.constData());Executed by:
| 36 | ||||||||||||||||||||||||
| 43 | } | - | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeData *mimeData, QByteArray *data, | - | ||||||||||||||||||||||||
| 46 | xcb_atom_t *atomFormat, int *dataFormat) | - | ||||||||||||||||||||||||
| 47 | { | - | ||||||||||||||||||||||||
| 48 | if (!data
| 0-29 | ||||||||||||||||||||||||
| 49 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | bool ret = false; | - | ||||||||||||||||||||||||
| 52 | *atomFormat = a; | - | ||||||||||||||||||||||||
| 53 | *dataFormat = 8; | - | ||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | if ((a == connection->atom(QXcbAtom::UTF8_STRING)
| 5-24 | ||||||||||||||||||||||||
| 56 | || a == XCB_ATOM_STRING
| 5-19 | ||||||||||||||||||||||||
| 57 | || a == connection->atom(QXcbAtom::TEXT)
| 5-14 | ||||||||||||||||||||||||
| 58 | && QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)
| 0-15 | ||||||||||||||||||||||||
| 59 | if (a == connection->atom(QXcbAtom::UTF8_STRING)
| 5-10 | ||||||||||||||||||||||||
| 60 | *data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData); | - | ||||||||||||||||||||||||
| 61 | ret = true; | - | ||||||||||||||||||||||||
| 62 | } executed 5 times by 5 tests: else if (a == XCB_ATOM_STRINGend of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 63 | a == connection->atom(QXcbAtom::TEXT)
| 0-5 | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | *data = QString::fromUtf8(QInternalMimeData::renderDataHelper( | - | ||||||||||||||||||||||||
| 66 | QLatin1String("text/plain"), mimeData)).toLatin1(); | - | ||||||||||||||||||||||||
| 67 | ret = true; | - | ||||||||||||||||||||||||
| 68 | } executed 10 times by 5 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||
| 69 | return executed 15 times by 5 tests: ret;return ret;Executed by:
executed 15 times by 5 tests: return ret;Executed by:
| 15 | ||||||||||||||||||||||||
| 70 | } | - | ||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | QString atomName = mimeAtomToString(connection, a); | - | ||||||||||||||||||||||||
| 73 | if (QInternalMimeData::hasFormatHelper(atomName, mimeData)
| 5-9 | ||||||||||||||||||||||||
| 74 | *data = QInternalMimeData::renderDataHelper(atomName, mimeData); | - | ||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | if (atomName == QLatin1String("text/uri-list")
| 0-9 | ||||||||||||||||||||||||
| 78 | && connection->atomName(a) == "text/x-moz-url"
| 0 | ||||||||||||||||||||||||
| 79 | const QByteArray uri = data->split('\n').first(); | - | ||||||||||||||||||||||||
| 80 | QString mozUri = QString::fromLatin1(uri, uri.size()); | - | ||||||||||||||||||||||||
| 81 | mozUri += QLatin1Char('\n'); | - | ||||||||||||||||||||||||
| 82 | *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), | - | ||||||||||||||||||||||||
| 83 | mozUri.length() * 2); | - | ||||||||||||||||||||||||
| 84 | } never executed: else if (atomName == QLatin1String("application/x-color")end of block
| 0-9 | ||||||||||||||||||||||||
| 85 | * never executed: dataFormat = 16;*dataFormat = 16;never executed: *dataFormat = 16; | 0 | ||||||||||||||||||||||||
| 86 | ret = true; | - | ||||||||||||||||||||||||
| 87 | } executed 9 times by 5 tests: else if ((a == XCB_ATOM_PIXMAPend of blockExecuted by:
| 0-9 | ||||||||||||||||||||||||
| 88 | ret = true; | - | ||||||||||||||||||||||||
| 89 | } never executed: else if (atomName == QLatin1String("text/plain")end of block
| 0-5 | ||||||||||||||||||||||||
| 90 | && mimeData->hasFormat(QLatin1String("text/uri-list"))
| 0 | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | *data = QInternalMimeData::renderDataHelper(atomName, mimeData); | - | ||||||||||||||||||||||||
| 93 | ret = true; | - | ||||||||||||||||||||||||
| 94 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 95 | return executed 14 times by 5 tests: ret;return ret;Executed by:
executed 14 times by 5 tests: return ret;Executed by:
| 14 | ||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | QVector<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, const QString &format) | - | ||||||||||||||||||||||||
| 99 | { | - | ||||||||||||||||||||||||
| 100 | QVector<xcb_atom_t> atoms; | - | ||||||||||||||||||||||||
| 101 | atoms.reserve(7); | - | ||||||||||||||||||||||||
| 102 | atoms.append(connection->internAtom(format.toLatin1())); | - | ||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | if (format == QLatin1String("text/plain")
| 4-5 | ||||||||||||||||||||||||
| 106 | atoms.append(connection->atom(QXcbAtom::UTF8_STRING)); | - | ||||||||||||||||||||||||
| 107 | atoms.append(XCB_ATOM_STRING); | - | ||||||||||||||||||||||||
| 108 | atoms.append(connection->atom(QXcbAtom::TEXT)); | - | ||||||||||||||||||||||||
| 109 | } executed 5 times by 5 tests: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | if (format == QLatin1String("text/uri-list")
| 0-9 | ||||||||||||||||||||||||
| 113 | atoms.append(connection->internAtom("text/x-moz-url")); | - | ||||||||||||||||||||||||
| 114 | atoms.append(connection->internAtom("text/plain")); | - | ||||||||||||||||||||||||
| 115 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | if (format == QLatin1String("image/ppm")
| 0-9 | ||||||||||||||||||||||||
| 119 | atoms.append(XCB_ATOM_PIXMAP); never executed: atoms.append(XCB_ATOM_PIXMAP); | 0 | ||||||||||||||||||||||||
| 120 | if (format == QLatin1String("image/pbm")
| 0-9 | ||||||||||||||||||||||||
| 121 | atoms.append(XCB_ATOM_BITMAP); never executed: atoms.append(XCB_ATOM_BITMAP); | 0 | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | return executed 9 times by 5 tests: atoms;return atoms;Executed by:
executed 9 times by 5 tests: return atoms;Executed by:
| 9 | ||||||||||||||||||||||||
| 124 | } | - | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &data, const QString &format, | - | ||||||||||||||||||||||||
| 127 | QVariant::Type requestedType, const QByteArray &encoding) | - | ||||||||||||||||||||||||
| 128 | { | - | ||||||||||||||||||||||||
| 129 | QString atomName = mimeAtomToString(connection, a); | - | ||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | if (!encoding.isEmpty()
| 0-2 | ||||||||||||||||||||||||
| 133 | && atomName == format + QLatin1String(";charset=") + QString::fromLatin1(encoding)
| 0 | ||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | if (requestedType == QVariant::String
| 0 | ||||||||||||||||||||||||
| 137 | QTextCodec *codec = QTextCodec::codecForName(encoding); | - | ||||||||||||||||||||||||
| 138 | if (codec
| 0 | ||||||||||||||||||||||||
| 139 | return never executed: codec->toUnicode(data);return codec->toUnicode(data);never executed: return codec->toUnicode(data); | 0 | ||||||||||||||||||||||||
| 140 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | return never executed: data;return data;never executed: return data; | 0 | ||||||||||||||||||||||||
| 144 | } | - | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||
| 147 | if (format == QLatin1String("text/plain")
| 0-2 | ||||||||||||||||||||||||
| 148 | if (a == connection->atom(QXcbAtom::UTF8_STRING)
| 0-2 | ||||||||||||||||||||||||
| 149 | return executed 2 times by 2 tests: QString::fromUtf8(data);return QString::fromUtf8(data);Executed by:
executed 2 times by 2 tests: return QString::fromUtf8(data);Executed by:
| 2 | ||||||||||||||||||||||||
| 150 | if (a == XCB_ATOM_STRING
| 0 | ||||||||||||||||||||||||
| 151 | a == connection->atom(QXcbAtom::TEXT)
| 0 | ||||||||||||||||||||||||
| 152 | return never executed: QString::fromLatin1(data);return QString::fromLatin1(data);never executed: return QString::fromLatin1(data); | 0 | ||||||||||||||||||||||||
| 153 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||
| 158 | if ((format == QLatin1String("text/html")
| 0 | ||||||||||||||||||||||||
| 159 | && data.size() > 1
| 0 | ||||||||||||||||||||||||
| 160 | const quint8 byte0 = data.at(0); | - | ||||||||||||||||||||||||
| 161 | const quint8 byte1 = data.at(1); | - | ||||||||||||||||||||||||
| 162 | if ((byte0 == 0xff
| 0 | ||||||||||||||||||||||||
| 163 | || (byte0 != 0
| 0 | ||||||||||||||||||||||||
| 164 | const QString str = QString::fromUtf16( | - | ||||||||||||||||||||||||
| 165 | reinterpret_cast<const ushort *>(data.constData()), data.size() / 2); | - | ||||||||||||||||||||||||
| 166 | if (!str.isNull()
| 0 | ||||||||||||||||||||||||
| 167 | if (format == QLatin1String("text/uri-list")
| 0 | ||||||||||||||||||||||||
| 168 | const QStringList urls = str.split(QLatin1Char('\n')); | - | ||||||||||||||||||||||||
| 169 | QList<QVariant> list; | - | ||||||||||||||||||||||||
| 170 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(urls)>::type> _container_((urls)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &s = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||
| 171 | const QUrl url(s.trimmed()); | - | ||||||||||||||||||||||||
| 172 | if (url.isValid()
| 0 | ||||||||||||||||||||||||
| 173 | list.append(url); never executed: list.append(url); | 0 | ||||||||||||||||||||||||
| 174 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||
| 178 | if (!list.isEmpty()
| 0 | ||||||||||||||||||||||||
| 179 | return never executed: list.first();return list.first();never executed: return list.first(); | 0 | ||||||||||||||||||||||||
| 180 | return never executed: list;return list;never executed: return list; | 0 | ||||||||||||||||||||||||
| 181 | } else { | - | ||||||||||||||||||||||||
| 182 | return never executed: str;return str;never executed: return str; | 0 | ||||||||||||||||||||||||
| 183 | } | - | ||||||||||||||||||||||||
| 184 | } | - | ||||||||||||||||||||||||
| 185 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 186 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||
| 188 | if (atomName == format
| 0 | ||||||||||||||||||||||||
| 189 | return never executed: data;return data;never executed: return data; | 0 | ||||||||||||||||||||||||
| 190 | return never executed: QVariant();return QVariant();never executed: return QVariant(); | 0 | ||||||||||||||||||||||||
| 191 | } | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType, | - | ||||||||||||||||||||||||
| 194 | const QVector<xcb_atom_t> &atoms, QByteArray *requestedEncoding) | - | ||||||||||||||||||||||||
| 195 | { | - | ||||||||||||||||||||||||
| 196 | requestedEncoding->clear(); | - | ||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||
| 199 | if (format == QLatin1String("text/plain")
| 0-2 | ||||||||||||||||||||||||
| 200 | if (atoms.contains(connection->atom(QXcbAtom::UTF8_STRING))
| 0-2 | ||||||||||||||||||||||||
| 201 | return executed 2 times by 2 tests: connection->atom(QXcbAtom::UTF8_STRING);return connection->atom(QXcbAtom::UTF8_STRING);Executed by:
executed 2 times by 2 tests: return connection->atom(QXcbAtom::UTF8_STRING);Executed by:
| 2 | ||||||||||||||||||||||||
| 202 | if (atoms.contains(XCB_ATOM_STRING)
| 0 | ||||||||||||||||||||||||
| 203 | return never executed: XCB_ATOM_STRING;return XCB_ATOM_STRING;never executed: return XCB_ATOM_STRING; | 0 | ||||||||||||||||||||||||
| 204 | if (atoms.contains(connection->atom(QXcbAtom::TEXT))
| 0 | ||||||||||||||||||||||||
| 205 | return never executed: connection->atom(QXcbAtom::TEXT);return connection->atom(QXcbAtom::TEXT);never executed: return connection->atom(QXcbAtom::TEXT); | 0 | ||||||||||||||||||||||||
| 206 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||
| 209 | if (format == QLatin1String("text/uri-list")
| 0 | ||||||||||||||||||||||||
| 210 | xcb_atom_t a = connection->internAtom(format.toLatin1()); | - | ||||||||||||||||||||||||
| 211 | if (a
| 0 | ||||||||||||||||||||||||
| 212 | return never executed: a;return a;never executed: return a; | 0 | ||||||||||||||||||||||||
| 213 | a = connection->internAtom("text/x-moz-url"); | - | ||||||||||||||||||||||||
| 214 | if (a
| 0 | ||||||||||||||||||||||||
| 215 | return never executed: a;return a;never executed: return a; | 0 | ||||||||||||||||||||||||
| 216 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | if (format == QLatin1String("image/ppm")
| 0 | ||||||||||||||||||||||||
| 220 | if (atoms.contains(XCB_ATOM_PIXMAP)
| 0 | ||||||||||||||||||||||||
| 221 | return never executed: XCB_ATOM_PIXMAP;return XCB_ATOM_PIXMAP;never executed: return XCB_ATOM_PIXMAP; | 0 | ||||||||||||||||||||||||
| 222 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||
| 226 | if (requestedType == QVariant::String
| 0 | ||||||||||||||||||||||||
| 227 | && format.startsWith(QLatin1String("text/"))
| 0 | ||||||||||||||||||||||||
| 228 | && !format.contains(QLatin1String("charset="))
| 0 | ||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | QString formatWithCharset = format; | - | ||||||||||||||||||||||||
| 231 | formatWithCharset.append(QLatin1String(";charset=utf-8")); | - | ||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||
| 233 | xcb_atom_t a = connection->internAtom(formatWithCharset.toLatin1()); | - | ||||||||||||||||||||||||
| 234 | if (a
| 0 | ||||||||||||||||||||||||
| 235 | *requestedEncoding = "utf-8"; | - | ||||||||||||||||||||||||
| 236 | return never executed: a;return a;never executed: return a; | 0 | ||||||||||||||||||||||||
| 237 | } | - | ||||||||||||||||||||||||
| 238 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | xcb_atom_t a = connection->internAtom(format.toLatin1()); | - | ||||||||||||||||||||||||
| 241 | if (a
| 0 | ||||||||||||||||||||||||
| 242 | return never executed: a;return a;never executed: return a; | 0 | ||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 245 | } | - | ||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |