aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/7zip/UI/FileManager/EnumFormatEtc.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp b/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
index 389aa3e..fc2fd6c 100644
--- a/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
+++ b/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
@@ -3,28 +3,27 @@
3#include "StdAfx.h" 3#include "StdAfx.h"
4 4
5#include "EnumFormatEtc.h" 5#include "EnumFormatEtc.h"
6#include "../../IDecl.h"
6#include "MyCom2.h" 7#include "MyCom2.h"
7 8
8class CEnumFormatEtc : 9class CEnumFormatEtc Z7_final:
9public IEnumFORMATETC, 10 public IEnumFORMATETC,
10public CMyUnknownImp 11 public CMyUnknownImp
11{ 12{
12public: 13 Z7_COM_UNKNOWN_IMP_1_MT(IEnumFORMATETC)
13 MY_UNKNOWN_IMP1_MT(IEnumFORMATETC)
14 14
15 STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched); 15 STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched) Z7_override;
16 STDMETHOD(Skip)(ULONG celt); 16 STDMETHOD(Skip)(ULONG celt) Z7_override;
17 STDMETHOD(Reset)(void); 17 STDMETHOD(Reset)(void) Z7_override;
18 STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc); 18 STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc) Z7_override;
19 19
20 CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats);
21 ~CEnumFormatEtc();
22
23private:
24 LONG m_RefCount; 20 LONG m_RefCount;
25 ULONG m_NumFormats; 21 ULONG m_NumFormats;
26 FORMATETC *m_Formats; 22 FORMATETC *m_Formats;
27 ULONG m_Index; 23 ULONG m_Index;
24public:
25 CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats);
26 ~CEnumFormatEtc();
28}; 27};
29 28
30static void DeepCopyFormatEtc(FORMATETC *dest, const FORMATETC *src) 29static void DeepCopyFormatEtc(FORMATETC *dest, const FORMATETC *src)
@@ -62,10 +61,10 @@ CEnumFormatEtc::~CEnumFormatEtc()
62 } 61 }
63} 62}
64 63
65STDMETHODIMP CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pceltFetched) 64Z7_COMWF_B CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pceltFetched)
66{ 65{
67 ULONG copied = 0; 66 ULONG copied = 0;
68 if (celt == 0 || pFormatEtc == 0) 67 if (celt == 0 || !pFormatEtc)
69 return E_INVALIDARG; 68 return E_INVALIDARG;
70 while (m_Index < m_NumFormats && copied < celt) 69 while (m_Index < m_NumFormats && copied < celt)
71 { 70 {
@@ -73,24 +72,24 @@ STDMETHODIMP CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pcel
73 copied++; 72 copied++;
74 m_Index++; 73 m_Index++;
75 } 74 }
76 if (pceltFetched != 0) 75 if (pceltFetched)
77 *pceltFetched = copied; 76 *pceltFetched = copied;
78 return (copied == celt) ? S_OK : S_FALSE; 77 return (copied == celt) ? S_OK : S_FALSE;
79} 78}
80 79
81STDMETHODIMP CEnumFormatEtc::Skip(ULONG celt) 80Z7_COMWF_B CEnumFormatEtc::Skip(ULONG celt)
82{ 81{
83 m_Index += celt; 82 m_Index += celt;
84 return (m_Index <= m_NumFormats) ? S_OK : S_FALSE; 83 return (m_Index <= m_NumFormats) ? S_OK : S_FALSE;
85} 84}
86 85
87STDMETHODIMP CEnumFormatEtc::Reset(void) 86Z7_COMWF_B CEnumFormatEtc::Reset(void)
88{ 87{
89 m_Index = 0; 88 m_Index = 0;
90 return S_OK; 89 return S_OK;
91} 90}
92 91
93STDMETHODIMP CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc) 92Z7_COMWF_B CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc)
94{ 93{
95 HRESULT hResult = CreateEnumFormatEtc(m_NumFormats, m_Formats, ppEnumFormatEtc); 94 HRESULT hResult = CreateEnumFormatEtc(m_NumFormats, m_Formats, ppEnumFormatEtc);
96 if (hResult == S_OK) 95 if (hResult == S_OK)
@@ -101,7 +100,7 @@ STDMETHODIMP CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc)
101// replacement for SHCreateStdEnumFmtEtc 100// replacement for SHCreateStdEnumFmtEtc
102HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat) 101HRESULT CreateEnumFormatEtc(UINT numFormats, const FORMATETC *formats, IEnumFORMATETC **enumFormat)
103{ 102{
104 if (numFormats == 0 || formats == 0 || enumFormat == 0) 103 if (numFormats == 0 || !formats || !enumFormat)
105 return E_INVALIDARG; 104 return E_INVALIDARG;
106 *enumFormat = new CEnumFormatEtc(formats, numFormats); 105 *enumFormat = new CEnumFormatEtc(formats, numFormats);
107 return (*enumFormat) ? S_OK : E_OUTOFMEMORY; 106 return (*enumFormat) ? S_OK : E_OUTOFMEMORY;