Update of /cvsroot/oorexx/oorexx/platform/windows/ole
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8892
Modified Files:
orexxole.c
Log Message:
1149952 - improvements to OLEObject type resolution.
Index: orexxole.c
===================================================================
RCS file: /cvsroot/oorexx/oorexx/platform/windows/ole/orexxole.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** orexxole.c 29 Aug 2006 10:38:19 -0000 1.6
--- orexxole.c 4 Sep 2006 12:25:55 -0000 1.7
***************
*** 573,604 ****
LPOLESTR lpAnsiToUnicode(LPCSTR pszA, int iInputLength)
{
! int iNewLength;
! LPOLESTR lpOleStr = NULL;
!
! // if this is the empty string, the input to the cbMultiByte parameter of
! // MultiByteToWideChar must be -1. If 0 the function is documented to fail.
! if (iInputLength == 0 && pszA && *pszA == 0)
! {
! iInputLength = -1;
!
! }
!
! iNewLength = MultiByteToWideChar( CP_ACP, 0, pszA, iInputLength, NULL, 0 );
!
! if ( iNewLength )
! {
! lpOleStr = (LPOLESTR) ORexxOleAlloc(iNewLength * 2 + 2);
! if (lpOleStr)
! {
! if ( MultiByteToWideChar( CP_ACP, 0, pszA, iInputLength, lpOleStr, iNewLength ) == 0)
! {
! /* conversion failed */
! ORexxOleFree(lpOleStr);
! lpOleStr = NULL;
! } /* endif */
! } /* endif */
! } /* endif */
!
! return lpOleStr;
}
--- 573,577 ----
LPOLESTR lpAnsiToUnicode(LPCSTR pszA, int iInputLength)
{
! return lpAnsiToUnicodeLength(pszA, iInputLength, NULL);
}
***************
*** 608,629 ****
int iNewLength;
LPOLESTR lpOleStr = NULL;
- *outLength = 0;
! iNewLength = MultiByteToWideChar( CP_ACP, 0, pszA, iInputLength, NULL, 0 );
!
! if ( iNewLength )
{
! lpOleStr = (LPOLESTR) ORexxOleAlloc(iNewLength * 2 + 2);
! if (lpOleStr)
{
! if ( MultiByteToWideChar( CP_ACP, 0, pszA, iInputLength, lpOleStr, iNewLength ) == 0)
{
! /* conversion failed */
! ORexxOleFree(lpOleStr);
! lpOleStr = NULL;
} /* endif */
- *outLength = iNewLength;
} /* endif */
! } /* endif */
return lpOleStr;
--- 581,614 ----
int iNewLength;
LPOLESTR lpOleStr = NULL;
! /* Special case the empty string, MultiByteToWideChar does not handle */
! /* an input length of 0. Create a true Unicode empty string. */
! if ( iInputLength == 0 && pszA && *pszA == 0 )
{
! lpOleStr = (LPOLESTR) ORexxOleAlloc(2);
! if ( outLength )
! *outLength = 0;
! }
! else
! {
! iNewLength = MultiByteToWideChar( CP_ACP, 0, pszA, iInputLength, NULL, 0 );
!
! if ( iNewLength )
{
! lpOleStr = (LPOLESTR) ORexxOleAlloc(iNewLength * 2 + 2);
! if (lpOleStr)
{
! if ( MultiByteToWideChar( CP_ACP, 0, pszA, iInputLength, lpOleStr, iNewLength ) == 0)
! {
! /* conversion failed */
! ORexxOleFree(lpOleStr);
! lpOleStr = NULL;
! } /* endif */
!
! if ( outLength )
! *outLength = iNewLength;
} /* endif */
} /* endif */
! } /* endelse */
return lpOleStr;
***************
*** 1780,1784 ****
BOOL fExploreTypeInfo( ITypeInfo *pTypeInfo, POLECLASSINFO pClsInfo )
{
! BOOL fOk = TRUE;
HRESULT hResult;
ITypeLib *pTypeLib = NULL;
--- 1765,1769 ----
BOOL fExploreTypeInfo( ITypeInfo *pTypeInfo, POLECLASSINFO pClsInfo )
{
! BOOL fOk = FALSE;
HRESULT hResult;
ITypeLib *pTypeLib = NULL;
***************
*** 1786,1793 ****
TYPEATTR *pTypeAttr;
INT j;
! unsigned int uTypeLibIndex = 0;
GUID typeGUID;
POLECONSTINFO cachedInfo;
/* at first get associated type info */
hResult = pTypeInfo->GetTypeAttr(&pTypeAttr);
--- 1771,1779 ----
TYPEATTR *pTypeAttr;
INT j;
! unsigned int iTypeIndex = 0;
GUID typeGUID;
POLECONSTINFO cachedInfo;
+ /* get containing type library / index of type description for this type. */
/* at first get associated type info */
hResult = pTypeInfo->GetTypeAttr(&pTypeAttr);
***************
*** 1801,1819 ****
/* now get info from all type info blocks in type library */
! hResult = pTypeInfo->GetContainingTypeLib(&pTypeLib, &uTypeLibIndex);
! if (pTypeLib)
{
ITypeInfo *pTypeInfo2 = NULL;
TYPEKIND iTypeInfoType;
iTypeInfoCount = (INT) pTypeLib->GetTypeInfoCount();
// find the GUID for the type library
{
! TLIBATTR *typeInfo = NULL;
! hResult = pTypeLib->GetLibAttr(&typeInfo);
if (hResult == S_OK) {
! memcpy(&typeGUID,&(typeInfo->guid),sizeof(GUID));
! pTypeLib->ReleaseTLibAttr(typeInfo);
} else // this is illegal, what do we do about it? [shouldn't happen]
memset(&typeGUID,0,sizeof(GUID));
--- 1787,1817 ----
/* now get info from all type info blocks in type library */
! hResult = pTypeInfo->GetContainingTypeLib(&pTypeLib, &iTypeIndex);
! if ( hResult == S_OK && pTypeLib )
{
ITypeInfo *pTypeInfo2 = NULL;
TYPEKIND iTypeInfoType;
+ hResult = pTypeLib->GetTypeInfo(iTypeIndex, &pTypeInfo2);
+ if (pTypeInfo2)
+ {
+ hResult = pTypeInfo2->GetTypeAttr(&pTypeAttr);
+ if ( hResult == S_OK )
+ {
+ fExploreTypeAttr(pTypeInfo2, pTypeAttr, pClsInfo);
+ pTypeInfo2->ReleaseTypeAttr(pTypeAttr);
+ } /* endif */
+
+ pTypeInfo2->Release();
+ } /* endif */
iTypeInfoCount = (INT) pTypeLib->GetTypeInfoCount();
// find the GUID for the type library
{
! TLIBATTR *pTLibAttr = NULL;
! hResult = pTypeLib->GetLibAttr(&pTLibAttr);
if (hResult == S_OK) {
! memcpy(&typeGUID,&(pTLibAttr->guid),sizeof(GUID));
! pTypeLib->ReleaseTLibAttr(pTLibAttr);
} else // this is illegal, what do we do about it? [shouldn't happen]
memset(&typeGUID,0,sizeof(GUID));
|