qxcbmime.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbmime.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the plugins of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qxcbmime.h"-
41-
42#include <QtCore/QTextCodec>-
43#include <QtGui/QImageWriter>-
44#include <QtCore/QBuffer>-
45#include <qdebug.h>-
46-
47#include <X11/Xutil.h>-
48-
49#undef XCB_ATOM_STRING-
50#undef XCB_ATOM_PIXMAP-
51#undef XCB_ATOM_BITMAP-
52-
53QT_BEGIN_NAMESPACE-
54-
55#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))-
56-
57QXcbMime::QXcbMime()-
58 : QInternalMimeData()-
59{
executed 140 times by 9 tests: end of block
Executed by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGuiApplication
  • tst_QPlainTextEdit
  • tst_QStyleSheetStyle
  • tst_QTextEdit
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
}
executed 140 times by 9 tests: end of block
Executed by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGuiApplication
  • tst_QPlainTextEdit
  • tst_QStyleSheetStyle
  • tst_QTextEdit
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
140
60-
61QXcbMime::~QXcbMime()-
62{}-
63-
64-
65-
66QString QXcbMime::mimeAtomToString(QXcbConnection *connection, xcb_atom_t a)-
67{-
68 if (a == XCB_NONE)
a == 0LDescription
TRUEnever evaluated
FALSEevaluated 59 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-59
69 return QString();
never executed: return QString();
0
70-
71 // special cases for string type-
72 if (a == XCB_ATOM_STRING
a == XCB_ATOM_STRINGDescription
TRUEevaluated 7 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 52 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
7-52
73 || a == connection->atom(QXcbAtom::UTF8_STRING)
a == connectio...::UTF8_STRING)Description
TRUEevaluated 9 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 43 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
9-43
74 || a == connection->atom(QXcbAtom::TEXT))
a == connectio...XcbAtom::TEXT)Description
TRUEevaluated 7 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 36 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
7-36
75 return QLatin1String("text/plain");
executed 23 times by 6 tests: return QLatin1String("text/plain");
Executed by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
23
76-
77 // special case for images-
78 if (a == XCB_ATOM_PIXMAP)
a == XCB_ATOM_PIXMAPDescription
TRUEnever evaluated
FALSEevaluated 36 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-36
79 return QLatin1String("image/ppm");
never executed: return QLatin1String("image/ppm");
0
80-
81 QByteArray atomName = connection->atomName(a);-
82-
83 // special cases for uris-
84 if (atomName == "text/x-moz-url")
atomName == "text/x-moz-url"Description
TRUEnever evaluated
FALSEevaluated 36 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-36
85 atomName = "text/uri-list";
never executed: atomName = "text/uri-list";
0
86-
87 return QString::fromLatin1(atomName.constData());
executed 36 times by 6 tests: return QString::fromLatin1(atomName.constData());
Executed by:
  • tst_QApplication
  • tst_QStyleSheetStyle
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
36
88}-
89-
90bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeData *mimeData, QByteArray *data,-
91 xcb_atom_t *atomFormat, int *dataFormat)-
92{-
93 if (!data)
!dataDescription
TRUEnever evaluated
FALSEevaluated 29 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-29
94 return false;
never executed: return false;
0
95-
96 bool ret = false;-
97 *atomFormat = a;-
98 *dataFormat = 8;-
99-
100 if ((a == connection->atom(QXcbAtom::UTF8_STRING)
a == connectio...::UTF8_STRING)Description
TRUEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 24 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
5-24
101 || a == XCB_ATOM_STRING
a == XCB_ATOM_STRINGDescription
TRUEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 19 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
5-19
102 || a == connection->atom(QXcbAtom::TEXT))
a == connectio...XcbAtom::TEXT)Description
TRUEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 14 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
5-14
103 && QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
QInternalMimeD...n"), mimeData)Description
TRUEevaluated 15 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEnever evaluated
0-15
104 if (a == connection->atom(QXcbAtom::UTF8_STRING)) {
a == connectio...::UTF8_STRING)Description
TRUEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 10 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
5-10
105 *data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);-
106 ret = true;-
107 } else if (a == XCB_ATOM_STRING ||
executed 5 times by 5 tests: end of block
Executed by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
a == XCB_ATOM_STRINGDescription
TRUEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
5
108 a == connection->atom(QXcbAtom::TEXT)) {
a == connectio...XcbAtom::TEXT)Description
TRUEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEnever evaluated
0-5
109 // ICCCM says STRING is latin1-
110 *data = QString::fromUtf8(QInternalMimeData::renderDataHelper(-
111 QLatin1String("text/plain"), mimeData)).toLatin1();-
112 ret = true;-
113 }
executed 10 times by 5 tests: end of block
Executed by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
10
114 return ret;
executed 15 times by 5 tests: return ret;
Executed by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
15
115 }-
116-
117 QString atomName = mimeAtomToString(connection, a);-
118 if (QInternalMimeData::hasFormatHelper(atomName, mimeData)) {
QInternalMimeD...ame, mimeData)Description
TRUEevaluated 9 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
5-9
119 *data = QInternalMimeData::renderDataHelper(atomName, mimeData);-
120 // mimeAtomToString() converts "text/x-moz-url" to "text/uri-list",-
121 // so QXcbConnection::atomName() has to be used.-
122 if (atomName == QLatin1String("text/uri-list")
atomName == QL...ext/uri-list")Description
TRUEnever evaluated
FALSEevaluated 9 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-9
123 && connection->atomName(a) == "text/x-moz-url") {
connection->at...ext/x-moz-url"Description
TRUEnever evaluated
FALSEnever evaluated
0
124 const QByteArray uri = data->split('\n').first();-
125 QString mozUri = QString::fromLatin1(uri, uri.size());-
126 mozUri += QLatin1Char('\n');-
127 *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()),-
128 mozUri.length() * 2);-
129 } else if (atomName == QLatin1String("application/x-color"))
never executed: end of block
atomName == QL...tion/x-color")Description
TRUEnever evaluated
FALSEevaluated 9 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-9
130 *dataFormat = 16;
never executed: *dataFormat = 16;
0
131 ret = true;-
132 } else if ((a == XCB_ATOM_PIXMAP || a == XCB_ATOM_BITMAP) && mimeData->hasImage()) {
executed 9 times by 5 tests: end of block
Executed by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
a == XCB_ATOM_PIXMAPDescription
TRUEnever evaluated
FALSEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
a == XCB_ATOM_BITMAPDescription
TRUEnever evaluated
FALSEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
mimeData->hasImage()Description
TRUEnever evaluated
FALSEnever evaluated
0-9
133 ret = true;-
134 } else if (atomName == QLatin1String("text/plain")
never executed: end of block
atomName == QL...("text/plain")Description
TRUEnever evaluated
FALSEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-5
135 && mimeData->hasFormat(QLatin1String("text/uri-list"))) {
mimeData->hasF...xt/uri-list"))Description
TRUEnever evaluated
FALSEnever evaluated
0
136 // Return URLs also as plain text.-
137 *data = QInternalMimeData::renderDataHelper(atomName, mimeData);-
138 ret = true;-
139 }
never executed: end of block
0
140 return ret;
executed 14 times by 5 tests: return ret;
Executed by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
14
141}-
142-
143QVector<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, const QString &format)-
144{-
145 QVector<xcb_atom_t> atoms;-
146 atoms.reserve(7);-
147 atoms.append(connection->internAtom(format.toLatin1()));-
148-
149 // special cases for strings-
150 if (format == QLatin1String("text/plain")) {
format == QLat...("text/plain")Description
TRUEevaluated 5 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
4-5
151 atoms.append(connection->atom(QXcbAtom::UTF8_STRING));-
152 atoms.append(XCB_ATOM_STRING);-
153 atoms.append(connection->atom(QXcbAtom::TEXT));-
154 }
executed 5 times by 5 tests: end of block
Executed by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
5
155-
156 // special cases for uris-
157 if (format == QLatin1String("text/uri-list")) {
format == QLat...ext/uri-list")Description
TRUEnever evaluated
FALSEevaluated 9 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-9
158 atoms.append(connection->internAtom("text/x-moz-url"));-
159 atoms.append(connection->internAtom("text/plain"));-
160 }
never executed: end of block
0
161-
162 //special cases for images-
163 if (format == QLatin1String("image/ppm"))
format == QLat...g("image/ppm")Description
TRUEnever evaluated
FALSEevaluated 9 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-9
164 atoms.append(XCB_ATOM_PIXMAP);
never executed: atoms.append(XCB_ATOM_PIXMAP);
0
165 if (format == QLatin1String("image/pbm"))
format == QLat...g("image/pbm")Description
TRUEnever evaluated
FALSEevaluated 9 times by 5 tests
Evaluated by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
0-9
166 atoms.append(XCB_ATOM_BITMAP);
never executed: atoms.append(XCB_ATOM_BITMAP);
0
167-
168 return atoms;
executed 9 times by 5 tests: return atoms;
Executed by:
  • tst_QApplication
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
9
169}-
170-
171QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &data, const QString &format,-
172 QVariant::Type requestedType, const QByteArray &encoding)-
173{-
174 QString atomName = mimeAtomToString(connection, a);-
175// qDebug() << "mimeConvertDataToFormat" << format << atomName << data;-
176-
177 if (!encoding.isEmpty()
!encoding.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
0-2
178 && atomName == format + QLatin1String(";charset=") + QString::fromLatin1(encoding)) {
atomName == fo...tin1(encoding)Description
TRUEnever evaluated
FALSEnever evaluated
0
179-
180#ifndef QT_NO_TEXTCODEC-
181 if (requestedType == QVariant::String) {
requestedType ...ariant::StringDescription
TRUEnever evaluated
FALSEnever evaluated
0
182 QTextCodec *codec = QTextCodec::codecForName(encoding);-
183 if (codec)
codecDescription
TRUEnever evaluated
FALSEnever evaluated
0
184 return codec->toUnicode(data);
never executed: return codec->toUnicode(data);
0
185 }
never executed: end of block
0
186#endif-
187-
188 return data;
never executed: return data;
0
189 }-
190-
191 // special cases for string types-
192 if (format == QLatin1String("text/plain")) {
format == QLat...("text/plain")Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
FALSEnever evaluated
0-2
193 if (a == connection->atom(QXcbAtom::UTF8_STRING))
a == connectio...::UTF8_STRING)Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
FALSEnever evaluated
0-2
194 return QString::fromUtf8(data);
executed 2 times by 2 tests: return QString::fromUtf8(data);
Executed by:
  • tst_QApplication
  • tst_QStyleSheetStyle
2
195 if (a == XCB_ATOM_STRING ||
a == XCB_ATOM_STRINGDescription
TRUEnever evaluated
FALSEnever evaluated
0
196 a == connection->atom(QXcbAtom::TEXT))
a == connectio...XcbAtom::TEXT)Description
TRUEnever evaluated
FALSEnever evaluated
0
197 return QString::fromLatin1(data);
never executed: return QString::fromLatin1(data);
0
198 }
never executed: end of block
0
199 // If data contains UTF16 text, convert it to a string.-
200 // Firefox uses UTF16 without BOM for text/x-moz-url, "text/html",-
201 // Google Chrome uses UTF16 without BOM for "text/x-moz-url",-
202 // UTF16 with BOM for "text/html".-
203 if ((format == QLatin1String("text/html") || format == QLatin1String("text/uri-list"))
format == QLat...g("text/html")Description
TRUEnever evaluated
FALSEnever evaluated
format == QLat...ext/uri-list")Description
TRUEnever evaluated
FALSEnever evaluated
0
204 && data.size() > 1) {
data.size() > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
205 const quint8 byte0 = data.at(0);-
206 const quint8 byte1 = data.at(1);-
207 if ((byte0 == 0xff && byte1 == 0xfe) || (byte0 == 0xfe && byte1 == 0xff)
byte0 == 0xffDescription
TRUEnever evaluated
FALSEnever evaluated
byte1 == 0xfeDescription
TRUEnever evaluated
FALSEnever evaluated
byte0 == 0xfeDescription
TRUEnever evaluated
FALSEnever evaluated
byte1 == 0xffDescription
TRUEnever evaluated
FALSEnever evaluated
0
208 || (byte0 != 0 && byte1 == 0) || (byte0 == 0 && byte1 != 0)) {
byte0 != 0Description
TRUEnever evaluated
FALSEnever evaluated
byte1 == 0Description
TRUEnever evaluated
FALSEnever evaluated
byte0 == 0Description
TRUEnever evaluated
FALSEnever evaluated
byte1 != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
209 const QString str = QString::fromUtf16(-
210 reinterpret_cast<const ushort *>(data.constData()), data.size() / 2);-
211 if (!str.isNull()) {
!str.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
212 if (format == QLatin1String("text/uri-list")) {
format == QLat...ext/uri-list")Description
TRUEnever evaluated
FALSEnever evaluated
0
213 const QStringList urls = str.split(QLatin1Char('\n'));-
214 QList<QVariant> list;-
215 foreach (const QString &s, urls) {-
216 const QUrl url(s.trimmed());-
217 if (url.isValid())
url.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
218 list.append(url);
never executed: list.append(url);
0
219 }
never executed: end of block
0
220 // We expect "text/x-moz-url" as <url><space><title>.-
221 // The atomName variable is not used because mimeAtomToString()-
222 // converts "text/x-moz-url" to "text/uri-list".-
223 if (!list.isEmpty() && connection->atomName(a) == "text/x-moz-url")
!list.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
connection->at...ext/x-moz-url"Description
TRUEnever evaluated
FALSEnever evaluated
0
224 return list.first();
never executed: return list.first();
0
225 return list;
never executed: return list;
0
226 } else {-
227 return str;
never executed: return str;
0
228 }-
229 }-
230 }
never executed: end of block
0
231 }
never executed: end of block
0
232-
233 if (atomName == format)
atomName == formatDescription
TRUEnever evaluated
FALSEnever evaluated
0
234 return data;
never executed: return data;
0
235-
236#if 0 // ###-
237 // special case for images-
238 if (format == QLatin1String("image/ppm")) {-
239 if (a == XCB_ATOM_PIXMAP && data.size() == sizeof(Pixmap)) {-
240 Pixmap xpm = *((Pixmap*)data.data());-
241 if (!xpm)-
242 return QByteArray();-
243 Window root;-
244 int x;-
245 int y;-
246 uint width;-
247 uint height;-
248 uint border_width;-
249 uint depth;-
250-
251 XGetGeometry(display, xpm, &root, &x, &y, &width, &height, &border_width, &depth);-
252 XImage *ximg = XGetImage(display,xpm,x,y,width,height,AllPlanes,depth==1 ? XYPixmap : ZPixmap);-
253 QImage qimg = QXlibStatic::qimageFromXImage(ximg);-
254 XDestroyImage(ximg);-
255-
256 QImageWriter imageWriter;-
257 imageWriter.setFormat("PPMRAW");-
258 QBuffer buf;-
259 buf.open(QIODevice::WriteOnly);-
260 imageWriter.setDevice(&buf);-
261 imageWriter.write(qimg);-
262 return buf.buffer();-
263 }-
264 }-
265#endif-
266 return QVariant();
never executed: return QVariant();
0
267}-
268-
269xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType,-
270 const QVector<xcb_atom_t> &atoms, QByteArray *requestedEncoding)-
271{-
272 requestedEncoding->clear();-
273-
274 // find matches for string types-
275 if (format == QLatin1String("text/plain")) {
format == QLat...("text/plain")Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
FALSEnever evaluated
0-2
276 if (atoms.contains(connection->atom(QXcbAtom::UTF8_STRING)))
atoms.contains...:UTF8_STRING))Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QApplication
  • tst_QStyleSheetStyle
FALSEnever evaluated
0-2
277 return connection->atom(QXcbAtom::UTF8_STRING);
executed 2 times by 2 tests: return connection->atom(QXcbAtom::UTF8_STRING);
Executed by:
  • tst_QApplication
  • tst_QStyleSheetStyle
2
278 if (atoms.contains(XCB_ATOM_STRING))
atoms.contains...B_ATOM_STRING)Description
TRUEnever evaluated
FALSEnever evaluated
0
279 return XCB_ATOM_STRING;
never executed: return XCB_ATOM_STRING;
0
280 if (atoms.contains(connection->atom(QXcbAtom::TEXT)))
atoms.contains...cbAtom::TEXT))Description
TRUEnever evaluated
FALSEnever evaluated
0
281 return connection->atom(QXcbAtom::TEXT);
never executed: return connection->atom(QXcbAtom::TEXT);
0
282 }
never executed: end of block
0
283-
284 // find matches for uri types-
285 if (format == QLatin1String("text/uri-list")) {
format == QLat...ext/uri-list")Description
TRUEnever evaluated
FALSEnever evaluated
0
286 xcb_atom_t a = connection->internAtom(format.toLatin1());-
287 if (a && atoms.contains(a))
aDescription
TRUEnever evaluated
FALSEnever evaluated
atoms.contains(a)Description
TRUEnever evaluated
FALSEnever evaluated
0
288 return a;
never executed: return a;
0
289 a = connection->internAtom("text/x-moz-url");-
290 if (a && atoms.contains(a))
aDescription
TRUEnever evaluated
FALSEnever evaluated
atoms.contains(a)Description
TRUEnever evaluated
FALSEnever evaluated
0
291 return a;
never executed: return a;
0
292 }
never executed: end of block
0
293-
294 // find match for image-
295 if (format == QLatin1String("image/ppm")) {
format == QLat...g("image/ppm")Description
TRUEnever evaluated
FALSEnever evaluated
0
296 if (atoms.contains(XCB_ATOM_PIXMAP))
atoms.contains...B_ATOM_PIXMAP)Description
TRUEnever evaluated
FALSEnever evaluated
0
297 return XCB_ATOM_PIXMAP;
never executed: return XCB_ATOM_PIXMAP;
0
298 }
never executed: end of block
0
299-
300 // for string/text requests try to use a format with a well-defined charset-
301 // first to avoid encoding problems-
302 if (requestedType == QVariant::String
requestedType ...ariant::StringDescription
TRUEnever evaluated
FALSEnever evaluated
0
303 && format.startsWith(QLatin1String("text/"))
format.startsW...ring("text/"))Description
TRUEnever evaluated
FALSEnever evaluated
0
304 && !format.contains(QLatin1String("charset="))) {
!format.contai...g("charset="))Description
TRUEnever evaluated
FALSEnever evaluated
0
305-
306 QString formatWithCharset = format;-
307 formatWithCharset.append(QLatin1String(";charset=utf-8"));-
308-
309 xcb_atom_t a = connection->internAtom(formatWithCharset.toLatin1());-
310 if (a && atoms.contains(a)) {
aDescription
TRUEnever evaluated
FALSEnever evaluated
atoms.contains(a)Description
TRUEnever evaluated
FALSEnever evaluated
0
311 *requestedEncoding = "utf-8";-
312 return a;
never executed: return a;
0
313 }-
314 }
never executed: end of block
0
315-
316 xcb_atom_t a = connection->internAtom(format.toLatin1());-
317 if (a && atoms.contains(a))
aDescription
TRUEnever evaluated
FALSEnever evaluated
atoms.contains(a)Description
TRUEnever evaluated
FALSEnever evaluated
0
318 return a;
never executed: return a;
0
319-
320 return 0;
never executed: return 0;
0
321}-
322-
323#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))-
324-
325QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9