dwrite: Validate format property values.

This commit is contained in:
Nikolay Sivov 2015-06-15 16:30:23 +03:00 committed by Alexandre Julliard
parent 8dd93c7e33
commit 0ec13316a7
2 changed files with 38 additions and 0 deletions

View File

@ -3615,7 +3615,12 @@ static ULONG WINAPI dwritetextformat_Release(IDWriteTextFormat1 *iface)
static HRESULT WINAPI dwritetextformat_SetTextAlignment(IDWriteTextFormat1 *iface, DWRITE_TEXT_ALIGNMENT alignment)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
TRACE("(%p)->(%d)\n", This, alignment);
if ((UINT32)alignment > DWRITE_TEXT_ALIGNMENT_JUSTIFIED)
return E_INVALIDARG;
This->format.textalignment = alignment;
return S_OK;
}
@ -3623,7 +3628,12 @@ static HRESULT WINAPI dwritetextformat_SetTextAlignment(IDWriteTextFormat1 *ifac
static HRESULT WINAPI dwritetextformat_SetParagraphAlignment(IDWriteTextFormat1 *iface, DWRITE_PARAGRAPH_ALIGNMENT alignment)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
TRACE("(%p)->(%d)\n", This, alignment);
if ((UINT32)alignment > DWRITE_PARAGRAPH_ALIGNMENT_CENTER)
return E_INVALIDARG;
This->format.paralign = alignment;
return S_OK;
}
@ -3631,7 +3641,12 @@ static HRESULT WINAPI dwritetextformat_SetParagraphAlignment(IDWriteTextFormat1
static HRESULT WINAPI dwritetextformat_SetWordWrapping(IDWriteTextFormat1 *iface, DWRITE_WORD_WRAPPING wrapping)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
TRACE("(%p)->(%d)\n", This, wrapping);
if ((UINT32)wrapping > DWRITE_WORD_WRAPPING_CHARACTER)
return E_INVALIDARG;
This->format.wrapping = wrapping;
return S_OK;
}
@ -3688,7 +3703,12 @@ static HRESULT WINAPI dwritetextformat_SetLineSpacing(IDWriteTextFormat1 *iface,
FLOAT spacing, FLOAT baseline)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
TRACE("(%p)->(%d %f %f)\n", This, method, spacing, baseline);
if (spacing < 0.0 || (UINT32)method > DWRITE_LINE_SPACING_METHOD_UNIFORM)
return E_INVALIDARG;
This->format.spacingmethod = method;
This->format.spacing = spacing;
This->format.baseline = baseline;

View File

@ -849,12 +849,21 @@ if (0) /* crashes on native */
hr = IDWriteTextFormat_SetTextAlignment(format, DWRITE_TEXT_ALIGNMENT_LEADING);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetTextAlignment(format, DWRITE_TEXT_ALIGNMENT_JUSTIFIED+1);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetParagraphAlignment(format, DWRITE_PARAGRAPH_ALIGNMENT_NEAR);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetParagraphAlignment(format, DWRITE_PARAGRAPH_ALIGNMENT_CENTER+1);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetWordWrapping(format, DWRITE_WORD_WRAPPING_WRAP);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetWordWrapping(format, DWRITE_WORD_WRAPPING_CHARACTER+1);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetReadingDirection(format, DWRITE_READING_DIRECTION_LEFT_TO_RIGHT);
ok(hr == S_OK, "got 0x%08x\n", hr);
@ -864,6 +873,15 @@ if (0) /* crashes on native */
hr = IDWriteTextFormat_SetLineSpacing(format, DWRITE_LINE_SPACING_METHOD_DEFAULT, 0.0, 0.0);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetLineSpacing(format, DWRITE_LINE_SPACING_METHOD_DEFAULT, 0.0, -10.0);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetLineSpacing(format, DWRITE_LINE_SPACING_METHOD_DEFAULT, -10.0, 0.0);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetLineSpacing(format, DWRITE_LINE_SPACING_METHOD_UNIFORM+1, 0.0, 0.0);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetTrimming(format, &trimming, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);