Qt 4.8
Public Functions | List of all members
QMacPasteboardMimeTiff Class Reference
Inheritance diagram for QMacPasteboardMimeTiff:
QMacPasteboardMime

Public Functions

bool canConvert (const QString &mime, QString flav)
 Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false. More...
 
QList< QByteArrayconvertFromMime (const QString &mime, QVariant data, QString flav)
 Returns data converted from MIME type mime to Mac UTI flav. More...
 
QString convertorName ()
 Returns a name for the convertor. More...
 
QVariant convertToMime (const QString &mime, QList< QByteArray > data, QString flav)
 Returns data converted from Mac UTI flav to MIME type mime. More...
 
QString flavorFor (const QString &mime)
 Returns the Mac UTI used for MIME type mime, or 0 if this convertor does not support mime. More...
 
QString mimeFor (QString flav)
 Returns the MIME UTI used for Mac flavor flav, or 0 if this convertor does not support flav. More...
 
 QMacPasteboardMimeTiff ()
 
- Public Functions inherited from QMacPasteboardMime
 QMacPasteboardMime (char)
 Constructs a new conversion object of type t, adding it to the globally accessed list of available convertors. More...
 
virtual ~QMacPasteboardMime ()
 Destroys a conversion object, removing it from the global list of available convertors. More...
 

Additional Inherited Members

- Public Types inherited from QMacPasteboardMime
enum  QMacPasteboardMimeType {
  MIME_DND =0x01, MIME_CLIP =0x02, MIME_QT_CONVERTOR =0x04, MIME_QT3_CONVERTOR =0x08,
  MIME_ALL =MIME_DND|MIME_CLIP
}
 
- Static Public Functions inherited from QMacPasteboardMime
static QList< QMacPasteboardMime * > all (uchar)
 Returns a list of all currently defined QMacPasteboardMime objects of type t. More...
 
static QMacPasteboardMimeconvertor (uchar, const QString &mime, QString flav)
 Returns the most-recently created QMacPasteboardMime of type t that can convert between the mime and flav formats. More...
 
static QString flavorToMime (uchar, QString flav)
 Returns a MIME type of type t for flav, or 0 if none exists. More...
 
static void initialize ()
 This is an internal function. More...
 

Detailed Description

Definition at line 650 of file qmime_mac.cpp.

Constructors and Destructors

◆ QMacPasteboardMimeTiff()

QMacPasteboardMimeTiff::QMacPasteboardMimeTiff ( )
inline

Definition at line 652 of file qmime_mac.cpp.

QMacPasteboardMime(char)
Constructs a new conversion object of type t, adding it to the globally accessed list of available co...
Definition: qmime_mac.cpp:180

Functions

◆ canConvert()

bool QMacPasteboardMimeTiff::canConvert ( const QString mime,
QString  flav 
)
virtual

Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 681 of file qmime_mac.cpp.

682 {
683  return flav == QLatin1String("public.tiff") && mime == QLatin1String("application/x-qt-image");
684 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ convertFromMime()

QList< QByteArray > QMacPasteboardMimeTiff::convertFromMime ( const QString mime,
QVariant  data,
QString  flav 
)
virtual

Returns data converted from MIME type mime to Mac UTI flav.

Note that Mac flavors must all be self-terminating. The return value may contain trailing data.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 706 of file qmime_mac.cpp.

707 {
708  QList<QByteArray> ret;
709  if (!canConvert(mime, flav))
710  return ret;
711 
714 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
716  QCFType<CFMutableDataRef> data = CFDataCreateMutable(0, 0);
717  QCFType<CGImageDestinationRef> imageDestination = CGImageDestinationCreateWithData(data, kUTTypeTIFF, 1, 0);
718  if (imageDestination != 0) {
719  CFTypeRef keys[2];
721  QCFType<CFDictionaryRef> options;
722  keys[0] = kCGImagePropertyPixelWidth;
723  keys[1] = kCGImagePropertyPixelHeight;
724  int width = img.width();
725  int height = img.height();
726  values[0] = CFNumberCreate(0, kCFNumberIntType, &width);
727  values[1] = CFNumberCreate(0, kCFNumberIntType, &height);
728  options = CFDictionaryCreate(0, reinterpret_cast<const void **>(keys),
729  reinterpret_cast<const void **>(values), 2,
730  &kCFTypeDictionaryKeyCallBacks,
731  &kCFTypeDictionaryValueCallBacks);
732  CGImageDestinationAddImage(imageDestination, cgimage, options);
733  CGImageDestinationFinalize(imageDestination);
734  }
735  QByteArray ar(CFDataGetLength(data), 0);
736  CFDataGetBytes(data,
737  CFRangeMake(0, ar.size()),
738  reinterpret_cast<UInt8 *>(ar.data()));
739  ret.append(ar);
740  } else
741 #endif
742  {
743 #ifdef Q_WS_MAC32
744  Handle tiff = NewHandle(0);
745  if (resolveMimeQuickTimeSymbols()) {
746  GraphicsExportComponent graphicsExporter;
747  ComponentResult result = OpenADefaultComponent(GraphicsExporterComponentType,
748  kQTFileTypeTIFF, &graphicsExporter);
749  if (!result) {
750  unsigned long sizeWritten;
751  result = ptrGraphicsExportSetInputCGImage(graphicsExporter, cgimage);
752  if (!result)
753  result = ptrGraphicsExportSetOutputHandle(graphicsExporter, tiff);
754  if (!result)
755  result = ptrGraphicsExportDoExport(graphicsExporter, &sizeWritten);
756 
757  CloseComponent(graphicsExporter);
758  }
759  }
760  int size = GetHandleSize((Handle)tiff);
761  QByteArray ar(reinterpret_cast<char *>(*tiff), size);
762  ret.append(ar);
763  DisposeHandle(tiff);
764 #endif
765  }
766  return ret;
767 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
CGImageRef qt_mac_createCGImageFromQImage(const QImage &img, const QImage **imagePtr=0)
QStringList keys
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
bool canConvert(const QString &mime, QString flav)
Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false...
Definition: qmime_mac.cpp:681
quint16 values[128]
const void * CFTypeRef
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
const char * variant

◆ convertorName()

QString QMacPasteboardMimeTiff::convertorName ( )
virtual

Returns a name for the convertor.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 662 of file qmime_mac.cpp.

663 {
664  return QLatin1String("Tiff");
665 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ convertToMime()

QVariant QMacPasteboardMimeTiff::convertToMime ( const QString mime,
QList< QByteArray data,
QString  flav 
)
virtual

Returns data converted from Mac UTI flav to MIME type mime.

Note that Mac flavors must all be self-terminating. The input data may contain trailing data.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 686 of file qmime_mac.cpp.

687 {
688  if(data.count() > 1)
689  qWarning("QMacPasteboardMimeTiff: Cannot handle multiple member data");
690  QVariant ret;
691  if (!canConvert(mime, flav))
692  return ret;
693  const QByteArray &a = data.first();
694  QCFType<CGImageRef> image;
695  QCFType<CFDataRef> tiffData = CFDataCreateWithBytesNoCopy(0,
696  reinterpret_cast<const UInt8 *>(a.constData()),
697  a.size(), kCFAllocatorNull);
698  QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithData(tiffData, 0);
699  image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0);
700 
701  if (image != 0)
702  ret = QVariant(QPixmap::fromMacCGImageRef(image).toImage());
703  return ret;
704 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QPixmap fromMacCGImageRef(CGImageRef image)
Returns a QPixmap that is equivalent to the given image.
Q_CORE_EXPORT void qWarning(const char *,...)
bool canConvert(const QString &mime, QString flav)
Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false...
Definition: qmime_mac.cpp:681
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ flavorFor()

QString QMacPasteboardMimeTiff::flavorFor ( const QString mime)
virtual

Returns the Mac UTI used for MIME type mime, or 0 if this convertor does not support mime.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 667 of file qmime_mac.cpp.

668 {
669  if(mime.startsWith(QLatin1String("application/x-qt-image")))
670  return QLatin1String("public.tiff");
671  return QString();
672 }
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654

◆ mimeFor()

QString QMacPasteboardMimeTiff::mimeFor ( QString  flav)
virtual

Returns the MIME UTI used for Mac flavor flav, or 0 if this convertor does not support flav.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 674 of file qmime_mac.cpp.

675 {
676  if(flav == QLatin1String("public.tiff"))
677  return QLatin1String("application/x-qt-image");
678  return QString();
679 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83

The documentation for this class was generated from the following file: