msxml3: Implement IXMLDOMImplementation Interface.

This commit is contained in:
Alistair Leslie-Hughes 2008-01-18 20:33:03 +11:00 committed by Alexandre Julliard
parent 8c3dd87fa8
commit ed5a22fb29
5 changed files with 252 additions and 2 deletions

View file

@ -13,6 +13,7 @@ C_SRCS = \
cdata.c \
comment.c \
domdoc.c \
domimpl.c \
element.c \
factory.c \
main.c \

View file

@ -804,8 +804,12 @@ static HRESULT WINAPI domdoc_get_implementation(
IXMLDOMDocument2 *iface,
IXMLDOMImplementation** impl )
{
FIXME("\n");
return E_NOTIMPL;
if(!impl)
return E_INVALIDARG;
*impl = (IXMLDOMImplementation*)create_doc_Implementation();
return S_OK;
}
static HRESULT WINAPI domdoc_get_documentElement(

188
dlls/msxml3/domimpl.c Normal file
View file

@ -0,0 +1,188 @@
/*
* DOM Document Implementation implementation
*
* Copyright 2007 Alistair Leslie-Hughes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "msxml2.h"
#include "msxml_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
#ifdef HAVE_LIBXML2
typedef struct _domimpl
{
const struct IXMLDOMImplementationVtbl *lpVtbl;
LONG ref;
} domimpl;
static inline domimpl *impl_from_IXMLDOMImplementation( IXMLDOMImplementation *iface )
{
return (domimpl *)((char*)iface - FIELD_OFFSET(domimpl, lpVtbl));
}
static HRESULT WINAPI dimimpl_QueryInterface(
IXMLDOMImplementation *iface,
REFIID riid,
void** ppvObject )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
if ( IsEqualGUID( riid, &IID_IXMLDOMImplementation ) ||
IsEqualGUID( riid, &IID_IDispatch ) ||
IsEqualGUID( riid, &IID_IUnknown ) )
{
*ppvObject = iface;
}
else
{
FIXME("Unsupported inteferace %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
IXMLDOMImplementation_AddRef( iface );
return S_OK;
}
static ULONG WINAPI dimimpl_AddRef(
IXMLDOMImplementation *iface )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
return InterlockedIncrement( &This->ref );
}
static ULONG WINAPI dimimpl_Release(
IXMLDOMImplementation *iface )
{
domimpl *This = impl_from_IXMLDOMImplementation( iface );
ULONG ref;
ref = InterlockedDecrement( &This->ref );
if ( ref == 0 )
{
HeapFree( GetProcessHeap(), 0, This );
}
return ref;
}
static HRESULT WINAPI dimimpl_GetTypeInfoCount(
IXMLDOMImplementation *iface,
UINT* pctinfo )
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI dimimpl_GetTypeInfo(
IXMLDOMImplementation *iface,
UINT iTInfo, LCID lcid,
ITypeInfo** ppTInfo )
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI dimimpl_GetIDsOfNames(
IXMLDOMImplementation *iface,
REFIID riid, LPOLESTR* rgszNames,
UINT cNames, LCID lcid, DISPID* rgDispId )
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI dimimpl_Invoke(
IXMLDOMImplementation *iface,
DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
EXCEPINFO* pExcepInfo, UINT* puArgErr )
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT WINAPI dimimpl_hasFeature(IXMLDOMImplementation* This, BSTR feature, BSTR version, VARIANT_BOOL *hasFeature)
{
static WCHAR bVersion[] = {'1','.','0',0};
static WCHAR bXML[] = {'X','M','L',0};
static WCHAR bDOM[] = {'D','O','M',0};
static WCHAR bMSDOM[] = {'M','S','-','D','O','M',0};
BOOL bValidFeature = FALSE;
BOOL bValidVersion = FALSE;
TRACE("feature(%s) version (%s)\n", debugstr_w(feature), debugstr_w(version));
if(!feature || !hasFeature)
return E_INVALIDARG;
*hasFeature = VARIANT_FALSE;
if(!version || lstrcmpiW(version, bVersion) == 0)
bValidVersion = TRUE;
if(lstrcmpiW(feature, bXML) == 0 || lstrcmpiW(feature, bDOM) == 0 || lstrcmpiW(feature, bMSDOM) == 0)
bValidFeature = TRUE;
if(bValidVersion && bValidFeature)
*hasFeature = VARIANT_TRUE;
return S_OK;
}
static const struct IXMLDOMImplementationVtbl dimimpl_vtbl =
{
dimimpl_QueryInterface,
dimimpl_AddRef,
dimimpl_Release,
dimimpl_GetTypeInfoCount,
dimimpl_GetTypeInfo,
dimimpl_GetIDsOfNames,
dimimpl_Invoke,
dimimpl_hasFeature
};
IUnknown* create_doc_Implementation()
{
domimpl *This;
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
if ( !This )
return NULL;
This->lpVtbl = &dimimpl_vtbl;
This->ref = 1;
return (IUnknown*) &This->lpVtbl;
}
#endif

View file

@ -44,6 +44,7 @@ extern IUnknown *create_comment( xmlNodePtr comment );
extern IUnknown *create_cdata( xmlNodePtr text );
extern IXMLDOMNodeList *create_children_nodelist( xmlNodePtr );
extern IXMLDOMNamedNodeMap *create_nodemap( IXMLDOMNode *node );
extern IUnknown *create_doc_Implementation();
extern HRESULT queryresult_create( xmlNodePtr, LPWSTR, IXMLDOMNodeList ** );

View file

@ -1872,6 +1872,7 @@ static void test_xmlTypes(void)
IXMLDOMAttribute *pAttrubute;
IXMLDOMNamedNodeMap *pAttribs;
IXMLDOMCDATASection *pCDataSec;
IXMLDOMImplementation *pIXMLDOMImplementation = NULL;
BSTR str;
IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1; /* Used for testing Siblings */
VARIANT v;
@ -1917,6 +1918,61 @@ static void test_xmlTypes(void)
ok( !lstrcmpW( str, _bstr_("document") ), "incorrect nodeTypeString string\n");
SysFreeString(str);
/* test implementation */
hr = IXMLDOMDocument_get_implementation(doc, NULL);
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
hr = IXMLDOMDocument_get_implementation(doc, &pIXMLDOMImplementation);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)
{
VARIANT_BOOL hasFeature = VARIANT_TRUE;
BSTR sEmpty = SysAllocStringLen(NULL, 0);
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, NULL, sEmpty, &hasFeature);
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, NULL);
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
ok(hr == S_OK, "ret %08x\n", hr );
ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, sEmpty, sEmpty, &hasFeature);
ok(hr == S_OK, "ret %08x\n", hr );
ok(hasFeature == VARIANT_FALSE, "hasFeature returned true\n");
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), NULL, &hasFeature);
ok(hr == S_OK, "ret %08x\n", hr );
ok(hasFeature == VARIANT_TRUE, "hasFeature returned false\n");
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), sEmpty, &hasFeature);
ok(hr == S_OK, "ret %08x\n", hr );
ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("DOM"), _bstr_("1.0"), &hasFeature);
ok(hr == S_OK, "ret %08x\n", hr );
ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("XML"), _bstr_("1.0"), &hasFeature);
ok(hr == S_OK, "ret %08x\n", hr );
ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature);
ok(hr == S_OK, "ret %08x\n", hr );
ok(hasFeature == VARIANT_TRUE, "hasFeature returned true\n");
hr = IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation, _bstr_("SSS"), NULL, &hasFeature);
ok(hr == S_OK, "ret %08x\n", hr );
ok(hasFeature == VARIANT_FALSE, "hasFeature returned false\n");
SysFreeString(sEmpty);
IXMLDOMImplementation_Release(pIXMLDOMImplementation);
}
hr = IXMLDOMDocument_createElement(doc, _bstr_("Testing"), &pRoot);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)