Commit 0a5086ab authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

ole32: Add support for reading BSTR properties.

parent 58c2462c
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include "dictionary.h" #include "dictionary.h"
#include "storage32.h" #include "storage32.h"
#include "enumx.h" #include "enumx.h"
#include "oleauto.h"
WINE_DEFAULT_DEBUG_CHANNEL(storage); WINE_DEFAULT_DEBUG_CHANNEL(storage);
...@@ -1125,6 +1126,40 @@ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const BYTE *data, ...@@ -1125,6 +1126,40 @@ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const BYTE *data,
} }
break; break;
} }
case VT_BSTR:
{
DWORD count, wcount;
StorageUtl_ReadDWord(data, 0, &count);
if (codepage == CP_UNICODE && count % 2)
{
WARN("Unicode string has odd number of bytes\n");
hr = STG_E_INVALIDHEADER;
}
else
{
if (codepage == CP_UNICODE)
wcount = count / 2;
else
wcount = MultiByteToWideChar(codepage, 0, (LPCSTR)(data + sizeof(DWORD)), count, NULL, 0);
prop->u.bstrVal = SysAllocStringLen(NULL, wcount); /* FIXME: use allocator? */
if (prop->u.bstrVal)
{
if (codepage == CP_UNICODE)
memcpy(prop->u.bstrVal, data + sizeof(DWORD), count);
else
MultiByteToWideChar(codepage, 0, (LPCSTR)(data + sizeof(DWORD)), count, prop->u.bstrVal, wcount);
prop->u.bstrVal[wcount - 1] = '\0';
TRACE("Read string value %s\n", debugstr_w(prop->u.bstrVal));
}
else
hr = STG_E_INSUFFICIENTMEMORY;
}
break;
}
case VT_BLOB: case VT_BLOB:
{ {
DWORD count; DWORD count;
......
...@@ -395,18 +395,16 @@ static void test_propertytovariant(void) ...@@ -395,18 +395,16 @@ static void test_propertytovariant(void)
CP_WINUNICODE, &propvar, &allocator); CP_WINUNICODE, &propvar, &allocator);
ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret); ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
todo_wine ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt); ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
if (propvar.vt == VT_BSTR) ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
PropVariantClear(&propvar); PropVariantClear(&propvar);
ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_bstr_mb, ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_bstr_mb,
CP_UTF8, &propvar, &allocator); CP_UTF8, &propvar, &allocator);
ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret); ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
todo_wine ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt); ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
if (propvar.vt == VT_BSTR) ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
PropVariantClear(&propvar); PropVariantClear(&propvar);
} }
......
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