Commit e0344e1a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Implement url() property of IXMLDOMDocument.

parent 61c8a4e6
...@@ -259,7 +259,7 @@ HRESULT create_moniker_from_url(LPCWSTR url, IMoniker **mon) ...@@ -259,7 +259,7 @@ HRESULT create_moniker_from_url(LPCWSTR url, IMoniker **mon)
return E_FAIL; return E_FAIL;
} }
if(FAILED(UrlCreateFromPathW(url, fileUrl, &needed, 0))) if(FAILED(UrlCreateFromPathW(fullpath, fileUrl, &needed, 0)))
{ {
ERR("can't create url from path\n"); ERR("can't create url from path\n");
return E_FAIL; return E_FAIL;
......
...@@ -131,7 +131,9 @@ struct domdoc ...@@ -131,7 +131,9 @@ struct domdoc
domdoc_properties* properties; domdoc_properties* properties;
HRESULT error; HRESULT error;
/* IObjectWithSite*/ WCHAR *url;
/* IObjectWithSite */
IUnknown *site; IUnknown *site;
/* IObjectSafety */ /* IObjectSafety */
...@@ -946,6 +948,7 @@ static ULONG WINAPI domdoc_Release( IXMLDOMDocument3 *iface ) ...@@ -946,6 +948,7 @@ static ULONG WINAPI domdoc_Release( IXMLDOMDocument3 *iface )
for (eid = 0; eid < EVENTID_LAST; eid++) for (eid = 0; eid < EVENTID_LAST; eid++)
if (This->events[eid]) IDispatch_Release(This->events[eid]); if (This->events[eid]) IDispatch_Release(This->events[eid]);
CoTaskMemFree(This->url);
release_namespaces(This); release_namespaces(This);
heap_free(This); heap_free(This);
} }
...@@ -2199,10 +2202,15 @@ static HRESULT WINAPI domdoc_load( ...@@ -2199,10 +2202,15 @@ static HRESULT WINAPI domdoc_load(
{ {
IMoniker *mon; IMoniker *mon;
CoTaskMemFree(This->url);
This->url = NULL;
hr = create_moniker_from_url( filename, &mon); hr = create_moniker_from_url( filename, &mon);
if ( SUCCEEDED(hr) ) if ( SUCCEEDED(hr) )
{ {
hr = domdoc_load_moniker( This, mon ); hr = domdoc_load_moniker( This, mon );
if (hr == S_OK)
IMoniker_GetDisplayName(mon, NULL, NULL, &This->url);
IMoniker_Release(mon); IMoniker_Release(mon);
} }
...@@ -2265,11 +2273,25 @@ static HRESULT WINAPI domdoc_get_parseError( ...@@ -2265,11 +2273,25 @@ static HRESULT WINAPI domdoc_get_parseError(
static HRESULT WINAPI domdoc_get_url( static HRESULT WINAPI domdoc_get_url(
IXMLDOMDocument3 *iface, IXMLDOMDocument3 *iface,
BSTR* urlString ) BSTR* url )
{ {
domdoc *This = impl_from_IXMLDOMDocument3(iface); domdoc *This = impl_from_IXMLDOMDocument3(iface);
FIXME("(%p)->(%p)\n", This, urlString);
return E_NOTIMPL; TRACE("(%p)->(%p)\n", This, url);
if (!url)
return E_INVALIDARG;
if (This->url)
{
*url = SysAllocString(This->url);
if (!*url)
return E_OUTOFMEMORY;
return S_OK;
}
else
return return_null_bstr(url);
} }
...@@ -3546,6 +3568,7 @@ HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document) ...@@ -3546,6 +3568,7 @@ HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document)
doc->safeopt = 0; doc->safeopt = 0;
doc->cp_list = NULL; doc->cp_list = NULL;
doc->namespaces = NULL; doc->namespaces = NULL;
doc->url = NULL;
memset(doc->events, 0, sizeof(doc->events)); memset(doc->events, 0, sizeof(doc->events));
/* events connection points */ /* events connection points */
......
...@@ -1258,6 +1258,11 @@ if (0) ...@@ -1258,6 +1258,11 @@ if (0)
ok( b == VARIANT_FALSE, "succeeded in loading XML string\n"); ok( b == VARIANT_FALSE, "succeeded in loading XML string\n");
SysFreeString( str ); SysFreeString( str );
str = (BSTR)0x1;
hr = IXMLDOMDocument_get_url(doc, &str);
ok(hr == S_FALSE, "got 0x%08x\n", hr);
ok(str == NULL, "got %p\n", str);
/* try load an empty document */ /* try load an empty document */
b = VARIANT_TRUE; b = VARIANT_TRUE;
str = SysAllocString( szEmpty ); str = SysAllocString( szEmpty );
...@@ -9583,6 +9588,11 @@ static void test_load(void) ...@@ -9583,6 +9588,11 @@ static void test_load(void)
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
ok(b == VARIANT_TRUE, "got %d\n", b); ok(b == VARIANT_TRUE, "got %d\n", b);
bstr1 = NULL;
hr = IXMLDOMDocument_get_url(doc, &bstr1);
ok(hr == S_OK, "got 0x%08x\n", hr);
SysFreeString(bstr1);
/* load from a path: VT_BSTR|VT_BYREF */ /* load from a path: VT_BSTR|VT_BYREF */
V_VT(&src) = VT_BSTR | VT_BYREF; V_VT(&src) = VT_BSTR | VT_BYREF;
V_BSTRREF(&src) = &path; V_BSTRREF(&src) = &path;
...@@ -9590,6 +9600,11 @@ static void test_load(void) ...@@ -9590,6 +9600,11 @@ static void test_load(void)
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
ok(b == VARIANT_TRUE, "got %d\n", b); ok(b == VARIANT_TRUE, "got %d\n", b);
bstr1 = NULL;
hr = IXMLDOMDocument_get_url(doc, &bstr1);
ok(hr == S_OK, "got 0x%08x\n", hr);
SysFreeString(bstr1);
/* load from a path: VT_BSTR|VT_BYREF, null ptr */ /* load from a path: VT_BSTR|VT_BYREF, null ptr */
V_VT(&src) = VT_BSTR | VT_BYREF; V_VT(&src) = VT_BSTR | VT_BYREF;
V_BSTRREF(&src) = NULL; V_BSTRREF(&src) = NULL;
...@@ -9597,6 +9612,11 @@ static void test_load(void) ...@@ -9597,6 +9612,11 @@ static void test_load(void)
EXPECT_HR(hr, E_INVALIDARG); EXPECT_HR(hr, E_INVALIDARG);
ok(b == VARIANT_FALSE, "got %d\n", b); ok(b == VARIANT_FALSE, "got %d\n", b);
bstr1 = NULL;
hr = IXMLDOMDocument_get_url(doc, &bstr1);
ok(hr == S_OK, "got 0x%08x\n", hr);
SysFreeString(bstr1);
DeleteFileA("test.xml"); DeleteFileA("test.xml");
/* load from existing path, no xml content */ /* load from existing path, no xml content */
...@@ -9609,6 +9629,11 @@ static void test_load(void) ...@@ -9609,6 +9629,11 @@ static void test_load(void)
ok(hr == S_FALSE, "got 0x%08x\n", hr); ok(hr == S_FALSE, "got 0x%08x\n", hr);
ok(b == VARIANT_FALSE, "got %d\n", b); ok(b == VARIANT_FALSE, "got %d\n", b);
bstr1 = (BSTR)0x1;
hr = IXMLDOMDocument_get_url(doc, &bstr1);
ok(hr == S_FALSE, "got 0x%08x\n", hr);
ok(bstr1 == NULL, "got %p\n", bstr1);
DeleteFileA("test.xml"); DeleteFileA("test.xml");
IXMLDOMDocument_Release(doc); IXMLDOMDocument_Release(doc);
...@@ -11737,6 +11762,25 @@ static void test_create_attribute(void) ...@@ -11737,6 +11762,25 @@ static void test_create_attribute(void)
free_bstrs(); free_bstrs();
} }
static void test_url(void)
{
IXMLDOMDocument *doc;
HRESULT hr;
BSTR s;
doc = create_document(&IID_IXMLDOMDocument);
hr = IXMLDOMDocument_get_url(doc, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
s = (BSTR)0x1;
hr = IXMLDOMDocument_get_url(doc, &s);
ok(hr == S_FALSE, "got 0x%08x\n", hr);
ok(s == NULL, "got %s\n", wine_dbgstr_w(s));
IXMLDOMDocument_Release(doc);
}
START_TEST(domdoc) START_TEST(domdoc)
{ {
HRESULT hr; HRESULT hr;
...@@ -11815,6 +11859,7 @@ START_TEST(domdoc) ...@@ -11815,6 +11859,7 @@ START_TEST(domdoc)
test_putref_schemas(); test_putref_schemas();
test_namedmap_newenum(); test_namedmap_newenum();
test_xmlns_attribute(); test_xmlns_attribute();
test_url();
test_xsltemplate(); test_xsltemplate();
test_xsltext(); test_xsltext();
......
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