1 /* 2 * ParseError implementation 3 * 4 * Copyright 2005 Huw Davies 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 */ 20 21 #include "precomp.h" 22 23 typedef struct 24 { 25 DispatchEx dispex; 26 IXMLDOMParseError2 IXMLDOMParseError2_iface; 27 LONG ref; 28 LONG code, line, linepos, filepos; 29 BSTR url, reason, srcText; 30 } parse_error_t; 31 32 static inline parse_error_t *impl_from_IXMLDOMParseError2( IXMLDOMParseError2 *iface ) 33 { 34 return CONTAINING_RECORD(iface, parse_error_t, IXMLDOMParseError2_iface); 35 } 36 37 static HRESULT WINAPI parseError_QueryInterface( 38 IXMLDOMParseError2 *iface, 39 REFIID riid, 40 void** ppvObject ) 41 { 42 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 43 44 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); 45 46 if ( IsEqualGUID( riid, &IID_IUnknown ) || 47 IsEqualGUID( riid, &IID_IDispatch ) || 48 IsEqualGUID( riid, &IID_IXMLDOMParseError ) || 49 IsEqualGUID( riid, &IID_IXMLDOMParseError2 ) ) 50 { 51 *ppvObject = iface; 52 } 53 else if (dispex_query_interface(&This->dispex, riid, ppvObject)) 54 { 55 return *ppvObject ? S_OK : E_NOINTERFACE; 56 } 57 else 58 { 59 FIXME("interface %s not implemented\n", debugstr_guid(riid)); 60 *ppvObject = NULL; 61 return E_NOINTERFACE; 62 } 63 64 IXMLDOMParseError2_AddRef( iface ); 65 66 return S_OK; 67 } 68 69 static ULONG WINAPI parseError_AddRef( 70 IXMLDOMParseError2 *iface ) 71 { 72 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 73 ULONG ref = InterlockedIncrement( &This->ref ); 74 TRACE("(%p)->(%d)\n", This, ref); 75 return ref; 76 } 77 78 static ULONG WINAPI parseError_Release( 79 IXMLDOMParseError2 *iface ) 80 { 81 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 82 ULONG ref = InterlockedDecrement( &This->ref ); 83 84 TRACE("(%p)->(%d)\n", This, ref); 85 if ( ref == 0 ) 86 { 87 SysFreeString(This->url); 88 SysFreeString(This->reason); 89 SysFreeString(This->srcText); 90 heap_free( This ); 91 } 92 93 return ref; 94 } 95 96 static HRESULT WINAPI parseError_GetTypeInfoCount( 97 IXMLDOMParseError2 *iface, 98 UINT* pctinfo ) 99 { 100 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 101 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo); 102 } 103 104 static HRESULT WINAPI parseError_GetTypeInfo( 105 IXMLDOMParseError2 *iface, 106 UINT iTInfo, 107 LCID lcid, 108 ITypeInfo** ppTInfo ) 109 { 110 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 111 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, 112 iTInfo, lcid, ppTInfo); 113 } 114 115 static HRESULT WINAPI parseError_GetIDsOfNames( 116 IXMLDOMParseError2 *iface, 117 REFIID riid, 118 LPOLESTR* rgszNames, 119 UINT cNames, 120 LCID lcid, 121 DISPID* rgDispId ) 122 { 123 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 124 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, 125 riid, rgszNames, cNames, lcid, rgDispId); 126 } 127 128 static HRESULT WINAPI parseError_Invoke( 129 IXMLDOMParseError2 *iface, 130 DISPID dispIdMember, 131 REFIID riid, 132 LCID lcid, 133 WORD wFlags, 134 DISPPARAMS* pDispParams, 135 VARIANT* pVarResult, 136 EXCEPINFO* pExcepInfo, 137 UINT* puArgErr ) 138 { 139 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 140 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, 141 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); 142 } 143 144 static HRESULT WINAPI parseError_get_errorCode( 145 IXMLDOMParseError2 *iface, 146 LONG *code ) 147 { 148 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 149 TRACE("(%p)->(%p)\n", This, code); 150 151 *code = This->code; 152 153 if(This->code == 0) 154 return S_FALSE; 155 156 return S_OK; 157 } 158 159 static HRESULT WINAPI parseError_get_url( 160 IXMLDOMParseError2 *iface, 161 BSTR *url ) 162 { 163 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 164 FIXME("(%p)->(%p)\n", This, url); 165 return E_NOTIMPL; 166 } 167 168 static HRESULT WINAPI parseError_get_reason( 169 IXMLDOMParseError2 *iface, 170 BSTR *reason ) 171 { 172 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 173 TRACE("(%p)->(%p)\n", This, reason); 174 175 if(!This->reason) 176 { 177 *reason = NULL; 178 return S_FALSE; 179 } 180 *reason = SysAllocString(This->reason); 181 return S_OK; 182 } 183 184 static HRESULT WINAPI parseError_get_srcText( 185 IXMLDOMParseError2 *iface, 186 BSTR *srcText ) 187 { 188 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 189 190 TRACE("(%p)->(%p)\n", This, srcText); 191 192 if (!srcText) return E_INVALIDARG; 193 194 *srcText = SysAllocString(This->srcText); 195 196 return S_OK; 197 } 198 199 static HRESULT WINAPI parseError_get_line( 200 IXMLDOMParseError2 *iface, 201 LONG *line ) 202 { 203 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 204 205 TRACE("(%p)->(%p): stub\n", This, line); 206 207 if (!line) return E_INVALIDARG; 208 209 *line = This->line; 210 return S_OK; 211 } 212 213 static HRESULT WINAPI parseError_get_linepos( 214 IXMLDOMParseError2 *iface, 215 LONG *linepos ) 216 { 217 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 218 219 TRACE("(%p)->(%p)\n", This, linepos); 220 221 if (!linepos) return E_INVALIDARG; 222 223 *linepos = This->linepos; 224 return S_OK; 225 } 226 227 static HRESULT WINAPI parseError_get_filepos( 228 IXMLDOMParseError2 *iface, 229 LONG *filepos ) 230 { 231 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 232 FIXME("(%p)->(%p)\n", This, filepos); 233 return E_NOTIMPL; 234 } 235 236 static HRESULT WINAPI parseError_get_errorXPath( 237 IXMLDOMParseError2 *iface, 238 BSTR *xpathexpr) 239 { 240 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 241 FIXME("(%p)->(%p)\n", This, xpathexpr); 242 return E_NOTIMPL; 243 } 244 245 static HRESULT WINAPI parseError_get_AllErrors( 246 IXMLDOMParseError2 *iface, 247 IXMLDOMParseErrorCollection **allErrors) 248 { 249 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 250 FIXME("(%p)->(%p)\n", This, allErrors); 251 return E_NOTIMPL; 252 } 253 254 static HRESULT WINAPI parseError_errorParameters( 255 IXMLDOMParseError2 *iface, 256 LONG index, 257 BSTR *param) 258 { 259 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 260 FIXME("(%p)->(%p)\n", This, param); 261 return E_NOTIMPL; 262 } 263 264 static HRESULT WINAPI parseError_get_errorParametersCount( 265 IXMLDOMParseError2 *iface, 266 LONG *count) 267 { 268 parse_error_t *This = impl_from_IXMLDOMParseError2( iface ); 269 FIXME("(%p)->(%p)\n", This, count); 270 return E_NOTIMPL; 271 } 272 273 static const struct IXMLDOMParseError2Vtbl XMLDOMParseError2Vtbl = 274 { 275 parseError_QueryInterface, 276 parseError_AddRef, 277 parseError_Release, 278 parseError_GetTypeInfoCount, 279 parseError_GetTypeInfo, 280 parseError_GetIDsOfNames, 281 parseError_Invoke, 282 parseError_get_errorCode, 283 parseError_get_url, 284 parseError_get_reason, 285 parseError_get_srcText, 286 parseError_get_line, 287 parseError_get_linepos, 288 parseError_get_filepos, 289 parseError_get_errorXPath, 290 parseError_get_AllErrors, 291 parseError_errorParameters, 292 parseError_get_errorParametersCount 293 }; 294 295 static const tid_t parseError_iface_tids[] = { 296 IXMLDOMParseError2_tid, 297 0 298 }; 299 300 static dispex_static_data_t parseError_dispex = { 301 NULL, 302 IXMLDOMParseError2_tid, 303 NULL, 304 parseError_iface_tids 305 }; 306 307 IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText, 308 LONG line, LONG linepos, LONG filepos ) 309 { 310 parse_error_t *This; 311 312 This = heap_alloc( sizeof(*This) ); 313 if ( !This ) 314 return NULL; 315 316 This->IXMLDOMParseError2_iface.lpVtbl = &XMLDOMParseError2Vtbl; 317 This->ref = 1; 318 319 This->code = code; 320 This->url = url; 321 This->reason = reason; 322 This->srcText = srcText; 323 This->line = line; 324 This->linepos = linepos; 325 This->filepos = filepos; 326 327 init_dispex(&This->dispex, (IUnknown*)&This->IXMLDOMParseError2_iface, &parseError_dispex); 328 329 return (IXMLDOMParseError*)&This->IXMLDOMParseError2_iface; 330 } 331