Don't change the UI level during ExecuteAction.
[wine] / dlls / msxml3 / factory.c
1 /*
2  *    MSXML Class Factory
3  *
4  * Copyright 2002 Lionel Ulmer
5  * Copyright 2005 Mike McCormack
6  *
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.
11  *
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.
16  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #define COBJMACROS
23
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "uuids.h"
30 #include "msxml.h"
31 #include "xmldom.h"
32
33 #include "wine/debug.h"
34
35 #include "msxml_private.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
38
39 typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
40
41 /******************************************************************************
42  * MSXML ClassFactory
43  */
44 typedef struct _xmlcf
45 {
46     const struct IClassFactoryVtbl *lpVtbl;
47     fnCreateInstance pfnCreateInstance;
48 } xmlcf;
49
50 static inline xmlcf *impl_from_IClassFactory( IClassFactory *iface )
51 {
52     return (xmlcf *)((char*)iface - FIELD_OFFSET(xmlcf, lpVtbl));
53 }
54
55 static HRESULT WINAPI xmlcf_QueryInterface(
56     IClassFactory *iface,
57     REFIID riid,
58     LPVOID *ppobj )
59 {
60     if (IsEqualGUID(riid, &IID_IUnknown) ||
61         IsEqualGUID(riid, &IID_IClassFactory))
62     {
63         IClassFactory_AddRef( iface );
64         *ppobj = iface;
65         return S_OK;
66     }
67
68     return E_NOINTERFACE;
69 }
70
71 static ULONG WINAPI xmlcf_AddRef(
72     IClassFactory *iface )
73 {
74     return 2;
75 }
76
77 static ULONG WINAPI xmlcf_Release(
78     IClassFactory *iface )
79 {
80     return 1;
81 }
82
83 static HRESULT WINAPI xmlcf_CreateInstance(
84     IClassFactory *iface,
85     LPUNKNOWN pOuter,
86     REFIID riid,
87     LPVOID *ppobj )
88 {
89     xmlcf *This = impl_from_IClassFactory( iface );
90     HRESULT r;
91     IUnknown *punk;
92     
93     TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj );
94
95     *ppobj = NULL;
96
97     if (pOuter)
98         return CLASS_E_NOAGGREGATION;
99
100     r = This->pfnCreateInstance( pOuter, (LPVOID*) &punk );
101     if (FAILED(r))
102         return r;
103
104     r = IUnknown_QueryInterface( punk, riid, ppobj );
105     if (FAILED(r))
106         return r;
107     IUnknown_Release( punk );
108     return r;
109 }
110
111 static HRESULT WINAPI xmlcf_LockServer(
112     IClassFactory *iface,
113     BOOL dolock)
114 {
115     FIXME("(%p)->(%d),stub!\n",iface,dolock);
116     return S_OK;
117 }
118
119 const struct IClassFactoryVtbl xmlcf_vtbl =
120 {
121     xmlcf_QueryInterface,
122     xmlcf_AddRef,
123     xmlcf_Release,
124     xmlcf_CreateInstance,
125     xmlcf_LockServer
126 };
127
128 static xmlcf domdoccf = { &xmlcf_vtbl, DOMDocument_create };
129
130 /******************************************************************
131  *              DllGetClassObject (MSXML3.@)
132  */
133 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
134 {
135     IClassFactory *cf = NULL;
136
137     TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv );
138
139     if( IsEqualGUID( rclsid, &CLSID_DOMDocument ) )
140         cf = (IClassFactory*) &domdoccf.lpVtbl;
141
142     if ( !cf )
143         return CLASS_E_CLASSNOTAVAILABLE;
144
145     return IClassFactory_QueryInterface( cf, iid, ppv );
146 }