Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenfactory.c
Go to the documentation of this file.
00001 /* 00002 * MSXML Class Factory 00003 * 00004 * Copyright 2002 Lionel Ulmer 00005 * Copyright 2005 Mike McCormack 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00020 */ 00021 00022 #define COBJMACROS 00023 00024 #include "config.h" 00025 00026 #include <stdarg.h> 00027 #include "windef.h" 00028 #include "winbase.h" 00029 #include "winuser.h" 00030 #include "ole2.h" 00031 #include "msxml.h" 00032 #include "xmldom.h" 00033 #include "msxml2.h" 00034 00035 /* undef the #define in msxml2 so that we can access the v.2 version 00036 independent CLSID as well as the v.3 one. */ 00037 #undef CLSID_DOMDocument 00038 00039 #include "wine/debug.h" 00040 00041 #include "msxml_private.h" 00042 00043 WINE_DEFAULT_DEBUG_CHANNEL(msxml); 00044 00045 typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj); 00046 00047 /****************************************************************************** 00048 * MSXML ClassFactory 00049 */ 00050 typedef struct _xmlcf 00051 { 00052 const struct IClassFactoryVtbl *lpVtbl; 00053 fnCreateInstance pfnCreateInstance; 00054 } xmlcf; 00055 00056 static inline xmlcf *impl_from_IClassFactory( IClassFactory *iface ) 00057 { 00058 return (xmlcf *)((char*)iface - FIELD_OFFSET(xmlcf, lpVtbl)); 00059 } 00060 00061 static HRESULT WINAPI xmlcf_QueryInterface( 00062 IClassFactory *iface, 00063 REFIID riid, 00064 LPVOID *ppobj ) 00065 { 00066 if (IsEqualGUID(riid, &IID_IUnknown) || 00067 IsEqualGUID(riid, &IID_IClassFactory)) 00068 { 00069 IClassFactory_AddRef( iface ); 00070 *ppobj = iface; 00071 return S_OK; 00072 } 00073 00074 FIXME("interface %s not implemented\n", debugstr_guid(riid)); 00075 return E_NOINTERFACE; 00076 } 00077 00078 static ULONG WINAPI xmlcf_AddRef( 00079 IClassFactory *iface ) 00080 { 00081 return 2; 00082 } 00083 00084 static ULONG WINAPI xmlcf_Release( 00085 IClassFactory *iface ) 00086 { 00087 return 1; 00088 } 00089 00090 static HRESULT WINAPI xmlcf_CreateInstance( 00091 IClassFactory *iface, 00092 LPUNKNOWN pOuter, 00093 REFIID riid, 00094 LPVOID *ppobj ) 00095 { 00096 xmlcf *This = impl_from_IClassFactory( iface ); 00097 HRESULT r; 00098 IUnknown *punk; 00099 00100 TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj ); 00101 00102 *ppobj = NULL; 00103 00104 if (pOuter) 00105 return CLASS_E_NOAGGREGATION; 00106 00107 r = This->pfnCreateInstance( pOuter, (LPVOID*) &punk ); 00108 if (FAILED(r)) 00109 return r; 00110 00111 r = IUnknown_QueryInterface( punk, riid, ppobj ); 00112 IUnknown_Release( punk ); 00113 return r; 00114 } 00115 00116 static HRESULT WINAPI xmlcf_LockServer( 00117 IClassFactory *iface, 00118 BOOL dolock) 00119 { 00120 FIXME("(%p)->(%d),stub!\n",iface,dolock); 00121 return S_OK; 00122 } 00123 00124 static const struct IClassFactoryVtbl xmlcf_vtbl = 00125 { 00126 xmlcf_QueryInterface, 00127 xmlcf_AddRef, 00128 xmlcf_Release, 00129 xmlcf_CreateInstance, 00130 xmlcf_LockServer 00131 }; 00132 00133 static xmlcf domdoccf = { &xmlcf_vtbl, DOMDocument_create }; 00134 static xmlcf schemacf = { &xmlcf_vtbl, SchemaCache_create }; 00135 static xmlcf xmldoccf = { &xmlcf_vtbl, XMLDocument_create }; 00136 static xmlcf saxreadcf = { &xmlcf_vtbl, SAXXMLReader_create }; 00137 static xmlcf httpreqcf = { &xmlcf_vtbl, XMLHTTPRequest_create }; 00138 00139 /****************************************************************** 00140 * DllGetClassObject (MSXML3.@) 00141 */ 00142 HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv ) 00143 { 00144 IClassFactory *cf = NULL; 00145 00146 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv ); 00147 00148 if( IsEqualCLSID( rclsid, &CLSID_DOMDocument ) || /* Version indep. v 2.x */ 00149 IsEqualCLSID( rclsid, &CLSID_DOMDocument2 ) || /* Version indep. v 3.0 */ 00150 IsEqualCLSID( rclsid, &CLSID_DOMDocument30 )|| /* Version dep. v 3.0 */ 00151 IsEqualCLSID( rclsid, &CLSID_DOMDocument40 )) /* Version dep. v 4.0 */ 00152 { 00153 cf = (IClassFactory*) &domdoccf.lpVtbl; 00154 } 00155 else if( IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache ) || 00156 IsEqualCLSID( rclsid, &CLSID_XMLSchemaCache30 ) ) 00157 { 00158 cf = (IClassFactory*) &schemacf.lpVtbl; 00159 } 00160 else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) ) 00161 { 00162 cf = (IClassFactory*) &xmldoccf.lpVtbl; 00163 } 00164 else if( IsEqualCLSID( rclsid, &CLSID_DOMFreeThreadedDocument ) || /* Version indep. v 2.x */ 00165 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument ) || 00166 IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument30 )) 00167 { 00168 cf = (IClassFactory*) &domdoccf.lpVtbl; 00169 } 00170 else if( IsEqualCLSID( rclsid, &CLSID_SAXXMLReader) || 00171 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader30 ) || 00172 IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 )) 00173 { 00174 cf = (IClassFactory*) &saxreadcf.lpVtbl; 00175 } 00176 else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest)) 00177 { 00178 cf = (IClassFactory*) &httpreqcf.lpVtbl; 00179 } 00180 00181 if ( !cf ) 00182 return CLASS_E_CLASSNOTAVAILABLE; 00183 00184 return IClassFactory_QueryInterface( cf, iid, ppv ); 00185 } Generated on Sat May 26 2012 04:20:01 for ReactOS by
1.7.6.1
|