#include "config.h"
#include <stdarg.h>
+#ifdef HAVE_LIBXML2
+# include <libxml/parser.h>
+# include <libxml/xmlerror.h>
+#endif
+
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
-#include "msxml2.h"
+#include "msxml6.h"
#include "msxml_private.h"
typedef struct _domcdata
{
xmlnode node;
- const struct IXMLDOMCDATASectionVtbl *lpVtbl;
+ IXMLDOMCDATASection IXMLDOMCDATASection_iface;
LONG ref;
} domcdata;
static inline domcdata *impl_from_IXMLDOMCDATASection( IXMLDOMCDATASection *iface )
{
- return (domcdata *)((char*)iface - FIELD_OFFSET(domcdata, lpVtbl));
+ return CONTAINING_RECORD(iface, domcdata, IXMLDOMCDATASection_iface);
}
static HRESULT WINAPI domcdata_QueryInterface(
void** ppvObject )
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
+ TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
if ( IsEqualGUID( riid, &IID_IXMLDOMCDATASection ) ||
IsEqualGUID( riid, &IID_IXMLDOMCharacterData) ||
+ IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
IsEqualGUID( riid, &IID_IDispatch ) ||
IsEqualGUID( riid, &IID_IUnknown ) )
{
*ppvObject = iface;
}
- else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
- {
- *ppvObject = IXMLDOMNode_from_impl(&This->node);
- }
- else if ( IsEqualGUID( riid, &IID_IXMLDOMText ) ||
- IsEqualGUID( riid, &IID_IXMLDOMElement ) )
+ else if(node_query_interface(&This->node, riid, ppvObject))
{
- TRACE("Unsupported interface\n");
- return E_NOINTERFACE;
+ return *ppvObject ? S_OK : E_NOINTERFACE;
}
else
{
- FIXME("Unsupported interface %s\n", debugstr_guid(riid));
+ TRACE("Unsupported interface %s\n", debugstr_guid(riid));
+ *ppvObject = NULL;
return E_NOINTERFACE;
}
IXMLDOMCDATASection *iface )
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return InterlockedIncrement( &This->ref );
+ ULONG ref = InterlockedIncrement( &This->ref );
+ TRACE("(%p)->(%d)\n", This, ref);
+ return ref;
}
static ULONG WINAPI domcdata_Release(
IXMLDOMCDATASection *iface )
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- ULONG ref;
+ ULONG ref = InterlockedDecrement( &This->ref );
- ref = InterlockedDecrement( &This->ref );
+ TRACE("(%p)->(%d)\n", This, ref);
if ( ref == 0 )
{
destroy_xmlnode(&This->node);
- HeapFree( GetProcessHeap(), 0, This );
+ heap_free( This );
}
return ref;
hr = get_typeinfo(IXMLDOMCDATASection_tid, &typeinfo);
if(SUCCEEDED(hr))
{
- hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
- pVarResult, pExcepInfo, puArgErr);
+ hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMCDATASection_iface, dispIdMember, wFlags,
+ pDispParams, pVarResult, pExcepInfo, puArgErr);
ITypeInfo_Release(typeinfo);
}
BSTR* p )
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
+
+ static const WCHAR cdata_sectionW[] =
+ {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0};
+
+ TRACE("(%p)->(%p)\n", This, p);
+
+ return return_bstr(cdata_sectionW, p);
}
static HRESULT WINAPI domcdata_get_nodeValue(
IXMLDOMCDATASection *iface,
- VARIANT* var1 )
+ VARIANT* value)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
+
+ TRACE("(%p)->(%p)\n", This, value);
+
+ return node_get_content(&This->node, value);
}
static HRESULT WINAPI domcdata_put_nodeValue(
IXMLDOMCDATASection *iface,
- VARIANT var1 )
+ VARIANT value)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
+
+ TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
+
+ return node_put_value(&This->node, &value);
}
static HRESULT WINAPI domcdata_get_nodeType(
DOMNodeType* domNodeType )
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_nodeType( IXMLDOMNode_from_impl(&This->node), domNodeType );
+
+ TRACE("(%p)->(%p)\n", This, domNodeType);
+
+ *domNodeType = NODE_CDATA_SECTION;
+ return S_OK;
}
static HRESULT WINAPI domcdata_get_parentNode(
IXMLDOMNode** parent )
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_parentNode( IXMLDOMNode_from_impl(&This->node), parent );
+
+ TRACE("(%p)->(%p)\n", This, parent);
+
+ return node_get_parent(&This->node, parent);
}
static HRESULT WINAPI domcdata_get_childNodes(
IXMLDOMNodeList** outList)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This->node), outList );
+
+ TRACE("(%p)->(%p)\n", This, outList);
+
+ return node_get_child_nodes(&This->node, outList);
}
static HRESULT WINAPI domcdata_get_firstChild(
IXMLDOMNode** domNode)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode );
+
+ TRACE("(%p)->(%p)\n", This, domNode);
+
+ return return_null_node(domNode);
}
static HRESULT WINAPI domcdata_get_lastChild(
IXMLDOMNode** domNode)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode );
+
+ TRACE("(%p)->(%p)\n", This, domNode);
+
+ return return_null_node(domNode);
}
static HRESULT WINAPI domcdata_get_previousSibling(
IXMLDOMNode** domNode)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This->node), domNode );
+
+ TRACE("(%p)->(%p)\n", This, domNode);
+
+ return node_get_previous_sibling(&This->node, domNode);
}
static HRESULT WINAPI domcdata_get_nextSibling(
IXMLDOMNode** domNode)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This->node), domNode );
+
+ TRACE("(%p)->(%p)\n", This, domNode);
+
+ return node_get_next_sibling(&This->node, domNode);
}
static HRESULT WINAPI domcdata_get_attributes(
IXMLDOMCDATASection *iface,
IXMLDOMNamedNodeMap** attributeMap)
{
- domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This->node), attributeMap );
+ domcdata *This = impl_from_IXMLDOMCDATASection( iface );
+
+ TRACE("(%p)->(%p)\n", This, attributeMap);
+
+ return return_null_ptr((void**)attributeMap);
}
static HRESULT WINAPI domcdata_insertBefore(
IXMLDOMCDATASection *iface,
- IXMLDOMNode* newNode, VARIANT var1,
+ IXMLDOMNode* newNode, VARIANT refChild,
IXMLDOMNode** outOldNode)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This->node), newNode, var1, outOldNode );
+
+ FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), outOldNode);
+
+ return node_insert_before(&This->node, newNode, &refChild, outOldNode);
}
static HRESULT WINAPI domcdata_replaceChild(
IXMLDOMNode** outOldNode)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
+
+ FIXME("(%p)->(%p %p %p) needs tests\n", This, newNode, oldNode, outOldNode);
+
+ return node_replace_child(&This->node, newNode, oldNode, outOldNode);
}
static HRESULT WINAPI domcdata_removeChild(
IXMLDOMCDATASection *iface,
- IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
+ IXMLDOMNode *child, IXMLDOMNode **oldChild)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
+ TRACE("(%p)->(%p %p)\n", This, child, oldChild);
+ return node_remove_child(&This->node, child, oldChild);
}
static HRESULT WINAPI domcdata_appendChild(
IXMLDOMCDATASection *iface,
- IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
+ IXMLDOMNode *child, IXMLDOMNode **outChild)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
+ TRACE("(%p)->(%p %p)\n", This, child, outChild);
+ return node_append_child(&This->node, child, outChild);
}
static HRESULT WINAPI domcdata_hasChildNodes(
IXMLDOMCDATASection *iface,
- VARIANT_BOOL* pbool)
+ VARIANT_BOOL *ret)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
+ TRACE("(%p)->(%p)\n", This, ret);
+ return node_has_childnodes(&This->node, ret);
}
static HRESULT WINAPI domcdata_get_ownerDocument(
IXMLDOMCDATASection *iface,
- IXMLDOMDocument** domDocument)
+ IXMLDOMDocument **doc)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
+ TRACE("(%p)->(%p)\n", This, doc);
+ return node_get_owner_doc(&This->node, doc);
}
static HRESULT WINAPI domcdata_cloneNode(
IXMLDOMCDATASection *iface,
- VARIANT_BOOL pbool, IXMLDOMNode** outNode)
+ VARIANT_BOOL deep, IXMLDOMNode** outNode)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
+ TRACE("(%p)->(%d %p)\n", This, deep, outNode);
+ return node_clone( &This->node, deep, outNode );
}
static HRESULT WINAPI domcdata_get_nodeTypeString(
BSTR* p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
+ static const WCHAR cdatasectionW[] = {'c','d','a','t','a','s','e','c','t','i','o','n',0};
+
+ TRACE("(%p)->(%p)\n", This, p);
+
+ return return_bstr(cdatasectionW, p);
}
static HRESULT WINAPI domcdata_get_text(
BSTR* p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
+ TRACE("(%p)->(%p)\n", This, p);
+ return node_get_text(&This->node, p);
}
static HRESULT WINAPI domcdata_put_text(
BSTR p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
+ TRACE("(%p)->(%p)\n", This, debugstr_w(p));
+ return node_put_text( &This->node, p );
}
static HRESULT WINAPI domcdata_get_specified(
IXMLDOMCDATASection *iface,
- VARIANT_BOOL* pbool)
+ VARIANT_BOOL* isSpecified)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
+ FIXME("(%p)->(%p) stub!\n", This, isSpecified);
+ *isSpecified = VARIANT_TRUE;
+ return S_OK;
}
static HRESULT WINAPI domcdata_get_definition(
IXMLDOMCDATASection *iface,
- IXMLDOMNode** domNode)
+ IXMLDOMNode** definitionNode)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
+ FIXME("(%p)->(%p)\n", This, definitionNode);
+ return E_NOTIMPL;
}
static HRESULT WINAPI domcdata_get_nodeTypedValue(
IXMLDOMCDATASection *iface,
- VARIANT* var1)
+ VARIANT* v)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
+ TRACE("(%p)->(%p)\n", This, v);
+ return node_get_content(&This->node, v);
}
static HRESULT WINAPI domcdata_put_nodeTypedValue(
IXMLDOMCDATASection *iface,
- VARIANT var1)
+ VARIANT typedValue)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
+ FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
+ return E_NOTIMPL;
}
static HRESULT WINAPI domcdata_get_dataType(
IXMLDOMCDATASection *iface,
- VARIANT* var1)
+ VARIANT* typename)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
+ TRACE("(%p)->(%p)\n", This, typename);
+ return return_null_var( typename );
}
static HRESULT WINAPI domcdata_put_dataType(
BSTR p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
+
+ FIXME("(%p)->(%s)\n", This, debugstr_w(p));
+
+ if(!p)
+ return E_INVALIDARG;
+
+ return E_FAIL;
}
static HRESULT WINAPI domcdata_get_xml(
BSTR* p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
+
+ TRACE("(%p)->(%p)\n", This, p);
+
+ return node_get_xml(&This->node, FALSE, FALSE, p);
}
static HRESULT WINAPI domcdata_transformNode(
IXMLDOMCDATASection *iface,
- IXMLDOMNode* domNode, BSTR* p)
+ IXMLDOMNode *node, BSTR *p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
+ TRACE("(%p)->(%p %p)\n", This, node, p);
+ return node_transform_node(&This->node, node, p);
}
static HRESULT WINAPI domcdata_selectNodes(
BSTR p, IXMLDOMNodeList** outList)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
+ TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
+ return node_select_nodes(&This->node, p, outList);
}
static HRESULT WINAPI domcdata_selectSingleNode(
BSTR p, IXMLDOMNode** outNode)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
+ TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
+ return node_select_singlenode(&This->node, p, outNode);
}
static HRESULT WINAPI domcdata_get_parsed(
IXMLDOMCDATASection *iface,
- VARIANT_BOOL* pbool)
+ VARIANT_BOOL* isParsed)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
+ FIXME("(%p)->(%p) stub!\n", This, isParsed);
+ *isParsed = VARIANT_TRUE;
+ return S_OK;
}
static HRESULT WINAPI domcdata_get_namespaceURI(
BSTR* p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
+ TRACE("(%p)->(%p)\n", This, p);
+ return node_get_namespaceURI(&This->node, p);
}
static HRESULT WINAPI domcdata_get_prefix(
IXMLDOMCDATASection *iface,
- BSTR* p)
+ BSTR* prefix)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
+ TRACE("(%p)->(%p)\n", This, prefix);
+ return return_null_bstr( prefix );
}
static HRESULT WINAPI domcdata_get_baseName(
IXMLDOMCDATASection *iface,
- BSTR* p)
+ BSTR* name)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
+ FIXME("(%p)->(%p): needs test\n", This, name);
+ return return_null_bstr( name );
}
static HRESULT WINAPI domcdata_transformNodeToObject(
IXMLDOMNode* domNode, VARIANT var1)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
+ FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
+ return E_NOTIMPL;
}
static HRESULT WINAPI domcdata_get_data(
IXMLDOMCDATASection *iface,
BSTR *p)
{
- domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- HRESULT hr = E_FAIL;
+ HRESULT hr;
VARIANT vRet;
if(!p)
return E_INVALIDARG;
- hr = IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), &vRet );
+ hr = IXMLDOMCDATASection_get_nodeValue( iface, &vRet );
if(hr == S_OK)
{
*p = V_BSTR(&vRet);
BSTR data)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- HRESULT hr = E_FAIL;
VARIANT val;
- TRACE("%p %s\n", This, debugstr_w(data) );
+ TRACE("(%p)->(%s)\n", This, debugstr_w(data) );
V_VT(&val) = VT_BSTR;
V_BSTR(&val) = data;
- hr = IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), val );
-
- return hr;
+ return IXMLDOMCDATASection_put_nodeValue( iface, val );
}
static HRESULT WINAPI domcdata_get_length(
LONG *len)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- xmlChar *pContent;
- LONG nLength = 0;
+ HRESULT hr;
+ BSTR data;
- TRACE("%p\n", iface);
+ TRACE("(%p)->(%p)\n", This, len);
if(!len)
return E_INVALIDARG;
- pContent = xmlNodeGetContent(This->node.node);
- if(pContent)
+ hr = IXMLDOMCDATASection_get_data(iface, &data);
+ if(hr == S_OK)
{
- nLength = xmlStrlen(pContent);
- xmlFree(pContent);
+ *len = SysStringLen(data);
+ SysFreeString(data);
}
- *len = nLength;
-
return S_OK;
}
LONG offset, LONG count, BSTR *p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- xmlChar *pContent;
- LONG nLength = 0;
- HRESULT hr = S_FALSE;
+ HRESULT hr;
+ BSTR data;
- TRACE("%p\n", iface);
+ TRACE("(%p)->(%d %d %p)\n", This, offset, count, p);
if(!p)
return E_INVALIDARG;
return E_INVALIDARG;
if(count == 0)
- return hr;
+ return S_FALSE;
- pContent = xmlNodeGetContent(This->node.node);
- if(pContent)
+ hr = IXMLDOMCDATASection_get_data(iface, &data);
+ if(hr == S_OK)
{
- nLength = xmlStrlen(pContent);
+ LONG len = SysStringLen(data);
- if( offset < nLength)
+ if(offset < len)
{
- BSTR sContent = bstr_from_xmlChar(pContent);
- if(offset + count > nLength)
- *p = SysAllocString(&sContent[offset]);
+ if(offset + count > len)
+ *p = SysAllocString(&data[offset]);
else
- *p = SysAllocStringLen(&sContent[offset], count);
-
- SysFreeString(sContent);
- hr = S_OK;
+ *p = SysAllocStringLen(&data[offset], count);
}
+ else
+ hr = S_FALSE;
- xmlFree(pContent);
+ SysFreeString(data);
}
return hr;
BSTR p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- xmlChar *pContent;
- HRESULT hr = S_FALSE;
+ HRESULT hr;
+ BSTR data;
+ LONG p_len;
- TRACE("%p\n", iface);
+ TRACE("(%p)->(%s)\n", This, debugstr_w(p));
/* Nothing to do if NULL or an Empty string passed in. */
- if(p == NULL || SysStringLen(p) == 0)
- return S_OK;
+ if((p_len = SysStringLen(p)) == 0) return S_OK;
- pContent = xmlChar_from_wchar( p );
- if(pContent)
+ hr = IXMLDOMCDATASection_get_data(iface, &data);
+ if(hr == S_OK)
{
- if(xmlTextConcat(This->node.node, pContent, SysStringLen(p) ) == 0)
- hr = S_OK;
- else
- hr = E_FAIL;
+ LONG len = SysStringLen(data);
+ BSTR str = SysAllocStringLen(NULL, p_len + len);
+
+ memcpy(str, data, len*sizeof(WCHAR));
+ memcpy(&str[len], p, p_len*sizeof(WCHAR));
+ str[len+p_len] = 0;
+
+ hr = IXMLDOMCDATASection_put_data(iface, str);
+
+ SysFreeString(str);
+ SysFreeString(data);
}
- else
- hr = E_FAIL;
- HeapFree(GetProcessHeap(), 0, pContent);
return hr;
}
LONG offset, BSTR p)
{
domcdata *This = impl_from_IXMLDOMCDATASection( iface );
- xmlChar *pXmlContent;
- BSTR sNewString;
- HRESULT hr = S_FALSE;
- LONG nLength = 0, nLengthP = 0;
- xmlChar *str = NULL;
+ HRESULT hr;
+ BSTR data;
+ LONG p_len;
- TRACE("%p\n", This);
+ TRACE("(%p)->(%d %s)\n", This, offset, debugstr_w(p));
/* If have a NULL or empty string, don't do anything. */
- if(SysStringLen(p) == 0)
+ if((p_len = SysStringLen(p)) == 0)
return S_OK;
if(offset < 0)
return E_INVALIDARG;
}
- pXmlContent = xmlNodeGetContent(This->node.node);
- if(pXmlContent)
+ hr = IXMLDOMCDATASection_get_data(iface, &data);
+ if(hr == S_OK)
{
- BSTR sContent = bstr_from_xmlChar( pXmlContent );
- nLength = SysStringLen(sContent);
- nLengthP = SysStringLen(p);
+ LONG len = SysStringLen(data);
+ BSTR str;
- if(nLength < offset)
+ if(len < offset)
{
- SysFreeString(sContent);
- xmlFree(pXmlContent);
-
+ SysFreeString(data);
return E_INVALIDARG;
}
- sNewString = SysAllocStringLen(NULL, nLength + nLengthP + 1);
- if(sNewString)
- {
- if(offset > 0)
- memcpy(sNewString, sContent, offset * sizeof(WCHAR));
-
- memcpy(&sNewString[offset], p, nLengthP * sizeof(WCHAR));
-
- if(offset+nLengthP < nLength)
- memcpy(&sNewString[offset+nLengthP], &sContent[offset], (nLength-offset) * sizeof(WCHAR));
+ str = SysAllocStringLen(NULL, len + p_len);
+ /* start part, supplied string and end part */
+ memcpy(str, data, offset*sizeof(WCHAR));
+ memcpy(&str[offset], p, p_len*sizeof(WCHAR));
+ memcpy(&str[offset+p_len], &data[offset], (len-offset)*sizeof(WCHAR));
+ str[len+p_len] = 0;
- sNewString[nLengthP + nLength] = 0;
-
- str = xmlChar_from_wchar(sNewString);
- if(str)
- {
- xmlNodeSetContent(This->node.node, str);
- hr = S_OK;
- }
- HeapFree(GetProcessHeap(), 0, str);
-
- SysFreeString(sNewString);
- }
-
- SysFreeString(sContent);
+ hr = IXMLDOMCDATASection_put_data(iface, str);
- xmlFree(pXmlContent);
+ SysFreeString(str);
+ SysFreeString(data);
}
return hr;
IXMLDOMCDATASection *iface,
LONG offset, LONG count)
{
+ domcdata *This = impl_from_IXMLDOMCDATASection( iface );
HRESULT hr;
LONG len = -1;
BSTR str;
- TRACE("%p %d %d\n", iface, offset, count);
+ TRACE("(%p)->(%d %d)\n", This, offset, count);
hr = IXMLDOMCDATASection_get_length(iface, &len);
if(hr != S_OK) return hr;
IXMLDOMCDATASection *iface,
LONG offset, LONG count, BSTR p)
{
- FIXME("\n");
- return E_NOTIMPL;
+ domcdata *This = impl_from_IXMLDOMCDATASection( iface );
+ HRESULT hr;
+
+ TRACE("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(p));
+
+ hr = IXMLDOMCDATASection_deleteData(iface, offset, count);
+
+ if (hr == S_OK)
+ hr = IXMLDOMCDATASection_insertData(iface, offset, p);
+
+ return hr;
}
static HRESULT WINAPI domcdata_splitText(
IXMLDOMCDATASection *iface,
LONG offset, IXMLDOMText **txtNode)
{
- FIXME("\n");
- return E_NOTIMPL;
-}
+ domcdata *This = impl_from_IXMLDOMCDATASection( iface );
+ IXMLDOMDocument *doc;
+ LONG length = 0;
+ HRESULT hr;
+
+ TRACE("(%p)->(%d %p)\n", This, offset, txtNode);
+ if (!txtNode || offset < 0) return E_INVALIDARG;
+
+ *txtNode = NULL;
+
+ IXMLDOMCDATASection_get_length(iface, &length);
+
+ if (offset > length) return E_INVALIDARG;
+ if (offset == length) return S_FALSE;
+
+ hr = IXMLDOMCDATASection_get_ownerDocument(iface, &doc);
+ if (hr == S_OK)
+ {
+ BSTR data;
+
+ hr = IXMLDOMCDATASection_substringData(iface, offset, length - offset, &data);
+ if (hr == S_OK)
+ {
+ hr = IXMLDOMDocument_createTextNode(doc, data, txtNode);
+ if (hr == S_OK)
+ {
+ IXMLDOMNode *parent;
+
+ hr = IXMLDOMCDATASection_get_parentNode(iface, &parent);
+ if (hr == S_OK)
+ {
+ IXMLDOMCDATASection_deleteData(iface, 0, offset);
+ hr = IXMLDOMNode_appendChild(parent, (IXMLDOMNode*)*txtNode, NULL);
+ IXMLDOMNode_Release(parent);
+ }
+ }
+ SysFreeString(data);
+ }
+ IXMLDOMDocument_Release(doc);
+ }
+
+ return hr;
+}
static const struct IXMLDOMCDATASectionVtbl domcdata_vtbl =
{
{
domcdata *This;
- This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
+ This = heap_alloc( sizeof *This );
if ( !This )
return NULL;
- This->lpVtbl = &domcdata_vtbl;
+ This->IXMLDOMCDATASection_iface.lpVtbl = &domcdata_vtbl;
This->ref = 1;
- init_xmlnode(&This->node, text, (IUnknown*)&This->lpVtbl, NULL);
+ init_xmlnode(&This->node, text, (IXMLDOMNode*)&This->IXMLDOMCDATASection_iface, NULL);
- return (IUnknown*) &This->lpVtbl;
+ return (IUnknown*)&This->IXMLDOMCDATASection_iface;
}
#endif