From 300191d58c498174c815de019c93800449154533 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 4 Jan 2008 09:11:27 +1100 Subject: [PATCH] msxml3: Implement createAttribute. --- dlls/msxml3/domdoc.c | 25 +++++++++++++++++++++++-- dlls/msxml3/tests/domdoc.c | 10 ++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index ab5f03ec492..d955926bb22 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -981,8 +981,29 @@ static HRESULT WINAPI domdoc_createAttribute( BSTR name, IXMLDOMAttribute** attribute ) { - FIXME("\n"); - return E_NOTIMPL; + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + xmlNodePtr xmlnode; + xmlChar *xml_name; + + TRACE("%p->(%s %p)\n", iface, debugstr_w(name), attribute); + + if(!attribute) + return E_INVALIDARG; + + *attribute = NULL; + + xml_name = xmlChar_from_wchar((WCHAR*)name); + xmlnode = (xmlNode *)xmlNewProp(NULL, xml_name, NULL); + HeapFree(GetProcessHeap(), 0, xml_name); + + if(!xmlnode) + return E_FAIL; + + xmlnode->doc = get_doc( This ); + + *attribute = (IXMLDOMAttribute*)create_attribute(xmlnode); + + return S_OK; } diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 7865d9b8af2..3084e330ce9 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -137,6 +137,8 @@ static const WCHAR szfn1_txt[] = {'f','n','1','.','t','x','t',0}; static WCHAR szComment[] = {'A',' ','C','o','m','m','e','n','t',0 }; +static WCHAR szAttribute[] = {'A','t','t','r',0 }; + #define expect_bstr_eq_and_free(bstr, expect) { \ BSTR bstrExp = alloc_str_from_narrow(expect); \ ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \ @@ -337,6 +339,7 @@ static void test_domdoc( void ) IXMLDOMNode *node; IXMLDOMText *nodetext = NULL; IXMLDOMComment *node_comment = NULL; + IXMLDOMAttribute *node_attr = NULL; VARIANT_BOOL b; VARIANT var; BSTR str; @@ -508,6 +511,13 @@ static void test_domdoc( void ) ok( r == S_OK, "returns %08x\n", r ); IXMLDOMText_Release( node_comment ); + /* test Create Attribute */ + r = IXMLDOMDocument_createAttribute(doc, NULL, NULL); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + r = IXMLDOMDocument_createAttribute(doc, szAttribute, &node_attr); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMText_Release( node_attr); + r = IXMLDOMDocument_Release( doc ); ok( r == 0, "document ref count incorrect\n");