Commit 88adaa06 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Partially implement ::setAttributeNode().

parent 27c01617
......@@ -50,7 +50,7 @@ static inline domelem *impl_from_IXMLDOMElement( IXMLDOMElement *iface )
return (domelem *)((char*)iface - FIELD_OFFSET(domelem, lpVtbl));
}
static inline xmlNodePtr get_element( domelem *This )
static inline xmlNodePtr get_element( const domelem *This )
{
return This->node.node;
}
......@@ -705,16 +705,61 @@ static HRESULT WINAPI domelem_getAttributeNode(
static HRESULT WINAPI domelem_setAttributeNode(
IXMLDOMElement *iface,
IXMLDOMAttribute* domAttribute,
IXMLDOMAttribute** attributeNode)
IXMLDOMAttribute* attribute,
IXMLDOMAttribute** old)
{
domelem *This = impl_from_IXMLDOMElement( iface );
xmlChar *name, *value;
BSTR nameW, prefix;
xmlAttrPtr attr;
VARIANT valueW;
HRESULT hr;
FIXME("(%p)->(%p %p)\n", This, domAttribute, attributeNode);
FIXME("(%p)->(%p %p): semi-stub\n", This, attribute, old);
if(!domAttribute) return E_INVALIDARG;
if (!attribute) return E_INVALIDARG;
return E_NOTIMPL;
if (old) *old = NULL;
hr = IXMLDOMAttribute_get_nodeName(attribute, &nameW);
if (hr != S_OK) return hr;
hr = IXMLDOMAttribute_get_nodeValue(attribute, &valueW);
if (hr != S_OK)
{
SysFreeString(nameW);
return hr;
}
TRACE("attribute: %s=%s\n", debugstr_w(nameW), debugstr_w(V_BSTR(&valueW)));
hr = IXMLDOMAttribute_get_prefix(attribute, &prefix);
if (hr == S_OK)
{
FIXME("namespaces not supported: %s\n", debugstr_w(prefix));
SysFreeString(prefix);
}
name = xmlChar_from_wchar(nameW);
value = xmlChar_from_wchar(V_BSTR(&valueW));
if (!name || !value)
{
SysFreeString(nameW);
VariantClear(&valueW);
heap_free(name);
heap_free(value);
return E_OUTOFMEMORY;
}
attr = xmlSetNsProp(get_element(This), NULL, name, value);
SysFreeString(nameW);
VariantClear(&valueW);
heap_free(name);
heap_free(value);
return attr ? S_OK : E_FAIL;
}
static HRESULT WINAPI domelem_removeAttributeNode(
......
......@@ -6853,20 +6853,29 @@ static void test_setAttributeNode(void)
ret_attr = (void*)0xdeadbeef;
hr = IXMLDOMElement_setAttributeNode(elem, attr, &ret_attr);
todo_wine ok( hr == S_OK, "got 0x%08x\n", hr);
todo_wine ok( ret_attr == NULL, "got %p\n", ret_attr);
ok( hr == S_OK, "got 0x%08x\n", hr);
ok( ret_attr == NULL, "got %p\n", ret_attr);
attr2 = NULL;
hr = IXMLDOMElement_getAttributeNode(elem, _bstr_("attr"), &attr2);
todo_wine ok( hr == S_OK, "got 0x%08x\n", hr);
if (attr2) IXMLDOMAttribute_Release(attr2);
ok( hr == S_OK, "got 0x%08x\n", hr);
IXMLDOMAttribute_Release(attr2);
/* try to add it another time */
ret_attr = (void*)0xdeadbeef;
hr = IXMLDOMElement_setAttributeNode(elem, attr, &ret_attr);
todo_wine ok( hr == E_FAIL, "got 0x%08x\n", hr);
ok( ret_attr == (void*)0xdeadbeef, "got %p\n", ret_attr);
todo_wine ok( ret_attr == (void*)0xdeadbeef, "got %p\n", ret_attr);
IXMLDOMElement_Release(elem);
/* initialy used element is released, attribute still 'has' a container */
hr = IXMLDOMDocument_get_documentElement(doc, &elem);
ok( hr == S_OK, "got 0x%08x\n", hr);
ret_attr = (void*)0xdeadbeef;
hr = IXMLDOMElement_setAttributeNode(elem, attr, &ret_attr);
todo_wine ok( hr == E_FAIL, "got 0x%08x\n", hr);
todo_wine ok( ret_attr == (void*)0xdeadbeef, "got %p\n", ret_attr);
IXMLDOMElement_Release(elem);
/* add attribute already attached to another document */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment