mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
clean-up
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24150 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e332dbe7fa
commit
e60e0a0932
@ -71,40 +71,37 @@ namespace frontend {
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
static FORMATETC setCf(int cf)
|
||||
static FORMATETC cfFromMime(QString const & mimetype)
|
||||
{
|
||||
FORMATETC formatetc;
|
||||
formatetc.cfFormat = cf;
|
||||
if (mimetype == emf_mime_type) {
|
||||
formatetc.cfFormat = CF_ENHMETAFILE;
|
||||
formatetc.tymed = TYMED_ENHMF;
|
||||
}
|
||||
else if (mimetype == wmf_mime_type) {
|
||||
formatetc.cfFormat = CF_METAFILEPICT;
|
||||
formatetc.tymed = TYMED_MFPICT;
|
||||
}
|
||||
else return formatetc;
|
||||
formatetc.ptd = NULL;
|
||||
formatetc.dwAspect = DVASPECT_CONTENT;
|
||||
formatetc.lindex = -1;
|
||||
if (cf == CF_ENHMETAFILE)
|
||||
formatetc.tymed = TYMED_ENHMF;
|
||||
if (cf == CF_METAFILEPICT)
|
||||
formatetc.tymed = TYMED_MFPICT;
|
||||
return formatetc;
|
||||
}
|
||||
|
||||
|
||||
static bool canGetData(int cf, IDataObject * pDataObj)
|
||||
{
|
||||
FORMATETC formatetc = setCf(cf);
|
||||
return pDataObj->QueryGetData(&formatetc) == S_OK;
|
||||
}
|
||||
|
||||
|
||||
class QWindowsMimeMetafile : public QWindowsMime {
|
||||
public:
|
||||
bool canConvertFromMime(FORMATETC const & formatetc, QMimeData const * mimeData) const;
|
||||
bool canConvertToMime(QString const & mimeType, IDataObject * pDataObj) const;
|
||||
bool convertFromMime(FORMATETC const & formatetc, const QMimeData * mimeData, STGMEDIUM * pmedium) const;
|
||||
QVariant convertToMime(QString const & mimeType, IDataObject * pDataObj, QVariant::Type preferredType) const;
|
||||
bool canConvertFromMime(FORMATETC const & formatetc, QMimeData const * mimedata) const;
|
||||
bool canConvertToMime(QString const & mimetype, IDataObject * pDataObj) const;
|
||||
bool convertFromMime(FORMATETC const & formatetc, const QMimeData * mimedata, STGMEDIUM * pmedium) const;
|
||||
QVariant convertToMime(QString const & mimetype, IDataObject * pDataObj, QVariant::Type preferredType) const;
|
||||
QVector<FORMATETC> formatsForMime(QString const & mimeType, QMimeData const * mimeData) const;
|
||||
QString mimeForFormat(FORMATETC const &) const;
|
||||
};
|
||||
|
||||
|
||||
QString QWindowsMimeMetafile::mimeForFormat(const FORMATETC & formatetc) const
|
||||
QString QWindowsMimeMetafile::mimeForFormat(FORMATETC const & formatetc) const
|
||||
{
|
||||
QString f;
|
||||
if (formatetc.cfFormat == CF_ENHMETAFILE)
|
||||
@ -116,45 +113,41 @@ QString QWindowsMimeMetafile::mimeForFormat(const FORMATETC & formatetc) const
|
||||
|
||||
|
||||
bool QWindowsMimeMetafile::canConvertFromMime(
|
||||
const FORMATETC & formatetc, const QMimeData * mimeData) const
|
||||
FORMATETC const & formatetc, QMimeData const * mimedata) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool QWindowsMimeMetafile::canConvertToMime(
|
||||
const QString & mimeType, IDataObject * pDataObj) const
|
||||
QString const & mimetype, IDataObject * pDataObj) const
|
||||
{
|
||||
return (mimeType == "image/x-emf" && canGetData(CF_ENHMETAFILE, pDataObj))
|
||||
|| (mimeType == "image/x-wmf" && canGetData(CF_METAFILEPICT, pDataObj));
|
||||
FORMATETC formatetc = cfFromMime(mimetype);
|
||||
return pDataObj->QueryGetData(&formatetc) == S_OK;
|
||||
}
|
||||
|
||||
|
||||
bool QWindowsMimeMetafile::convertFromMime(
|
||||
const FORMATETC & formatetc, const QMimeData * mimeData,
|
||||
FORMATETC const & formatetc, QMimeData const * mimedata,
|
||||
STGMEDIUM * pmedium) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QVariant QWindowsMimeMetafile::convertToMime(
|
||||
const QString & mimeType, IDataObject * pDataObj,
|
||||
QVariant::Type preferredType) const
|
||||
QVariant QWindowsMimeMetafile::convertToMime(QString const & mimetype,
|
||||
IDataObject * pDataObj, QVariant::Type preferredType) const
|
||||
{
|
||||
QVariant ret;
|
||||
|
||||
if (canConvertToMime(mimeType, pDataObj)) {
|
||||
FORMATETC formatetc;
|
||||
if (mimeType == "image/x-emf")
|
||||
formatetc = setCf(CF_ENHMETAFILE);
|
||||
if (mimeType == "image/x-wmf")
|
||||
formatetc = setCf(CF_METAFILEPICT);
|
||||
STGMEDIUM s;
|
||||
QByteArray data;
|
||||
int dataSize;
|
||||
if (!canConvertToMime(mimetype, pDataObj))
|
||||
return data;
|
||||
|
||||
if (pDataObj->GetData(&formatetc, &s) == S_OK) {
|
||||
FORMATETC formatetc = cfFromMime(mimetype);
|
||||
STGMEDIUM s;
|
||||
if (pDataObj->GetData(&formatetc, &s) != S_OK)
|
||||
return data;
|
||||
|
||||
int dataSize;
|
||||
if (s.tymed == TYMED_ENHMF) {
|
||||
dataSize = GetEnhMetaFileBits(s.hEnhMetaFile, 0, NULL);
|
||||
data.resize(dataSize);
|
||||
@ -166,21 +159,16 @@ QVariant QWindowsMimeMetafile::convertToMime(
|
||||
}
|
||||
data.detach();
|
||||
ReleaseStgMedium(&s);
|
||||
}
|
||||
ret = data;
|
||||
}
|
||||
return ret;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
QVector<FORMATETC> QWindowsMimeMetafile::formatsForMime(
|
||||
const QString & mimeType, const QMimeData * mimeData) const
|
||||
QString const & mimetype, QMimeData const * mimedata) const
|
||||
{
|
||||
QVector<FORMATETC> formats;
|
||||
if (mimeType == "image/x-emf")
|
||||
formats += setCf(CF_ENHMETAFILE);
|
||||
if (mimeType == "image/x-wmf")
|
||||
formats += setCf(CF_METAFILEPICT);
|
||||
formats += cfFromMime(mimetype);
|
||||
return formats;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user