Author: cwittich Date: Sat Feb 6 22:34:28 2010 New Revision: 45470 URL: http://svn.reactos.org/svn/reactos?rev=45470&view=rev Log: [MSXML3] sync msxml3 to wine 1.1.38
Modified: trunk/reactos/dll/win32/msxml3/attribute.c trunk/reactos/dll/win32/msxml3/bsc.c trunk/reactos/dll/win32/msxml3/cdata.c trunk/reactos/dll/win32/msxml3/comment.c trunk/reactos/dll/win32/msxml3/docfrag.c trunk/reactos/dll/win32/msxml3/domdoc.c trunk/reactos/dll/win32/msxml3/domimpl.c trunk/reactos/dll/win32/msxml3/element.c trunk/reactos/dll/win32/msxml3/entityref.c trunk/reactos/dll/win32/msxml3/factory.c trunk/reactos/dll/win32/msxml3/httprequest.c trunk/reactos/dll/win32/msxml3/msxml_private.h trunk/reactos/dll/win32/msxml3/node.c trunk/reactos/dll/win32/msxml3/nodelist.c trunk/reactos/dll/win32/msxml3/nodemap.c trunk/reactos/dll/win32/msxml3/parseerror.c trunk/reactos/dll/win32/msxml3/pi.c trunk/reactos/dll/win32/msxml3/queryresult.c trunk/reactos/dll/win32/msxml3/regsvr.c trunk/reactos/dll/win32/msxml3/saxreader.c trunk/reactos/dll/win32/msxml3/schema.c trunk/reactos/dll/win32/msxml3/text.c trunk/reactos/dll/win32/msxml3/xmldoc.c trunk/reactos/dll/win32/msxml3/xmlelem.c trunk/reactos/include/psdk/msxml2.idl Modified: trunk/reactos/dll/win32/msxml3/attribute.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/attribute.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/attribute.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/attribute.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -94,7 +94,7 @@ if ( ref == 0 ) { destroy_xmlnode(&This->node); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -546,7 +546,7 @@ { domattr *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); + This = heap_alloc( sizeof *This ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/bsc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/bsc.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/bsc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/bsc.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -93,11 +93,9 @@ TRACE("(%p) ref=%d\n", This, ref); if(!ref) { - if(This->binding) - IBinding_Release(This->binding); - if(This->memstream) - IStream_Release(This->memstream); - HeapFree(GetProcessHeap(), 0, This); + if (This->binding) IBinding_Release(This->binding); + if (This->memstream) IStream_Release(This->memstream); + heap_free(This); } return ref; @@ -270,7 +268,7 @@ if(FAILED(hr)) return hr; - bsc = HeapAlloc(GetProcessHeap(), 0, sizeof(bsc_t)); + bsc = heap_alloc(sizeof(bsc_t)); bsc->lpVtbl = &bsc_vtbl; bsc->ref = 1; Modified: trunk/reactos/dll/win32/msxml3/cdata.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/cdata.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/cdata.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/cdata.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -101,7 +101,7 @@ if ( ref == 0 ) { destroy_xmlnode(&This->node); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -606,7 +606,7 @@ } else hr = E_FAIL; - HeapFree(GetProcessHeap(), 0, pContent); + heap_free(pContent); return hr; } @@ -667,7 +667,7 @@ xmlNodeSetContent(This->node.node, str); hr = S_OK; } - HeapFree(GetProcessHeap(), 0, str); + heap_free(str); SysFreeString(sNewString); } @@ -684,8 +684,47 @@ IXMLDOMCDATASection *iface, LONG offset, LONG count) { - FIXME("\n"); - return E_NOTIMPL; + HRESULT hr; + LONG len = -1; + BSTR str; + + TRACE("%p %d %d\n", iface, offset, count); + + hr = IXMLDOMCDATASection_get_length(iface, &len); + if(hr != S_OK) return hr; + + if((offset < 0) || (offset > len) || (count < 0)) + return E_INVALIDARG; + + if(len == 0) return S_OK; + + /* cutting start or end */ + if((offset == 0) || ((count + offset) >= len)) + { + if(offset == 0) + IXMLDOMCDATASection_substringData(iface, count, len - count, &str); + else + IXMLDOMCDATASection_substringData(iface, 0, offset, &str); + hr = IXMLDOMCDATASection_put_data(iface, str); + } + else + /* cutting from the inside */ + { + BSTR str_end; + + IXMLDOMCDATASection_substringData(iface, 0, offset, &str); + IXMLDOMCDATASection_substringData(iface, offset + count, len - count, &str_end); + + hr = IXMLDOMCDATASection_put_data(iface, str); + if(hr == S_OK) + hr = IXMLDOMCDATASection_appendData(iface, str_end); + + SysFreeString(str_end); + } + + SysFreeString(str); + + return hr; } static HRESULT WINAPI domcdata_replaceData( @@ -765,7 +804,7 @@ { domcdata *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); + This = heap_alloc( sizeof *This ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/comment.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/comment.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/comment.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/comment.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -95,7 +95,7 @@ if ( ref == 0 ) { destroy_xmlnode(&This->node); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -541,7 +541,7 @@ LONG nLength = 0; HRESULT hr = S_FALSE; - TRACE("%p\n", iface); + TRACE("%p %d %d %p\n", iface, offset, count, p); if(!p) return E_INVALIDARG; @@ -551,7 +551,7 @@ return E_INVALIDARG; if(count == 0) - return hr; + return S_FALSE; pContent = xmlNodeGetContent(This->node.node); if(pContent) @@ -630,7 +630,7 @@ LONG nLength = 0, nLengthP = 0; xmlChar *str = NULL; - TRACE("%p\n", This); + TRACE("%p %d %p\n", iface, offset, p); /* If have a NULL or empty string, don't do anything. */ if(SysStringLen(p) == 0) @@ -692,8 +692,47 @@ IXMLDOMComment *iface, LONG offset, LONG count) { - FIXME("\n"); - return E_NOTIMPL; + HRESULT hr; + LONG len = -1; + BSTR str; + + TRACE("%p %d %d\n", iface, offset, count); + + hr = IXMLDOMComment_get_length(iface, &len); + if(hr != S_OK) return hr; + + if((offset < 0) || (offset > len) || (count < 0)) + return E_INVALIDARG; + + if(len == 0) return S_OK; + + /* cutting start or end */ + if((offset == 0) || ((count + offset) >= len)) + { + if(offset == 0) + IXMLDOMComment_substringData(iface, count, len - count, &str); + else + IXMLDOMComment_substringData(iface, 0, offset, &str); + hr = IXMLDOMComment_put_data(iface, str); + } + else + /* cutting from the inside */ + { + BSTR str_end; + + IXMLDOMComment_substringData(iface, 0, offset, &str); + IXMLDOMComment_substringData(iface, offset + count, len - count, &str_end); + + hr = IXMLDOMComment_put_data(iface, str); + if(hr == S_OK) + hr = IXMLDOMComment_appendData(iface, str_end); + + SysFreeString(str_end); + } + + SysFreeString(str); + + return hr; } static HRESULT WINAPI domcomment_replaceData( @@ -763,7 +802,7 @@ { domcomment *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); + This = heap_alloc( sizeof *This ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/docfrag.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/docfrag.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/docfrag.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/docfrag.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -94,7 +94,7 @@ if ( ref == 0 ) { destroy_xmlnode(&This->node); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -519,7 +519,7 @@ { domfrag *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); + This = heap_alloc( sizeof *This ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/domdoc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/domdoc.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/domdoc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/domdoc.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -119,7 +119,7 @@ static xmldoc_priv * create_priv(void) { xmldoc_priv *priv; - priv = HeapAlloc( GetProcessHeap(), 0, sizeof (*priv) ); + priv = heap_alloc( sizeof (*priv) ); if(priv) { @@ -164,9 +164,9 @@ LIST_FOR_EACH_ENTRY_SAFE( orphan, orphan2, &priv->orphans, orphan_entry, entry ) { xmlFreeNode( orphan->node ); - HeapFree( GetProcessHeap(), 0, orphan ); + heap_free( orphan ); } - HeapFree(GetProcessHeap(), 0, doc->_private); + heap_free(doc->_private); xmlFreeDoc(doc); } @@ -179,7 +179,7 @@ xmldoc_priv *priv = priv_from_xmlDocPtr(doc); orphan_entry *entry; - entry = HeapAlloc( GetProcessHeap(), 0, sizeof (*entry) ); + entry = heap_alloc( sizeof (*entry) ); if(!entry) return E_OUTOFMEMORY; @@ -198,7 +198,7 @@ if( entry->node == node ) { list_remove( &entry->entry ); - HeapFree( GetProcessHeap(), 0, entry ); + heap_free( entry ); return S_OK; } } @@ -1041,7 +1041,7 @@ TRACE("created xmlptr %p\n", xmlnode); elem_unk = create_element(xmlnode); - HeapFree(GetProcessHeap(), 0, xml_name); + heap_free(xml_name); hr = IUnknown_QueryInterface(elem_unk, &IID_IXMLDOMElement, (void **)element); IUnknown_Release(elem_unk); @@ -1094,7 +1094,7 @@ xml_content = xmlChar_from_wchar(data); xmlnode = xmlNewText(xml_content); - HeapFree(GetProcessHeap(), 0, xml_content); + heap_free(xml_content); if(!xmlnode) return E_FAIL; @@ -1126,7 +1126,7 @@ xml_content = xmlChar_from_wchar(data); xmlnode = xmlNewComment(xml_content); - HeapFree(GetProcessHeap(), 0, xml_content); + heap_free(xml_content); if(!xmlnode) return E_FAIL; @@ -1158,7 +1158,7 @@ xml_content = xmlChar_from_wchar(data); xmlnode = xmlNewCDataBlock(get_doc( This ), xml_content, strlen( (char*)xml_content) ); - HeapFree(GetProcessHeap(), 0, xml_content); + heap_free(xml_content); if(!xmlnode) return E_FAIL; @@ -1199,8 +1199,8 @@ TRACE("created xmlptr %p\n", xmlnode); *pi = (IXMLDOMProcessingInstruction*)create_pi(xmlnode); - HeapFree(GetProcessHeap(), 0, xml_content); - HeapFree(GetProcessHeap(), 0, xml_target); + heap_free(xml_content); + heap_free(xml_target); return S_OK; #else @@ -1228,7 +1228,7 @@ xml_name = xmlChar_from_wchar(name); xmlnode = (xmlNode *)xmlNewProp(NULL, xml_name, NULL); - HeapFree(GetProcessHeap(), 0, xml_name); + heap_free(xml_name); if(!xmlnode) return E_FAIL; @@ -1260,7 +1260,7 @@ xml_name = xmlChar_from_wchar(name); xmlnode = xmlNewReference(get_doc( This ), xml_name ); - HeapFree(GetProcessHeap(), 0, xml_name); + heap_free(xml_name); if(!xmlnode) return E_FAIL; @@ -1279,17 +1279,28 @@ BSTR tagName, IXMLDOMNodeList** resultList ) { + static const WCHAR xpathformat[] = + { '/','/','*','[','l','o','c','a','l','-','n','a','m','e','(',')','=','\'','%','s','\'',']',0 }; domdoc *This = impl_from_IXMLDOMDocument2( iface ); LPWSTR szPattern; HRESULT hr; TRACE("(%p)->(%s, %p)\n", This, debugstr_w(tagName), resultList); - szPattern = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(2+lstrlenW(tagName)+1)); - szPattern[0] = szPattern[1] = '/'; - lstrcpyW(szPattern + 2, tagName); + if (tagName[0] == '*' && tagName[1] == 0) + { + szPattern = heap_alloc(sizeof(WCHAR)*4); + szPattern[0] = szPattern[1] = '/'; + szPattern[2] = '*'; + szPattern[3] = 0; + } + else + { + szPattern = heap_alloc(sizeof(WCHAR)*(20+lstrlenW(tagName)+1)); + wsprintfW(szPattern, xpathformat, tagName); + } hr = queryresult_create((xmlNodePtr)get_doc(This), szPattern, resultList); - HeapFree(GetProcessHeap(), 0, szPattern); + heap_free(szPattern); return hr; } @@ -1359,7 +1370,7 @@ break; } - HeapFree(GetProcessHeap(), 0, xml_name); + heap_free(xml_name); if(xmlnode && *node) { @@ -1588,7 +1599,7 @@ LPSTR str; len = WideCharToMultiByte( CP_UTF8, 0, bstr, blen, NULL, 0, NULL, NULL ); - str = HeapAlloc( GetProcessHeap(), 0, len ); + str = heap_alloc( len ); if ( !str ) return FALSE; WideCharToMultiByte( CP_UTF8, 0, bstr, blen, str, len, NULL, NULL ); @@ -1619,7 +1630,7 @@ if ( bstrXML && bstr_to_utf8( bstrXML, &str, &len ) ) { xmldoc = doparse( str, len ); - HeapFree( GetProcessHeap(), 0, str ); + heap_free( str ); if ( !xmldoc ) This->error = E_FAIL; else @@ -2193,7 +2204,7 @@ { domdoc *doc; - doc = HeapAlloc( GetProcessHeap(), 0, sizeof (*doc) ); + doc = heap_alloc( sizeof (*doc) ); if( !doc ) return E_OUTOFMEMORY; Modified: trunk/reactos/dll/win32/msxml3/domimpl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/domimpl.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/domimpl.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/domimpl.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -89,7 +89,7 @@ ref = InterlockedDecrement( &This->ref ); if ( ref == 0 ) { - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -216,7 +216,7 @@ { domimpl *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); + This = heap_alloc( sizeof *This ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/element.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/element.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/element.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/element.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -502,7 +502,7 @@ len = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, NULL, 0 ); if (element->ns) len += MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->ns->prefix, -1, NULL, 0 ); - str = HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) ); + str = heap_alloc( len * sizeof (WCHAR) ); if ( !str ) return E_OUTOFMEMORY; if (element->ns) @@ -512,7 +512,7 @@ } MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) element->name, -1, str + offset, len - offset ); *p = SysAllocString( str ); - HeapFree( GetProcessHeap(), 0, str ); + heap_free( str ); return S_OK; } @@ -545,7 +545,7 @@ else xml_value = xmlGetNsProp(element, xml_name, NULL); - HeapFree(GetProcessHeap(), 0, xml_name); + heap_free(xml_name); if(xml_value) { V_VT(value) = VT_BSTR; @@ -587,8 +587,8 @@ if(!xmlSetNsProp(element, NULL, xml_name, xml_value)) hr = E_FAIL; - HeapFree(GetProcessHeap(), 0, xml_value); - HeapFree(GetProcessHeap(), 0, xml_name); + heap_free(xml_value); + heap_free(xml_name); VariantClear(&var); return hr; @@ -598,8 +598,19 @@ IXMLDOMElement *iface, BSTR p) { - FIXME("\n"); - return E_NOTIMPL; + domelem *This = impl_from_IXMLDOMElement( iface ); + IXMLDOMNamedNodeMap *attr; + HRESULT hr; + + TRACE("(%p)->(%s)", This, debugstr_w(p)); + + hr = IXMLDOMElement_get_attributes(iface, &attr); + if (hr != S_OK) return hr; + + hr = IXMLDOMNamedNodeMap_removeNamedItem(attr, p, NULL); + IXMLDOMNamedNodeMap_Release(attr); + + return hr; } static HRESULT WINAPI domelem_getAttributeNode( @@ -628,7 +639,7 @@ if(!xmlValidateNameValue(xml_name)) { - HeapFree(GetProcessHeap(), 0, xml_name); + heap_free(xml_name); return E_FAIL; } @@ -639,7 +650,7 @@ IUnknown_Release(unk); } - HeapFree(GetProcessHeap(), 0, xml_name); + heap_free(xml_name); return hr; } @@ -666,6 +677,8 @@ IXMLDOMElement *iface, BSTR bstrName, IXMLDOMNodeList** resultList) { + static const WCHAR xpathformat[] = + { '.','/','/','*','[','l','o','c','a','l','-','n','a','m','e','(',')','=','\'','%','s','\'',']',0 }; domelem *This = impl_from_IXMLDOMElement( iface ); LPWSTR szPattern; xmlNodePtr element; @@ -673,10 +686,19 @@ TRACE("(%p)->(%s,%p)\n", This, debugstr_w(bstrName), resultList); - szPattern = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(3+lstrlenW(bstrName)+1)); - szPattern[0] = '.'; - szPattern[1] = szPattern[2] = '/'; - lstrcpyW(szPattern+3, bstrName); + if (bstrName[0] == '*' && bstrName[1] == 0) + { + szPattern = heap_alloc(sizeof(WCHAR)*5); + szPattern[0] = '.'; + szPattern[1] = szPattern[2] = '/'; + szPattern[3] = '*'; + szPattern[4] = 0; + } + else + { + szPattern = heap_alloc(sizeof(WCHAR)*(21+lstrlenW(bstrName)+1)); + wsprintfW(szPattern, xpathformat, bstrName); + } TRACE("%s\n", debugstr_w(szPattern)); element = get_element(This); @@ -684,7 +706,7 @@ hr = E_FAIL; else hr = queryresult_create(element, szPattern, resultList); - HeapFree(GetProcessHeap(), 0, szPattern); + heap_free(szPattern); return hr; } @@ -768,7 +790,7 @@ { domelem *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); + This = heap_alloc( sizeof *This ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/entityref.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/entityref.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/entityref.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/entityref.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -94,7 +94,7 @@ if ( ref == 0 ) { destroy_xmlnode(&This->node); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -518,7 +518,7 @@ { entityref *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); + This = heap_alloc( sizeof *This ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/factory.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/factory.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/factory.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/factory.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -147,7 +147,8 @@ if( IsEqualCLSID( rclsid, &CLSID_DOMDocument ) || /* Version indep. v 2.x */ IsEqualCLSID( rclsid, &CLSID_DOMDocument2 ) || /* Version indep. v 3.0 */ - IsEqualCLSID( rclsid, &CLSID_DOMDocument30 ) ) /* Version dep. v 3.0 */ + IsEqualCLSID( rclsid, &CLSID_DOMDocument30 )|| /* Version dep. v 3.0 */ + IsEqualCLSID( rclsid, &CLSID_DOMDocument40 )) /* Version dep. v 4.0 */ { cf = (IClassFactory*) &domdoccf.lpVtbl; } Modified: trunk/reactos/dll/win32/msxml3/httprequest.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/httprequest.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/httprequest.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/httprequest.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -83,7 +83,7 @@ ref = InterlockedDecrement( &This->ref ); if ( ref == 0 ) { - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -317,7 +317,7 @@ TRACE("(%p,%p)\n", pUnkOuter, ppObj); - req = HeapAlloc( GetProcessHeap(), 0, sizeof (*req) ); + req = heap_alloc( sizeof (*req) ); if( !req ) return E_OUTOFMEMORY; Modified: trunk/reactos/dll/win32/msxml3/msxml_private.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/msxml_private.h?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/msxml_private.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/msxml_private.h [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -135,7 +135,7 @@ extern HRESULT xmldoc_add_orphan( xmlDocPtr doc, xmlNodePtr node ); extern HRESULT xmldoc_remove_orphan( xmlDocPtr doc, xmlNodePtr node ); -extern HRESULT XMLElement_create( IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj ); +extern HRESULT XMLElement_create( IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj, BOOL own ); extern xmlDocPtr parse_xml(char *ptr, int len); Modified: trunk/reactos/dll/win32/msxml3/node.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/node.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/node.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/node.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -130,7 +130,7 @@ ref = InterlockedDecrement( &This->ref ); if(!ref) { destroy_xmlnode(This); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -354,7 +354,7 @@ { str = xmlChar_from_wchar(V_BSTR(&string_value)); xmlNodeSetContent(This->node, str); - HeapFree(GetProcessHeap(),0,str); + heap_free(str); hr = S_OK; break; } @@ -920,7 +920,7 @@ /* Escape the string. */ str2 = xmlEncodeEntitiesReentrant(This->node->doc, str); - HeapFree(GetProcessHeap(), 0, str); + heap_free(str); xmlNodeSetContent(This->node, str2); xmlFree(str2); @@ -1284,7 +1284,7 @@ else ERR("Failed to Create Namepsace\n"); } - HeapFree( GetProcessHeap(), 0, str ); + heap_free( str ); } return hr; Modified: trunk/reactos/dll/win32/msxml3/nodelist.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/nodelist.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/nodelist.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/nodelist.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -104,7 +104,7 @@ if ( ref == 0 ) { xmldoc_release( This->parent->doc ); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -314,7 +314,7 @@ { xmlnodelist *nodelist; - nodelist = HeapAlloc( GetProcessHeap(), 0, sizeof *nodelist ); + nodelist = heap_alloc( sizeof *nodelist ); if ( !nodelist ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/nodemap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/nodemap.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/nodemap.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/nodemap.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -102,7 +102,7 @@ if ( ref == 0 ) { IXMLDOMNode_Release( This->node ); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -191,7 +191,7 @@ xmlChar *xmlstr; len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL ); - xmlstr = HeapAlloc( GetProcessHeap(), 0, len ); + xmlstr = heap_alloc( len ); if ( xmlstr ) WideCharToMultiByte( CP_UTF8, 0, str, -1, (LPSTR) xmlstr, len, NULL, NULL ); return xmlstr; @@ -218,7 +218,7 @@ element_name = xmlChar_from_wchar( name ); attr = xmlHasNsProp( node, element_name, NULL ); - HeapFree( GetProcessHeap(), 0, element_name ); + heap_free( element_name ); if ( !attr ) { @@ -303,7 +303,7 @@ element_name = xmlChar_from_wchar( name ); attr = xmlHasNsProp( node, element_name, NULL ); - HeapFree( GetProcessHeap(), 0, element_name ); + heap_free( element_name ); if ( !attr ) { @@ -531,7 +531,7 @@ { xmlnodemap *nodemap; - nodemap = HeapAlloc( GetProcessHeap(), 0, sizeof *nodemap ); + nodemap = heap_alloc( sizeof *nodemap ); if ( !nodemap ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/parseerror.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/parseerror.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/parseerror.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/parseerror.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -97,7 +97,7 @@ SysFreeString(This->url); SysFreeString(This->reason); SysFreeString(This->srcText); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -283,7 +283,7 @@ { parse_error_t *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof(*This) ); + This = heap_alloc( sizeof(*This) ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/pi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/pi.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/pi.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/pi.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -94,7 +94,7 @@ if ( ref == 0 ) { destroy_xmlnode(&This->node); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -604,7 +604,7 @@ { dom_pi *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); + This = heap_alloc( sizeof *This ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/queryresult.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/queryresult.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/queryresult.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/queryresult.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -413,7 +413,7 @@ IXMLDOMNodeList_Release( (IXMLDOMNodeList*) &This->lpVtbl ); if (ctxt != NULL) xmlXPathFreeContext(ctxt); - HeapFree(GetProcessHeap(), 0, str); + heap_free(str); return hr; } Modified: trunk/reactos/dll/win32/msxml3/regsvr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/regsvr.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/regsvr.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/regsvr.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -47,7 +47,7 @@ #include "wine/debug.h" #include "wine/unicode.h" -WINE_DEFAULT_DEBUG_CHANNEL(ole); +WINE_DEFAULT_DEBUG_CHANNEL(msxml); /* * Near the bottom of this file are the exported DllRegisterServer and @@ -702,7 +702,7 @@ }; /*********************************************************************** - * DllRegisterServer (OLEAUT32.@) + * DllRegisterServer (MSXML3.@) */ HRESULT WINAPI DllRegisterServer(void) { @@ -729,7 +729,7 @@ } /*********************************************************************** - * DllUnregisterServer (OLEAUT32.@) + * DllUnregisterServer (MSXML3.@) */ HRESULT WINAPI DllUnregisterServer(void) { Modified: trunk/reactos/dll/win32/msxml3/saxreader.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/saxreader.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/saxreader.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/saxreader.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -126,6 +126,11 @@ return (saxattributes *)((char*)iface - FIELD_OFFSET(saxattributes, lpSAXAttributesVtbl)); } +static inline BOOL has_content_handler(const saxlocator *locator) +{ + return (locator->vbInterface && locator->saxreader->vbcontentHandler) || + (!locator->vbInterface && locator->saxreader->contentHandler); +} static HRESULT namespacePush(saxlocator *locator, int ns) { @@ -161,13 +166,13 @@ dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, NULL, 0); if(len != -1) dLen++; - str = HeapAlloc(GetProcessHeap(), 0, dLen * sizeof (WCHAR)); + str = heap_alloc(dLen * sizeof (WCHAR)); if (!str) return NULL; MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, str, dLen); if(len != -1) str[dLen-1] = '\0'; bstr = SysAllocString(str); - HeapFree(GetProcessHeap(), 0, str); + heap_free(str); return bstr; } @@ -185,7 +190,7 @@ dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)prefix, -1, NULL, 0) + MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)name, -1, NULL, 0); - str = HeapAlloc(GetProcessHeap(), 0, dLen * sizeof(WCHAR)); + str = heap_alloc(dLen * sizeof(WCHAR)); if(!str) return NULL; @@ -194,7 +199,7 @@ MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)name, -1, &str[dLast], dLen-dLast); bstr = SysAllocString(str); - HeapFree(GetProcessHeap(), 0, str); + heap_free(str); return bstr; } @@ -624,12 +629,12 @@ SysFreeString(This->szQName[index]); } - HeapFree(GetProcessHeap(), 0, This->szLocalname); - HeapFree(GetProcessHeap(), 0, This->szURI); - HeapFree(GetProcessHeap(), 0, This->szValue); - HeapFree(GetProcessHeap(), 0, This->szQName); - - HeapFree(GetProcessHeap(), 0, This); + heap_free(This->szLocalname); + heap_free(This->szURI); + heap_free(This->szValue); + heap_free(This->szQName); + + heap_free(This); } return ref; @@ -914,7 +919,7 @@ int index; static const xmlChar xmlns[] = "xmlns"; - attributes = HeapAlloc(GetProcessHeap(), 0, sizeof(*attributes)); + attributes = heap_alloc(sizeof(*attributes)); if(!attributes) return E_OUTOFMEMORY; @@ -924,23 +929,19 @@ attributes->nb_attributes = nb_namespaces+nb_attributes; - attributes->szLocalname = - HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*attributes->nb_attributes); - attributes->szURI = - HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*attributes->nb_attributes); - attributes->szValue = - HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*attributes->nb_attributes); - attributes->szQName = - HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*attributes->nb_attributes); + attributes->szLocalname = heap_alloc(sizeof(BSTR)*attributes->nb_attributes); + attributes->szURI = heap_alloc(sizeof(BSTR)*attributes->nb_attributes); + attributes->szValue = heap_alloc(sizeof(BSTR)*attributes->nb_attributes); + attributes->szQName = heap_alloc(sizeof(BSTR)*attributes->nb_attributes); if(!attributes->szLocalname || !attributes->szURI || !attributes->szValue || !attributes->szQName) { - HeapFree(GetProcessHeap(), 0, attributes->szLocalname); - HeapFree(GetProcessHeap(), 0, attributes->szURI); - HeapFree(GetProcessHeap(), 0, attributes->szValue); - HeapFree(GetProcessHeap(), 0, attributes->szQName); - HeapFree(GetProcessHeap(), 0, attributes); + heap_free(attributes->szLocalname); + heap_free(attributes->szURI); + heap_free(attributes->szValue); + heap_free(attributes->szQName); + heap_free(attributes); return E_FAIL; } @@ -978,8 +979,7 @@ saxlocator *This = ctx; HRESULT hr; - if((This->vbInterface && This->saxreader->vbcontentHandler) - || (!This->vbInterface && This->saxreader->contentHandler)) + if(has_content_handler(This)) { if(This->vbInterface) hr = IVBSAXContentHandler_startDocument(This->saxreader->vbcontentHandler); @@ -1003,8 +1003,7 @@ if(This->ret != S_OK) return; - if((This->vbInterface && This->saxreader->vbcontentHandler) - || (!This->vbInterface && This->saxreader->contentHandler)) + if(has_content_handler(This)) { if(This->vbInterface) hr = IVBSAXContentHandler_endDocument(This->saxreader->vbcontentHandler); @@ -1039,8 +1038,7 @@ update_position(This, (xmlChar*)This->pParserCtxt->input->cur+1); hr = namespacePush(This, nb_namespaces); - if(hr==S_OK && ((This->vbInterface && This->saxreader->vbcontentHandler) - || (!This->vbInterface && This->saxreader->contentHandler))) + if(hr==S_OK && has_content_handler(This)) { for(index=0; index<nb_namespaces; index++) { @@ -1119,8 +1117,7 @@ nsNr = namespacePop(This); - if((This->vbInterface && This->saxreader->vbcontentHandler) - || (!This->vbInterface && This->saxreader->contentHandler)) + if(has_content_handler(This)) { NamespaceUri = bstr_from_xmlChar(URI); LocalName = bstr_from_xmlChar(localname); @@ -1186,9 +1183,7 @@ xmlChar *end; BOOL lastEvent = FALSE; - if((This->vbInterface && !This->saxreader->vbcontentHandler) - || (!This->vbInterface && !This->saxreader->contentHandler)) - return; + if(!(has_content_handler(This))) return; cur = (xmlChar*)ch; if(*(ch-1)=='\r') cur--; @@ -1320,7 +1315,7 @@ va_end(args); len = MultiByteToWideChar(CP_UNIXCP, 0, message, -1, NULL, 0); - wszError = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len); + wszError = heap_alloc(sizeof(WCHAR)*len); if(wszError) MultiByteToWideChar(CP_UNIXCP, 0, message, -1, wszError, len); @@ -1334,7 +1329,7 @@ ISAXErrorHandler_fatalError(This->saxreader->errorHandler, (ISAXLocator*)&This->lpSAXLocatorVtbl, wszError, E_FAIL); - HeapFree(GetProcessHeap(), 0, wszError); + heap_free(wszError); xmlStopParser(This->pParserCtxt); This->ret = E_FAIL; @@ -1384,8 +1379,7 @@ if(change) *end = '\n'; - if((This->vbInterface && This->saxreader->vbcontentHandler) || - (!This->vbInterface && This->saxreader->contentHandler)) + if(has_content_handler(This)) { Chars = bstr_from_xmlCharN(cur, end-cur+1); if(This->vbInterface) @@ -1645,10 +1639,10 @@ { SysFreeString(This->publicId); SysFreeString(This->systemId); - HeapFree(GetProcessHeap(), 0, This->nsStack); + heap_free(This->nsStack); ISAXXMLReader_Release((ISAXXMLReader*)&This->saxreader->lpSAXXMLReaderVtbl); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -1734,7 +1728,7 @@ { saxlocator *locator; - locator = HeapAlloc( GetProcessHeap(), 0, sizeof (*locator) ); + locator = heap_alloc( sizeof (*locator) ); if( !locator ) return E_OUTOFMEMORY; @@ -1755,11 +1749,11 @@ locator->ret = S_OK; locator->nsStackSize = 8; locator->nsStackLast = 0; - locator->nsStack = HeapAlloc(GetProcessHeap(), 0, locator->nsStackSize); + locator->nsStack = heap_alloc(locator->nsStackSize); if(!locator->nsStack) { ISAXXMLReader_Release((ISAXXMLReader*)&reader->lpSAXXMLReaderVtbl); - HeapFree(GetProcessHeap(), 0, locator); + heap_free(locator); return E_OUTOFMEMORY; } @@ -1787,6 +1781,7 @@ return E_FAIL; } + xmlFree(locator->pParserCtxt->sax); locator->pParserCtxt->sax = &locator->saxreader->sax; locator->pParserCtxt->userData = locator; @@ -1852,7 +1847,6 @@ } This->isParsing = FALSE; - locator->pParserCtxt->sax = NULL; xmlFreeParserCtxt(locator->pParserCtxt); locator->pParserCtxt = NULL; ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl); @@ -2045,6 +2039,7 @@ hr = internal_parseBuffer(This, (const char*)bstrData, SysStringByteLen(bstrData), vbInterface); IXMLDOMDocument_Release(xmlDoc); + SysFreeString(bstrData); break; } if(IUnknown_QueryInterface(V_UNKNOWN(&varInput), @@ -2315,7 +2310,7 @@ if(This->vbdeclHandler) IVBSAXDeclHandler_Release(This->vbdeclHandler); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -2810,7 +2805,7 @@ TRACE("(%p,%p)\n", pUnkOuter, ppObj); - reader = HeapAlloc( GetProcessHeap(), 0, sizeof (*reader) ); + reader = heap_alloc( sizeof (*reader) ); if( !reader ) return E_OUTOFMEMORY; Modified: trunk/reactos/dll/win32/msxml3/schema.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/schema.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/schema.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/schema.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -86,7 +86,7 @@ if ( ref == 0 ) { - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -233,7 +233,7 @@ HRESULT SchemaCache_create(IUnknown *pUnkOuter, LPVOID *ppObj) { - schema_t *schema = HeapAlloc( GetProcessHeap(), 0, sizeof (*schema) ); + schema_t *schema = heap_alloc( sizeof (*schema) ); if( !schema ) return E_OUTOFMEMORY; Modified: trunk/reactos/dll/win32/msxml3/text.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/text.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/text.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/text.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -103,7 +103,7 @@ if ( ref == 0 ) { destroy_xmlnode(&This->node); - HeapFree( GetProcessHeap(), 0, This ); + heap_free( This ); } return ref; @@ -605,7 +605,7 @@ hr = S_OK; else hr = E_FAIL; - HeapFree( GetProcessHeap(), 0, pContent ); + heap_free( pContent ); } else hr = E_FAIL; @@ -669,7 +669,7 @@ xmlNodeSetContent(This->node.node, str); hr = S_OK; } - HeapFree(GetProcessHeap(), 0, str); + heap_free(str); SysFreeString(sNewString); } @@ -686,8 +686,47 @@ IXMLDOMText *iface, LONG offset, LONG count) { - FIXME("\n"); - return E_NOTIMPL; + HRESULT hr; + LONG len = -1; + BSTR str; + + TRACE("%p %d %d\n", iface, offset, count); + + hr = IXMLDOMText_get_length(iface, &len); + if(hr != S_OK) return hr; + + if((offset < 0) || (offset > len) || (count < 0)) + return E_INVALIDARG; + + if(len == 0) return S_OK; + + /* cutting start or end */ + if((offset == 0) || ((count + offset) >= len)) + { + if(offset == 0) + IXMLDOMText_substringData(iface, count, len - count, &str); + else + IXMLDOMText_substringData(iface, 0, offset, &str); + hr = IXMLDOMText_put_data(iface, str); + } + else + /* cutting from the inside */ + { + BSTR str_end; + + IXMLDOMText_substringData(iface, 0, offset, &str); + IXMLDOMText_substringData(iface, offset + count, len - count, &str_end); + + hr = IXMLDOMText_put_data(iface, str); + if(hr == S_OK) + hr = IXMLDOMText_appendData(iface, str_end); + + SysFreeString(str_end); + } + + SysFreeString(str); + + return hr; } static HRESULT WINAPI domtext_replaceData( @@ -767,7 +806,7 @@ { domtext *This; - This = HeapAlloc( GetProcessHeap(), 0, sizeof *This ); + This = heap_alloc( sizeof *This ); if ( !This ) return NULL; Modified: trunk/reactos/dll/win32/msxml3/xmldoc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/xmldoc.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/xmldoc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/xmldoc.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -54,7 +54,6 @@ HRESULT error; /* IXMLDocument */ - IXMLElement *root; xmlDocPtr xmldoc; /* IPersistStream */ @@ -118,7 +117,7 @@ { xmlFreeDoc(This->xmldoc); if (This->stream) IStream_Release(This->stream); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); } return ref; @@ -198,17 +197,19 @@ static HRESULT WINAPI xmldoc_get_root(IXMLDocument *iface, IXMLElement **p) { xmldoc *This = impl_from_IXMLDocument(iface); + xmlNodePtr root; TRACE("(%p, %p)\n", iface, p); if (!p) return E_INVALIDARG; - *p = This->root; - if (!*p) + *p = NULL; + + if (!(root = xmlDocGetRootElement(This->xmldoc))) return E_FAIL; - return S_OK; + return XMLElement_create((IUnknown *)This, root, (LPVOID *)p, FALSE); } static HRESULT WINAPI xmldoc_get_fileSize(IXMLDocument *iface, BSTR *p) @@ -439,14 +440,32 @@ static HRESULT WINAPI xmldoc_get_version(IXMLDocument *iface, BSTR *p) { - FIXME("(%p, %p): stub\n", iface, p); - return E_NOTIMPL; + xmldoc *This = impl_from_IXMLDocument(iface); + + TRACE("(%p, %p)\n", This, p); + + if (!p) return E_INVALIDARG; + *p = bstr_from_xmlChar(This->xmldoc->version); + + return S_OK; } static HRESULT WINAPI xmldoc_get_doctype(IXMLDocument *iface, BSTR *p) { - FIXME("(%p, %p): stub\n", iface, p); - return E_NOTIMPL; + xmldoc *This = impl_from_IXMLDocument(iface); + xmlDtd *dtd; + + TRACE("(%p, %p)\n", This, p); + + if (!p) return E_INVALIDARG; + + dtd = xmlGetIntSubset(This->xmldoc); + if (!dtd) return S_FALSE; + + *p = bstr_from_xmlChar(dtd->name); + CharUpperBuffW(*p, SysStringLen(*p)); + + return S_OK; } static HRESULT WINAPI xmldoc_get_dtdURl(IXMLDocument *iface, BSTR *p) @@ -501,7 +520,7 @@ node->type = type_msxml_to_libxml(V_I4(&vType)); /* FIXME: create xmlNodePtr based on vType and var1 */ - return XMLElement_create((IUnknown *)iface, node, (LPVOID *)ppElem); + return XMLElement_create((IUnknown *)iface, node, (LPVOID *)ppElem, TRUE); } static const struct IXMLDocumentVtbl xmldoc_vtbl = @@ -556,8 +575,13 @@ static HRESULT WINAPI xmldoc_IPersistStreamInit_GetClassID( IPersistStreamInit *iface, CLSID *classid) { - FIXME("(%p,%p): stub!\n", iface, classid); - return E_NOTIMPL; + xmldoc *this = impl_from_IPersistStreamInit(iface); + TRACE("(%p,%p)\n", this, classid); + + if (!classid) return E_POINTER; + + *classid = CLSID_XMLDocument; + return S_OK; } static HRESULT WINAPI xmldoc_IPersistStreamInit_IsDirty( @@ -581,7 +605,6 @@ IPersistStreamInit *iface, LPSTREAM pStm) { xmldoc *This = impl_from_IPersistStreamInit(iface); - xmlNodePtr xmlnode; HRESULT hr; HGLOBAL hglobal; DWORD read, written, len; @@ -593,6 +616,8 @@ if (!pStm) return E_INVALIDARG; + /* release previously allocated stream */ + if (This->stream) IStream_Release(This->stream); hr = CreateStreamOnHGlobal(NULL, TRUE, &This->stream); if (FAILED(hr)) return hr; @@ -616,7 +641,10 @@ len = GlobalSize(hglobal); ptr = GlobalLock(hglobal); if (len != 0) + { + xmlFreeDoc(This->xmldoc); This->xmldoc = parse_xml(ptr, len); + } GlobalUnlock(hglobal); if (!This->xmldoc) @@ -625,8 +653,7 @@ return E_FAIL; } - xmlnode = xmlDocGetRootElement(This->xmldoc); - return XMLElement_create((IUnknown *)This, xmlnode, (LPVOID *)&This->root); + return S_OK; } static HRESULT WINAPI xmldoc_IPersistStreamInit_Save( @@ -639,15 +666,17 @@ static HRESULT WINAPI xmldoc_IPersistStreamInit_GetSizeMax( IPersistStreamInit *iface, ULARGE_INTEGER *pcbSize) { - FIXME("(%p, %p): stub!\n", iface, pcbSize); + xmldoc *This = impl_from_IPersistStreamInit(iface); + TRACE("(%p, %p)\n", This, pcbSize); return E_NOTIMPL; } static HRESULT WINAPI xmldoc_IPersistStreamInit_InitNew( IPersistStreamInit *iface) { - FIXME("(%p): stub!\n", iface); - return E_NOTIMPL; + xmldoc *This = impl_from_IPersistStreamInit(iface); + TRACE("(%p)\n", This); + return S_OK; } static const IPersistStreamInitVtbl xmldoc_IPersistStreamInit_VTable = @@ -669,7 +698,7 @@ TRACE("(%p,%p)\n", pUnkOuter, ppObj); - doc = HeapAlloc(GetProcessHeap(), 0, sizeof (*doc)); + doc = heap_alloc(sizeof (*doc)); if(!doc) return E_OUTOFMEMORY; @@ -677,7 +706,6 @@ doc->lpvtblIPersistStreamInit = &xmldoc_IPersistStreamInit_VTable; doc->ref = 1; doc->error = S_OK; - doc->root = NULL; doc->xmldoc = NULL; doc->stream = NULL; Modified: trunk/reactos/dll/win32/msxml3/xmlelem.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msxml3/xmlelem.c?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/dll/win32/msxml3/xmlelem.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msxml3/xmlelem.c [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -48,6 +48,7 @@ const IXMLElementVtbl *lpVtbl; LONG ref; xmlNodePtr node; + BOOL own; } xmlelem; static inline xmlelem *impl_from_IXMLElement(IXMLElement *iface) @@ -94,7 +95,8 @@ ref = InterlockedDecrement(&This->ref); if (ref == 0) { - HeapFree(GetProcessHeap(), 0, This); + if (This->own) xmlFreeNode(This->node); + heap_free(This); } return ref; @@ -171,31 +173,17 @@ return hr; } -static inline BSTR str_dup_upper(BSTR str) -{ - INT len = (lstrlenW(str) + 1) * sizeof(WCHAR); - BSTR p = SysAllocStringLen(NULL, len); - if (p) - { - memcpy(p, str, len); - CharUpperW(p); - } - return p; -} - static HRESULT WINAPI xmlelem_get_tagName(IXMLElement *iface, BSTR *p) { xmlelem *This = impl_from_IXMLElement(iface); - BSTR temp; TRACE("(%p, %p)\n", iface, p); if (!p) return E_INVALIDARG; - temp = bstr_from_xmlChar(This->node->name); - *p = str_dup_upper(temp); - SysFreeString(temp); + *p = bstr_from_xmlChar(This->node->name); + CharUpperBuffW(*p, SysStringLen(*p)); TRACE("returning %s\n", debugstr_w(*p)); @@ -226,7 +214,7 @@ if (!This->node->parent) return S_FALSE; - return XMLElement_create((IUnknown *)iface, This->node->parent, (LPVOID *)parent); + return XMLElement_create((IUnknown *)iface, This->node->parent, (LPVOID *)parent, FALSE); } static HRESULT WINAPI xmlelem_setAttribute(IXMLElement *iface, BSTR strPropertyName, @@ -245,8 +233,8 @@ value = xmlChar_from_wchar(V_BSTR(&PropertyValue)); attr = xmlSetProp(This->node, name, value); - HeapFree(GetProcessHeap(), 0, name); - HeapFree(GetProcessHeap(), 0, value); + heap_free(name); + heap_free(value); return (attr) ? S_OK : S_FALSE; } @@ -287,7 +275,7 @@ V_BSTR(PropertyValue) = bstr_from_xmlChar(val); } - HeapFree(GetProcessHeap(), 0, name); + heap_free(name); xmlFree(val); TRACE("returning %s\n", debugstr_w(V_BSTR(PropertyValue))); return (val) ? S_OK : S_FALSE; @@ -317,7 +305,7 @@ hr = S_OK; done: - HeapFree(GetProcessHeap(), 0, name); + heap_free(name); return hr; } @@ -330,7 +318,7 @@ if (!p) return E_INVALIDARG; - return XMLElementCollection_create((IUnknown *)iface, This->node->children, (LPVOID *)p); + return XMLElementCollection_create((IUnknown *)iface, This->node, (LPVOID *)p); } static LONG type_libxml_to_msxml(xmlElementType type) @@ -402,7 +390,7 @@ content = xmlChar_from_wchar(p); xmlNodeSetContent(This->node, content); - HeapFree( GetProcessHeap(), 0, content); + heap_free(content); return S_OK; } @@ -421,13 +409,31 @@ else child = xmlAddNextSibling(This->node, childElem->node->last); + /* parent is responsible for child data */ + if (child) childElem->own = FALSE; + return (child) ? S_OK : S_FALSE; } static HRESULT WINAPI xmlelem_removeChild(IXMLElement *iface, IXMLElement *pChildElem) { - FIXME("(%p, %p): stub\n", iface, pChildElem); - return E_NOTIMPL; + xmlelem *This = impl_from_IXMLElement(iface); + xmlelem *childElem = impl_from_IXMLElement(pChildElem); + + TRACE("(%p, %p)\n", This, childElem); + + if (!pChildElem) + return E_INVALIDARG; + + /* only supported for This is childElem parent case */ + if (This->node != childElem->node->parent) + return E_INVALIDARG; + + xmlUnlinkNode(childElem->node); + /* standalone element now */ + childElem->own = TRUE; + + return S_OK; } static const struct IXMLElementVtbl xmlelem_vtbl = @@ -453,7 +459,7 @@ xmlelem_removeChild }; -HRESULT XMLElement_create(IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj) +HRESULT XMLElement_create(IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj, BOOL own) { xmlelem *elem; @@ -464,13 +470,14 @@ *ppObj = NULL; - elem = HeapAlloc(GetProcessHeap(), 0, sizeof (*elem)); + elem = heap_alloc(sizeof (*elem)); if(!elem) return E_OUTOFMEMORY; elem->lpVtbl = &xmlelem_vtbl; elem->ref = 1; elem->node = node; + elem->own = own; *ppObj = &elem->lpVtbl; @@ -493,6 +500,19 @@ xmlNodePtr current; } xmlelem_collection; +static inline LONG xmlelem_collection_updatelength(xmlelem_collection *collection) +{ + xmlNodePtr ptr = collection->node->children; + + collection->length = 0; + while (ptr) + { + collection->length++; + ptr = ptr->next; + } + return collection->length; +} + static inline xmlelem_collection *impl_from_IXMLElementCollection(IXMLElementCollection *iface) { return (xmlelem_collection *)((char*)iface - FIELD_OFFSET(xmlelem_collection, lpVtbl)); @@ -546,7 +566,7 @@ ref = InterlockedDecrement(&This->ref); if (ref == 0) { - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); } return ref; @@ -597,7 +617,7 @@ if (!p) return E_INVALIDARG; - *p = This->length; + *p = xmlelem_collection_updatelength(This); return S_OK; } @@ -619,7 +639,7 @@ VARIANT var2, IDispatch **ppDisp) { xmlelem_collection *This = impl_from_IXMLElementCollection(iface); - xmlNodePtr ptr = This->node; + xmlNodePtr ptr = This->node->children; int index, i; TRACE("(%p, %p)\n", iface, ppDisp); @@ -632,13 +652,15 @@ index = V_I4(&var1); if (index < 0) return E_INVALIDARG; + + xmlelem_collection_updatelength(This); if (index >= This->length) return E_FAIL; for (i = 0; i < index; i++) ptr = ptr->next; - return XMLElement_create((IUnknown *)iface, ptr, (LPVOID *)ppDisp); + return XMLElement_create((IUnknown *)iface, ptr, (LPVOID *)ppDisp, FALSE); } static const struct IXMLElementCollectionVtbl xmlelem_collection_vtbl = @@ -698,7 +720,7 @@ This->current = This->current->next; V_VT(rgVar) = VT_DISPATCH; - return XMLElement_create((IUnknown *)iface, ptr, (LPVOID *)&V_DISPATCH(rgVar)); + return XMLElement_create((IUnknown *)iface, ptr, (LPVOID *)&V_DISPATCH(rgVar), FALSE); } static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Skip( @@ -712,7 +734,7 @@ IEnumVARIANT *iface) { xmlelem_collection *This = impl_from_IEnumVARIANT(iface); - This->current = This->node; + This->current = This->node->children; return S_OK; } @@ -737,16 +759,15 @@ static HRESULT XMLElementCollection_create(IUnknown *pUnkOuter, xmlNodePtr node, LPVOID *ppObj) { xmlelem_collection *collection; - xmlNodePtr ptr; TRACE("(%p,%p)\n", pUnkOuter, ppObj); *ppObj = NULL; - if (!node) + if (!node->children) return S_FALSE; - collection = HeapAlloc(GetProcessHeap(), 0, sizeof (*collection)); + collection = heap_alloc(sizeof (*collection)); if(!collection) return E_OUTOFMEMORY; @@ -755,14 +776,8 @@ collection->ref = 1; collection->length = 0; collection->node = node; - collection->current = node; - - ptr = node; - while (ptr) - { - collection->length++; - ptr = ptr->next; - } + collection->current = node->children; + xmlelem_collection_updatelength(collection); *ppObj = &collection->lpVtbl; Modified: trunk/reactos/include/psdk/msxml2.idl URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/msxml2.idl?rev=45470&r1=45469&r2=45470&view=diff ============================================================================== --- trunk/reactos/include/psdk/msxml2.idl [iso-8859-1] (original) +++ trunk/reactos/include/psdk/msxml2.idl [iso-8859-1] Sat Feb 6 22:34:28 2010 @@ -1070,6 +1070,14 @@ [default, source] dispinterface XMLDOMDocumentEvents; } +[ + uuid(88d969c0-f192-11d4-a65f-0040963251e5) +] +coclass DOMDocument40 +{ + [default] interface IXMLDOMDocument2; + [default, source] dispinterface XMLDOMDocumentEvents; +} [ uuid(F6D90F12-9C73-11D3-B32E-00C04F990BB4)