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)
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");
return E_FAIL;
......
......@@ -131,7 +131,9 @@ struct domdoc
domdoc_properties* properties;
HRESULT error;
/* IObjectWithSite*/
WCHAR *url;
/* IObjectWithSite */
IUnknown *site;
/* IObjectSafety */
......@@ -946,6 +948,7 @@ static ULONG WINAPI domdoc_Release( IXMLDOMDocument3 *iface )
for (eid = 0; eid < EVENTID_LAST; eid++)
if (This->events[eid]) IDispatch_Release(This->events[eid]);
CoTaskMemFree(This->url);
release_namespaces(This);
heap_free(This);
}
......@@ -2199,10 +2202,15 @@ static HRESULT WINAPI domdoc_load(
{
IMoniker *mon;
CoTaskMemFree(This->url);
This->url = NULL;
hr = create_moniker_from_url( filename, &mon);
if ( SUCCEEDED(hr) )
{
hr = domdoc_load_moniker( This, mon );
if (hr == S_OK)
IMoniker_GetDisplayName(mon, NULL, NULL, &This->url);
IMoniker_Release(mon);
}
......@@ -2265,11 +2273,25 @@ static HRESULT WINAPI domdoc_get_parseError(
static HRESULT WINAPI domdoc_get_url(
IXMLDOMDocument3 *iface,
BSTR* urlString )
BSTR* url )
{
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)
doc->safeopt = 0;
doc->cp_list = NULL;
doc->namespaces = NULL;
doc->url = NULL;
memset(doc->events, 0, sizeof(doc->events));
/* events connection points */
......
......@@ -1258,6 +1258,11 @@ if (0)
ok( b == VARIANT_FALSE, "succeeded in loading XML string\n");
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 */
b = VARIANT_TRUE;
str = SysAllocString( szEmpty );
......@@ -9583,6 +9588,11 @@ static void test_load(void)
EXPECT_HR(hr, S_OK);
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 */
V_VT(&src) = VT_BSTR | VT_BYREF;
V_BSTRREF(&src) = &path;
......@@ -9590,6 +9600,11 @@ static void test_load(void)
EXPECT_HR(hr, S_OK);
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 */
V_VT(&src) = VT_BSTR | VT_BYREF;
V_BSTRREF(&src) = NULL;
......@@ -9597,6 +9612,11 @@ static void test_load(void)
EXPECT_HR(hr, E_INVALIDARG);
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");
/* load from existing path, no xml content */
......@@ -9609,6 +9629,11 @@ static void test_load(void)
ok(hr == S_FALSE, "got 0x%08x\n", hr);
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");
IXMLDOMDocument_Release(doc);
......@@ -11737,6 +11762,25 @@ static void test_create_attribute(void)
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)
{
HRESULT hr;
......@@ -11815,6 +11859,7 @@ START_TEST(domdoc)
test_putref_schemas();
test_namedmap_newenum();
test_xmlns_attribute();
test_url();
test_xsltemplate();
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