diff options
Diffstat (limited to 'plugins/mTextControl/src/dataobject.cpp')
-rw-r--r-- | plugins/mTextControl/src/dataobject.cpp | 128 |
1 files changed, 57 insertions, 71 deletions
diff --git a/plugins/mTextControl/src/dataobject.cpp b/plugins/mTextControl/src/dataobject.cpp index 99e0348bc6..c8f4f50e8f 100644 --- a/plugins/mTextControl/src/dataobject.cpp +++ b/plugins/mTextControl/src/dataobject.cpp @@ -63,16 +63,15 @@ private: //
// Constructor
//
-CDataObject::CDataObject(const FORMATETC *fmtetc, const STGMEDIUM *stgmed, int count)
+CDataObject::CDataObject(const FORMATETC *fmtetc, const STGMEDIUM *stgmed, int count)
{
- m_lRefCount = 1;
+ m_lRefCount = 1;
m_nNumFormats = count;
-
- m_pFormatEtc = new FORMATETC[count];
- m_pStgMedium = new STGMEDIUM[count];
- for(int i = 0; i < count; i++)
- {
+ m_pFormatEtc = new FORMATETC[count];
+ m_pStgMedium = new STGMEDIUM[count];
+
+ for (int i = 0; i < count; i++) {
m_pFormatEtc[i] = fmtetc[i];
m_pStgMedium[i] = stgmed[i];
}
@@ -84,13 +83,12 @@ CDataObject::CDataObject(const FORMATETC *fmtetc, const STGMEDIUM *stgmed, int c CDataObject::~CDataObject()
{
// cleanup
- for (int i = 0; i < m_nNumFormats; i++)
- {
-// ReleaseStgMedium(&m_pStgMedium[i]);
+ for (int i = 0; i < m_nNumFormats; i++) {
+ // ReleaseStgMedium(&m_pStgMedium[i]);
}
- if(m_pFormatEtc) delete[] m_pFormatEtc;
- if(m_pStgMedium) delete[] m_pStgMedium;
+ if (m_pFormatEtc) delete[] m_pFormatEtc;
+ if (m_pStgMedium) delete[] m_pStgMedium;
}
//
@@ -98,8 +96,8 @@ CDataObject::~CDataObject() //
ULONG __stdcall CDataObject::AddRef(void)
{
- // increment object reference count
- return InterlockedIncrement(&m_lRefCount);
+ // increment object reference count
+ return InterlockedIncrement(&m_lRefCount);
}
//
@@ -107,18 +105,15 @@ ULONG __stdcall CDataObject::AddRef(void) //
ULONG __stdcall CDataObject::Release(void)
{
- // decrement object reference count
+ // decrement object reference count
LONG count = InterlockedDecrement(&m_lRefCount);
-
- if(count == 0)
- {
+
+ if (count == 0) {
delete this;
return 0;
}
- else
- {
- return count;
- }
+
+ return count;
}
//
@@ -126,28 +121,23 @@ ULONG __stdcall CDataObject::Release(void) //
HRESULT __stdcall CDataObject::QueryInterface(REFIID iid, void **ppvObject)
{
- // check to see what interface has been requested
- if(iid == IID_IDataObject || iid == IID_IUnknown)
- {
- AddRef();
- *ppvObject = this;
- return S_OK;
- }
- else
- {
- *ppvObject = 0;
- return E_NOINTERFACE;
- }
+ // check to see what interface has been requested
+ if (iid == IID_IDataObject || iid == IID_IUnknown) {
+ AddRef();
+ *ppvObject = this;
+ return S_OK;
+ }
+
+ *ppvObject = 0;
+ return E_NOINTERFACE;
}
int CDataObject::LookupFormatEtc(FORMATETC *pFormatEtc)
{
- for (int i = 0; i < m_nNumFormats; i++)
- {
- if ((pFormatEtc->tymed & m_pFormatEtc[i].tymed) &&
- pFormatEtc->cfFormat == m_pFormatEtc[i].cfFormat &&
- pFormatEtc->dwAspect == m_pFormatEtc[i].dwAspect)
- {
+ for (int i = 0; i < m_nNumFormats; i++) {
+ if ((pFormatEtc->tymed & m_pFormatEtc[i].tymed) &&
+ pFormatEtc->cfFormat == m_pFormatEtc[i].cfFormat &&
+ pFormatEtc->dwAspect == m_pFormatEtc[i].dwAspect) {
return i;
}
}
@@ -158,35 +148,33 @@ int CDataObject::LookupFormatEtc(FORMATETC *pFormatEtc) //
// IDataObject::GetData
//
-HRESULT __stdcall CDataObject::GetData (FORMATETC *pFormatEtc, STGMEDIUM *pMedium)
+HRESULT __stdcall CDataObject::GetData(FORMATETC *pFormatEtc, STGMEDIUM *pMedium)
{
int idx;
//
// try to match the requested FORMATETC with one of our supported formats
//
- if ((idx = LookupFormatEtc(pFormatEtc)) == -1)
- {
+ if ((idx = LookupFormatEtc(pFormatEtc)) == -1) {
return DV_E_FORMATETC;
}
//
// found a match! transfer the data into the supplied storage-medium
//
- pMedium->tymed = m_pFormatEtc[idx].tymed;
- pMedium->pUnkForRelease = 0;
-
- switch (pMedium->tymed)
- {
- case TYMED_HGLOBAL:
- case TYMED_GDI:
- case TYMED_ENHMF:
-// pMedium->hBitmap = (HBITMAP)OleDuplicateData(m_pStgMedium[idx].hBitmap, pFormatEtc->cfFormat, 0);
- pMedium->hBitmap = m_pStgMedium[idx].hBitmap;
- break;
-
- default:
- return DV_E_FORMATETC;
+ pMedium->tymed = m_pFormatEtc[idx].tymed;
+ pMedium->pUnkForRelease = 0;
+
+ switch (pMedium->tymed) {
+ case TYMED_HGLOBAL:
+ case TYMED_GDI:
+ case TYMED_ENHMF:
+ // pMedium->hBitmap = (HBITMAP)OleDuplicateData(m_pStgMedium[idx].hBitmap, pFormatEtc->cfFormat, 0);
+ pMedium->hBitmap = m_pStgMedium[idx].hBitmap;
+ break;
+
+ default:
+ return DV_E_FORMATETC;
}
if (pMedium->hBitmap == NULL) return STG_E_MEDIUMFULL;
@@ -196,7 +184,7 @@ HRESULT __stdcall CDataObject::GetData (FORMATETC *pFormatEtc, STGMEDIUM *pMediu //
// IDataObject::GetDataHere
//
-HRESULT __stdcall CDataObject::GetDataHere (FORMATETC *pFormatEtc, STGMEDIUM *pMedium)
+HRESULT __stdcall CDataObject::GetDataHere(FORMATETC *pFormatEtc, STGMEDIUM *pMedium)
{
// GetDataHere is only required for IStream and IStorage mediums
// It is an error to call GetDataHere for things like HGLOBAL and other clipboard formats
@@ -211,7 +199,7 @@ HRESULT __stdcall CDataObject::GetDataHere (FORMATETC *pFormatEtc, STGMEDIUM *pM //
// Called to see if the IDataObject supports the specified format of data
//
-HRESULT __stdcall CDataObject::QueryGetData (FORMATETC *pFormatEtc)
+HRESULT __stdcall CDataObject::QueryGetData(FORMATETC *pFormatEtc)
{
return (LookupFormatEtc(pFormatEtc) == -1) ? DV_E_FORMATETC : S_OK;
}
@@ -219,7 +207,7 @@ HRESULT __stdcall CDataObject::QueryGetData (FORMATETC *pFormatEtc) //
// IDataObject::GetCanonicalFormatEtc
//
-HRESULT __stdcall CDataObject::GetCanonicalFormatEtc (FORMATETC *pFormatEct, FORMATETC *pFormatEtcOut)
+HRESULT __stdcall CDataObject::GetCanonicalFormatEtc(FORMATETC *pFormatEct, FORMATETC *pFormatEtcOut)
{
// Apparently we have to set this field to NULL even though we don't do anything else
pFormatEtcOut->ptd = NULL;
@@ -229,7 +217,7 @@ HRESULT __stdcall CDataObject::GetCanonicalFormatEtc (FORMATETC *pFormatEct, FOR //
// IDataObject::SetData
//
-HRESULT __stdcall CDataObject::SetData (FORMATETC *pFormatEtc, STGMEDIUM *pMedium, BOOL fRelease)
+HRESULT __stdcall CDataObject::SetData(FORMATETC *pFormatEtc, STGMEDIUM *pMedium, BOOL fRelease)
{
return E_NOTIMPL;
}
@@ -237,16 +225,14 @@ HRESULT __stdcall CDataObject::SetData (FORMATETC *pFormatEtc, STGMEDIUM *pMediu //
// IDataObject::EnumFormatEtc
//
-HRESULT __stdcall CDataObject::EnumFormatEtc (DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc)
+HRESULT __stdcall CDataObject::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc)
{
- if(dwDirection == DATADIR_GET)
- {
+ if (dwDirection == DATADIR_GET) {
// for Win2k+ you can use the SHCreateStdEnumFmtEtc API call, however
// to support all Windows platforms we need to implement IEnumFormatEtc ourselves.
return CreateEnumFormatEtc(m_nNumFormats, m_pFormatEtc, ppEnumFormatEtc);
}
- else
- {
+ else {
// the direction specified is not support for drag+drop
return E_NOTIMPL;
}
@@ -255,7 +241,7 @@ HRESULT __stdcall CDataObject::EnumFormatEtc (DWORD dwDirection, IEnumFORMATETC //
// IDataObject::DAdvise
//
-HRESULT __stdcall CDataObject::DAdvise (FORMATETC *pFormatEtc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
+HRESULT __stdcall CDataObject::DAdvise(FORMATETC *pFormatEtc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
{
return OLE_E_ADVISENOTSUPPORTED;
}
@@ -263,7 +249,7 @@ HRESULT __stdcall CDataObject::DAdvise (FORMATETC *pFormatEtc, DWORD advf, IAdvi //
// IDataObject::DUnadvise
//
-HRESULT __stdcall CDataObject::DUnadvise (DWORD dwConnection)
+HRESULT __stdcall CDataObject::DUnadvise(DWORD dwConnection)
{
return OLE_E_ADVISENOTSUPPORTED;
}
@@ -271,7 +257,7 @@ HRESULT __stdcall CDataObject::DUnadvise (DWORD dwConnection) //
// IDataObject::EnumDAdvise
//
-HRESULT __stdcall CDataObject::EnumDAdvise (IEnumSTATDATA **ppEnumAdvise)
+HRESULT __stdcall CDataObject::EnumDAdvise(IEnumSTATDATA **ppEnumAdvise)
{
return OLE_E_ADVISENOTSUPPORTED;
}
@@ -279,9 +265,9 @@ HRESULT __stdcall CDataObject::EnumDAdvise (IEnumSTATDATA **ppEnumAdvise) //
// Helper function
//
-HRESULT CreateDataObject (const FORMATETC *fmtetc, const STGMEDIUM *stgmeds, UINT count, IDataObject **ppDataObject)
+HRESULT CreateDataObject(const FORMATETC *fmtetc, const STGMEDIUM *stgmeds, UINT count, IDataObject **ppDataObject)
{
- if(ppDataObject == 0)
+ if (ppDataObject == 0)
return E_INVALIDARG;
*ppDataObject = new CDataObject(fmtetc, stgmeds, count);
|