cocoa: remove rtf converter from cocoa

There is now a modified rtf converter in qmacmime
that can also write rtf back to the pasteboard, and
that works on both OS X and iOS.
So we can therefore remove the one from the cocoa port.

Change-Id: Ieed04502752290d2f139f98cec69477ff1edbe4e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Richard Moe Gustavsen 2014-05-07 15:15:07 +02:00 committed by The Qt Project
parent 6388163df8
commit 986309cbf0

View File

@ -197,77 +197,10 @@ QList<QByteArray> QMacPasteboardMimeTiff::convertFromMime(const QString &mime, Q
return ret;
}
// This handler is special: It supports converting public.rtf top text/html,
// but not the other way around.
class QMacPasteboardMimeRtfText : public QMacInternalPasteboardMime {
public:
QMacPasteboardMimeRtfText() : QMacInternalPasteboardMime(MIME_ALL) { }
QString convertorName();
QString flavorFor(const QString &mime);
QString mimeFor(QString flav);
bool canConvert(const QString &mime, QString flav);
QVariant convertToMime(const QString &mime, QList<QByteArray> data, QString flav);
QList<QByteArray> convertFromMime(const QString &mime, QVariant data, QString flav);
};
QString QMacPasteboardMimeRtfText::convertorName()
{
return QLatin1String("Rtf");
}
QString QMacPasteboardMimeRtfText::flavorFor(const QString &mime)
{
if (mime == QLatin1String("text/html"))
return QLatin1String("public.rtf");
return QString();
}
QString QMacPasteboardMimeRtfText::mimeFor(QString flav)
{
if (flav == QLatin1String("public.rtf"))
return QLatin1String("text/html");
return QString();
}
bool QMacPasteboardMimeRtfText::canConvert(const QString &mime, QString flav)
{
return flavorFor(mime) == flav;
}
QVariant QMacPasteboardMimeRtfText::convertToMime(const QString &mimeType, QList<QByteArray> data, QString flavor)
{
if (!canConvert(mimeType, flavor))
return QVariant();
if (data.count() > 1)
qWarning("QMacPasteboardMimeHTMLText: Cannot handle multiple member data");
// Convert Rtf to Html.
NSAttributedString *string = [[NSAttributedString alloc] initWithRTF:data.at(0).toNSData() documentAttributes:NULL];
NSError *error;
NSRange range = NSMakeRange(0,[string length]);
NSDictionary *dict = [NSDictionary dictionaryWithObject:NSHTMLTextDocumentType forKey:NSDocumentTypeDocumentAttribute];
NSData *htmldata = [string dataFromRange:range documentAttributes:dict error:&error];
[string release];
return QByteArray::fromNSData(htmldata);
}
QList<QByteArray> QMacPasteboardMimeRtfText::convertFromMime(const QString &mime, QVariant data, QString flavor)
{
Q_UNUSED(mime);
Q_UNUSED(data);
Q_UNUSED(flavor);
qWarning("QMacPasteboardMimeRtfText: Conversion from Html to Rtf is not supported");
QList<QByteArray> ret;
return ret;
}
void QCocoaMimeTypes::initializeMimeTypes()
{
new QMacPasteboardMimeTraditionalMacPlainText;
new QMacPasteboardMimeTiff;
new QMacPasteboardMimeRtfText;
}
QT_END_NAMESPACE