update dev300-m58
[ooovba.git] / xmerge / source / activesync / XMergeFactory.cpp
blobf61d2401a257724ef4c7ad01e7cca2d120ff6c2c
1 // XMergeFactory.cpp: implementation of the CXMergeFactory class.
2 //
3 //////////////////////////////////////////////////////////////////////
5 #include "stdafx.h"
7 #include "XMergeFilter.h"
8 #include "XMergeFactory.h"
10 //////////////////////////////////////////////////////////////////////
11 // IUnknown implementation
12 //////////////////////////////////////////////////////////////////////
13 STDMETHODIMP CXMergeFactory::QueryInterface(REFIID riid, void **ppvObject)
15 if(ppvObject == NULL)
16 return E_INVALIDARG;
18 if(::IsEqualIID(riid, IID_IUnknown) || ::IsEqualIID(riid, IID_IClassFactory))
20 *ppvObject = static_cast<IClassFactory*>(this);
22 else
24 *ppvObject = NULL;
25 return E_NOINTERFACE;
28 reinterpret_cast<IUnknown*>(*ppvObject)->AddRef();
29 return S_OK;
33 STDMETHODIMP_(ULONG) CXMergeFactory::AddRef()
35 return ::InterlockedIncrement(&m_cRef);
39 STDMETHODIMP_(ULONG) CXMergeFactory::Release()
41 if(::InterlockedDecrement(&m_cRef) == 0)
43 delete this;
44 return 0;
47 return m_cRef;
51 //////////////////////////////////////////////////////////////////////
52 // IUnknown implementation
53 //////////////////////////////////////////////////////////////////////
54 STDMETHODIMP CXMergeFactory::CreateInstance(IUnknown *pUnkOuter, REFIID iid, void **ppvObject)
56 if (ppvObject == NULL)
57 return E_INVALIDARG;
59 if (pUnkOuter != NULL) // cannot aggregate
61 *ppvObject = NULL;
62 return CLASS_E_NOAGGREGATION;
65 if (iid == IID_ICeFileFilter)
67 CXMergeFilter *pFilter = new CXMergeFilter();
68 if(pFilter == NULL)
70 *ppvObject = NULL;
71 return E_OUTOFMEMORY;
74 HRESULT hr = pFilter->QueryInterface(iid, ppvObject);
75 pFilter->Release();
77 return hr;
80 return E_INVALIDARG;
84 STDMETHODIMP CXMergeFactory::LockServer(BOOL fLock)
86 _Module.LockServer(fLock);
87 return S_OK;