dwrite: Implement GetString().

This commit is contained in:
Nikolay Sivov 2012-10-07 18:43:15 -04:00 committed by Alexandre Julliard
parent 114ef0688b
commit 9b0f49264e
3 changed files with 51 additions and 5 deletions

View File

@ -286,8 +286,21 @@ static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings *
static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size)
{
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
FIXME("(%p)->(%u %p %u): stub\n", This, index, buffer, size);
return E_NOTIMPL;
TRACE("(%p)->(%u %p %u)\n", This, index, buffer, size);
if (index >= This->count) {
if (buffer) *buffer = 0;
return E_FAIL;
}
if (size < strlenW(This->data[index].string)+1) {
if (buffer) *buffer = 0;
return E_NOT_SUFFICIENT_BUFFER;
}
strcpyW(buffer, This->data[index].string);
return S_OK;
}
static const IDWriteLocalizedStringsVtbl localizedstringsvtbl = {

View File

@ -320,6 +320,7 @@ static void test_GetFamilyNames(void)
IDWriteGdiInterop *interop;
IDWriteFont *font;
LOGFONTW logfont;
WCHAR buffer[100];
HRESULT hr;
UINT32 len;
@ -357,15 +358,45 @@ if (0) /* crashes on native */
if (0) /* crashes on native */
hr = IDWriteLocalizedStrings_GetStringLength(names, 0, NULL);
len = 100;
hr = IDWriteLocalizedStrings_GetStringLength(names, 10, &len);
ok(hr == E_FAIL, "got 0x%08x\n", hr);
ok(len == (UINT32)-1, "got %u\n", len);
len = 0;
hr = IDWriteLocalizedStrings_GetStringLength(names, 0, &len);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(len > 0, "got %u\n", len);
len = 100;
hr = IDWriteLocalizedStrings_GetStringLength(names, 10, &len);
/* GetString */
hr = IDWriteLocalizedStrings_GetString(names, 0, NULL, 0);
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
hr = IDWriteLocalizedStrings_GetString(names, 10, NULL, 0);
ok(hr == E_FAIL, "got 0x%08x\n", hr);
ok(len == (UINT32)-1, "got %u\n", len);
if (0)
hr = IDWriteLocalizedStrings_GetString(names, 0, NULL, 100);
buffer[0] = 1;
hr = IDWriteLocalizedStrings_GetString(names, 10, buffer, 100);
ok(hr == E_FAIL, "got 0x%08x\n", hr);
ok(buffer[0] == 0, "got %x\n", buffer[0]);
buffer[0] = 1;
hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len-1);
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
ok(buffer[0] == 0, "got %x\n", buffer[0]);
buffer[0] = 1;
hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len);
ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr);
ok(buffer[0] == 0, "got %x\n", buffer[0]);
buffer[0] = 0;
hr = IDWriteLocalizedStrings_GetString(names, 0, buffer, len+1);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(buffer[0] != 0, "got %x\n", buffer[0]);
IDWriteLocalizedStrings_Release(names);

View File

@ -1939,6 +1939,8 @@ static inline HRESULT HRESULT_FROM_WIN32(unsigned int x)
/* the codes 4000-40ff are reserved for OLE */
#undef NOERROR /* arpa/nameser_compat.h defines this */
#define E_NOT_SUFFICIENT_BUFFER HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
#ifdef RC_INVOKED
#define _HRESULT_TYPEDEF_(x) (x)
#else