Commit 57c784e2 authored by Andrey Turkin's avatar Andrey Turkin Committed by Alexandre Julliard

oleaut32: Implement ITypeInfo::GetDocumentation.

parent 636e35d8
......@@ -973,6 +973,7 @@ if(use_midl_tlb) {
static void test_CreateTypeLib(void) {
static const WCHAR stdoleW[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
static OLECHAR typelibW[] = {'t','y','p','e','l','i','b',0};
static OLECHAR helpfileW[] = {'C',':','\\','b','o','g','u','s','.','h','l','p',0};
static OLECHAR interface1W[] = {'i','n','t','e','r','f','a','c','e','1',0};
static OLECHAR interface2W[] = {'i','n','t','e','r','f','a','c','e','2',0};
static OLECHAR interface3W[] = {'i','n','t','e','r','f','a','c','e','3',0};
......@@ -1052,16 +1053,19 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeLib_SetName(createtl, typelibW);
ok(hres == S_OK, "got %08x\n", hres);
hres = ICreateTypeLib_SetHelpFileName(createtl, helpfileW);
ok(hres == S_OK, "got %08x\n", hres);
hres = ITypeLib_GetDocumentation(tl, -1, NULL, NULL, NULL, NULL);
ok(hres == S_OK, "got %08x\n", hres);
hres = ITypeLib_GetDocumentation(tl, -1, &name, NULL, NULL, NULL);
hres = ITypeLib_GetDocumentation(tl, -1, &name, NULL, NULL, &helpfile);
ok(hres == S_OK, "got %08x\n", hres);
ok(!memcmp(name, typelibW, sizeof(typelibW)), "name = %s\n", wine_dbgstr_w(name));
ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
SysFreeString(name);
ITypeLib_Release(tl);
SysFreeString(helpfile);
hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
ok(hres == S_OK, "got %08x\n", hres);
......@@ -1069,9 +1073,33 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface1);
ok(hres == S_OK, "got %08x\n", hres);
hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL);
ok(hres == S_OK, "got %08x\n", hres);
ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
SysFreeString(name);
ITypeLib_Release(tl);
name = (BSTR)0xdeadbeef;
helpfile = (BSTR)0xdeadbeef;
hres = ITypeInfo_GetDocumentation(interface1, -1, &name, &docstring, &helpcontext, &helpfile);
ok(hres == S_OK, "got %08x\n", hres);
ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
ok(docstring == NULL, "docstring != NULL\n");
ok(helpcontext == 0, "helpcontext != 0\n");
ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
SysFreeString(name);
SysFreeString(helpfile);
hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
hres = ITypeInfo_GetRefTypeInfo(interface1, 0, NULL);
ok(hres == E_INVALIDARG, "got %08x\n", hres);
hres = ICreateTypeInfo_LayOut(createti);
ok(hres == S_OK, "got %08x\n", hres);
......@@ -1212,6 +1240,15 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
ok(hres == S_OK, "got %08x\n", hres);
hres = ITypeInfo_GetDocumentation(interface1, 0, &name, &docstring, &helpcontext, &helpfile);
ok(hres == S_OK, "got %08x\n", hres);
ok(name == NULL, "name != NULL\n");
ok(docstring == NULL, "docstring != NULL\n");
ok(helpcontext == 0x201, "helpcontext != 0x201\n");
ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
SysFreeString(helpfile);
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, NULL, 1);
ok(hres == E_INVALIDARG, "got %08x\n", hres);
......@@ -1227,6 +1264,12 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 1);
ok(hres == S_OK, "got %08x\n", hres);
hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
ok(hres == S_OK, "got %08x\n", hres);
ok(!memcmp(name, func1W, sizeof(func1W)), "name = %s\n", wine_dbgstr_w(name));
SysFreeString(name);
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names2, 3);
ok(hres == S_OK, "got %08x\n", hres);
......
......@@ -3163,8 +3163,83 @@ static HRESULT WINAPI ITypeInfo2_fnGetDocumentation(
DWORD* pdwHelpContext,
BSTR* pBstrHelpFile)
{
FIXME("(%p,%d,%p,%p,%p,%p), stub!\n", iface, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
return E_OUTOFMEMORY;
ICreateTypeInfo2Impl *This = impl_from_ITypeInfo2(iface);
HRESULT status = TYPE_E_ELEMENTNOTFOUND;
INT nameoffset, docstringoffset, helpcontext;
TRACE("(%p,%d,%p,%p,%p,%p)\n", iface, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
if (memid == -1)
{
nameoffset = This->typeinfo->NameOffset;
docstringoffset = This->typeinfo->docstringoffs;
helpcontext = This->typeinfo->helpcontext;
status = S_OK;
} else {
CyclicList *iter;
if (This->typedata) {
for(iter=This->typedata->next->next; iter!=This->typedata->next; iter=iter->next) {
if (iter->indice == memid) {
const int *typedata = iter->u.data;
int size = typedata[0] - typedata[5]*(typedata[4]&0x1000?16:12);
nameoffset = iter->name;
/* FIXME implement this once SetFuncDocString is implemented */
docstringoffset = -1;
helpcontext = (size < 7*sizeof(int)) ? 0 : typedata[6];
status = S_OK;
break;
}
}
}
}
if (!status) {
WCHAR *string;
if (pBstrName) {
if (nameoffset == -1)
*pBstrName = NULL;
else {
MSFT_NameIntro *name = (MSFT_NameIntro*)&This->typelib->
typelib_segment_data[MSFT_SEG_NAME][nameoffset];
ctl2_decode_name((char*)&name->namelen, &string);
*pBstrName = SysAllocString(string);
if(!*pBstrName)
return E_OUTOFMEMORY;
}
}
if (pBstrDocString) {
if (docstringoffset == -1)
*pBstrDocString = NULL;
else {
MSFT_NameIntro *name = (MSFT_NameIntro*)&This->typelib->
typelib_segment_data[MSFT_SEG_NAME][docstringoffset];
ctl2_decode_name((char*)&name->namelen, &string);
*pBstrDocString = SysAllocString(string);
if(!*pBstrDocString) {
if (pBstrName) SysFreeString(*pBstrName);
return E_OUTOFMEMORY;
}
}
}
if (pdwHelpContext) {
*pdwHelpContext = helpcontext;
}
if (pBstrHelpFile) {
status = ITypeLib_GetDocumentation((ITypeLib*)&This->typelib->lpVtblTypeLib2,
-1, NULL, NULL, NULL, pBstrHelpFile);
if (status) {
if (pBstrName) SysFreeString(*pBstrName);
if (pBstrDocString) SysFreeString(*pBstrDocString);
}
}
}
return status;
}
/******************************************************************************
......@@ -4549,7 +4624,7 @@ static HRESULT WINAPI ITypeLib2_fnGetDocumentation(
if(!iter)
return TYPE_E_ELEMENTNOTFOUND;
return ITypeInfo_GetDocumentation((ITypeInfo*)iter->lpVtblTypeInfo2,
return ITypeInfo_GetDocumentation((ITypeInfo*)&iter->lpVtblTypeInfo2,
-1, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
}
......
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