Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QOleEnumFmtEtc Class Reference

#include <qdnd_p.h>

Inheritance diagram for QOleEnumFmtEtc:

Public Functions

STDMETHOD() Clone (LPENUMFORMATETC FAR *newEnum)
 
bool isNull () const
 
STDMETHOD() Next (ULONG celt, LPFORMATETC rgelt, ULONG FAR *pceltFetched)
 
 QOleEnumFmtEtc (const QVector< FORMATETC > &fmtetcs)
 
 QOleEnumFmtEtc (const QVector< LPFORMATETC > &lpfmtetcs)
 
STDMETHOD() QueryInterface (REFIID riid, void FAR *FAR *ppvObj)
 
STDMETHOD() Reset (void)
 
STDMETHOD() Skip (ULONG celt)
 
 STDMETHOD_ (ULONG, AddRef)(void)
 
 STDMETHOD_ (ULONG, Release)(void)
 
virtual ~QOleEnumFmtEtc ()
 

Private Functions

bool copyFormatEtc (LPFORMATETC dest, LPFORMATETC src) const
 

Properties

ULONG m_dwRefs
 
bool m_isNull
 
QVector< LPFORMATETC > m_lpfmtetcs
 
ULONG m_nIndex
 

Detailed Description

Definition at line 139 of file qdnd_p.h.

Constructors and Destructors

◆ QOleEnumFmtEtc() [1/2]

QOleEnumFmtEtc::QOleEnumFmtEtc ( const QVector< FORMATETC > &  fmtetcs)
explicit

Definition at line 53 of file qole_win.cpp.

Referenced by Clone().

54 {
55  m_isNull = false;
56  m_dwRefs = 1;
57  m_nIndex = 0;
58 
59  for (int idx = 0; idx < fmtetcs.count(); ++idx) {
60  LPFORMATETC destetc = new FORMATETC();
61  if (copyFormatEtc(destetc, (LPFORMATETC)&(fmtetcs.at(idx)))) {
62  m_lpfmtetcs.append(destetc);
63  } else {
64  m_isNull = true;
65  delete destetc;
66  break;
67  }
68  }
69 }
ULONG m_nIndex
Definition: qdnd_p.h:163
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const
Definition: qole_win.cpp:227
bool m_isNull
Definition: qdnd_p.h:165
struct tagFORMATETC FORMATETC
Definition: qmime.h:66
QVector< LPFORMATETC > m_lpfmtetcs
Definition: qdnd_p.h:164
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
ULONG m_dwRefs
Definition: qdnd_p.h:162

◆ QOleEnumFmtEtc() [2/2]

QOleEnumFmtEtc::QOleEnumFmtEtc ( const QVector< LPFORMATETC > &  lpfmtetcs)
explicit

Definition at line 71 of file qole_win.cpp.

72 {
73  m_isNull = false;
74  m_dwRefs = 1;
75  m_nIndex = 0;
76 
77  for (int idx = 0; idx < lpfmtetcs.count(); ++idx) {
78  LPFORMATETC srcetc = lpfmtetcs.at(idx);
79  LPFORMATETC destetc = new FORMATETC();
80  if (copyFormatEtc(destetc, srcetc)) {
81  m_lpfmtetcs.append(destetc);
82  } else {
83  m_isNull = true;
84  delete destetc;
85  break;
86  }
87  }
88 }
ULONG m_nIndex
Definition: qdnd_p.h:163
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const
Definition: qole_win.cpp:227
bool m_isNull
Definition: qdnd_p.h:165
struct tagFORMATETC FORMATETC
Definition: qmime.h:66
QVector< LPFORMATETC > m_lpfmtetcs
Definition: qdnd_p.h:164
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
ULONG m_dwRefs
Definition: qdnd_p.h:162

◆ ~QOleEnumFmtEtc()

QOleEnumFmtEtc::~QOleEnumFmtEtc ( )
virtual

Definition at line 90 of file qole_win.cpp.

91 {
92  LPMALLOC pmalloc;
93 
94 #if !defined(Q_OS_WINCE)
95  if (CoGetMalloc(MEMCTX_TASK, &pmalloc) == NOERROR) {
96 #else
97  if (SHGetMalloc(&pmalloc) == NOERROR) {
98 #endif
99  for (int idx = 0; idx < m_lpfmtetcs.count(); ++idx) {
100  LPFORMATETC tmpetc = m_lpfmtetcs.at(idx);
101  if (tmpetc->ptd)
102  pmalloc->Free(tmpetc->ptd);
103  delete tmpetc;
104  }
105 
106  pmalloc->Release();
107  }
108  m_lpfmtetcs.clear();
109 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QVector< LPFORMATETC > m_lpfmtetcs
Definition: qdnd_p.h:164
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350

Functions

◆ Clone()

STDMETHODIMP QOleEnumFmtEtc::Clone ( LPENUMFORMATETC FAR *  newEnum)

Definition at line 209 of file qole_win.cpp.

210 {
211  if (newEnum == NULL)
212  return ResultFromScode(E_INVALIDARG);
213 
215  result->m_nIndex = m_nIndex;
216 
217  if (result->isNull()) {
218  delete result;
219  return ResultFromScode(E_OUTOFMEMORY);
220  } else {
221  *newEnum = result;
222  }
223 
224  return NOERROR;
225 }
ULONG m_nIndex
Definition: qdnd_p.h:163
QOleEnumFmtEtc(const QVector< FORMATETC > &fmtetcs)
Definition: qole_win.cpp:53
bool isNull() const
Definition: qole_win.cpp:111
QVector< LPFORMATETC > m_lpfmtetcs
Definition: qdnd_p.h:164

◆ copyFormatEtc()

bool QOleEnumFmtEtc::copyFormatEtc ( LPFORMATETC  dest,
LPFORMATETC  src 
) const
private

Definition at line 227 of file qole_win.cpp.

Referenced by Next(), and QOleEnumFmtEtc().

228 {
229  if (dest == NULL || src == NULL)
230  return false;
231 
232  *dest = *src;
233 
234  if (src->ptd) {
235  LPMALLOC pmalloc;
236 
237 #if !defined(Q_OS_WINCE)
238  if (CoGetMalloc(MEMCTX_TASK, &pmalloc) != NOERROR)
239 #else
240  if (SHGetMalloc(&pmalloc) != NOERROR)
241 #endif
242  return false;
243 
244  pmalloc->Alloc(src->ptd->tdSize);
245  memcpy(dest->ptd, src->ptd, size_t(src->ptd->tdSize));
246 
247  pmalloc->Release();
248  }
249 
250  return true;
251 }

◆ isNull()

bool QOleEnumFmtEtc::isNull ( ) const

Definition at line 111 of file qole_win.cpp.

Referenced by Clone(), and QOleDataObject::EnumFormatEtc().

112 {
113  return m_isNull;
114 }
bool m_isNull
Definition: qdnd_p.h:165

◆ Next()

STDMETHODIMP QOleEnumFmtEtc::Next ( ULONG  celt,
LPFORMATETC  rgelt,
ULONG FAR *  pceltFetched 
)

Definition at line 147 of file qole_win.cpp.

148 {
149  ULONG i=0;
150  ULONG nOffset;
151 
152  if (rgelt == NULL)
153  return ResultFromScode(E_INVALIDARG);
154 
155  while (i < celt) {
156  nOffset = m_nIndex + i;
157 
158  if (nOffset < ULONG(m_lpfmtetcs.count())) {
159  copyFormatEtc((LPFORMATETC)&(rgelt[i]), m_lpfmtetcs.at(nOffset));
160  i++;
161  } else {
162  break;
163  }
164  }
165 
166  m_nIndex += (WORD)i;
167 
168  if (pceltFetched != NULL)
169  *pceltFetched = i;
170 
171  if (i != celt)
172  return ResultFromScode(S_FALSE);
173 
174  return NOERROR;
175 }
ULONG m_nIndex
Definition: qdnd_p.h:163
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const
Definition: qole_win.cpp:227
QVector< LPFORMATETC > m_lpfmtetcs
Definition: qdnd_p.h:164
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350

◆ QueryInterface()

STDMETHODIMP QOleEnumFmtEtc::QueryInterface ( REFIID  riid,
void FAR *FAR *  ppvObj 
)

Definition at line 118 of file qole_win.cpp.

119 {
120  if (riid == IID_IUnknown || riid == IID_IEnumFORMATETC) {
121  *ppvObj = this;
122  AddRef();
123  return NOERROR;
124  }
125  *ppvObj = NULL;
126  return ResultFromScode(E_NOINTERFACE);
127 }

◆ Reset()

STDMETHODIMP QOleEnumFmtEtc::Reset ( void  )

Definition at line 202 of file qole_win.cpp.

203 {
204  m_nIndex = 0;
205  return NOERROR;
206 }
ULONG m_nIndex
Definition: qdnd_p.h:163

◆ Skip()

STDMETHODIMP QOleEnumFmtEtc::Skip ( ULONG  celt)

Definition at line 178 of file qole_win.cpp.

179 {
180  ULONG i=0;
181  ULONG nOffset;
182 
183  while (i < celt) {
184  nOffset = m_nIndex + i;
185 
186  if (nOffset < ULONG(m_lpfmtetcs.count())) {
187  i++;
188  } else {
189  break;
190  }
191  }
192 
193  m_nIndex += (WORD)i;
194 
195  if (i != celt)
196  return ResultFromScode(S_FALSE);
197 
198  return NOERROR;
199 }
ULONG m_nIndex
Definition: qdnd_p.h:163
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QVector< LPFORMATETC > m_lpfmtetcs
Definition: qdnd_p.h:164

◆ STDMETHOD_() [1/2]

QOleEnumFmtEtc::STDMETHOD_ ( ULONG  ,
AddRef   
)

◆ STDMETHOD_() [2/2]

QOleEnumFmtEtc::STDMETHOD_ ( ULONG  ,
Release   
)

Properties

◆ m_dwRefs

ULONG QOleEnumFmtEtc::m_dwRefs
private

Definition at line 162 of file qdnd_p.h.

Referenced by QOleEnumFmtEtc(), and QueryInterface().

◆ m_isNull

bool QOleEnumFmtEtc::m_isNull
private

Definition at line 165 of file qdnd_p.h.

Referenced by isNull(), and QOleEnumFmtEtc().

◆ m_lpfmtetcs

QVector<LPFORMATETC> QOleEnumFmtEtc::m_lpfmtetcs
private

Definition at line 164 of file qdnd_p.h.

Referenced by Clone(), Next(), QOleEnumFmtEtc(), Skip(), and ~QOleEnumFmtEtc().

◆ m_nIndex

ULONG QOleEnumFmtEtc::m_nIndex
private

Definition at line 163 of file qdnd_p.h.

Referenced by Clone(), Next(), QOleEnumFmtEtc(), Reset(), and Skip().


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