Commit 9b0f4926 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Implement GetString().

parent 114ef068
...@@ -286,8 +286,21 @@ static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings * ...@@ -286,8 +286,21 @@ static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings *
static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size) static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size)
{ {
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface); 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 = { static const IDWriteLocalizedStringsVtbl localizedstringsvtbl = {
......
...@@ -320,6 +320,7 @@ static void test_GetFamilyNames(void) ...@@ -320,6 +320,7 @@ static void test_GetFamilyNames(void)
IDWriteGdiInterop *interop; IDWriteGdiInterop *interop;
IDWriteFont *font; IDWriteFont *font;
LOGFONTW logfont; LOGFONTW logfont;
WCHAR buffer[100];
HRESULT hr; HRESULT hr;
UINT32 len; UINT32 len;
...@@ -357,15 +358,45 @@ if (0) /* crashes on native */ ...@@ -357,15 +358,45 @@ if (0) /* crashes on native */
if (0) /* crashes on native */ if (0) /* crashes on native */
hr = IDWriteLocalizedStrings_GetStringLength(names, 0, NULL); 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; len = 0;
hr = IDWriteLocalizedStrings_GetStringLength(names, 0, &len); hr = IDWriteLocalizedStrings_GetStringLength(names, 0, &len);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ok(len > 0, "got %u\n", len); ok(len > 0, "got %u\n", len);
len = 100; /* GetString */
hr = IDWriteLocalizedStrings_GetStringLength(names, 10, &len); 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(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); IDWriteLocalizedStrings_Release(names);
......
...@@ -1939,6 +1939,8 @@ static inline HRESULT HRESULT_FROM_WIN32(unsigned int x) ...@@ -1939,6 +1939,8 @@ static inline HRESULT HRESULT_FROM_WIN32(unsigned int x)
/* the codes 4000-40ff are reserved for OLE */ /* the codes 4000-40ff are reserved for OLE */
#undef NOERROR /* arpa/nameser_compat.h defines this */ #undef NOERROR /* arpa/nameser_compat.h defines this */
#define E_NOT_SUFFICIENT_BUFFER HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
#ifdef RC_INVOKED #ifdef RC_INVOKED
#define _HRESULT_TYPEDEF_(x) (x) #define _HRESULT_TYPEDEF_(x) (x)
#else #else
......
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