wined3d: Move storing the render target from ActiveRender to SetRenderTarget.
[wine/testsucceed.git] / dlls / msxml3 / factory.c
blob53d59d1057bca754f6c6fcb867470d9b5dc58f55
1 /*
2 * MSXML Class Factory
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2005 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define COBJMACROS
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "msxml.h"
30 #include "xmldom.h"
31 #include "msxml2.h"
33 /* undef the #define in msxml2 so that we can access the v.2 version
34 independent CLSID as well as the v.3 one. */
35 #undef CLSID_DOMDocument
37 #include "wine/debug.h"
39 #include "msxml_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
43 typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
45 /******************************************************************************
46 * MSXML ClassFactory
48 typedef struct _xmlcf
50 const struct IClassFactoryVtbl *lpVtbl;
51 fnCreateInstance pfnCreateInstance;
52 } xmlcf;
54 static inline xmlcf *impl_from_IClassFactory( IClassFactory *iface )
56 return (xmlcf *)((char*)iface - FIELD_OFFSET(xmlcf, lpVtbl));
59 static HRESULT WINAPI xmlcf_QueryInterface(
60 IClassFactory *iface,
61 REFIID riid,
62 LPVOID *ppobj )
64 if (IsEqualGUID(riid, &IID_IUnknown) ||
65 IsEqualGUID(riid, &IID_IClassFactory))
67 IClassFactory_AddRef( iface );
68 *ppobj = iface;
69 return S_OK;
72 FIXME("interface %s not implemented\n", debugstr_guid(riid));
73 return E_NOINTERFACE;
76 static ULONG WINAPI xmlcf_AddRef(
77 IClassFactory *iface )
79 return 2;
82 static ULONG WINAPI xmlcf_Release(
83 IClassFactory *iface )
85 return 1;
88 static HRESULT WINAPI xmlcf_CreateInstance(
89 IClassFactory *iface,
90 LPUNKNOWN pOuter,
91 REFIID riid,
92 LPVOID *ppobj )
94 xmlcf *This = impl_from_IClassFactory( iface );
95 HRESULT r;
96 IUnknown *punk;
98 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
100 *ppobj = NULL;
102 if (pOuter)
103 return CLASS_E_NOAGGREGATION;
105 r = This->pfnCreateInstance( pOuter, (LPVOID*) &punk );
106 if (FAILED(r))
107 return r;
109 r = IUnknown_QueryInterface( punk, riid, ppobj );
110 if (FAILED(r))
111 return r;
112 IUnknown_Release( punk );
113 return r;
116 static HRESULT WINAPI xmlcf_LockServer(
117 IClassFactory *iface,
118 BOOL dolock)
120 FIXME("(%p)->(%d),stub!\n",iface,dolock);
121 return S_OK;
124 static const struct IClassFactoryVtbl xmlcf_vtbl =
126 xmlcf_QueryInterface,
127 xmlcf_AddRef,
128 xmlcf_Release,
129 xmlcf_CreateInstance,
130 xmlcf_LockServer
133 static xmlcf domdoccf = { &xmlcf_vtbl, DOMDocument_create };
135 /******************************************************************
136 * DllGetClassObject (MSXML3.@)
138 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
140 IClassFactory *cf = NULL;
142 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
144 if( IsEqualGUID( rclsid, &CLSID_DOMDocument ) || /* Version indep. v 2.x */
145 IsEqualGUID( rclsid, &CLSID_DOMDocument2 ) || /* Version indep. v 3.0 */
146 IsEqualGUID( rclsid, &CLSID_DOMDocument30 ) ) /* Version dep. v 3.0 */
147 cf = (IClassFactory*) &domdoccf.lpVtbl;
149 if ( !cf )
150 return CLASS_E_CLASSNOTAVAILABLE;
152 return IClassFactory_QueryInterface( cf, iid, ppv );