Commit 63d18fd0 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Add a tiny helper to return DWRITE_TEXT_RANGE values.

parent 65a468ef
......@@ -330,6 +330,12 @@ static inline BOOL is_in_layout_range(const DWRITE_TEXT_RANGE *outer, const DWRI
(inner->startPosition + inner->length <= outer->startPosition + outer->length);
}
static inline HRESULT return_range(const struct layout_range *range, DWRITE_TEXT_RANGE *r)
{
if (r) *r = range->range;
return S_OK;
}
/* Set attribute value for given range, does all needed splitting/merging of existing ranges. */
static HRESULT set_layout_range_attr(struct dwrite_textlayout *layout, enum layout_range_attr_kind attr, struct layout_range_attr_value *value)
{
......@@ -902,9 +908,8 @@ static HRESULT WINAPI dwritetextlayout_layout_GetFontWeight(IDWriteTextLayout *i
range = get_layout_range_by_pos(This, position);
*weight = range->weight;
if (r) *r = range->range;
return S_OK;
return return_range(range, r);
}
static HRESULT WINAPI dwritetextlayout_layout_GetFontStyle(IDWriteTextLayout *iface,
......@@ -920,9 +925,8 @@ static HRESULT WINAPI dwritetextlayout_layout_GetFontStyle(IDWriteTextLayout *if
range = get_layout_range_by_pos(This, position);
*style = range->style;
if (r) *r = range->range;
return S_OK;
return return_range(range, r);
}
static HRESULT WINAPI dwritetextlayout_layout_GetFontStretch(IDWriteTextLayout *iface,
......@@ -954,9 +958,8 @@ static HRESULT WINAPI dwritetextlayout_GetUnderline(IDWriteTextLayout *iface,
range = get_layout_range_by_pos(This, position);
*underline = range->underline;
if (r) *r = range->range;
return S_OK;
return return_range(range, r);
}
static HRESULT WINAPI dwritetextlayout_GetStrikethrough(IDWriteTextLayout *iface,
......@@ -972,9 +975,8 @@ static HRESULT WINAPI dwritetextlayout_GetStrikethrough(IDWriteTextLayout *iface
range = get_layout_range_by_pos(This, position);
*strikethrough = range->strikethrough;
if (r) *r = range->range;
return S_OK;
return return_range(range, r);
}
static HRESULT WINAPI dwritetextlayout_GetDrawingEffect(IDWriteTextLayout *iface,
......@@ -992,9 +994,8 @@ static HRESULT WINAPI dwritetextlayout_GetDrawingEffect(IDWriteTextLayout *iface
*effect = range->effect;
if (*effect)
IUnknown_AddRef(*effect);
if (r) *r = range->range;
return S_OK;
return return_range(range, r);
}
static HRESULT WINAPI dwritetextlayout_GetInlineObject(IDWriteTextLayout *iface,
......@@ -1009,9 +1010,8 @@ static HRESULT WINAPI dwritetextlayout_GetInlineObject(IDWriteTextLayout *iface,
*object = range ? range->object : NULL;
if (*object)
IDWriteInlineObject_AddRef(*object);
if (r) *r = range->range;
return S_OK;
return return_range(range, r);
}
static HRESULT WINAPI dwritetextlayout_GetTypography(IDWriteTextLayout *iface,
......
......@@ -628,6 +628,15 @@ static void test_SetInlineObject(void)
ok(r2.startPosition == 0 && r2.length == 2, "got %d, %d\n", r2.startPosition, r2.length);
IDWriteInlineObject_Release(inlinetest);
/* get from somewhere inside a range */
inlinetest = NULL;
r2.startPosition = r2.length = 100;
hr = IDWriteTextLayout_GetInlineObject(layout, 1, &inlinetest, &r2);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(inlinetest == inlineobj, "got %p\n", inlinetest);
ok(r2.startPosition == 0 && r2.length == 2, "got %d, %d\n", r2.startPosition, r2.length);
IDWriteInlineObject_Release(inlinetest);
range.startPosition = 1;
range.length = 1;
hr = IDWriteTextLayout_SetInlineObject(layout, inlineobj2, range);
......
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