From 247b11e046d666cf1614348ea227efc262cfff57 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 25 Feb 2010 15:22:52 +0100 Subject: [PATCH] oleaut32: Added ITypeLib2_GetDocumentation implementation. --- dlls/oleaut32/tests/typelib.c | 26 +++++++++++ dlls/oleaut32/typelib2.c | 88 +++++++++++++++++++++++++++++++++-- 2 files changed, 111 insertions(+), 3 deletions(-) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 1582bb2521f..40423f38f4d 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -970,6 +970,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 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 coclassW[] = {'c','o','c','l','a','s','s',0}; @@ -994,6 +995,8 @@ static void test_CreateTypeLib(void) { TYPEATTR *typeattr; TLIBATTR *libattr; HREFTYPE hreftype; + BSTR name, docstring, helpfile; + DWORD helpcontext; int impltypeflags; HRESULT hres; @@ -1024,6 +1027,29 @@ static void test_CreateTypeLib(void) { ITypeLib_ReleaseTLibAttr(tl, libattr); + name = (BSTR)0xdeadbeef; + hres = ITypeLib_GetDocumentation(tl, -1, &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 == 0, "helpcontext != 0\n"); + ok(helpfile == NULL, "helpfile != NULL\n"); + + hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL); + ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres); + + hres = ICreateTypeLib_SetName(createtl, typelibW); + 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); + ok(hres == S_OK, "got %08x\n", hres); + ok(!memcmp(name, typelibW, sizeof(typelibW)), "name = %s\n", wine_dbgstr_w(name)); + + SysFreeString(name); + ITypeLib_Release(tl); hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti); diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index 0f7f18bcf25..ca4bda76546 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -395,6 +395,27 @@ static int ctl2_encode_name( return (length + 7) & ~3; } +/**************************************************************************** + * ctl2_decode_name + * + * Converts string stored in typelib data to unicode. + */ +static void ctl2_decode_name( + char *data, /* [I] String to be decoded */ + WCHAR **string) /* [O] Decoded string */ +{ + int i, length; + static WCHAR converted_string[0x104]; + + length = data[0]; + + for(i=0; i>= 2; for(i=0; itypeinfos; iter!=NULL && index!=0; iter=iter->next_typeinfo) + index--; + + if(!iter) + return TYPE_E_ELEMENTNOTFOUND; + + return ITypeInfo_GetDocumentation((ITypeInfo*)iter->lpVtblTypeInfo2, + -1, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile); + } + + if(pBstrName) { + if(This->typelib_header.NameOffset == -1) + *pBstrName = NULL; + else { + MSFT_NameIntro *name = (MSFT_NameIntro*)&This-> + typelib_segment_data[MSFT_SEG_NAME][This->typelib_header.NameOffset]; + + ctl2_decode_name((char*)&name->namelen, &string); + + *pBstrName = SysAllocString(string); + if(!*pBstrName) + return E_OUTOFMEMORY; + } + } + + if(pBstrDocString) { + if(This->typelib_header.helpstring == -1) + *pBstrDocString = NULL; + else { + ctl2_decode_string(&This->typelib_segment_data[MSFT_SEG_STRING][This->typelib_header.helpstring], &string); + + *pBstrDocString = SysAllocString(string); + if(!*pBstrDocString) { + if(pBstrName) SysFreeString(*pBstrName); + return E_OUTOFMEMORY; + } + } + } + + if(pdwHelpContext) + *pdwHelpContext = This->typelib_header.helpcontext; + + if(pBstrHelpFile) { + if(This->typelib_header.helpfile == -1) + *pBstrHelpFile = NULL; + else { + ctl2_decode_string(&This->typelib_segment_data[MSFT_SEG_STRING][This->typelib_header.helpfile], &string); + + *pBstrHelpFile = SysAllocString(string); + if(!*pBstrHelpFile) { + if(pBstrName) SysFreeString(*pBstrName); + if(pBstrDocString) SysFreeString(*pBstrDocString); + return E_OUTOFMEMORY; + } + } + } + + return S_OK; } /******************************************************************************