diff options
author | George Hazan <george.hazan@gmail.com> | 2014-12-01 12:56:22 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-12-01 12:56:22 +0000 |
commit | 70e0c09fcffa5520d3cfdc4708c81248b135c796 (patch) | |
tree | 6d000d835ddf3c890d1d23a7f946fd62111f8497 /plugins/mTextControl/src/enumformat.cpp | |
parent | 4a58d85d8dd5f120eb0d0c429e0b46cdeb25c629 (diff) |
- more warning fixes;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@11191 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/mTextControl/src/enumformat.cpp')
-rw-r--r-- | plugins/mTextControl/src/enumformat.cpp | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/plugins/mTextControl/src/enumformat.cpp b/plugins/mTextControl/src/enumformat.cpp index 7daac154d7..9aa3895e05 100644 --- a/plugins/mTextControl/src/enumformat.cpp +++ b/plugins/mTextControl/src/enumformat.cpp @@ -21,7 +21,6 @@ class CEnumFormatEtc : public IEnumFORMATETC
{
public:
-
//
// IUnknown members
//
@@ -56,7 +55,7 @@ private: //
HRESULT CreateEnumFormatEtc(UINT nNumFormats, FORMATETC *pFormatEtc, IEnumFORMATETC **ppEnumFormatEtc)
{
- if(nNumFormats == 0 || pFormatEtc == 0 || ppEnumFormatEtc == 0)
+ if (nNumFormats == 0 || pFormatEtc == 0 || ppEnumFormatEtc == 0)
return E_INVALIDARG;
*ppEnumFormatEtc = new CEnumFormatEtc(pFormatEtc, nNumFormats);
@@ -71,9 +70,8 @@ static void DeepCopyFormatEtc(FORMATETC *dest, FORMATETC *source) {
// copy the source FORMATETC into dest
*dest = *source;
-
- if(source->ptd)
- {
+
+ if (source->ptd) {
// allocate memory for the DVTARGETDEVICE if necessary
dest->ptd = (DVTARGETDEVICE*)CoTaskMemAlloc(sizeof(DVTARGETDEVICE));
@@ -87,14 +85,13 @@ static void DeepCopyFormatEtc(FORMATETC *dest, FORMATETC *source) //
CEnumFormatEtc::CEnumFormatEtc(FORMATETC *pFormatEtc, int nNumFormats)
{
- m_lRefCount = 1;
- m_nIndex = 0;
+ m_lRefCount = 1;
+ m_nIndex = 0;
m_nNumFormats = nNumFormats;
- m_pFormatEtc = new FORMATETC[nNumFormats];
-
+ m_pFormatEtc = new FORMATETC[nNumFormats];
+
// copy the FORMATETC structures
- for(int i = 0; i < nNumFormats; i++)
- {
+ for (int i = 0; i < nNumFormats; i++) {
DeepCopyFormatEtc(&m_pFormatEtc[i], &pFormatEtc[i]);
}
}
@@ -104,11 +101,9 @@ CEnumFormatEtc::CEnumFormatEtc(FORMATETC *pFormatEtc, int nNumFormats) //
CEnumFormatEtc::~CEnumFormatEtc()
{
- if(m_pFormatEtc)
- {
- for(ULONG i = 0; i < m_nNumFormats; i++)
- {
- if(m_pFormatEtc[i].ptd)
+ if (m_pFormatEtc) {
+ for (ULONG i = 0; i < m_nNumFormats; i++) {
+ if (m_pFormatEtc[i].ptd)
CoTaskMemFree(m_pFormatEtc[i].ptd);
}
@@ -121,8 +116,8 @@ CEnumFormatEtc::~CEnumFormatEtc() //
ULONG __stdcall CEnumFormatEtc::AddRef(void)
{
- // increment object reference count
- return InterlockedIncrement(&m_lRefCount);
+ // increment object reference count
+ return InterlockedIncrement(&m_lRefCount);
}
//
@@ -130,16 +125,14 @@ ULONG __stdcall CEnumFormatEtc::AddRef(void) //
ULONG __stdcall CEnumFormatEtc::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
- {
+ else {
return count;
}
}
@@ -149,18 +142,16 @@ ULONG __stdcall CEnumFormatEtc::Release(void) //
HRESULT __stdcall CEnumFormatEtc::QueryInterface(REFIID iid, void **ppvObject)
{
- // check to see what interface has been requested
- if(iid == IID_IEnumFORMATETC || 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_IEnumFORMATETC || iid == IID_IUnknown) {
+ AddRef();
+ *ppvObject = this;
+ return S_OK;
+ }
+ else {
+ *ppvObject = 0;
+ return E_NOINTERFACE;
+ }
}
//
@@ -171,22 +162,21 @@ HRESULT __stdcall CEnumFormatEtc::QueryInterface(REFIID iid, void **ppvObject) //
HRESULT __stdcall CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG * pceltFetched)
{
- ULONG copied = 0;
+ ULONG copied = 0;
// validate arguments
- if(celt == 0 || pFormatEtc == 0)
+ if (celt == 0 || pFormatEtc == 0)
return E_INVALIDARG;
// copy FORMATETC structures into caller's buffer
- while(m_nIndex < m_nNumFormats && copied < celt)
- {
+ while (m_nIndex < m_nNumFormats && copied < celt) {
DeepCopyFormatEtc(&pFormatEtc[copied], &m_pFormatEtc[m_nIndex]);
copied++;
m_nIndex++;
}
// store result
- if(pceltFetched != 0)
+ if (pceltFetched != 0)
*pceltFetched = copied;
// did we copy all that was requested?
@@ -221,12 +211,10 @@ HRESULT __stdcall CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc) // make a duplicate enumerator
hResult = CreateEnumFormatEtc(m_nNumFormats, m_pFormatEtc, ppEnumFormatEtc);
- if(hResult == S_OK)
- {
+ if (hResult == S_OK) {
// manually set the index state
- ((CEnumFormatEtc *) *ppEnumFormatEtc)->m_nIndex = m_nIndex;
+ ((CEnumFormatEtc *)*ppEnumFormatEtc)->m_nIndex = m_nIndex;
}
return hResult;
}
-
|